:root {
  color-scheme: dark;
  --bg: #06111f;
  --panel: rgba(8, 25, 44, 0.34);
  --panel-strong: rgba(10, 30, 54, 0.58);
  --line: rgba(168, 215, 255, 0.16);
  --text: #eef8ff;
  --muted: #8fb0ca;
  --soft: #c4dbee;
  --accent: #78d6ff;
  --accent-2: #b8ccff;
  --accent-3: #7f8cff;
  --shadow: 0 32px 120px rgba(0, 12, 34, 0.58);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background:
    linear-gradient(145deg, rgba(3, 10, 26, 0.94), rgba(6, 20, 42, 0.9)),
    radial-gradient(circle at 20% 18%, rgba(108, 205, 255, 0.22), transparent 30%),
    radial-gradient(circle at 78% 12%, rgba(137, 121, 255, 0.18), transparent 28%),
    radial-gradient(circle at 50% 88%, rgba(39, 120, 202, 0.2), transparent 32%),
    #06111f;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

#ambientCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.92;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 18px 24px 22px;
}

.topbar {
  display: flex;
  width: min(calc(100vw - 430px), 1120px);
  max-width: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 18px 0;
  pointer-events: none;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(120, 214, 255, 0.1);
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--text);
  font-size: 24px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  color: var(--text);
  font-size: 20px;
  line-height: 1.18;
  letter-spacing: 0;
}

.brand p,
#trackMeta,
#signalDetail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status-strip {
  display: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  max-width: 260px;
  min-height: 32px;
  align-items: center;
  overflow: hidden;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 9, 11, 0.56);
  color: var(--soft);
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.immersive-layout {
  display: grid;
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 98px);
  grid-template-columns: minmax(0, calc(100vw - 430px)) 382px;
  gap: 24px;
  align-items: stretch;
  margin: 0;
}

.radio-stage,
.panel {
  border: 0;
  border-radius: 28px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.radio-stage {
  position: relative;
  display: grid;
  min-height: calc(100vh - 82px);
  grid-template-rows: auto minmax(540px, 1fr) auto auto auto;
  overflow: hidden;
  padding: 26px 8px 22px 26px;
}

.radio-stage::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--accent), transparent 82%), transparent 48%),
    radial-gradient(circle at 50% 58%, rgba(133, 188, 255, 0.15), transparent 48%),
    linear-gradient(310deg, rgba(126, 140, 255, 0.15), transparent 55%);
  content: "";
}

.side-stack {
  position: sticky;
  top: 18px;
  z-index: 5;
  display: block;
  width: 382px;
  min-height: calc(100vh - 40px);
  align-self: start;
}

.panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 18px;
}

.side-stack .signal-panel {
  display: none;
}

.stage-top,
.panel-head,
.plan-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.stage-top {
  position: relative;
  z-index: 3;
  align-items: center;
  margin-bottom: 24px;
  opacity: 0.76;
}

.stage-top h2 {
  max-width: min(44vw, 520px);
  overflow: hidden;
  font-size: 20px;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-top #trackMeta {
  max-width: min(46vw, 560px);
  margin-top: 5px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-top .eyebrow {
  margin-bottom: 6px;
  font-size: 11px;
  opacity: 1;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  pointer-events: auto;
}

.select-wrap {
  display: grid;
  gap: 6px;
  min-width: 158px;
}

.select-wrap span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: rgba(4, 8, 10, 0.7);
  color: var(--text);
}

select {
  padding: 0 10px;
}

input[type="text"] {
  padding: 0 12px;
}

select:focus,
input[type="text"]:focus {
  border-color: color-mix(in srgb, var(--accent), white 18%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 76%);
}

.icon-button,
.play-button {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--text);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(242, 247, 244, 0.07);
}

.icon-button:hover,
.play-button:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 247, 244, 0.34);
  background: rgba(242, 247, 244, 0.13);
}

.icon-button svg,
.play-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.play-button svg {
  width: 28px;
  height: 28px;
}

.play-button svg path:first-child {
  fill: currentColor;
  stroke: none;
}

.visual-stage {
  position: relative;
  display: grid;
  min-height: 570px;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  border-radius: 28px;
}

.visual-stage::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 46%, color-mix(in srgb, var(--accent), transparent 68%), transparent 36%),
    radial-gradient(circle at 50% 62%, rgba(137, 121, 255, 0.12), transparent 48%),
    linear-gradient(180deg, transparent 0%, rgba(4, 12, 28, 0.3) 100%);
  content: "";
  filter: saturate(1.18);
}

.visual-stage::after {
  position: absolute;
  right: 7%;
  bottom: 7%;
  left: 7%;
  z-index: 0;
  height: 26%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(120, 214, 255, 0.16), rgba(184, 204, 255, 0.08) 44%, transparent 72%);
  filter: blur(12px);
  content: "";
  pointer-events: none;
}

.particle-stage-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  cursor: grab;
  touch-action: none;
}

.particle-stage-canvas:active {
  cursor: grabbing;
}

.particle-caption {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 1;
  display: none;
  min-width: 124px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 82%), transparent),
    rgba(4, 8, 10, 0.54);
  color: var(--text);
  text-align: right;
  backdrop-filter: blur(18px);
}

.lyric-mist {
  display: none;
}

.particle-caption span {
  display: block;
  font-size: 22px;
  font-weight: 950;
  line-height: 1.05;
}

.particle-caption small {
  display: block;
  margin-top: 5px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.signal-overlay {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.signal-overlay div,
.signal-card,
.metric-grid div,
#moodTimeline li,
#trackList li,
.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(242, 247, 244, 0.055);
}

.signal-overlay div {
  min-height: 70px;
  padding: 12px;
}

.signal-overlay span,
.signal-card span,
.metric-grid dt {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.signal-overlay strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(16px, 2.2vw, 24px);
  line-height: 1.12;
}

.progress-wrap {
  position: relative;
  z-index: 2;
  width: min(82%, 860px);
  margin: -96px auto 0;
  padding: 12px 16px 10px;
  border: 1px solid rgba(176, 222, 255, 0.12);
  border-radius: 14px;
  background: rgba(8, 26, 48, 0.14);
  box-shadow: 0 14px 48px rgba(15, 82, 150, 0.1);
  backdrop-filter: blur(24px);
}

.progress-track {
  position: relative;
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(242, 247, 244, 0.11);
}

#progressBar {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 14px 0 8px;
  padding-right: 0;
}

.play-button {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent), #ffffff 9%);
  color: #06100f;
}

.station-plan {
  position: relative;
  z-index: 2;
  width: min(84%, 900px);
  margin: -2px auto 0 5%;
  padding: 10px 16px;
  border: 1px solid rgba(176, 222, 255, 0.13);
  border-radius: 22px;
  background: rgba(8, 26, 48, 0.16);
  box-shadow: 0 18px 80px rgba(0, 12, 34, 0.16);
  backdrop-filter: blur(24px);
}

#trackList {
  position: relative;
  display: grid;
  min-height: 112px;
  grid-template-columns: repeat(var(--track-count, 3), minmax(76px, 1fr));
  gap: 0;
  align-items: end;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

#trackList::before {
  position: absolute;
  right: 0;
  bottom: 36px;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent), white 8%), transparent);
  content: "";
}

#trackList li {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 96px;
  align-items: end;
  padding: 0 5px 2px;
  border: 0;
  background: transparent;
  color: var(--soft);
  font-size: 13px;
}

#trackList li.is-current {
  background: transparent;
}

.track-node {
  position: absolute;
  top: var(--curve-y, 42%);
  left: 50%;
  width: 13px;
  height: 13px;
  border: 1px solid color-mix(in srgb, var(--accent), white 28%);
  border-radius: 50%;
  background: rgba(242, 247, 244, 0.2);
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent), transparent 35%);
  transform: translate(-50%, -50%);
}

#trackList li.is-current .track-node {
  width: 18px;
  height: 18px;
  background: var(--accent-2);
  box-shadow:
    0 0 0 7px color-mix(in srgb, var(--accent-2), transparent 78%),
    0 0 34px color-mix(in srgb, var(--accent), white 20%);
}

.track-name {
  min-width: 0;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

#trackList li.is-current .track-name,
#trackList li:hover .track-name {
  opacity: 1;
  transform: translateY(0);
}

.track-name strong,
.track-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-name strong {
  color: var(--text);
  font-size: 12px;
}

.track-name span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.signal-panel {
  display: none;
}

.live-dot {
  width: 12px;
  height: 12px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent), transparent 78%);
}

.source-select {
  min-width: 0;
}

.signal-card {
  padding: 14px;
}

.signal-card strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.12;
}

.signal-card small {
  display: block;
  min-height: 36px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
}

.metric-grid div {
  min-height: 72px;
  padding: 11px;
}

.metric-grid dd {
  margin: 9px 0 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
}

.timeline-block {
  min-height: 0;
}

#moodTimeline {
  display: grid;
  max-height: 154px;
  gap: 8px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

#moodTimeline li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  color: var(--soft);
  font-size: 12px;
}

.companion-panel {
  position: relative;
  gap: 18px;
  height: calc(100vh - 40px);
  max-height: none;
  overflow: hidden;
  padding: 20px;
  border: 1px solid rgba(176, 222, 255, 0.12);
  border-radius: 30px;
  background:
    radial-gradient(circle at 74% 10%, rgba(120, 214, 255, 0.16), transparent 26%),
    linear-gradient(180deg, rgba(12, 38, 70, 0.2), rgba(3, 11, 27, 0.16) 58%, rgba(3, 11, 27, 0.28)),
    rgba(8, 26, 48, 0.1);
  box-shadow:
    0 28px 90px rgba(0, 12, 34, 0.28),
    inset 0 1px 0 rgba(235, 248, 255, 0.08);
  backdrop-filter: blur(34px) saturate(1.2);
}

.companion-panel::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(235, 248, 255, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(235, 248, 255, 0.026) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.16));
  content: "";
}

.companion-panel .panel-head {
  position: relative;
  align-items: center;
  opacity: 0.92;
}

.companion-panel .eyebrow {
  color: rgba(184, 204, 255, 0.82);
}

.companion-panel h2 {
  max-width: 210px;
  font-size: 22px;
  font-weight: 780;
}

.companion-orbit {
  position: relative;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(184, 204, 255, 0.3);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(238, 248, 255, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 64% 28%, rgba(120, 214, 255, 0.82) 0 4px, transparent 5px),
    radial-gradient(circle at 34% 72%, rgba(184, 204, 255, 0.7) 0 3px, transparent 4px);
  box-shadow: 0 0 28px rgba(120, 214, 255, 0.18);
}

.chat-feed {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 8px 4px 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(184, 204, 255, 0.28) transparent;
}

.message {
  max-width: 94%;
  padding: 12px 13px;
  border-radius: 16px;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.58;
}

.message.assistant {
  align-self: flex-start;
  border-color: rgba(176, 222, 255, 0.12);
  border-bottom-left-radius: 6px;
  background: rgba(235, 248, 255, 0.055);
}

.message.user {
  align-self: flex-end;
  border-color: rgba(120, 214, 255, 0.26);
  border-bottom-right-radius: 6px;
  background: rgba(120, 214, 255, 0.13);
  color: var(--text);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(176, 222, 255, 0.1);
  border-radius: 18px;
  background: rgba(3, 12, 30, 0.22);
}

.chat-form input[type="text"] {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.chat-form input[type="text"]:focus {
  box-shadow: none;
}

.send-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(120, 214, 255, 0.16);
}

@media (max-width: 1180px) {
  .immersive-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    width: 100%;
  }

  .radio-stage {
    min-height: 760px;
    padding-right: 0;
  }

  .side-stack {
    position: static;
    width: auto;
    min-height: 0;
    margin-top: 14px;
  }

  .companion-panel {
    height: 430px;
    max-height: 430px;
  }
}

@media (max-width: 840px) {
  .app {
    padding: 14px;
  }

  .topbar,
  .stage-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-strip,
  .control-row {
    justify-content: flex-start;
  }

  .control-row {
    width: 100%;
    flex-wrap: wrap;
  }

  .select-wrap {
    flex: 1 1 190px;
  }

  .radio-stage {
    min-height: 720px;
    grid-template-rows: auto minmax(300px, 1fr) auto auto auto;
    padding: 18px 8px;
  }

  .visual-stage {
    min-height: 320px;
  }

  .particle-caption {
    right: 12px;
    bottom: 12px;
  }

  .signal-overlay {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-stack {
    width: 100%;
  }

  .progress-wrap,
  .station-plan {
    width: 100%;
  }

  .lyric-mist {
    top: 13%;
    width: 88%;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 21px;
  }

  h2 {
    font-size: 18px;
  }

  .brand {
    align-items: flex-start;
  }

  .signal-overlay,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  #trackList {
    min-height: 126px;
    grid-template-columns: repeat(var(--track-count, 3), minmax(48px, 1fr));
  }
}
