:root {
  --ink: #0c1014;
  --panel: #12171c;
  --panel-2: #171d24;
  --line: rgba(243, 239, 230, 0.1);
  --warm: #f3efe6;
  --muted: #9aa3ad;
  --faint: #6b7480;
  --brass: #c4a574;
  --accent: #7eb8a2;
  --danger: #d4796a;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--warm);
  font-family: var(--font);
  font-size: 14px;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 16, 20, 0.95);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--brass); color: var(--ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 650; letter-spacing: -0.02em; }
.brand-by { font-size: 11px; color: var(--faint); }
.topbar-center {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.btn:hover { border-color: rgba(243, 239, 230, 0.28); }
.btn.primary {
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass);
  font-weight: 650;
}
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 280px;
  min-height: 0;
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .panel.left, .panel.right { max-height: 220px; }
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel.right {
  border-right: none;
  border-left: 1px solid var(--line);
}
.panel-title {
  margin: 0;
  padding: 12px 14px 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 700;
}
.side-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 10px 0;
}
.side-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--faint);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}
.side-tab.is-active {
  color: var(--warm);
  background: rgba(243, 239, 230, 0.06);
  border-color: var(--line);
}
.side-body {
  padding: 10px 12px 16px;
  overflow: auto;
  flex: 1;
}

.center {
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse at top, rgba(196, 165, 116, 0.06), transparent 50%),
    var(--ink);
  display: flex;
  flex-direction: column;
}

.dropzone {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}
.drop-card {
  width: min(520px, 100%);
  border: 1px dashed rgba(196, 165, 116, 0.45);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  background: rgba(18, 23, 28, 0.8);
}
.dropzone.is-drag .drop-card {
  border-color: var(--brass);
  background: rgba(196, 165, 116, 0.08);
}
.drop-title { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -0.03em; }
.drop-sub { margin: 8px 0 16px; color: var(--muted); }
.drop-chips {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 18px;
}
.drop-chips span {
  font-size: 11px; padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--faint);
}
.drop-card .btn { margin: 4px; }

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
  gap: 10px;
}
.detect-bar {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--panel);
}
.detect-title { font-weight: 650; margin-bottom: 6px; }
.detect-cols {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.detect-cols span {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(126, 184, 162, 0.12);
  color: var(--accent);
}
.suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggest {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  min-width: 120px;
}
.suggest:hover, .suggest.is-active {
  border-color: color-mix(in srgb, var(--brass) 55%, transparent);
  background: rgba(196, 165, 116, 0.08);
}
.suggest strong { display: block; font-size: 13px; margin-bottom: 2px; }
.suggest span { font-size: 11px; color: var(--muted); }

.plot-wrap {
  flex: 1;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #070b10;
  position: relative;
  overflow: hidden;
}
#plot {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
.plot-hint {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: 11px;
  color: var(--faint);
  pointer-events: none;
}

#inspector { padding: 0 14px 16px; overflow: auto; flex: 1; }
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field select, .field input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0a0e12;
  padding: 8px 10px;
}
.inspector-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.list button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--muted);
}
.list button.is-active, .list button:hover {
  background: rgba(243, 239, 230, 0.05);
  border-color: var(--line);
  color: var(--warm);
}
.list .meta { display: block; font-size: 11px; color: var(--faint); margin-top: 2px; }

.codebar {
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.code-toggle {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 650;
}
.code-body {
  border-top: 1px solid var(--line);
  padding: 8px 12px 12px;
}
.code-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.code-tab { font-size: 12px; color: var(--faint); }
.code-tab.is-active { color: var(--warm); }
.script-view {
  margin: 0;
  min-height: 110px;
  max-height: 220px;
  overflow: auto;
  background: #070b10;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  outline: none;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--accent);
  margin: 2px 0;
}
.check::before { content: "✓"; font-size: 11px; }
