:root {
  color-scheme: dark;
  --page: #071018;
  --page-deep: #040a10;
  --surface: rgba(15, 27, 38, .78);
  --surface-strong: rgba(19, 33, 45, .94);
  --surface-soft: rgba(255, 255, 255, .035);
  --line: rgba(174, 201, 222, .19);
  --line-strong: rgba(190, 216, 235, .34);
  --text: #f1f5f8;
  --muted: #93a2ae;
  --faint: #61717e;
  --blue: #4c84ff;
  --cyan: #49c7df;
  --green: #4fd68a;
  --amber: #f3a047;
  --red: #ee5964;
  --violet: #9a82e6;
  --wechat: #56d58e;
  --douyin: #86cfff;
  --xhs: #ef5962;
  --shadow: 0 20px 54px rgba(0, 0, 0, .28);
  --inner: inset 0 1px 0 rgba(255, 255, 255, .055);
  --radius: 12px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #eaf0f4;
  --page-deep: #dfe8ee;
  --surface: rgba(255, 255, 255, .78);
  --surface-strong: rgba(255, 255, 255, .95);
  --surface-soft: rgba(255, 255, 255, .52);
  --line: rgba(39, 59, 74, .16);
  --line-strong: rgba(39, 59, 74, .27);
  --text: #111b24;
  --muted: #586a78;
  --faint: #82919c;
  --shadow: 0 18px 45px rgba(43, 62, 77, .12);
  --inner: inset 0 1px 0 rgba(255, 255, 255, .85);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--page);
  font-family: Inter, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(112deg, rgba(50, 91, 129, .09), transparent 38%),
    linear-gradient(292deg, rgba(43, 109, 100, .055), transparent 42%),
    var(--page);
}

button,
input,
select { font: inherit; color: inherit; }

button,
a,
select,
input { -webkit-tap-highlight-color: transparent; }

button,
a { touch-action: manipulation; }

button { cursor: pointer; }

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--blue), white 18%);
  outline-offset: 2px;
}

svg { display: block; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 999;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-strong);
  transform: translateY(-150%);
  transition: transform .18s ease-out;
}

.skip-link:focus-visible { transform: translateY(0); }

#ambientCanvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .48;
}

.app-shell {
  width: min(1680px, calc(100% - 24px));
  margin: 12px auto 30px;
}

.glass {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--inner), var(--shadow);
  backdrop-filter: blur(24px) saturate(130%);
  -webkit-backdrop-filter: blur(24px) saturate(130%);
}

.topnav {
  position: sticky;
  top: 10px;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 58px;
  padding: 8px 10px;
  border-radius: var(--radius);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
}

.brand-icon {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  width: 34px;
  height: 34px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-strong);
  box-shadow: var(--inner);
}

.brand-icon i {
  width: 3px;
  border-radius: 2px;
  background: var(--text);
}

.brand-icon i:nth-child(1) { height: 8px; }
.brand-icon i:nth-child(2) { height: 15px; }
.brand-icon i:nth-child(3) { height: 11px; }

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.nav-links a {
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  transition: color .18s ease, border-color .18s ease, background-color .18s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-soft);
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 7px;
}

.icon-action,
.primary-button,
.text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  transition: transform .18s ease, border-color .18s ease, background-color .18s ease, color .18s ease;
}

.icon-action {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
}

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

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  color: #08111a;
  border-color: color-mix(in srgb, var(--blue), white 18%);
  background: #88abff;
  font-size: 13px;
  font-weight: 750;
}

.icon-action:hover,
.text-button:hover { border-color: var(--line-strong); background: color-mix(in srgb, var(--surface-soft), white 5%); }
.primary-button:hover { transform: translateY(-1px); background: #9bb9ff; }
.primary-button:active,
.icon-action:active { transform: translateY(0); }

.page-heading {
  display: grid;
  grid-template-columns: minmax(300px, .9fr) minmax(620px, 1.6fr);
  align-items: end;
  gap: 26px;
  padding: 26px 4px 16px;
  scroll-margin-top: 82px;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}

h1,
h2,
h3,
p { margin: 0; }

h1 {
  font-size: clamp(30px, 3.2vw, 46px);
  line-height: 1.08;
  letter-spacing: 0;
  text-wrap: balance;
}

.page-heading p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.source-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.source-card {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 9px;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-soft);
  text-align: left;
  text-decoration: none;
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, background-color .2s ease;
}

.source-card::after {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  content: "";
  background: var(--platform);
  opacity: .68;
  transform: scaleX(.25);
  transform-origin: left;
  transition: transform .24s ease-out;
}

.source-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.source-card:hover::after { transform: scaleX(1); }

.source-card-action {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--platform);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.source-card-action svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.platform-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid color-mix(in srgb, var(--platform), transparent 40%);
  border-radius: 9px;
  color: var(--platform);
  background: color-mix(in srgb, var(--platform), transparent 87%);
  font-size: 12px;
  font-weight: 800;
}

.source-card strong,
.source-card small,
.source-card em { display: block; min-width: 0; }
.source-card strong { font-size: 13px; }
.source-card small { margin-top: 3px; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-card em { margin-top: 2px; color: var(--platform); font-size: 10px; font-style: normal; }

.sync-alert {
  position: fixed;
  z-index: 80;
  right: 24px;
  top: 24px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 28px;
  gap: 12px;
  width: min(440px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--red), transparent 50%);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface), #071018 10%);
  box-shadow: 0 20px 55px rgba(0, 0, 0, .32);
  backdrop-filter: blur(22px) saturate(130%);
  animation: syncAlertIn .28s ease-out both;
}

.sync-alert[hidden] { display: none; }
.sync-alert-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid color-mix(in srgb, var(--platform), transparent 42%); border-radius: 10px; color: var(--platform); background: color-mix(in srgb, var(--platform), transparent 88%); font-weight: 900; }
.sync-alert-copy { min-width: 0; }
.sync-alert-copy strong { display: block; margin-top: 3px; font-size: 16px; }
.sync-alert-copy p { margin: 7px 0 4px; color: var(--text-soft); font-size: 12px; line-height: 1.55; }
.sync-alert-copy small { color: var(--muted); font-size: 10px; }
.sync-alert-actions { display: flex; gap: 8px; margin-top: 12px; }
.sync-alert-actions a,
.sync-alert-actions button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface-soft); font-size: 11px; font-weight: 800; text-decoration: none; }
.sync-alert-actions a { color: var(--blue); }
.sync-alert-actions button:disabled { cursor: wait; opacity: .62; }
.sync-alert-close { width: 28px; height: 28px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 20px; }
@keyframes syncAlertIn { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.action-toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 26px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 15px;
  border: 1px solid color-mix(in srgb, var(--green), transparent 45%);
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface), var(--green) 8%);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .28);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .2s ease, transform .2s ease;
}
.action-toast.error { border-color: color-mix(in srgb, var(--red), transparent 42%); background: color-mix(in srgb, var(--surface), var(--red) 9%); }
.action-toast.show { opacity: 1; transform: translate(-50%, 0); }

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 146px;
  border-radius: var(--radius);
  overflow: hidden;
}

.kpi-card {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
  min-width: 0;
}

.kpi-card + .kpi-card { border-left: 1px solid var(--line); }

.kpi-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 66px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-strong), white 3%);
  box-shadow: var(--inner), 0 12px 24px rgba(0, 0, 0, .18);
}

.kpi-icon::before,
.kpi-icon::after {
  position: absolute;
  inset: 7px;
  z-index: -1;
  content: "";
  border: 1px solid var(--line);
  border-radius: 14px;
  transform: translate(-9px, 5px) rotate(-7deg);
}

.kpi-icon::after { transform: translate(8px, -4px) rotate(5deg); }

.kpi-icon svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kpi-copy { min-width: 0; }
.kpi-copy span { display: block; color: var(--muted); font-size: 12px; }
.kpi-copy strong { display: block; margin-top: 8px; font-size: clamp(26px, 2.4vw, 39px); line-height: 1; white-space: nowrap; }
.kpi-copy small { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; }
.kpi-copy small b { margin-left: 6px; color: var(--green); font-weight: 650; }

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.12fr) minmax(330px, .98fr);
  gap: 14px;
  margin-top: 14px;
}

.trend-panel,
.mix-panel,
.message-panel,
.growth-section,
.library-main,
.detail-panel { border-radius: var(--radius); }

.trend-panel {
  min-height: 510px;
  padding: 22px;
  overflow: hidden;
}

.analytics-rail { display: grid; grid-template-rows: 1.12fr .88fr; gap: 14px; }
.mix-panel,
.message-panel { padding: 20px; min-height: 0; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.panel-head h2 { font-size: 20px; line-height: 1.2; }
.panel-head.compact h2 { font-size: 18px; }

.panel-tools { display: flex; align-items: center; gap: 10px; }

.segmented,
.view-tabs,
.date-presets {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface-strong), transparent 18%);
}

.segmented button,
.view-tabs button,
.date-presets button {
  min-height: 29px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  transition: color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.segmented button:hover,
.view-tabs button:hover,
.date-presets button:hover { color: var(--text); }

.segmented button.active,
.view-tabs button.active,
.date-presets button.active {
  color: var(--text);
  background: color-mix(in srgb, var(--blue), transparent 78%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue), transparent 56%);
}

.range-label {
  min-width: 70px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 18px 0 5px;
}

.legend-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  transition: opacity .16s ease, color .16s ease;
}

.legend-button i { width: 16px; height: 3px; border-radius: 2px; background: var(--series); }
.legend-button.active { color: var(--text); }
.legend-button:not(.active) { opacity: .38; }

.trend-chart {
  position: relative;
  min-height: 330px;
  padding-top: 4px;
}

.trend-chart svg { width: 100%; height: 330px; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis-label { fill: var(--faint); font-size: 10px; }
.chart-line {
  fill: none;
  stroke: var(--series);
  stroke-width: var(--stroke, 2.2);
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--series), transparent 45%));
  animation: draw-line .9s cubic-bezier(.2, .8, .2, 1) both;
}

.chart-line.total { stroke-dasharray: 5 6; opacity: .85; }
.chart-area { fill: url(#trendFill); opacity: .22; }
.chart-point { fill: var(--surface-strong); stroke: var(--series); stroke-width: 2; opacity: 0; transition: opacity .16s ease, r .16s ease; }
.trend-chart:hover .chart-point { opacity: .75; }
.chart-point:hover,
.chart-point:focus { opacity: 1; r: 5; }

@keyframes draw-line {
  from { stroke-dasharray: 1 2000; stroke-dashoffset: 900; opacity: .25; }
  to { stroke-dasharray: 2000 0; stroke-dashoffset: 0; opacity: 1; }
}

.trend-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}

.trend-summary div { padding: 12px 14px; min-width: 0; }
.trend-summary div + div { border-left: 1px solid var(--line); }
.trend-summary span { display: block; color: var(--muted); font-size: 10px; }
.trend-summary strong { display: block; margin-top: 5px; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.platform-mix {
  display: grid;
  grid-template-columns: minmax(130px, .82fr) minmax(180px, 1.18fr);
  align-items: center;
  gap: 18px;
  min-height: 230px;
  padding-top: 10px;
}

.donut-wrap { display: grid; place-items: center; }
.donut {
  position: relative;
  display: grid;
  place-items: center;
  width: 156px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--donut);
  box-shadow: 0 14px 28px rgba(0, 0, 0, .22);
  transform: rotate(-90deg);
  transition: transform .35s ease-out;
}

.donut:hover { transform: rotate(-90deg) scale(1.025); }
.donut::after { position: absolute; inset: 22px; content: ""; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-strong); }
.donut-center { position: relative; z-index: 1; transform: rotate(90deg); text-align: center; }
.donut-center strong { display: block; font-size: 19px; }
.donut-center span { color: var(--muted); font-size: 10px; }

.mix-list { display: grid; gap: 12px; }
.mix-item { --bar: 0%; }
.mix-item-head { display: flex; align-items: center; gap: 7px; }
.mix-item-head i { width: 7px; height: 7px; border-radius: 50%; background: var(--platform); }
.mix-item-head span { color: var(--muted); font-size: 11px; }
.mix-item-head strong { margin-left: auto; font-size: 12px; }
.mix-item small { display: block; margin: 4px 0 6px 14px; color: var(--faint); font-size: 10px; }
.mix-track { display: block; height: 3px; margin-left: 14px; border-radius: 2px; background: var(--line); overflow: hidden; }
.mix-track b { display: block; width: var(--bar); height: 100%; border-radius: inherit; background: var(--platform); transform-origin: left; animation: grow-bar .7s ease-out both; }

@keyframes grow-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.text-button { min-height: 28px; padding: 0 9px; color: var(--muted); font-size: 10px; }
.text-button > span { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 5px; padding: 0 5px; border-radius: 9px; color: var(--text); background: color-mix(in srgb, var(--blue), transparent 78%); font-size: 9px; }
.message-list { display: grid; gap: 8px; margin-top: 14px; }
.message-item {
  display: grid;
  grid-template-columns: 31px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-soft);
  text-align: left;
  transition: transform .16s ease, border-color .16s ease, background-color .16s ease;
}
.message-item:hover { transform: translateX(3px); border-color: var(--line-strong); }
.message-item .platform-mark { width: 31px; height: 31px; border-radius: 7px; font-size: 9px; }
.message-copy { min-width: 0; }
.message-copy strong { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-tail { display: flex; align-items: center; gap: 10px; }
.message-tail time { color: var(--faint); font-size: 9px; white-space: nowrap; }

.growth-section { margin-top: 14px; padding: 20px; scroll-margin-top: 82px; }
.growth-note { max-width: 480px; color: var(--muted); font-size: 11px; text-align: right; }
.growth-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin-top: 16px; }
.growth-card {
  position: relative;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease;
}
.growth-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--platform), transparent 52%); }
.growth-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.growth-card-head strong { font-size: 14px; }
.growth-card-head span { color: var(--platform); font-size: 10px; }
.growth-main { display: grid; grid-template-columns: .8fr 1.2fr; align-items: end; gap: 10px; margin-top: 14px; }
.growth-total span { color: var(--muted); font-size: 10px; }
.growth-total strong { display: block; margin-top: 5px; font-size: 26px; }
.mini-chart svg { width: 100%; height: 62px; }
.mini-chart line { stroke: var(--line); }
.mini-chart polyline { fill: none; stroke: var(--platform); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--platform), transparent 50%)); }
.growth-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 12px; }
.growth-metrics div { min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 7px; }
.growth-metrics span { display: block; color: var(--muted); font-size: 9px; }
.growth-metrics strong { display: block; margin-top: 4px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.growth-metrics strong.gain { color: var(--green); }

.library-section {
  display: grid;
  grid-template-columns: minmax(0, 3.25fr) minmax(300px, 1fr);
  gap: 14px;
  margin-top: 14px;
  scroll-margin-top: 82px;
}

.library-main { min-width: 0; padding: 18px; }
.library-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.library-head h2 { font-size: 21px; }
.library-head p { margin-top: 5px; color: var(--muted); font-size: 10px; }

.filter-bar {
  display: grid;
  grid-template-columns: auto 120px 140px auto minmax(190px, 1fr);
  align-items: end;
  gap: 8px;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.control { display: grid; gap: 4px; }
.control > span { color: var(--muted); font-size: 9px; }
.control select,
.search-box,
.custom-dates input,
.export-grid input,
.export-grid select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-strong);
}
.control select { width: 100%; padding: 0 28px 0 9px; }
.order-control { align-self: end; }
.order-control button { min-height: 28px; }
.search-box { display: flex; align-items: center; gap: 7px; padding: 0 10px; }
.search-box svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 11px; }
.search-box input::placeholder { color: var(--faint); }

.custom-dates { display: none; align-items: center; gap: 8px; margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.custom-dates.show { display: flex; }
.custom-dates label { display: flex; align-items: center; gap: 6px; }
.custom-dates input { padding: 0 8px; }

.library-view { min-height: 540px; margin-top: 10px; }
.table-wrap { max-height: 620px; border: 1px solid var(--line); border-radius: 9px; overflow: auto; overscroll-behavior: contain; }
.data-table { width: 100%; min-width: 1340px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 38px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 9px;
  font-weight: 650;
  text-align: right;
}
.data-table th.col-video { width: 360px; text-align: left; }
.data-table th.col-time { width: 128px; }
.data-table th.col-number { width: 78px; }
.data-table th.col-ratio { width: 110px; }
.data-table th.col-rate { width: 86px; }
.data-table td { height: 76px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 11px; text-align: right; }
.data-table tbody tr { cursor: pointer; content-visibility: auto; contain-intrinsic-size: auto 76px; transition: background-color .16s ease, box-shadow .16s ease; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--blue), transparent 94%); }
.data-table tbody tr.active { background: color-mix(in srgb, var(--blue), transparent 88%); box-shadow: inset 2px 0 0 var(--blue); }
.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  text-align: left;
  background: var(--surface-strong);
  box-shadow: 8px 0 14px -14px var(--ink);
}
.data-table th:first-child { z-index: 4; }
.data-table td:first-child { z-index: 1; background: var(--surface); }
.data-table tbody tr:hover td:first-child { background: color-mix(in srgb, var(--surface), var(--blue) 6%); }
.data-table tbody tr.active td:first-child { background: color-mix(in srgb, var(--surface), var(--blue) 12%); }
.ratio-value { color: var(--blue); font-weight: 750; white-space: nowrap; }

.video-cell { display: grid; grid-template-columns: 46px 1fr; align-items: center; gap: 9px; min-width: 0; }
.thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--faint);
  background: var(--surface-soft);
  overflow: hidden;
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.video-copy { min-width: 0; }
.video-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 8px; }
.platform-badge { padding: 2px 5px; border: 1px solid color-mix(in srgb, var(--platform), transparent 55%); border-radius: 5px; color: var(--platform); background: color-mix(in srgb, var(--platform), transparent 89%); }
.video-copy strong { display: block; margin-top: 5px; overflow: hidden; font-size: 11px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
.video-tags { display: flex; align-items: center; gap: 4px; min-width: 0; margin-top: 5px; overflow: hidden; }
.video-tags span { flex: 0 1 auto; max-width: 110px; padding: 2px 5px; border-radius: 4px; color: var(--muted); background: rgba(255, 255, 255, .045); font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-positive { color: var(--green); }
.rate-cell { display: inline-flex; align-items: center; gap: 5px; }
.rate-cell i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }

.board-view { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; max-height: 620px; overflow: auto; }
.board-column { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.board-head strong { font-size: 12px; }
.board-head span { color: var(--muted); font-size: 9px; }
.board-card { display: grid; grid-template-columns: 39px 1fr; gap: 8px; width: 100%; margin-top: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: var(--surface-strong); text-align: left; content-visibility: auto; contain-intrinsic-size: auto 58px; transition: transform .16s ease, border-color .16s ease; }
.board-card:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.board-card .thumb { width: 39px; height: 39px; }
.board-card strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 10px; line-height: 1.3; }
.board-card small { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-size: 8px; }

.matrix-view { display: grid; gap: 5px; max-height: 620px; overflow: auto; }
.matrix-row { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(5, minmax(90px, 1fr)); gap: 5px; width: 100%; padding: 0; border: 0; color: var(--text); background: transparent; text-align: left; content-visibility: auto; contain-intrinsic-size: auto 52px; }
.matrix-row > span { display: flex; align-items: center; min-width: 0; min-height: 48px; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: color-mix(in srgb, var(--heat), transparent 70%); font-size: 10px; }
.matrix-row > span:first-child { gap: 8px; background: var(--surface-soft); }
.matrix-row .thumb { flex: 0 0 auto; width: 34px; height: 34px; }
.matrix-row b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timeline-view { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; max-height: 620px; overflow: auto; }
.timeline-day { min-height: 92px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface-soft); text-align: left; transition: transform .16s ease, border-color .16s ease; }
.timeline-day:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.timeline-day span { color: var(--muted); font-size: 9px; }
.timeline-day strong { display: block; margin-top: 8px; font-size: 18px; }
.timeline-day small { display: block; margin-top: 6px; color: var(--green); font-size: 9px; }
.timeline-bar { display: block; height: 3px; margin-top: 10px; border-radius: 2px; background: var(--line); overflow: hidden; }
.timeline-bar i { display: block; width: var(--bar); height: 100%; background: var(--blue); }

.detail-panel {
  position: sticky;
  top: 84px;
  align-self: start;
  min-height: 620px;
  padding: 16px;
  overflow: hidden;
}
.detail-cover { position: relative; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); overflow: hidden; }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-platform-row { display: flex; align-items: center; gap: 7px; min-width: 0; margin-top: 12px; }
.detail-platform-row .video-tags { margin-top: 0; }
.detail-title { margin-top: 13px; font-size: 17px; line-height: 1.35; text-wrap: pretty; }
.detail-date { margin-top: 7px; color: var(--muted); font-size: 10px; }
.detail-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 14px; }
.detail-metrics div { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.detail-metrics span { display: block; color: var(--muted); font-size: 9px; }
.detail-metrics strong { display: block; margin-top: 5px; font-size: 15px; }
.detail-source { margin-top: 12px; padding: 10px; border-left: 2px solid var(--platform); color: var(--muted); background: color-mix(in srgb, var(--platform), transparent 92%); font-size: 9px; line-height: 1.6; }
.empty-state { display: grid; place-items: center; min-height: 280px; color: var(--muted); font-size: 12px; }

.site-footer { display: flex; justify-content: space-between; gap: 12px; padding: 18px 4px 0; color: var(--faint); font-size: 10px; }

.message-dialog { width: min(760px, calc(100% - 28px)); max-height: min(82vh, 760px); padding: 0; border: 0; color: var(--text); background: transparent; overflow: visible; }
.message-dialog::backdrop { background: rgba(2, 7, 11, .76); backdrop-filter: blur(10px); }
.message-card { display: grid; grid-template-rows: auto auto minmax(0, 1fr); max-height: min(82vh, 760px); padding: 22px; border-radius: 14px; overflow: hidden; }
.message-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.message-dialog-head h2 { margin-top: 3px; font-size: 24px; }
.message-dialog-head p { margin-top: 5px; color: var(--muted); font-size: 10px; }
.message-filters { display: flex; gap: 7px; margin-top: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.message-filters button { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface-soft); font-size: 10px; white-space: nowrap; }
.message-filters button.active { border-color: color-mix(in srgb, var(--blue), transparent 30%); color: var(--text); background: color-mix(in srgb, var(--blue), transparent 82%); }
.message-filters button span { color: var(--faint); font-size: 9px; }
.message-dialog-list { display: grid; gap: 8px; margin: 12px -4px 0 0; padding-right: 4px; overflow-y: auto; overscroll-behavior: contain; }
.message-dialog-item { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 72px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: color-mix(in srgb, var(--surface-soft), transparent 8%); text-align: left; transition: transform .16s ease, border-color .16s ease, background-color .16s ease; }
.message-dialog-item:hover { transform: translateX(3px); border-color: color-mix(in srgb, var(--platform), transparent 35%); background: color-mix(in srgb, var(--platform), transparent 93%); }
.message-dialog-item .platform-mark { width: 38px; height: 38px; border-radius: 9px; }
.message-dialog-item .message-copy strong { margin-top: 3px; font-size: 12px; }
.message-dialog-item .message-copy > span:last-child { max-width: 520px; margin-top: 5px; font-size: 10px; }
.message-meta { display: flex !important; align-items: center; gap: 6px; margin: 0 !important; }
.message-meta b { padding: 2px 5px; border-radius: 4px; color: var(--platform); background: color-mix(in srgb, var(--platform), transparent 88%); font-size: 8px; font-weight: 750; }
.message-meta i { color: var(--faint); font-size: 9px; font-style: normal; }
.message-dialog-item .message-tail > i { color: var(--faint); font-size: 22px; font-style: normal; }
.message-empty { display: grid; place-items: center; min-height: 240px; color: var(--muted); font-size: 11px; }

.export-dialog { width: min(720px, calc(100% - 28px)); padding: 0; border: 0; color: var(--text); background: transparent; }
.export-dialog::backdrop { background: rgba(2, 7, 11, .72); backdrop-filter: blur(8px); }
.export-card { padding: 20px; border-radius: 12px; }
.export-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.export-head h2 { font-size: 20px; }
.export-head p { margin-top: 6px; color: var(--muted); font-size: 11px; }
.export-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 18px; }
.export-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; }
.export-grid input,
.export-grid select { width: 100%; padding: 0 10px; }
.platform-checks { display: flex; gap: 15px; margin: 16px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.platform-checks legend { color: var(--muted); font-size: 9px; }
.platform-checks label { font-size: 11px; }
.export-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.export-actions span { color: var(--muted); font-size: 10px; }

.chart-tooltip {
  position: fixed;
  z-index: 100;
  width: 186px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .14s ease, transform .14s ease;
}
.chart-tooltip.show { opacity: 1; transform: translateY(0); }
.chart-tooltip strong { display: block; font-size: 11px; }
.chart-tooltip div { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; color: var(--muted); font-size: 9px; }
.chart-tooltip div b { color: var(--text); }

.reveal-panel { opacity: 0; transform: translateY(12px); }
.reveal-panel.is-visible { opacity: 1; transform: translateY(0); transition: opacity .45s ease-out, transform .45s ease-out; }
.loading-shimmer { position: relative; overflow: hidden; }
.loading-shimmer::after { position: absolute; inset: 0; content: ""; background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.06) 45%, transparent 70%); transform: translateX(-100%); animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

@media (max-width: 1180px) {
  .nav-links a { padding-inline: 9px; }
  .brand { min-width: 185px; }
  .page-heading { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
  .analytics-rail { grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
  .filter-bar { grid-template-columns: auto 110px 130px 1fr; }
  .search-box { grid-column: 1 / -1; }
  .library-section { grid-template-columns: minmax(0, 2.4fr) minmax(280px, 1fr); }
}

@media (max-width: 900px) {
  .app-shell { width: min(100% - 16px, 1680px); margin-top: 8px; }
  .topnav { grid-template-columns: 1fr auto; }
  .nav-links { grid-column: 1 / -1; justify-content: start; order: 3; margin-top: 6px; overflow-x: auto; }
  .nav-links a { flex: 0 0 auto; }
  .source-status,
  .kpi-grid,
  .growth-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card + .kpi-card { border-left: 0; }
  .kpi-card:nth-child(even) { border-left: 1px solid var(--line); }
  .kpi-card:nth-child(n+3) { border-top: 1px solid var(--line); }
  .library-section { grid-template-columns: 1fr; }
  .detail-panel { position: static; min-height: auto; }
}

@media (max-width: 660px) {
  .topnav { position: relative; top: 0; }
  .brand span:last-child { display: none; }
  .brand { min-width: 0; }
  .nav-actions .primary-button { width: 38px; padding: 0; font-size: 0; }
  .page-heading { padding-top: 20px; }
  .source-status,
  .kpi-grid,
  .growth-grid,
  .analytics-rail { grid-template-columns: 1fr; }
  .kpi-card,
  .kpi-card:nth-child(even) { border-left: 0; }
  .kpi-card + .kpi-card { border-top: 1px solid var(--line); }
  .panel-head,
  .library-head { align-items: stretch; flex-direction: column; }
  .panel-tools { justify-content: space-between; }
  .trend-panel { padding: 15px; }
  .trend-chart svg { height: 270px; }
  .trend-summary { grid-template-columns: repeat(2, 1fr); }
  .trend-summary div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .trend-summary div:nth-child(4) { border-top: 1px solid var(--line); }
  .platform-mix { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: repeat(2, 1fr); }
  .date-presets { grid-column: 1 / -1; overflow-x: auto; }
  .date-presets button { flex: 0 0 auto; }
  .order-control { grid-column: 1 / -1; }
  .search-box { grid-column: 1 / -1; }
  .view-tabs { width: 100%; overflow-x: auto; }
  .view-tabs button { flex: 1 0 auto; }
  .data-table { min-width: 790px; }
  .board-view { grid-template-columns: 1fr; }
  .matrix-view { overflow-x: auto; }
  .matrix-row { min-width: 800px; }
  .export-grid { grid-template-columns: 1fr; }
  .message-card { padding: 16px; }
  .message-dialog-item { grid-template-columns: 34px minmax(0, 1fr); }
  .message-dialog-item .message-tail { grid-column: 2; justify-content: space-between; }
  .platform-checks { flex-wrap: wrap; }
  .site-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  #ambientCanvas { display: none; }
  .reveal-panel { opacity: 1; transform: none; }
}
