/* File:  web/css/emerge.css © 2026 projectemergence. All rights reserved. */
/* File:  Emerge/src/public/css/emerge.css © 2025 projectemergence. All rights reserved. */
/* ====================================================
   Maestro Frame (advanced controls)
   Global Imports and Base Styles
   ==================================================== */

@import url('tokens.css');
@import url('shared.css');
@import url('wavevar.css');

/* ====================================================
   Custom Shop Styles
   ==================================================== */
.card.shop-card {
  background-color: var(--color-bg-card) !important;
  color: #e0e0e0; /* Light text */
  border: 1px solid #444;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card.shop-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  border-color: #666;
}

.card.shop-card .card-title {
  color: #fff;
  font-weight: bold;
}

.card.shop-card .card-text {
  color: #ccc;
}

.card.shop-card .btn-primary {
  background-color: var(--color-accent-blue);
  border-color: var(--color-accent-blue);
}

.card.shop-card .btn-primary:hover {
  background-color: rgba(var(--color-accent-blue-rgb), 0.8);
  border-color: rgba(var(--color-accent-blue-rgb), 0.8);
}

/* Ensure images fit well */
.card.shop-card .card-img-top {
  height: 200px; /* Fixed height for consistency */
  object-fit: cover; /* Crop to fill */
}

/* Reset & Global Settings */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  /* Avoid creating an ancestor scrolling box that breaks sticky positioning. */
  overflow-x: clip;
}

/* Base Typography & Colors */
body {
  background-color: var(--color-bg-body);
  color: var(--color-text-main);
  font-family: var(--font-stack-main);
}

button,
input,
select,
textarea,
option {
  font-family: var(--font-stack-main);
}



/* Link Styles */
a {
  color: var(--color-text-main);
  text-decoration: none;
}
a:hover {
  color: var(--color-text-light);
}
p {
  font-family: var(--font-stack-main);
  line-height: 1.6;
}

/* ====================================================
   Typing Effect Styles
   ==================================================== */
.load,
pre,
div.term.content-page,
.term {
  padding: 0;
  margin: 0;
}
.term {
  font-family: var(--font-stack-main);
  color: var(--color-text-light);
  opacity: 0.8;
  font-size: var(--phi-font-l);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--phi-space-s) var(--phi-space-m);
  white-space: pre-wrap;
  position: relative;
}
.term.typing-term {
  padding-left: 60px;
}
.term:after {
  content: "_";
  opacity: 1;
  animation: cursor 1s infinite;
}
@keyframes cursor {
  0%, 40% { opacity: 0; }
  50%, 90% { opacity: 1; }
  100% { opacity: 0; }
}

/* ====================================================
   Layout & Structural Elements
   ==================================================== */

:root {
  /* Inherited from tokens.css: --header-height, --header-peek */
  --header-drag-offset: 0px;
  --header-visible-height: var(--header-height);
  --header-content-shift: 0px;
}

/* Header */
header {
  background-color: var(--color-bg-header);
  box-shadow: 1px 0 5px var(--color-bg-overlay);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  padding: 0 var(--phi-space-l);
  height: var(--header-height);
  /* Keep the navigation stationary at the top through normal page scrolling. */
  transition: box-shadow 0.3s ease;
  overflow: visible;
}
header .header-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(.4rem, .9vw, .8rem);
  width: 100%;
  min-width: 0;
  transform: translateY(var(--header-content-shift, 0px));
  transition: transform 0.3s ease, opacity 0.25s ease;
}
header .site-header__identity {
  grid-column: 1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: clamp(.5rem, 1vw, .8rem);
  min-width: 0;
}
header .load {
  min-width: 0;
  overflow: hidden;
}
header .header-term {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
header .audio-controls {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: clamp(.2rem, .45vw, .4rem);
  min-width: 0;
  margin: 0 !important;
}
header .audio-controls .btn {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  inline-size: clamp(2.35rem, 2.8vw, 2.75rem);
  block-size: clamp(2.35rem, 2.8vw, 2.75rem);
  min-inline-size: 0;
  min-block-size: 0;
  margin: 0 !important;
  padding: 0;
  line-height: 1;
}
header .volume-control-wrapper {
  flex: 0 1 auto;
  min-width: 0;
}
header .header-volume-slider {
  inline-size: clamp(4.5rem, 6vw, 6rem);
  max-inline-size: 100%;
  margin: 0;
}
header #login-btn,
header .login-hub {
  grid-column: 3;
  justify-self: end;
  flex: 0 0 auto;
  margin: 0 !important;
}
body.header-dragging header {
  transition: none;
}
/* RallyLayout owns --header-visible-height on :root for expanded, collapsed,
   and every intermediate drag frame. The body class is state only. */
body.header-collapsed header {
  box-shadow: none;
  pointer-events: none;
}
body.header-collapsed.header-dragging header {
  pointer-events: auto;
}
body.header-collapsed #header-flow,
body.header-collapsed .header-param-flash {
  opacity: 0;
  pointer-events: none;
}
body.header-collapsed.header-dragging #header-flow {
  opacity: 1;
}
/* main#main-content already follows --header-visible-height during header drag.
   Do not translate its containing block a second time. */

.header-drag-hint {
  display: none;
  position: fixed;
  top: var(--header-visible-height);
  left: 50%;
  transform: translate(-50%, 0);
  width: min(26vw, 220px);
  height: var(--header-peek);
  transition: top 0.25s ease;
  padding: 0;
  border: none;
  background: transparent;
  cursor: grab;
  user-select: none;
  touch-action: none;
  z-index: var(--z-header-drag);
}
body.header-dragging .header-drag-hint {
  transition: none;
}
.header-drag-hint:focus {
  outline: 2px solid #ffd166;
  outline-offset: 6px;
}
.header-drag-hint:active {
  cursor: grabbing;
}
.header-hint-grip {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  height: 1px;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.25));
  box-shadow: 0 0 0 1px var(--glass-bg-mid);
  overflow: visible;
}
.header-hint-grip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 46%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--glass-border-strong), rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.24));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  animation: headerLinePulse 2.2s ease-in-out infinite;
}
.header-hint-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
body.header-collapsed .header-drag-hint {
  opacity: 0.9;
  top: 0;
}
body.header-dragging .header-hint-grip::after {
  animation-duration: 1.1s;
}
@keyframes headerLinePulse {
  0%,
  100% {
    transform: translateX(-50%) scaleY(1);
    filter: drop-shadow(0 0 0 var(--glass-border));
    opacity: 0.78;
  }
  50% {
    transform: translateX(-50%) scaleY(1.7);
    filter: drop-shadow(0 6px 14px var(--glass-border-strong));
    opacity: 1;
  }
}
.sticky-layout {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
}
.sticky-layout .page-scroll-container {
  width: 100%;
  height: auto;
  overflow: visible;
}
.sticky-layout main {
  padding-top: 0;
}
.sticky-layout .page-scroll-container:focus {
  outline: none;
}
.flow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 0;
}
.header-param-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  padding: 0.65rem 1.1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(135deg, rgba(14, 18, 28, 0.92), rgba(24, 28, 40, 0.88));
  color: #f5f8ff;
  font-family: var(--font-stack-main);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2;
  max-width: 70vw;
  line-height: 1.2;
}
.header-param-flash.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
@media (max-width: 768px) {
  .header-param-flash {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    padding: 0.55rem 0.9rem;
    max-width: 90vw;
  }
}
header > * {
  position: relative;
  z-index: 1;
}
.left-align { text-align: left; }
.right-align { text-align: right; }

/* Blur Overlay */
.blur-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(5px);
  background-color: var(--color-bg-overlay);
  z-index: 998;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Footer */
.footer-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--footer-height);
  overflow: hidden;
  z-index: var(--z-footer);
  display: none; /* disable trademark pop-up */
}
.footer {
  position: absolute;
  bottom: -100px;
  width: 100%;
  height: var(--footer-height);
  color: var(--color-text-light);
  background-color: var(--color-bg-footer);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: bottom 0.3s ease-in-out;
}
.footer-container:hover .footer {
  bottom: 0;
}

/* ====================================================
   Timeline Component
   ==================================================== */
.timeline {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  margin: 0 auto;
  max-width: 700px;
  position: relative;
}
.timeline:before {
  content: "";
  position: absolute;
  left: 50%;
  width: 2px;
  height: 100%;
  margin-left: -1px;
  background: var(--glass-border);
}
@media only screen and (max-width: 767px) {
  .timeline:before { left: 40px; }
}
.timeline__content-title {
  font-family: var(--font-stack-main);
  font-weight: normal;
  font-size: 66px;
  margin: -10px 0 0;
  padding: 0 10px;
  box-sizing: border-box;
  transition: 0.4s;
  color: var(--color-text-light);
}
.timeline__content-desc {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: normal;
  line-height: 25px;
  margin: 0;
  box-sizing: border-box;
}
.timeline-item {
  width: calc(50% - 40px);
  padding: 40px 0;
  display: flex;
  position: relative;
  box-sizing: border-box;
  opacity: 0.3;
  filter: blur(2px);
  transform: translateY(-80px);
  transition: 0.5s;
}
.timeline-item:before {
  content: attr(data-text);
  position: absolute;
  top: 70%;
  margin-top: -5px;
  right: calc(-100% - 56px);
  width: 100%;
  padding-left: 15px;
  letter-spacing: 3px;
  font-size: 13px;
  font-family: var(--font-stack-main);
  color: var(--glass-text-muted);
  border-left: 2px solid var(--glass-text-muted);
  opacity: 0;
}
.timeline-item:nth-child(even) {
  align-self: flex-end;
}
.timeline-item:nth-child(even):before {
  left: calc(-100% - 56px);
  right: auto;
  padding-left: 0;
  padding-right: 15px;
  text-align: right;
  border-left: none;
  border-right: 2px solid var(--glass-text-muted);
}
.timeline-item--active {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}
.timeline-item--active:before {
  top: 50%;
  opacity: 1;
  transition: 0.3s all 0.2s;
}
.timeline-item--active .timeline__content-title {
  margin: -50px 0 20px;
}
@media only screen and (max-width: 767px) {
  .timeline-item {
    align-self: baseline !important;
    width: 100%;
    padding: 0 30px 150px 80px;
  }
  .timeline-item:before {
    left: 10px !important;
    padding: 0 !important;
    top: 50px;
    width: 60px;
    text-align: center !important;
    border: none !important;
  }
  .timeline-item:last-child {
    padding-bottom: 40px;
  }
}
.timeline__img {
  max-width: 100%;
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.4);
}
.timeline-container {
  width: 100%;
  padding: 80px 0;
  background-attachment: fixed;
  background-size: cover;
  position: relative;
  transition: 0.3s ease;
}

/* Timeline Header */
.timeline-header {
  width: 100%;
  text-align: center;
  margin-bottom: 80px;
  position: relative;
}
.timeline-header__title {
  color: var(--color-text-light);
  font-size: var(--phi-font-xxl);
  font-family: var(--font-stack-main);
  font-weight: normal;
  margin: 0;
}
.timeline-header__subtitle {
  color: var(--glass-text-muted);
  font-family: var(--font-stack-main);
  font-size: 16px;
  letter-spacing: 5px;
  margin: 10px 0 0;
  font-weight: normal;
}

/* ====================================================
   Contact Form Styles
   ==================================================== */
.contact-form-wrapper {
  max-width: 600px;
  width: 100%;
  padding: 20px;
  z-index: 9;
}
.contact-form {
  padding-bottom: 0.5em;
}
.contact-form-el {
  position: relative;
}
.contact-form-el > .input {
  display: block;
  width: 100%;
  margin-bottom: 1.3em;
  border-bottom: 2px solid #bbbbbb;
  background-color: #1f1f1f;
  color: #e0e0e0;
  padding: 10px 0;
}
.contact-form-el > textarea {
  resize: vertical;
  min-width: 100%;
  min-height: 10em;
  height: auto;
  background: #1f1f1f;
  color: #e0e0e0;
  padding: 10px 0;
}
.contact-form-el > label {
  position: absolute;
  top: 0.3em;
  left: 0;
  font-size: 0.8em;
  font-family: var(--font-stack-main);
  font-weight: 300;
  text-transform: uppercase;
  color: #5f6361;
  pointer-events: none;
  transition: all 300ms linear;
}
.contact-form-el > .input:focus + label,
.contact-form-el > .input:valid + label {
  transform: translateY(-1.7em);
  transform-origin: bottom left;
  color: #bbbbbb;
}
#contact {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 15px 0;
}
@media (min-height: 700px) {
  #contact { align-items: center; }
}
@media (max-width: 768px) {
  .contact-form-wrapper { max-width: 90%; }
}
@media (max-width: 520px) {
  .contact-form-wrapper { padding: 15px; }
}
@keyframes move_arrow_h {
  0% { transform: translateX(0); }
  50% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

/* ====================================================
   Carousel & Gallery Styles
   ==================================================== */
/* New Carousel Layout (using no-gutter and thumbnail styles) */
.no-gutter {
  margin-left: 0;
  margin-right: 0;
}
.no-gutter > [class*='col-'] {
  padding-left: 2px;
  padding-right: 2px;
}
.container {
  text-align: center;
  padding: 20px;
}
#myCarousel .carousel-item > img {
  width: 100%;
  height: 400px;
  object-fit: contain;
  margin: auto;
}

.carousel-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin: 0 auto;
  max-width: 100%;
  width: 80%;
}


#myCarousel {
  flex: 0 0 70%;
  max-width: 70%;
  margin: 0;
}

#thumbCarousel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 5px;
}

#thumbCarousel .thumb {
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.3s ease;
  padding: 2px;
}

#thumbCarousel .thumb img {
  width: 100%;
  height: 50px;
  object-fit: cover;
  opacity: 0.7;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: block;
}
#thumbCarousel .thumb.active img,
#thumbCarousel .thumb:hover img {
  opacity: 1;
  border-color: #808080;
  transform: scale(1.05);
}

.thumb-container {
  flex: 0 0 30%;
  display: flex;
  flex-direction: column;
  height: 400px;
  max-height: calc(100vh - 60px);
  margin-left: 0;
  align-items: center;
  justify-content: space-between;
}

.thumb-arrow {
  display: block;
  font-size: 1.5rem;
  margin: 0.25rem 0;
  cursor: pointer;
  text-align: center;
  color: #fff;
}
@media (max-width: 1200px) {
  #thumbCarousel { gap: 5px; }
  #thumbCarousel .thumb { padding: 4px; }
}
@media (max-width: 992px) {
  #thumbCarousel { gap: 5px; }
  #thumbCarousel .thumb { padding: 3px; }
}
@media (max-width: 768px) {
  #thumbCarousel { gap: 8px; }
  #thumbCarousel .thumb { padding: 2px; }
}
@media (max-width: 576px) {
  #thumbCarousel { gap: 6px; }
  #thumbCarousel .thumb { padding: 1px; }
}

/* ====================================================
   Button Styles
   ==================================================== */
#gallery-button {
  padding: 10px 20px;
  font-size: 1.2rem;
}
.global-button {
  background-color: #5f6361;
  color: #fff;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  position: relative;
  overflow: hidden;
}
.global-button:hover {
  background-color: #565957;
}

/* Header capture is intentionally audio-only: the red dot never enables
   AudioWeaves telemetry sidecars. */
#swarm-record.aw-header-record {
  display: inline-grid;
  place-items: center;
  padding: 0;
}
#swarm-play,
#swarm-stop,
#swarm-record,
#swarm-redistrib {
  box-sizing: border-box;
}
#audioweaves-transport-status {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
#swarm-record .aw-header-record__dot {
  display: block;
  width: .72rem;
  height: .72rem;
  border-radius: 50%;
  background: #ff334c;
  box-shadow: 0 0 0 1px rgba(255,255,255,.18), 0 0 12px rgba(255,51,76,.42);
}
#swarm-record[data-recording="1"] .aw-header-record__dot {
  box-shadow: 0 0 0 2px rgba(255,255,255,.18), 0 0 18px rgba(255,51,76,.78);
  animation: aw-header-record-pulse 1.15s ease-in-out infinite;
}
#swarm-record[data-recording="1"] {
  border-color: rgba(255,72,96,.88);
  background: rgba(116,12,30,.34);
}
@keyframes aw-header-record-pulse {
  0%, 100% { transform: scale(.82); opacity: .72; }
  50% { transform: scale(1.08); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #swarm-record[data-recording="1"] .aw-header-record__dot { animation: none; }
}
.global-button::before {
  content: '>';
  position: absolute;
  right: 10px;
  transition: transform 0.3s ease;
}
.contact-form .global-button:hover::before {
  animation: move_arrow_h 1500ms ease-in infinite forwards;
}

/* ====================================================
   Menu Styles
   ==================================================== */
/* Menu Toggle (White Square) */
.menu-toggle {
  width: 40px;
  height: 40px;
  cursor: pointer;
  position: relative;
  z-index: var(--z-menu-toggle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.menu-toggle .square {
  width: 100%;
  height: 100%;
  background-color: var(--color-text-light);
  transition: transform 0.3s ease;
}
.menu-toggle.active .square {
  transform: rotate(45deg);
}
/* Vertical Menu */
.vertical-menu {
  position: fixed;
  top: 60px;
  left: 0;
  width: 250px;
  height: calc(100vh - 60px);
  box-sizing: border-box;
  z-index: var(--z-menu-vertical);
  padding-top: 20px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
.vertical-menu.show {
  transform: translateX(0);
}
body.header-collapsed .vertical-menu {
  top: var(--header-peek);
  height: calc(100vh - var(--header-peek));
}
.vertical-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#vertical-menu > .site-menu-list {
  min-height: 100%;
}

#vertical-menu .forge-account-menu-item {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.12);
}

#vertical-menu .forge-account-menu-item a {
  color: rgba(164,233,222,.92);
}
.vertical-menu ul li {
  opacity: 0;
  transform: translateX(-20px);
  animation: slideIn 0.3s forwards;
}
.vertical-menu ul li:nth-child(1) { animation-delay: 0.1s; }
.vertical-menu ul li:nth-child(2) { animation-delay: 0.2s; }
.vertical-menu ul li:nth-child(3) { animation-delay: 0.3s; }
.vertical-menu ul li:nth-child(4) { animation-delay: 0.4s; }
.vertical-menu ul li:nth-child(5) { animation-delay: 0.5s; }
.vertical-menu ul li:nth-child(6) { animation-delay: 0.6s; }
.vertical-menu ul li a {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  text-decoration: none;
  color: var(--color-text-main);
  font-size: 1rem;
}
.vertical-menu ul li a:hover {
  color: var(--color-text-light);
}
.vertical-menu ul li a i {
  margin-right: 10px;
  font-size: 1.2rem;
}
@keyframes slideIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 768px) {
  header.site-header {
    flex-wrap: nowrap;
    padding: 0 0.85rem;
    gap: 0.5rem;
    min-height: 60px;
  }

  #menu-toggle {
    margin-right: 0.25rem;
  }

  .header-icon {
    display: block !important;
    font-family: var(--font-stack-main);
    font-size: 2.55rem;
    line-height: 1;
    padding: 0 0.5rem;
    color: var(--color-text-light);
    margin-left: 0.25rem;
    align-self: center;
  }

  .header-icon.unlock-stage-blue {
    color: #4bb3ff;
  }

  .header-icon.unlock-stage-red {
    color: #ff3b30;
  }

  .volume-container-responsive {
      display: none;
      position: absolute;
      top: calc(100% + 10px);
      right: -10px;
      background: rgba(18, 22, 32, 0.95);
      border: 1px solid var(--glass-border-strong);
      border-radius: 12px;
      padding: 1rem 0.5rem;
      box-shadow: 0 10px 30px rgba(0,0,0,0.55);
      z-index: 1100;
      backdrop-filter: blur(10px);
  }

  .volume-container-responsive.show {
      display: flex;
      flex-direction: column;
      align-items: center;
      animation: fadeIn 0.2s ease;
  }

  .volume-container-responsive input[type="range"] {
      writing-mode: vertical-lr;
      direction: rtl;
      width: 8px;
      height: 120px;
      padding: 0;
      margin: 0;
      background: transparent;
  }

}

.login-hub {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.login-hub__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-hub__icon {
  width: 1.1em;
  height: 1.1em;
}

.login-hub__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 190px;
  padding: 0.45rem;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(12, 16, 24, 0.94), rgba(6, 8, 12, 0.96));
  border: 1px solid var(--glass-bg-high);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 0.35rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
}

.login-hub__item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--glass-bg-mid);
  border: 1px solid var(--glass-bg-mid);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.login-hub__item:hover,
.login-hub__item:focus {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--glass-bg-high);
}

.login-hub__menu.is-open,
.login-hub:focus-within .login-hub__menu,
.login-hub:hover .login-hub__menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.login-hub__toggle[aria-expanded="true"] {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.2);
}

/* Canonical header responsive refinements. */
@media (max-width: 68rem) {
  .sticky-layout header {
    padding-inline: clamp(.65rem, 1.8vw, 1rem);
  }

  .sticky-layout header .header-term {
    font-size: clamp(.8rem, 1.6vw, 1rem);
  }

  .sticky-layout header .header-volume-slider {
    inline-size: clamp(4rem, 7vw, 5rem);
  }
}

@media (max-width: 48rem) {
  .sticky-layout header .header-content {
    gap: clamp(.25rem, 1.6vw, .5rem);
  }

  .sticky-layout header .load {
    display: none !important;
  }

  .sticky-layout header .audio-controls .btn {
    inline-size: clamp(2.2rem, 8vw, 2.5rem);
    block-size: clamp(2.2rem, 8vw, 2.5rem);
  }

}

@media (max-width: 900px){
  .vertical-menu {
    top: 58px;
    width: min(86vw, 320px);
    height: calc(100vh - 58px);
    background: linear-gradient(180deg, rgba(10,14,22,0.96), rgba(6,8,12,0.96));
    border-right: 1px solid var(--glass-bg-high);
    box-shadow: 12px 0 28px rgba(0,0,0,0.55);
  }
  /* Hide heavy HUD overlays inside visualizers on mobile */
  .lhud-central,
  .hud,
  .player,
  #audioweaves-visualizer-status,
  #audioweaves-visualizer-file-controls,
  #audioweaves-visualizer .audioweaves-visualizer-controls,
  #audioweaves-visualizer .visualizer-hub {
    display: none !important;
  }
}

/* ===== Maestro advanced controls overlay ===== */
#maestro-frame {
  background: rgba(0,0,0,0.85);
  border: 1px solid #222;
  width: 100%;
  min-height: calc(100vh - 260px);
  padding: 1rem;
  display: flex;
  flex-direction: row;
  gap: 1rem;
}

/* Global View Switching (Tabs) */
#maestro-frame[data-mobile-view="controls"] #maestro-controls { display: flex; }
#maestro-frame[data-mobile-view="controls"] #audioweaves-panel { display: none; }
#maestro-frame[data-mobile-view="graphs"] #maestro-controls { display: none; }
#maestro-frame[data-mobile-view="graphs"] #audioweaves-panel { display: flex; }
#maestro-frame[data-mobile-view="graphs"] #audioweaves-visualizer { display: none !important; }
#maestro-frame[data-mobile-view="visualizer"] #maestro-controls { display: none; }
#maestro-frame[data-mobile-view="visualizer"] #audioweaves-panel { display: flex; }
#maestro-frame[data-mobile-view="visualizer"] #audioweaves-plots,
#maestro-frame[data-mobile-view="visualizer"] #audioweaves-legends { display: none !important; }
#maestro-frame[data-mobile-view="visualizer"] #audioweaves-visualizer { display: flex; }

body.audioweaves-fullscreen #audioweaves-bottom-nav { display: none !important; }

.maestro-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.maestro-controls {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 100%;
}

.maestro-controls .tab-content {
  flex: 1;
  overflow-y: auto;
  padding-top: .5rem;
}

.maestro-controls .nav-tabs {
  border-bottom: 1px solid #444;
}

.maestro-controls .nav-tabs .nav-link {
  color: #fff;
  border: 1px solid #444;
}

.maestro-controls .nav-tabs .nav-link.active {
  background-color: #444;
  color: #fff;
}

.maestro-controls .group-label {
  width: 100%;
  font-weight: 600;
  margin-top: .75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.maestro-controls .control-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.maestro-controls .control-row label {
  min-width: 70px;
  margin: 0;
}
.maestro-controls .nav-tabs .nav-link,
.maestro-controls .group-label {
  user-select: none;
}
.maestro-controls .control-toggle-label {
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  font-weight: 600;
  color: #dfe7f1;
  background: rgba(38, 44, 54, 0.55);
  box-shadow: inset 0 0 0 1px var(--glass-bg-high);
  text-shadow: 0 0 0.35rem rgba(15, 20, 25, 0.45);
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease,
    text-shadow 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  user-select: none;
  touch-action: manipulation;
}
.maestro-controls .control-toggle-label.control-user {
  background: rgba(87, 64, 0, 0.55);
  color: #ffe29a;
  box-shadow: 0 0 0.6rem rgba(255, 184, 0, 0.28);
  text-shadow: 0 0 0.6rem rgba(255, 184, 0, 0.4);
}
.maestro-controls .control-owner-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.08rem 0.45rem;
  border-radius: 0.65rem;
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.16);
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  outline: none;
  border: none;
}
.maestro-controls .control-owner-chip[data-controller="user"] {
  background: rgba(255, 184, 0, 0.85);
  color: #2d1b00;
  box-shadow: 0 0 0.45rem rgba(255, 184, 0, 0.55);
}
.maestro-controls .control-toggle-label.control-conductor {
  background: linear-gradient(120deg, rgba(0, 132, 102, 0.75), rgba(0, 66, 51, 0.88));
  color: #c6ffee;
  text-shadow: 0 0 0.9rem var(--hud-flux-color);
  box-shadow: 0 0 0.7rem rgba(0, 255, 204, 0.32);
}
.maestro-controls .control-owner-chip[data-controller="conductor"] {
  background: var(--hud-flux-color);
  color: #003828;
  box-shadow: 0 0 0.5rem rgba(0, 255, 204, 0.6);
}


.maestro-controls .control-row input[type="range"],
.maestro-controls .control-row select {
  flex: 1;
  background: transparent;
  border-radius: 999px;
  height: 0.75rem;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
}

.maestro-controls .control-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.4);
  background: radial-gradient(circle at 30% 30%, #fff, #7af);
  box-shadow: 0 0 0 3px rgba(var(--color-accent-blue-rgb), 0.25), 0 4px 12px rgba(0,0,0,0.5);
}
.maestro-controls .control-row input[type="range"]::-moz-range-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.4);
  background: radial-gradient(circle at 30% 30%, #fff, #7af);
  box-shadow: 0 0 0 3px rgba(var(--color-accent-blue-rgb), 0.25), 0 4px 12px rgba(0,0,0,0.5);
}

.maestro-controls .control-row button {
  align-self: flex-start;
}

.control-bounds-shell {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.05rem 0.5rem;
  --interval-start: 0%;
  --interval-end: 100%;
}
.control-bounds-shell::before {
  content: '';
  position: absolute;
  inset: 0.35rem 0.15rem;
  border-radius: 999px;
  background: linear-gradient(90deg,
    rgba(35, 39, 46, 0.9) 0%,
    rgba(35, 39, 46, 0.9) var(--interval-start),
    rgba(64, 73, 86, 0.45) var(--interval-start),
    rgba(64, 73, 86, 0.45) var(--interval-end),
    rgba(25, 27, 35, 0.9) var(--interval-end),
    rgba(25, 27, 35, 0.95) 100%);
  box-shadow: inset 0 0 0 1px var(--glass-bg-mid), inset 0 10px 25px rgba(0,0,0,0.38);
  z-index: 1;
}
.control-main-slider {
  grid-area: 1 / 1;
  width: 100%;
  position: relative;
  z-index: 3;
  --interval-start: 0%;
  --interval-end: 100%;
  --thumb-pct: 50%;
  background: linear-gradient(
    90deg,
    rgba(70, 76, 90, 0.4) 0%,
    rgba(70, 76, 90, 0.4) var(--interval-start),
    rgba(0, 255, 208, 0.6) var(--interval-start),
    rgba(255, 184, 0, 0.6) var(--interval-end),
    rgba(24, 26, 32, 0.65) var(--interval-end),
    rgba(24, 26, 32, 0.82) 100%
  );
  border-radius: 999px;
  height: 0.75rem;
  box-shadow: inset 0 0 0 1px var(--glass-border), inset 0 12px 28px rgba(0,0,0,0.38);
}
.control-main-slider::-webkit-slider-runnable-track,
.control-bound-range::-webkit-slider-runnable-track {
  height: 0.75rem;
  border-radius: 999px;
  background: transparent;
}
.control-main-slider::-moz-range-track,
.control-bound-range::-moz-range-track {
  height: 0.75rem;
  border-radius: 999px;
  background: transparent;
}
.control-bounds-shell .control-bound-range {
  grid-area: 1 / 1;
  width: 100%;
  height: 0.85rem;
  z-index: 4;
  pointer-events: none;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.control-bound-range::-webkit-slider-thumb { pointer-events: auto; }
.control-bound-range::-moz-range-thumb { pointer-events: auto; }
.control-bounds-shell .control-bound-min::-webkit-slider-thumb,
.control-bounds-shell .control-bound-min::-moz-range-thumb {
  background: radial-gradient(circle at 30% 30%, #fff, #0ff);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 4px rgba(0, 255, 255, 0.28), 0 6px 14px rgba(0,0,0,0.55);
}
.control-bounds-shell .control-bound-max::-webkit-slider-thumb,
.control-bounds-shell .control-bound-max::-moz-range-thumb {
  background: radial-gradient(circle at 30% 30%, #fff, #f0f);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 4px rgba(255, 0, 255, 0.26), 0 6px 14px rgba(0,0,0,0.55);
}
.control-bounds-shell .control-bound-range::-webkit-slider-thumb,
.control-bounds-shell .control-bound-range::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.5);
  background: radial-gradient(circle at 30% 30%, #fff, #ff6ad5);
}
.control-bounds-shell .control-bound-range.control-bound-max::-webkit-slider-thumb,
.control-bounds-shell .control-bound-range.control-bound-max::-moz-range-thumb {
  background: radial-gradient(circle at 30% 30%, #fff, #7ef29d);
}
.control-bounds-shell::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  pointer-events: none;
  background: radial-gradient(circle at var(--interval-start), rgba(0,255,208,0.16), transparent 26%),
    radial-gradient(circle at var(--interval-end), rgba(255,184,0,0.14), transparent 26%);
  filter: blur(6px);
  z-index: 2;
}
.control-bounds-shell input[type="range"][data-show-value]:after,
.control-bounds-shell input[type="range"]:focus-visible:after {
  content: attr(data-value);
  position: absolute;
  top: -1.35rem;
  left: var(--thumb-pct, 50%);
  transform: translateX(-50%);
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--hud-flux-color), rgba(0, 148, 112, 0.9));
  color: #001915;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  z-index: 6;
}
.control-bounds-shell input[type="range"].control-bound-max[data-show-value]:after,
.control-bounds-shell input[type="range"].control-bound-max:focus-visible:after {
  background: linear-gradient(135deg, rgba(255,184,0,0.94), rgba(160,102,0,0.92));
  color: #1f0f00;
}

@media (max-width: 768px){
  .maestro-controls .control-row {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .maestro-controls .control-row label {
    width: 100%;
  }
  .maestro-controls .control-toggle-label {
    width: 100%;
    justify-content: space-between;
  }
  .maestro-controls .control-row input[type="range"],
  .maestro-controls .control-row select,
  .maestro-controls .control-row input[type="text"] {
    flex: 1 1 100%;
  }
}

@media (max-width: 900px){
  #maestro-frame {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 160px);
  }
  #audioweaves-panel { min-height: 40vh; }
}

#audioweaves-panel {
  flex: 1;
  flex-direction: row;
  min-width: 0;
  position: relative;
  font-family: var(--font-stack-main);
  background: radial-gradient(circle at 15% 20%, rgba(22, 44, 77, 0.3), transparent 25%),
    radial-gradient(circle at 80% 60%, rgba(0, 125, 255, 0.22), transparent 30%),
    #01060e;
  border: 1px solid #0c1727;
  border-radius: 16px;
  padding: 0.75rem;
  box-shadow: inset 0 0 0 1px var(--glass-bg-low), 0 18px 40px rgba(0,0,0,0.55);
  gap: 0.75rem;
}

#audioweaves-panel button,
#audioweaves-panel input,
#audioweaves-panel select,
#audioweaves-panel label,
#audioweaves-panel .nav-link,
#audioweaves-panel .audioweaves-visualizer-status,
#audioweaves-panel .audioweaves-visualizer-toolbar,
#audioweaves-panel .graph-legend {
  font-family: var(--font-stack-main);
}

.audioweaves-vertical-label {
  position: absolute;
  left: -1.6rem;
  top: 1rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--font-stack-main);
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

@media (max-width: 768px) {
  .audioweaves-vertical-label {
    left: -1.1rem;
    font-size: 0.68rem;
  }
}

body.audioweaves-fullscreen {
  overflow: hidden;
  --header-visible-height: 0px;
}

body.audioweaves-fullscreen header {
  display: none !important;
}
body.audioweaves-fullscreen .header-drag-hint {
  display: none;
}

body.audioweaves-fullscreen #maestro-frame {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: var(--z-fullscreen);
  background: #000;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
  flex-direction: column;
  gap: 0;
  border: none;
}

body.audioweaves-fullscreen #maestro-controls {
  display: none !important;
}

body.audioweaves-fullscreen #audioweaves-panel {
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
}

body.audioweaves-fullscreen #audioweaves-plots {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  background: #000;
}

body.audioweaves-fullscreen #current-melody,
body.audioweaves-fullscreen #audioweaves-legends,
body.audioweaves-fullscreen .audioweaves-visualizer-toolbar,
body.audioweaves-fullscreen #audioweaves-visualizer-status,
body.audioweaves-fullscreen #audioweaves-visualizer-file-controls,
body.audioweaves-fullscreen #audioweaves-visualizer-source,
body.audioweaves-fullscreen #audioweaves-visualizer-scene,
body.audioweaves-fullscreen .visualizer-file-audio {
  display: none !important;
}

body.audioweaves-fullscreen #audioweaves-visualizer {
  flex: 1 1 auto;
  min-height: 0;
}

body.audioweaves-fullscreen .audioweaves-visualizer-canvas,
body.audioweaves-fullscreen #graph-scroll {
  border: none;
}

body.audioweaves-fullscreen #graph-scroll {
  flex: 1 1 auto;
  height: auto;
}

#audioweaves-plots {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#audioweaves-visualizer {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.audioweaves-visualizer-toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.audioweaves-visualizer-toolbar .form-group {
  min-width: 160px;
}

.audioweaves-visualizer-toolbar .visualizer-file-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.audioweaves-visualizer-toolbar .visualizer-file-input button {
  white-space: nowrap;
}

.visualizer-file-audio {
  display: block;
  width: 220px;
  max-width: 100%;
  margin-top: 0.35rem;
}

.audioweaves-visualizer-canvas {
  flex: 1;
  min-height: 0;
  border: 1px solid #fff;
  background: #000;
  position: relative;
}

#audioweaves-visualizer-canvas,
#audioweaves-visualizer-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#audioweaves-visualizer-frame {
  border: none;
  background: #000;
}

#graph-scroll {
  flex: 1;
  width: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  border: 1px solid rgba(137,214,255,0.22);
  background: linear-gradient(180deg, rgba(6, 12, 24, 0.9), rgba(2, 8, 18, 0.96));
  border-radius: 14px;
  min-height: min(34vh, 340px);
  box-shadow: inset 0 0 0 1px rgba(68,131,209,0.22), 0 14px 30px rgba(0,0,0,0.35);
}

#graph-scroll canvas {
  display: block;
  background: radial-gradient(circle at 20% 20%, rgba(0,255,200,0.06), transparent 30%),
    radial-gradient(circle at 75% 40%, rgba(255,140,0,0.08), transparent 35%),
    #000;
}


#fft-timeline-wrap {
  border: 1px solid rgba(121, 208, 255, 0.24);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(7, 12, 25, 0.88), rgba(4, 8, 18, 0.94));
  box-shadow: inset 0 0 24px rgba(24, 119, 255, 0.08), 0 12px 26px rgba(0,0,0,0.35);
  overflow: hidden;
}

.fft-timeline-header {
  border-bottom: 1px solid rgba(120, 210, 255, 0.18);
  background: linear-gradient(90deg, rgba(20, 27, 45, 0.95), rgba(15, 19, 37, 0.92));
}

#fft-timeline-scroll {
  max-height: min(56vh, 620px);
  min-height: 260px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 220, 255, 0.55) rgba(4, 12, 26, 0.65);
}

#fft-timeline-scroll::-webkit-scrollbar { height: 10px; }
#fft-timeline-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, rgba(120,220,255,0.85), rgba(125,153,255,0.8));
  border-radius: 999px;
}
#fft-timeline-scroll::-webkit-scrollbar-track { background: rgba(3, 12, 25, 0.8); }

#audioweaves-fft-timeline {
  display: block;
  width: 100%;
  background: radial-gradient(circle at 30% 18%, rgba(74, 119, 255, 0.17), transparent 42%),
              linear-gradient(180deg, rgba(4, 10, 22, 0.95), rgba(2, 6, 16, 0.98));
}

#current-melody {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.melody-icon-btn {
  background: var(--glass-border);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  padding: 0;
}

.melody-mode-btn {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.melody-mode-btn .melody-mode-text {
  pointer-events: none;
  transform: translateY(-1px);
}

.melody-icon-btn:hover,
.melody-icon-btn:focus {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.melody-title-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 60%;
  min-width: 140px;
  justify-content: center;
  transition: background 0.2s ease;
  font-size: 0.85rem;
}

.melody-title-btn:hover,
.melody-title-btn:focus {
  background: var(--glass-border-strong);
}

.melody-title-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.melody-label-inline {
  width: 100%;
  justify-content: flex-start;
}

.maestro-controls .control-row select.aw-pill-select {
  height: auto;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.34);
  color: #fff;
  padding: 0.25rem 2rem 0.25rem 0.75rem;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset;
}

.maestro-controls .control-row select.aw-pill-select:focus {
  outline: none;
  border-color: rgba(122, 186, 255, 0.8);
  box-shadow: 0 0 0 2px rgba(var(--color-accent-blue-rgb), 0.25);
}

.melody-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translate(-50%, 0.75rem);
  background: rgba(14, 18, 33, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.5rem;
  min-width: 260px;
  max-width: min(420px, 85vw);
  max-height: 320px;
  display: flex;
  flex-direction: column;
  z-index: 15;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.melody-dropdown-list {
  overflow-y: auto;
  padding: 0.5rem 0;
}

.melody-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  cursor: grab;
  font-size: 0.85rem;
  color: #f4f6ff;
  transition: background 0.2s ease, color 0.2s ease;
}

.melody-dropdown-item:hover,
.melody-dropdown-item:focus {
  background: var(--glass-bg-high);
  color: #fff;
}

.melody-dropdown-item.dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.melody-dropdown-item.active {
  background: rgba(124, 92, 255, 0.22);
  color: #fff;
}

.melody-dropdown-item .melody-index {
  font-size: 0.7rem;
  opacity: 0.75;
}

.melody-dropdown-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem 0.65rem;
  border-top: 1px solid var(--glass-border-strong);
}

.melody-dropdown-footer .btn {
  white-space: nowrap;
}

.motion-cue-pulse {
  animation: motionPulse 320ms ease-out;
}

@keyframes motionPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.45); }
  70% { box-shadow: 0 0 0 12px var(--glass-border); }
  100% { box-shadow: 0 0 0 18px rgba(255, 255, 255, 0); }
}
#melody-panel {
  background: rgba(10, 14, 30, 0.92);
  border: 1px solid var(--glass-border-strong);
  border-radius: 0.75rem;
  padding: 1.25rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}

.melody-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.melody-panel-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--glass-border-strong);
  border-radius: 0.5rem;
  padding: 0.5rem 0;
  background: rgba(0, 0, 0, 0.25);
}

.melody-panel-list .melody-dropdown-item {
  cursor: pointer;
}

.melody-panel-header h5 {
  font-size: 1.05rem;
  letter-spacing: 0.03em;
}

.melody-panel-footer {
  display: flex;
  justify-content: flex-end;
}

#audioweaves-legends {
  width: 100%;
  flex: 0 0 auto;
  max-height: 240px;
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.12rem 0.18rem 0.08rem;
  overflow: hidden;
}

#audioweaves-legend {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 0.02rem 0.02rem 0.1rem;
}

.graph-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.24rem;
  font-size: 0.6rem;
  line-height: 1.35;
  margin: 0;
  font-family: var(--font-stack-main);
  letter-spacing: 0.01em;
  color: #e6ecf4;
}

.legend-group {
  --group-color: #9fb8ff;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.16rem;
  padding: 0.3rem;
  margin-bottom: 0.4rem;
  border: 1px solid color-mix(in srgb, var(--group-color) 28%, rgba(255,255,255,0.2));
  border-left: 3px solid var(--group-color);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(10, 17, 30, 0.9), rgba(6, 11, 22, 0.93));
  box-shadow: 0 6px 14px rgba(0,0,0,0.22), inset 0 0 16px color-mix(in srgb, var(--group-color) 16%, transparent);
}

.legend-group.legend-group-collapsed {
  opacity: 0.82;
}

.legend-group-header {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.legend-group-title {
  flex: 1;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--group-color) 65%, #ffffff);
  padding: 0.1rem 0.2rem;
  font-weight: 700;
  font-size: 0.58rem;
  letter-spacing: 0.15px;
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
}

.legend-group-title:hover,
.legend-group-title:focus {
  background: var(--glass-border);
  outline: none;
}

.legend-group-title.legend-group-off { opacity: 0.45; }
.legend-group-title.legend-group-partial { color: #f9f9f9; }

.legend-group-actions {
  display: inline-flex;
  gap: 0.14rem;
}

.legend-group-btn {
  border: 1px solid rgba(255,255,255,0.22);
  background: var(--glass-bg-mid);
  color: #eaf2ff;
  border-radius: 6px;
  padding: 0.04rem 0.26rem;
  line-height: 1.05;
  font-size: 0.58rem;
}

.legend-group-btn:hover,
.legend-group-btn:focus {
  background: var(--glass-bg-high);
  outline: none;
}

.legend-items {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.14rem;
  min-width: 0;
}

.legend-group.legend-group-collapsed .legend-items {
  display: none;
}

.graph-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.18rem;
  border-left: 2px solid var(--entry-color, rgba(255,255,255,0.2));
  border: none;
  background: transparent;
  color: #e6ecf4;
  cursor: pointer;
  text-align: left;
  transition: opacity 120ms ease, background 120ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: none;
  appearance: none;
}

.graph-legend .legend-item:hover {
  background: var(--glass-bg-low);
}

.graph-legend .legend-item-hidden {
  opacity: 0.5;
  text-decoration: line-through;
}

.graph-legend .legend-swatch {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 1px;
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: none;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  #audioweaves-panel { max-height: 70vh; }
  #audioweaves-plots { max-height: 55vh; }
  #graph-scroll { max-height: 240px; min-height: 180px; overflow-y: auto; }
  #audioweaves-legends { max-height: 200px; }
  #audioweaves-legend { max-height: 180px; }
}


/* ====================================================
   Shop / Rolodex Styles
   ==================================================== */
.c-rolodex {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  perspective: 1000px;
  transform-style: preserve-3d;
  width: 100%;
}
.c-rolodex__container {
  position: absolute;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  transform-style: preserve-3d;
}
.c-rolodex__container > * {
  width: 35%;
  position: absolute;
  top: 50%;
  margin-top: -120px;
  cursor: pointer;
  transform-style: preserve-3d;
}
.c-rolodex__container > *:after {
  content: '';
  display: block;
  padding-bottom: 100%;
  position: relative;
  background: var(--color-bg-overlay);
}
.bg-cover {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
@media (max-width: 768px) {
  .c-rolodex__container {
    align-items: center;
    justify-content: center;
  }
}


/* Dev Blog Styles */
.dev-blog .post {
    border-bottom: 1px solid #555;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
}
.dev-blog .post h2 {
    color: #fff;
}

/* Blog Timeline Layout */
#blog-timeline {
  position: relative;
  padding-left: 50px;
}

#blog-timeline::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
}

.blog-item {
  position: relative;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
}

/* Remove circular marker */
.blog-item::before {
  display: none;
}

/* Tweak header link focus color */
.dev-blog .card-header .btn-link {
  color: inherit;
}

.dev-blog .card-header .btn-link:focus {
  box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5);
}

/* ============================
   Forge Panel Styles
   ============================ */
.forge-wrapper {
  display: block;
  min-height: calc(100vh - var(--header-visible-height, 60px));
  overflow: visible;
}

.forge-main {
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  padding: 0 0 2rem;
  overflow: visible;
}

.panel-content {
  margin-top: .35rem;
  overflow: visible;
  flex-grow: 1;
}

.forge-section {
  min-height: 22rem;
  padding: clamp(.75rem, 1.6vw, 1.4rem);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 10px;
  background:
    radial-gradient(circle at 12% 0%, rgba(58,151,164,.08), transparent 36%),
    rgba(7,10,14,.7);
}

.forge-section-head {
  margin-bottom: .85rem;
}

.forge-section-head h2 {
  margin: 0;
  font-size: clamp(1.05rem, 1.8vw, 1.4rem);
}

.forge-section-head p {
  margin: .2rem 0 0;
  color: rgba(255,255,255,.55);
  font-size: .8rem;
}

.forge-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  min-height: 2rem;
  position: static;
  width: auto;
  margin: 0 0 .85rem;
  padding: .2rem 0;
  background: transparent;
  border: 0;
}

.forge-nav a {
  color: rgba(255,255,255,.72);
  padding: .35rem .55rem;
  text-align: center;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  font-size: .72rem;
}

.forge-nav img {
  height: 34px;
  width: auto;
}

.forge-nav a.active {
  color: #fff;
  border-color: rgba(164,233,222,.48);
  background: rgba(164,233,222,.08);
}

/* Scoreboard styling */
.scoreboard-section {
  background: #1b1b1b;
  border: 1px solid #444;
  padding: 1rem;
  border-radius: 6px;
}

.score-title {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 3px #09f;
}

.score-table th,
.score-table td {
  color: #eee;
  vertical-align: middle;
}
.score-panel:not(:last-child) {
  margin-bottom: 1rem;
}

.score-group-menu {
  margin-bottom: 1rem;
}

.thumbnail-carousel {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 100%;
}

.thumbnail-carousel img {
  height: 60px;
  margin-right: 0.5rem;
  cursor: pointer;
}

.thumbnail-carousel img.active {
  outline: 2px solid #17a2b8;
}

@media (max-width: 768px) {
  .forge-wrapper {
    min-height: 0;
  }

  .forge-section {
    min-height: 0;
    padding: .75rem;
  }
}

/* Data subpage styling */
.json-data {
  background: #f5f5f5;
  padding: 1rem;
  white-space: pre-wrap;
}

/* Forge maps - keep world map images inside the panel */
.maps-section .selected-map {
  max-width: 100%;
  max-height: 60vh;
  height: auto;
  object-fit: contain;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.map-controls label {
  margin-right: 0.5rem;
}

.maps-section .map-wrapper {
  position: relative;
  display: inline-block;
}
.maps-section .map-grid {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Weaver realm */
.skill-list div {
  padding: 0.25rem 0;
}

/* Weaver realm improvements */
.token-bar {
  background: #1b1b1b;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.5rem;
}
.token-bar .token-red { color: #f44336; }
.token-bar .token-green { color: #4caf50; }
.token-bar .token-blue { color: #2196f3; }
.token-bar .token-yellow { color: #ffeb3b; }
.skill-detail {
  background: #1b1b1b;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.5rem;
}
.conversion-bar button {
  margin: 0 0.25rem;
}
.amt-buttons .active {
  font-weight: bold;
}
/* Blog pixel border effect */
.blog-item {
  position: relative;
}
.blog-item::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  pointer-events: none;
  background:
    repeating-linear-gradient(to right, #17a2b8 0 4px, transparent 4px 8px) top left/0 2px repeat-x,
    repeating-linear-gradient(to right, #17a2b8 0 4px, transparent 4px 8px) bottom left/0 2px repeat-x,
    repeating-linear-gradient(to bottom, #17a2b8 0 4px, transparent 4px 8px) top left/2px 0 repeat-y,
    repeating-linear-gradient(to bottom, #17a2b8 0 4px, transparent 4px 8px) top right/2px 0 repeat-y;
  transition: background-size 0.5s steps(5);
}
.blog-item.pixel-border::before {
  background-size:
    100% 2px,
    100% 2px,
    2px 100%,
    2px 100%;
}


/* ====================================================
   Mobile Responsive Adjustments (Added by Jules)
   ==================================================== */
@media (max-width: 768px) {
  /* Carousel Layout: Stack vertical, full width */
  .carousel-container {
    flex-direction: column;
    width: 100%;
    align-items: center;
  }

  /* Main Carousel Image */
  #myCarousel {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: 1rem;
  }

  #myCarousel .carousel-item > img {
     height: auto !important; /* Allow height to scale */
     max-height: none;
     width: 100%;
  }

  /* Thumbnail Container: Horizontal below image */
  .thumb-container {
    flex-direction: row;
    width: 100%;
    height: auto !important; /* Override JS calculated height */
    margin-left: 0 !important; /* Override ms-3 */
    margin-top: 5px;
    align-items: center;
    justify-content: center;
  }

  /* Thumb Carousel: Horizontal scrolling */
  #thumbCarousel {
    flex-direction: row;
    overflow-x: auto;
    width: auto;
    flex: 1;
    gap: 8px;
  }

  #thumbCarousel .thumb {
    padding: 0 2px;
  }

  #thumbCarousel .thumb img {
     height: 50px !important;
     width: auto;
  }

  /* Arrows: Point Left/Right instead of Up/Down */
  .thumb-arrow {
    margin: 0 10px;
    font-size: 1.2rem;
  }
  .thumb-arrow.up {
    transform: rotate(-90deg); /* Up -> Left */
  }
  .thumb-arrow.down {
    transform: rotate(-90deg); /* Down -> Right */
  }

  /* Text Content Zone: Larger (less padding) and smaller font */
  .term {
    font-size: 0.9rem; /* Reduced from 1.2em */
    padding: 10px 0; /* Reduced side padding */
  }

  /* Increase content width by reducing main padding */
  main#main-content {
      padding-left: 15px !important;
      padding-right: 15px !important;
  }
}

/* Mobile Improvements (Added by Jules) */
@media (max-width: 768px) {
  /* Hide scrollbar for thumbnail carousel */
  #thumbCarousel {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
  }
  #thumbCarousel::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }

  /* Text Layout Fixes */
  .term.typing-term {
    padding-left: 10px !important; /* Reduce left margin (was 60px) */
    padding-right: 10px !important;
  }
  .term {
    font-size: 0.8rem; /* Further reduce font size */
    width: 100%;
  }
  /* Ensure paragraphs use full width and left alignment on mobile */
  .term .paragraph {
    text-align: left !important;
    width: 100%;
  }

  /* Header Alignment Fixes */
  header .header-content {
    align-items: center !important; /* Enforce vertical centering */
  }
  .header-icon {
    display: flex !important;
    align-items: center;
    height: 100%;
    line-height: normal !important; /* Reset rigid line-height */
    margin-top: 2px; /* Micro-adjustment for visual center */
  }
}

/* --- Mobile Fixes Round 2 (Added by Jules) --- */

/* 1. Prevent Horizontal Scroll on Game Page */
body, html {
  overflow-x: clip;
}
@media (max-width: 768px) {
  .carousel-container,
  #thumbCarousel,
  .thumb-container {
    max-width: 100vw;
    box-sizing: border-box;
  }
}

/* 2. Reduce Header Icon Size on Mobile */
@media (max-width: 768px) {
  .header-icon {
    font-size: 2rem !important; /* Reduced from 2.55rem */
  }
}

/* 3. Standardize Font Sizes (Audioweaves & Global Mobile) */
@media (max-width: 768px) {
  /* Enforce standard size for tabs, labels, and buttons */
  .maestro-controls .nav-tabs .nav-link,
  .maestro-controls .group-label,
  .maestro-controls .control-row label,
  .maestro-controls button,
  .maestro-controls select,
  .maestro-controls input {
    font-size: 0.85rem !important;
  }

  /* Adjust tab padding to fit smaller font */
  .maestro-controls .nav-tabs .nav-link {
    padding: 0.4rem 0.6rem;
  }

  /* Ensure range inputs align with smaller text */
  .maestro-controls .control-row {
    min-height: 1.8rem;
  }
}

/* --- Mobile Event Page Redesign (Added by Jules) --- */
@media (max-width: 768px) {
  /* Remove central line */
  .timeline:before {
    display: none;
  }

  /* Full width items, simple vertical stack */
  .timeline-item {
    width: 100% !important;
    padding: 0 0 20px 0 !important;
    align-self: flex-start !important;
    transform: none !important;
    opacity: 1 !important;
    filter: none !important;
  }

  /* Remove side markers/dates (x.x.20xx) or restyle them to be simple text */
  .timeline-item:before {
    display: none !important; /* Hide the complex absolute side marker */
  }

  /* Reset odd/even alignment logic */
  .timeline-item:nth-child(even) {
    align-self: flex-start !important;
  }
  .timeline-item:nth-child(even):before {
    display: none !important;
  }

  /* Image full width */
  .timeline__img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 10px;
  }

  /* Text Container */
  .timeline__content {
    text-align: left;
    padding: 10px;
    background: var(--glass-bg-mid); /* Slight card bg */
    border-radius: 8px;
  }

  /* Reduce massive title font */
  .timeline__content-title {
    font-size: 1.5rem !important; /* Reduced from 66px */
    margin: 0 0 5px 0 !important;
    line-height: 1.2;
  }

  .timeline__content-desc {
    font-size: 0.9rem !important;
    line-height: 1.4;
  }
}

/* --- Further Global Mobile Font Reductions --- */
@media (max-width: 768px) {
  /* Global Base */
  body, html {
    font-size: 13px; /* Slightly smaller base */
  }

  /* Term Text */
  .term {
    font-size: 0.7rem !important; /* Reduced from 0.8rem */
  }

  /* Audioweaves Controls & Tabs */
  .maestro-controls .nav-tabs .nav-link,
  .maestro-controls .group-label,
  .maestro-controls .control-row label,
  .maestro-controls button,
  .maestro-controls select,
  .maestro-controls input {
    font-size: 0.75rem !important; /* Reduced from 0.85rem */
  }

  /* Headings */
  h1, .h1 { font-size: 1.8rem !important; }
  h2, .h2 { font-size: 1.5rem !important; }
  h3, .h3 { font-size: 1.25rem !important; }

  /* Page Titles */
  .page-title {
    font-size: 1.8rem !important;
  }
}

/* --- Mobile Shop Layout (Added by Jules) --- */
@media (max-width: 768px) {
  /* Hide Rolodex on mobile if it exists, assume standard list is used */
  #rolodex-container {
    display: none;
  }

  /* Shop Content Horizontal Scroll Snap */
  #shop-content .row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1rem;
    padding: 1rem 0;
    margin: 0;
    width: 100%;
    scrollbar-width: none; /* Hide scrollbar */
  }

  #shop-content .row::-webkit-scrollbar {
    display: none;
  }

  /* Single Card View */
  #shop-content .col-6,
  #shop-content .col-md-4,
  #shop-content .col-lg-3 {
    flex: 0 0 85vw; /* Show one card predominantly */
    max-width: 85vw;
    scroll-snap-align: center;
    padding: 0;
  }

  /* Card Sizing */
  .card.shop-card {
    height: 60vh; /* Fixed height for consistency */
    min-height: 400px;
    margin-bottom: 0 !important; /* Remove bottom margin in scroll view */
  }

  .card.shop-card .card-img-top {
    height: 50%; /* Image takes half height */
    object-fit: cover;
  }

  .card.shop-card .card-body {
    height: 50%;
    overflow-y: auto; /* Allow text scroll if needed */
  }

  /* Center the scroll view initially if needed (optional) */
  /* Add padding to container so first/last items center properly? */
  #shop-content .row::after {
    content: '';
    flex: 0 0 1rem; /* Spacer at end */
  }
}

/* The document is the single vertical scroll authority across screen sizes.
   The site header remains sticky and the content stays in normal flow. */
main#main-content {
  position: static;
  width: 100%;
  height: auto;
  min-height: 0;
  overflow: visible;
  margin: 0;
}
.sticky-layout .page-scroll-container {
  position: static;
  height: auto;
  overflow: visible;
}
.sticky-layout main { padding-top: 0; }

/* Mobile: Ensure main content padding is applied internally if needed */
@media (max-width: 768px) {
  main#main-content {
      /* Re-apply side padding via internal container or specific children,
         but main itself is the viewport frame */
      padding-left: 0 !important;
      padding-right: 0 !important;
  }

  /* Add padding to direct children containers if they lack it */
  main#main-content > .content-page {
      padding-left: 15px;
      padding-right: 15px;
      padding-bottom: 20px;
  }

  /* Rally pages usually handle their own padding/layout */
  main#main-content > .content-page[id^="pageRally"] {
      padding: 0;
      overflow: hidden; /* Rally usually fixes its own layout */
  }
}
