:root {
  --bg: #05070b;
  --panel: #0d1219;
  --panel-strong: #121923;
  --line: rgba(207, 173, 96, 0.26);
  --gold: #d7b46a;
  --gold-strong: #ffe1a0;
  --text: #eef3f8;
  --muted: #8f9cad;
  --red: #ef4444;
  --cyan: #19d3d6;
  --green: #2ac77b;
  --blue: #2783ff;
  color-scheme: dark;
  font-family:
    "Inter", "DIN Alternate", "SF Pro Display", "HarmonyOS Sans SC", "MiSans",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(215, 180, 106, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(25, 211, 214, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, #030508 0%, #07111a 46%, #040609 100%);
  background-size: 56px 56px, 56px 56px, auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
video,
img {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 clamp(22px, 4vw, 64px);
  border-bottom: 1px solid rgba(215, 180, 106, 0.18);
  background: rgba(3, 5, 8, 0.92);
  backdrop-filter: blur(18px);
}

.brand,
.nav-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  color: var(--gold-strong);
  font-size: 18px;
  font-weight: 800;
}

.brand img {
  width: 34px;
  height: 34px;
}

.nav-actions {
  gap: clamp(18px, 3vw, 42px);
  color: rgba(238, 243, 248, 0.72);
  font-size: 15px;
  font-weight: 700;
}

.nav-actions a {
  position: relative;
  padding: 22px 0 19px;
}

.nav-actions a:hover,
.nav-actions a:focus-visible,
.nav-actions .nav-active {
  color: var(--gold-strong);
  outline: none;
}

.nav-actions .nav-active::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, rgba(255, 225, 160, 0.16), var(--gold-strong), rgba(255, 225, 160, 0.16));
  box-shadow: 0 0 16px rgba(215, 180, 106, 0.54);
}

.app-shell {
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: clamp(22px, 3vw, 42px) clamp(18px, 4vw, 70px) 42px;
}

.dashboard-head {
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: #fff7df;
  font-size: clamp(34px, 3.4vw, 58px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  color: #fff7df;
  font-size: 24px;
  letter-spacing: 0;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 820px;
}

.metric {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(215, 180, 106, 0.25);
  border-radius: 8px;
  color: rgba(238, 243, 248, 0.72);
  background: rgba(13, 18, 25, 0.72);
  font-size: 13px;
  white-space: nowrap;
}

.metric strong {
  margin-right: 6px;
  color: var(--gold-strong);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.metric.source {
  color: var(--cyan);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 18px;
  align-items: stretch;
}

.chart-panel,
.rhythm-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(215, 180, 106, 0.08), transparent 34%),
    rgba(5, 7, 11, 0.86);
  box-shadow: inset 0 0 28px rgba(215, 180, 106, 0.04);
}

.chart-panel {
  overflow: hidden;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid rgba(215, 180, 106, 0.16);
  background: rgba(18, 25, 35, 0.68);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: rgba(238, 243, 248, 0.74);
  font-size: 13px;
  font-weight: 700;
}

.legend-item {
  position: relative;
  padding-left: 18px;
}

.legend-item::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px;
  height: 10px;
  content: "";
  transform: translateY(-50%);
  border-radius: 2px;
}

.legend-item.up::before {
  background: var(--red);
}

.legend-item.down::before {
  background: var(--cyan);
}

.legend-item.rhythm::before {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold-strong);
  box-shadow:
    0 0 0 1px rgba(5, 7, 11, 0.9),
    0 0 12px rgba(255, 225, 160, 0.58);
}

.legend-item.rhythm::after {
  position: absolute;
  top: 50%;
  left: 5px;
  width: 0;
  height: 0;
  content: "";
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid #05070b;
  transform: translateY(-50%);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 225, 160, 0.34);
  border-radius: 8px;
  color: var(--gold-strong);
  background: rgba(5, 7, 11, 0.72);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(255, 225, 160, 0.74);
  outline: none;
}

.index-chart {
  position: relative;
  width: 100%;
  height: min(68vh, 720px);
  min-height: 560px;
}

.chart-node-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.node-play {
  position: absolute;
  z-index: 2;
  border: 0;
}

.node-play {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(5, 7, 11, 0.9);
  border-radius: 999px;
  background: rgba(255, 225, 160, 0.96);
  box-shadow:
    0 0 0 1px rgba(255, 225, 160, 0.3),
    0 4px 14px rgba(0, 0, 0, 0.34),
    0 0 14px rgba(255, 225, 160, 0.44);
  cursor: pointer;
  pointer-events: auto;
}

.node-play::before {
  display: block;
  width: 0;
  height: 0;
  margin-left: calc(var(--node-play-size, 18px) * 0.08);
  content: "";
  border-top: calc(var(--node-play-size, 18px) * 0.24) solid transparent;
  border-bottom: calc(var(--node-play-size, 18px) * 0.24) solid transparent;
  border-left: calc(var(--node-play-size, 18px) * 0.38) solid #05070b;
}

.node-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 4;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 225, 160, 0.42);
  border-radius: 8px;
  color: #fff7df;
  background: rgba(5, 7, 11, 0.96);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
}

.node-play:hover,
.node-play:focus-visible {
  outline: 2px solid rgba(25, 211, 214, 0.72);
  outline-offset: 2px;
}

.node-play:hover .node-tooltip,
.node-play:focus-visible .node-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.rhythm-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.panel-head {
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(215, 180, 106, 0.16);
}

.rhythm-list {
  display: grid;
  gap: 12px;
  padding-top: 14px;
}

.empty-rhythm {
  min-height: 86px;
  padding: 20px 16px;
  border: 1px dashed rgba(215, 180, 106, 0.3);
  border-radius: 8px;
  color: rgba(238, 243, 248, 0.56);
  background: rgba(13, 18, 25, 0.46);
  font-size: 14px;
  line-height: 1.6;
}

.clip-button {
  width: 100%;
  min-height: 92px;
  padding: 14px;
  border: 1px solid rgba(215, 180, 106, 0.22);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  background: rgba(13, 18, 25, 0.82);
  cursor: pointer;
}

.clip-button:hover,
.clip-button:focus-visible {
  border-color: rgba(255, 225, 160, 0.7);
  outline: none;
  background: rgba(18, 25, 35, 0.92);
}

.clip-date {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.clip-title {
  display: block;
  color: #fff7df;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.clip-meta {
  display: block;
  margin-top: 8px;
  color: rgba(238, 243, 248, 0.56);
  font-size: 12px;
}

.risk-note {
  margin: 16px 0 0;
  color: rgba(238, 243, 248, 0.5);
  font-size: 12px;
  line-height: 1.6;
}

.player-dialog {
  width: min(980px, calc(100vw - 96px));
  max-height: calc(100dvh - 180px);
  padding: 0;
  border: 1px solid rgba(255, 225, 160, 0.34);
  border-radius: 8px;
  color: var(--text);
  background: #05070b;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.72);
  overflow: hidden;
}

.player-dialog[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.player-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.close-player {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 225, 160, 0.4);
  border-radius: 8px;
  color: var(--gold-strong);
  background: rgba(5, 7, 11, 0.72);
  cursor: pointer;
}

.player-stage {
  display: grid;
  place-items: center;
  width: 100%;
  height: min(48dvh, 560px);
  min-height: 320px;
  max-height: calc(100dvh - 280px);
  background: #000;
}

.player-stage [hidden] {
  display: none;
}

.player-stage video,
.player-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player-meta {
  display: grid;
  gap: 8px;
  padding: 16px 18px 18px;
  border-top: 1px solid rgba(215, 180, 106, 0.18);
  background: rgba(13, 18, 25, 0.92);
}

.player-meta span,
.player-meta time {
  color: rgba(238, 243, 248, 0.58);
  font-size: 13px;
}

.player-meta strong {
  color: #fff7df;
  font-size: 18px;
}

@media (max-width: 1080px) {
  .dashboard-head,
  .workbench {
    grid-template-columns: 1fr;
  }

  .dashboard-head {
    display: grid;
    align-items: start;
  }

  .metric-row {
    justify-content: start;
  }

  .workbench {
    display: grid;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    min-height: auto;
    padding: 14px 18px;
  }

  .brand span {
    display: none;
  }

  .nav-actions {
    gap: 18px;
    font-size: 13px;
  }

  .nav-actions a {
    padding: 10px 0 8px;
  }

  .app-shell {
    padding: 18px 12px 30px;
  }

  .metric-row,
  .legend {
    gap: 8px;
  }

  .metric {
    min-height: 38px;
    font-size: 12px;
  }

  .index-chart {
    min-height: 520px;
  }

  .player-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  .player-stage {
    height: min(70dvh, 720px);
    max-height: calc(100dvh - 132px);
  }

  .player-meta strong {
    font-size: 15px;
  }

  .rhythm-panel {
    padding: 14px;
  }
}
