:root {
  color-scheme: dark;
  --bg: #0a0a0f;
  --bg-alt: #12121a;
  --surface: rgba(26, 26, 36, 0.68);
  --surface-solid: #1a1a24;
  --surface-high: #20202b;
  --text: #fafafa;
  --muted: #8b8b96;
  --faint: #5f5f6c;
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --sidebar: 370px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button, select, input { color: inherit; }
button { cursor: pointer; }
svg { display: block; }

.ambient { position: fixed; border-radius: 50%; filter: blur(130px); pointer-events: none; z-index: -2; }
.ambient-one { width: 520px; height: 520px; top: -260px; left: 16%; background: rgba(245, 158, 11, 0.055); }
.ambient-two { width: 460px; height: 460px; right: -250px; bottom: -160px; background: rgba(148, 163, 184, 0.035); }
.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.topbar {
  min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: rgba(10, 10, 15, .74);
  backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid rgba(245, 158, 11, .22);
  border-radius: 13px; background: var(--accent-soft); box-shadow: 0 0 28px rgba(245, 158, 11, .08);
}
.brand-mark svg { width: 31px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand h1 { margin: 1px 0 0; font: 600 23px/1.1 "Space Grotesk", sans-serif; letter-spacing: -.03em; }
.eyebrow, .section-kicker { margin: 0; color: var(--accent); font: 500 10px/1.4 "JetBrains Mono", monospace; letter-spacing: .14em; }
.top-actions { display: flex; gap: 10px; }

.button {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 17px;
  border-radius: 10px; border: 1px solid transparent; text-decoration: none; font-weight: 600; font-size: 13px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: scale(.98); }
.button:focus-visible, .icon-button:focus-visible, select:focus-visible, input:focus-visible, .drop-zone:focus-within, .text-button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.button-primary { background: var(--accent); color: #0a0a0f; box-shadow: 0 0 22px rgba(245, 158, 11, .16); }
.button-primary:hover:not(:disabled) { box-shadow: 0 0 26px rgba(245, 158, 11, .35); filter: brightness(1.06); }
.button-outline { border-color: var(--border-hover); background: rgba(255,255,255,.025); }
.button-outline:hover:not(:disabled) { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.055); }
.button-ghost { background: transparent; color: #d4d4d8; }
.button-ghost:hover { background: rgba(255,255,255,.05); }
.button:disabled { cursor: not-allowed; opacity: .35; }

.app-shell { min-height: calc(100vh - 78px); display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  padding: 18px; border-right: 1px solid var(--border); background: rgba(14, 14, 20, .72);
  overflow-y: auto; max-height: calc(100vh - 78px); position: sticky; top: 78px;
}
.panel {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); backdrop-filter: blur(10px);
  padding: 17px; margin-bottom: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.16);
}
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.panel-heading.compact { align-items: center; }
.panel h2 { margin: 4px 0 0; font: 600 17px/1.2 "Space Grotesk", sans-serif; letter-spacing: -.02em; }
.status-dot { width: 8px; height: 8px; margin: 6px; border-radius: 50%; background: #52525b; box-shadow: 0 0 0 5px rgba(82,82,91,.1); transition: .2s ease; }
.status-dot.active { background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.1), 0 0 16px rgba(34,197,94,.35); }
.count-badge { min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font: 500 11px "JetBrains Mono", monospace; }

.drop-zone {
  min-height: 146px; border: 1px dashed rgba(245,158,11,.28); border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 20px; background: rgba(245,158,11,.025);
  transition: .2s ease; cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover { border-color: rgba(245,158,11,.68); background: rgba(245,158,11,.07); box-shadow: inset 0 0 30px rgba(245,158,11,.035); }
.drop-zone input { position: absolute; opacity: 0; pointer-events: none; }
.drop-zone svg { width: 27px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 12px; }
.drop-title { font-weight: 600; font-size: 13px; }
.drop-subtitle { margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.5; max-width: 260px; }
.preservation-note { display: flex; gap: 10px; margin-top: 13px; color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.preservation-note strong { color: #d4d4d8; }
.preservation-note svg { flex: 0 0 17px; width: 17px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }

.field-label, .field > span, .color-field > span { display: block; margin-bottom: 7px; color: #b4b4bd; font-size: 10px; font-weight: 600; letter-spacing: .035em; }
select, input[type="text"] {
  width: 100%; min-height: 39px; border: 1px solid var(--border); border-radius: 8px; background: rgba(10,10,15,.65);
  padding: 0 11px; font-size: 12px; transition: .18s ease;
}
select:hover, input[type="text"]:hover { border-color: var(--border-hover); }
select:disabled { opacity: .45; }
.data-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 12px; }
.data-summary > div { min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,.018); padding: 9px 8px; }
.data-summary span { display: block; color: var(--faint); font-size: 8.5px; margin-bottom: 4px; white-space: nowrap; }
.data-summary strong { font: 500 12px "JetBrains Mono", monospace; }

.icon-button {
  width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px;
  background: rgba(255,255,255,.025); transition: .18s ease;
}
.icon-button:hover { border-color: var(--border-hover); background: rgba(255,255,255,.055); }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

details { border-top: 1px solid var(--border); }
details:last-child { border-bottom: 1px solid var(--border); }
summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 43px; color: #d6d6dc; font-size: 11px; font-weight: 600; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--faint); font: 400 17px "JetBrains Mono"; transition: transform .2s ease; }
details[open] summary::after { transform: rotate(45deg); color: var(--accent); }
.details-body { padding: 2px 0 16px; }
.two-column-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 12px; }
.control { min-width: 0; }
.control > span { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; color: #b4b4bd; font-size: 10px; font-weight: 600; }
.control output { color: var(--accent); font: 500 9.5px "JetBrains Mono", monospace; }
input[type="range"] { width: 100%; height: 3px; appearance: none; border-radius: 99px; background: #34343e; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(245,158,11,.10); }
.field.full, .switch-row.full { grid-column: 1 / -1; }
.color-field input[type="color"] { width: 100%; height: 38px; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: rgba(10,10,15,.65); }
.switch-row { min-height: 37px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #b4b4bd; font-size: 10px; font-weight: 600; position: relative; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row i { width: 33px; height: 19px; border-radius: 99px; background: #34343e; position: relative; transition: .2s ease; }
.switch-row i::after { content: ""; width: 13px; height: 13px; border-radius: 50%; background: #8b8b96; position: absolute; top: 3px; left: 3px; transition: .2s ease; }
.switch-row input:checked + i { background: rgba(245,158,11,.3); box-shadow: inset 0 0 0 1px rgba(245,158,11,.26); }
.switch-row input:checked + i::after { left: 17px; background: var(--accent); }

.workspace { min-width: 0; padding: 20px 24px 26px; display: flex; flex-direction: column; }
.workspace-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.workspace-title h2 { margin: 5px 0 0; font: 600 19px/1.2 "Space Grotesk", sans-serif; letter-spacing: -.02em; }
.live-indicator { color: var(--muted); font: 500 9px "JetBrains Mono", monospace; letter-spacing: .12em; }
.live-indicator i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #52525b; margin-right: 6px; }
.live-indicator.active i { background: #22c55e; box-shadow: 0 0 10px rgba(34,197,94,.5); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.export-menu { display: flex; gap: 8px; position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); width: 190px; padding: 6px; border: 1px solid var(--border-hover); border-radius: 10px; background: #181820; box-shadow: var(--shadow); z-index: 15; }
.menu button { width: 100%; min-height: 38px; padding: 0 10px; text-align: left; border: 0; border-radius: 7px; background: transparent; font-size: 12px; }
.menu button:hover { background: rgba(255,255,255,.055); color: var(--accent); }

.plot-stage {
  flex: 1; min-height: 640px; overflow: auto; border: 1px solid var(--border); border-radius: 15px; background: #101017;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 36px 36px; box-shadow: inset 0 0 80px rgba(0,0,0,.22), 0 12px 40px rgba(0,0,0,.17);
  position: relative;
}
#plot { min-width: 100%; min-height: 100%; display: none; }
.empty-state { min-height: 640px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; }
.empty-icon { width: 112px; height: 112px; display: grid; place-items: center; border-radius: 26px; background: rgba(245,158,11,.04); border: 1px solid rgba(245,158,11,.14); box-shadow: 0 0 50px rgba(245,158,11,.05); margin-bottom: 24px; }
.empty-icon svg { width: 69px; fill: none; stroke: #8d6a2a; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h3 { margin: 8px 0; font: 600 28px "Space Grotesk", sans-serif; letter-spacing: -.035em; }
.empty-state > p:not(.section-kicker) { max-width: 520px; margin: 0 0 22px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.integrity-bar { display: flex; align-items: center; gap: 30px; min-height: 68px; margin-top: 12px; padding: 0 16px; border: 1px solid var(--border); border-radius: 12px; background: rgba(18,18,26,.72); }
.integrity-item { display: flex; align-items: center; gap: 10px; min-width: 0; }
.integrity-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: rgba(34,197,94,.1); color: #4ade80; font-size: 12px; }
.integrity-icon.neutral { background: var(--accent-soft); color: var(--accent); }
.integrity-item strong { display: block; font-size: 10px; margin-bottom: 3px; }
.integrity-item small { display: block; color: var(--faint); font: 400 8.5px "JetBrains Mono", monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.text-button { margin-left: auto; border: 0; background: transparent; color: var(--accent); font-size: 10px; font-weight: 600; }
.text-button:disabled { color: var(--faint); cursor: not-allowed; }

.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
dialog { width: min(900px, calc(100vw - 40px)); max-height: 82vh; padding: 20px; border: 1px solid var(--border-hover); border-radius: 14px; background: #13131b; color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.67); backdrop-filter: blur(5px); }
dialog h2 { margin: 5px 0 0; font: 600 21px "Space Grotesk", sans-serif; }
.dialog-note { color: var(--muted); font-size: 11px; }
pre { max-height: 58vh; overflow: auto; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: #09090e; color: #d4d4d8; font: 10px/1.65 "JetBrains Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 15px; border: 1px solid var(--border-hover); border-radius: 9px; background: #20202b; box-shadow: var(--shadow); font-size: 11px; z-index: 100; transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  :root { --sidebar: 330px; }
  .workspace { padding-left: 17px; padding-right: 17px; }
  .integrity-item:nth-child(2) { display: none; }
}
@media (max-width: 820px) {
  .topbar { position: relative; padding: 12px 14px; }
  .brand h1 { font-size: 19px; }
  .brand-mark { width: 42px; height: 42px; }
  .top-actions .button-ghost { display: none; }
  .app-shell { display: block; }
  .sidebar { position: relative; top: auto; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); padding: 14px; }
  .workspace { padding: 15px 14px 22px; }
  .plot-stage, .empty-state { min-height: 520px; }
  .workspace-toolbar { align-items: flex-end; }
  .integrity-bar { gap: 12px; }
  .integrity-item small { max-width: 180px; }
}
@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .top-actions .button-outline { padding: 0 11px; font-size: 0; }
  .top-actions .button-outline::after { content: "Source"; font-size: 12px; }
  .workspace-toolbar { display: block; }
  .export-menu { margin-top: 12px; }
  .export-menu .button { flex: 1; }
  .two-column-controls { grid-template-columns: 1fr; }
  .field.full, .switch-row.full { grid-column: auto; }
  .data-summary { grid-template-columns: 1fr 1fr 1fr; }
  .integrity-bar { display: grid; grid-template-columns: 1fr auto; padding: 10px 12px; }
  .integrity-item:nth-child(2) { display: none; }
  .text-button { margin: 0; }
}
