/* ShadCN-inspired tokens, light + dark, drives all chrome around the 3D scene */

:root {
  --radius: 8px;
  --background: oklch(0.985 0.002 250);
  --foreground: oklch(0.15 0.02 260);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.15 0.02 260);
  --muted: oklch(0.96 0.005 260);
  --muted-foreground: oklch(0.5 0.015 260);
  --border: oklch(0.91 0.008 260);
  --input: oklch(0.93 0.008 260);
  --primary: oklch(0.55 0.14 240);
  --primary-foreground: #fff;
  --secondary: oklch(0.96 0.006 260);
  --secondary-foreground: oklch(0.2 0.02 260);
  --accent: oklch(0.94 0.012 260);
  --accent-foreground: oklch(0.2 0.02 260);
  --ring: oklch(0.55 0.14 240 / 0.35);
  --success: oklch(0.62 0.16 155);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 24px -8px rgb(0 0 0 / 0.12), 0 4px 8px -4px rgb(0 0 0 / 0.06);
}

:root[data-theme="dark"] {
  --background: oklch(0.30 0.012 260);
  --foreground: oklch(0.97 0.005 260);
  --card: oklch(0.34 0.014 260 / 0.94);
  --card-foreground: oklch(0.97 0.005 260);
  --muted: oklch(0.38 0.012 260);
  --muted-foreground: oklch(0.78 0.012 260);
  --border: oklch(0.46 0.012 260);
  --input: oklch(0.42 0.012 260);
  --secondary: oklch(0.38 0.012 260);
  --secondary-foreground: oklch(0.95 0.005 260);
  --accent: oklch(0.42 0.012 260);
  --accent-foreground: oklch(0.95 0.005 260);
  --shadow-lg: 0 10px 30px -8px rgb(0 0 0 / 0.4), 0 4px 10px -4px rgb(0 0 0 / 0.25);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", "Helvetica Neue",
               "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  background: var(--background);
  color: var(--foreground);
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#three-canvas {
  position: fixed; inset: 0; z-index: 0;
}

#ui-root { position: relative; z-index: 1; }

.sc-mono {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.sc-num { font-variant-numeric: tabular-nums; font-weight: 500; }
.sc-muted { color: var(--muted-foreground); }
.sc-accent { color: var(--primary); font-weight: 600; }

/* ── Top bar ───────────────────────────────────────────────────────────── */
.sc-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: color-mix(in oklab, var(--card) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  z-index: 20;
}
.sc-topbar-left, .sc-topbar-right {
  display: flex; align-items: center; gap: 10px;
}
.sc-logo {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
}
.sc-topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.sc-topbar-h1 { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.sc-topbar-h2 { font-size: 11px; color: var(--muted-foreground); }

.sc-station-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 8px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  font-size: 12px; font-weight: 500; color: var(--foreground);
  cursor: pointer; transition: background .12s, border-color .12s;
  font-family: inherit;
}
.sc-station-pill:hover { background: var(--accent); border-color: color-mix(in oklab, var(--border) 70%, var(--foreground) 8%); }

.sc-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  display: inline-block;
}
.sc-dot-ok {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 25%, transparent);
}

.sc-sep { background: var(--border); height: 1px; width: 100%; }
.sc-sep-v { width: 1px; height: 22px; background: var(--border); }
.sc-sep-tight { height: 18px; margin: 0 2px; }

.sc-divider { color: var(--muted-foreground); margin: 0 4px; }

/* ── Badge ─────────────────────────────────────────────────────────────── */
.sc-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 11px; font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.sc-badge-secondary {
  background: var(--secondary); color: var(--secondary-foreground);
  border-color: var(--border);
}
.sc-badge-outline {
  background: transparent; color: var(--foreground);
  border-color: var(--border);
}
.sc-badge-success {
  background: color-mix(in oklab, var(--success) 14%, transparent);
  color: color-mix(in oklab, var(--success) 80%, var(--foreground));
  border-color: color-mix(in oklab, var(--success) 30%, transparent);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.sc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer; transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  padding: 0 12px; height: 32px;
  color: var(--foreground);
  background: transparent;
}
.sc-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.sc-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.sc-btn-default { background: var(--secondary); border-color: var(--border); }
.sc-btn-default:hover { background: var(--accent); }

.sc-btn-outline { background: transparent; border-color: var(--border); }
.sc-btn-outline:hover { background: var(--accent); }

.sc-btn-ghost { background: transparent; }
.sc-btn-ghost:hover { background: var(--accent); }

.sc-btn-primary {
  background: var(--primary); color: var(--primary-foreground);
  border-color: color-mix(in oklab, var(--primary) 80%, black);
}
.sc-btn-primary:hover {
  background: color-mix(in oklab, var(--primary) 88%, black);
}

.sc-btn-icon { width: 32px; height: 32px; padding: 0; }

/* ── Card ──────────────────────────────────────────────────────────────── */
.sc-card {
  background: color-mix(in oklab, var(--card) 92%, transparent);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(var(--card-blur, 16px)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--card-blur, 16px)) saturate(140%);
  overflow: hidden;
}
.sc-card-hd { padding: 14px 16px 12px; }
.sc-card-title {
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--foreground);
}
.sc-card-desc {
  font-size: 11.5px; color: var(--muted-foreground);
  margin-top: 2px;
}
.sc-card-ct { padding: 12px 16px 14px; }

.sc-card-hd-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.sc-collapse-btn {
  width: 24px; height: 24px; flex-shrink: 0;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  border-radius: calc(var(--radius) - 4px);
  color: var(--muted-foreground); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  margin-top: -2px;
}
.sc-collapse-btn:hover {
  background: var(--accent); color: var(--foreground);
  border-color: var(--border);
}
.sc-row-gap { display: inline-flex; align-items: center; gap: 6px; }

.sc-card-collapsed .sc-card-hd { padding-bottom: 14px; }
.sc-card-collapsed .sc-card-desc { display: none; }

/* Smooth collapse using grid-template-rows trick */
.sc-collapsible {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .28s cubic-bezier(.32,.72,0,1),
              opacity .22s ease;
  opacity: 1;
}
.sc-collapsible.closed {
  grid-template-rows: 0fr;
  opacity: 0;
}
.sc-collapsible-inner {
  overflow: hidden;
  min-height: 0;
}

.sc-card {
  transition: box-shadow .2s ease;
}

/* density tweaks */
.sc-density-compact .sc-card-hd { padding: 10px 14px 8px; }
.sc-density-compact .sc-card-ct { padding: 10px 14px 12px; }
.sc-density-compact .sc-card-desc { display: none; }
.sc-density-compact .sc-kv-row { padding: 4px 0; }

/* ── Floating positions ─────────────────────────────────────────────────── */
.sc-floater { position: fixed; z-index: 10; }
.sc-floater-tl { top: 68px;  left: 14px;   width: 240px; }
.sc-floater-tr { top: 68px;  right: 14px;  width: 290px; }
.sc-floater-bl { bottom: 56px; left: 14px;  width: 200px; }
.sc-floater-br { bottom: 56px; right: 14px; width: 200px; }

/* sidebar layout: shove the floaters into a column on the right */
body[data-layout="sidebar"] .sc-floater-tl,
body[data-layout="sidebar"] .sc-floater-tr,
body[data-layout="sidebar"] .sc-floater-bl,
body[data-layout="sidebar"] .sc-floater-br {
  position: fixed; right: 14px; left: auto;
  width: 304px;
}
body[data-layout="sidebar"] .sc-floater-tl { top: 68px; }
body[data-layout="sidebar"] .sc-floater-tr { top: calc(68px + 230px + 12px); }
body[data-layout="sidebar"] .sc-floater-bl { top: auto; bottom: 56px; }
body[data-layout="sidebar"] .sc-floater-br { top: auto; bottom: 56px; }

/* ── KV grid ───────────────────────────────────────────────────────────── */
.sc-kv { display: flex; flex-direction: column; gap: 0; }
.sc-kv-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 6px 0;
  border-bottom: 1px dashed color-mix(in oklab, var(--border) 70%, transparent);
}
.sc-kv-row:last-child { border-bottom: none; }
.sc-kv-k { font-size: 11.5px; color: var(--muted-foreground); }
.sc-kv-v { font-size: 12px; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }

/* ── Legend ────────────────────────────────────────────────────────────── */
.sc-legend-card { width: 200px; }
.sc-legend-content {
  display: flex; gap: 12px; align-items: stretch; padding-top: 14px; padding-bottom: 14px;
}
.sc-legend-bar {
  width: 8px; border-radius: 4px;
  background: linear-gradient(to bottom,
    oklch(0.74 0.16 50),
    oklch(0.55 0.18 295),
    oklch(0.55 0.14 240));
  min-height: 96px;
}
.sc-legend-labels {
  display: flex; flex-direction: column;
  justify-content: space-between; flex: 1;
  font-size: 11px; color: var(--muted-foreground);
}
.sc-legend-row { display: flex; align-items: center; gap: 6px; }
.sc-legend-swatch { width: 8px; height: 8px; border-radius: 2px; }

/* ── Playback ──────────────────────────────────────────────────────────── */
.sc-playback-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sc-playback-stats {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.sc-playback-time {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--foreground);
}
.sc-playback-meta { font-size: 11px; color: var(--muted-foreground); }

.sc-progress-track {
  position: relative;
  height: 6px; background: var(--input); border-radius: 999px;
  cursor: pointer; margin-bottom: 14px;
}
.sc-progress-fill {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: var(--primary); border-radius: 999px;
  pointer-events: none;
}
.sc-progress-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
.sc-progress-track:hover .sc-progress-thumb { opacity: 1; }

.sc-playback-controls {
  display: flex; align-items: center; gap: 6px;
}

/* ── Toggle group (segmented) ──────────────────────────────────────────── */
.sc-toggle-group {
  display: inline-flex;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 2px;
}
.sc-toggle-item {
  font-family: inherit; font-size: 11px; font-weight: 500;
  padding: 0 9px; height: 24px;
  background: transparent; border: none;
  color: var(--muted-foreground);
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer; transition: background .12s, color .12s;
}
.sc-toggle-item:hover { color: var(--foreground); }
.sc-toggle-item.active {
  background: var(--card); color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

/* ── Switch ────────────────────────────────────────────────────────────── */
.sc-switch {
  position: relative;
  width: 36px; height: 20px;
  background: var(--input);
  border: none; border-radius: 999px;
  cursor: pointer; transition: background .15s;
  padding: 0; flex-shrink: 0;
}
.sc-switch.on { background: var(--primary); }
.sc-switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.sc-switch.on .sc-switch-thumb { transform: translateX(16px); }

/* ── Row helpers ───────────────────────────────────────────────────────── */
.sc-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sc-row-label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sc-row-title { font-size: 12px; font-weight: 500; color: var(--foreground); }
.sc-row-sub   { font-size: 11px; color: var(--muted-foreground); }
.sc-mt { margin-top: 12px; }

/* ── Hint strip ────────────────────────────────────────────────────────── */
.sc-hint {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: color-mix(in oklab, var(--card) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  font-size: 11px; color: var(--muted-foreground);
  z-index: 10;
}
.sc-kbd {
  display: inline-flex; align-items: center;
  padding: 2px 6px; margin-left: 6px;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 500;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--foreground);
}
.sc-kbd + .sc-kbd { margin-left: 14px; }
.sc-hint > .sc-kbd:first-child { margin-left: 0; }

/* ── Hover card ────────────────────────────────────────────────────────── */
.sc-hover {
  position: fixed; z-index: 30; pointer-events: none;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow-lg);
  padding: 10px 12px;
  font-size: 11.5px;
}
.sc-hover-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sc-hover-idx {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-weight: 600; color: var(--primary); font-size: 12px;
}
.sc-hover-grid {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px;
  font-variant-numeric: tabular-nums;
}
.sc-hover-grid > span:nth-child(odd) { color: var(--muted-foreground); }
.sc-hover-grid .num { font-family: ui-monospace, "JetBrains Mono", monospace; font-weight: 500; }

/* ── Sheet ─────────────────────────────────────────────────────────────── */
.sc-sheet-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: oklch(0 0 0 / 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.sc-sheet-overlay.open { opacity: 1; pointer-events: auto; }

.sc-sheet {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 92vw; z-index: 41;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px -10px rgb(0 0 0 / 0.18);
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
  display: flex; flex-direction: column;
}
.sc-sheet.open { transform: translateX(0); }

/* Left-side sheet variant (file drawer) */
.sc-sheet-left {
  right: auto; left: 0;
  border-left: none;
  border-right: 1px solid var(--border);
  box-shadow: 10px 0 30px -10px rgb(0 0 0 / 0.18);
  transform: translateX(-100%);
}
.sc-sheet-left.open { transform: translateX(0); }

/* Files list */
.sc-files-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 6px;
}
.sc-file-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer; text-align: left;
  font-family: inherit; color: var(--foreground);
  transition: background .12s, border-color .12s;
}
.sc-file-item:hover { background: var(--accent); }
.sc-file-item.active {
  background: color-mix(in oklab, var(--primary) 8%, transparent);
  border-color: color-mix(in oklab, var(--primary) 40%, var(--border));
}
.sc-file-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--secondary);
  border-radius: calc(var(--radius) - 4px);
  color: var(--muted-foreground);
}
.sc-file-item.active .sc-file-icon {
  background: color-mix(in oklab, var(--primary) 14%, transparent);
  color: var(--primary);
}
.sc-file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sc-file-name {
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sc-file-sub { font-size: 10.5px; color: var(--muted-foreground); }

.sc-files-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 32px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.sc-files-empty-icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--secondary);
  border-radius: 50%;
  color: var(--muted-foreground);
  margin-bottom: 4px;
}
.sc-files-empty-title { font-size: 13px; font-weight: 500; }
.sc-files-empty-desc { font-size: 11.5px; color: var(--muted-foreground); }
.sc-sheet-hd {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.sc-sheet-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.sc-sheet-desc  { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }
.sc-sheet-x {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.sc-sheet-x:hover { background: var(--accent); color: var(--foreground); border-color: var(--border); }
.sc-sheet-body {
  flex: 1; overflow-y: auto;
  padding: 4px 20px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.sc-sheet-section { padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.sc-sheet-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-foreground);
}
.sc-sheet-status { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Tweaks panel — adopt theme colors ────────────────────────────────── */
.twk-panel {
  background: color-mix(in oklab, var(--card) 92%, transparent) !important;
  color: var(--foreground) !important;
  border-color: var(--border) !important;
  border-radius: var(--radius) !important;
}
