/* VedaCanvas - DataVedas theme tokens (family-consistent with VedaProfile) */
:root, html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161a;
  --bg-soft: #1b1e24;
  --panel: #1e222a;
  --ink: #e8e6e1;
  --ink-dim: #a09c94;
  --border: #2e333d;
  --accent: #e8792b;
  --accent-soft: rgba(232, 121, 43, 0.12);
  --hover: rgba(232, 121, 43, 0.07);
  --shadow: rgba(0, 0, 0, 0.4);
  --ok: #4caf7d;
  --warn: #d9a13b;
  --bad: #d96b5b;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #faf8f5;
  --bg-soft: #f1eee9;
  --panel: #ffffff;
  --ink: #23211e;
  --ink-dim: #6d675e;
  --border: #ddd7cd;
  --accent: #c9611a;
  --accent-soft: rgba(201, 97, 26, 0.10);
  --hover: rgba(201, 97, 26, 0.06);
  --shadow: rgba(60, 50, 30, 0.15);
  --ok: #2e8f5f;
  --warn: #a8721c;
  --bad: #b34a3a;
}
* { box-sizing: border-box; }
select, input[type="number"], input[type="text"] {
  background: var(--bg); color: var(--ink); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 9px; font-family: inherit; font-size: 0.88rem;
}
select option { background: var(--panel); color: var(--ink); }
select:focus, input[type="number"]:focus, input[type="text"]:focus {
  outline: none; border-color: var(--accent);
}
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, -apple-system, sans-serif; line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: var(--bg-soft); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.02em; color: var(--ink); white-space: nowrap; }
.brand .lens { color: var(--accent); }
.topbar .ds-name { flex: 1; text-align: center; font-size: 0.9rem; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn {
  background: transparent; color: var(--ink);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 13px; font-size: 0.85rem; cursor: pointer; font-family: inherit; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1.25;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* landing */
.landing { max-width: 900px; margin: 0 auto; padding: 60px 24px 80px; }
.landing h1 { font-size: 2.2rem; margin: 0 0 6px; }
.landing .tagline { color: var(--ink-dim); font-size: 1.05rem; margin-bottom: 40px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0; font-size: 1.1rem; }
.card p { margin: 0; color: var(--ink-dim); font-size: 0.9rem; flex: 1; }
.card .btn { align-self: flex-start; }
.privacy {
  margin-top: 44px; padding: 16px 20px; border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 8px; color: var(--ink-dim); font-size: 0.9rem;
}

/* workbench */
.bench-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
.main { padding: 24px 28px 120px; min-height: 100vh; }
.main h5, .methods h5 { margin: 18px 0 8px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; }
.methods {
  position: sticky; top: 58px; max-height: calc(100vh - 58px); overflow-y: auto;
  padding: 22px 22px 60px; background: var(--bg-soft); border-left: 1px solid var(--border);
  min-height: calc(100vh - 58px);
}
.op-log { min-height: 30px; margin-bottom: 12px; }
.log-line { font-size: 0.84rem; color: var(--ink-dim); padding: 2px 0; }
.log-line:first-child { color: var(--ink); }

.rel-section { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; margin-bottom: 14px; }
.rel-section h5 { margin-top: 0; }
.rel-controls { font-size: 0.88rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.rel-controls select, .rel-controls input[type="number"], .rel-controls input[type="text"] {
  background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-family: inherit;
}
.rel-controls label { cursor: pointer; font-size: 0.85rem; }
.muted-note { color: var(--ink-dim); font-size: 0.8rem; line-height: 1.5; margin-top: 6px; }
.warn-note { color: var(--warn); font-size: 0.8rem; }

/* boot overlay */
.boot-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 100;
  display: none; align-items: center; justify-content: center;
}
.boot-box { max-width: 480px; text-align: center; padding: 24px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: vfspin 0.9s linear infinite;
}
@keyframes vfspin { to { transform: rotate(360deg); } }
#boot-status { font-size: 0.92rem; }

@media (max-width: 1000px) {
  .bench-grid { grid-template-columns: minmax(0, 1fr); }
  .methods { position: static; min-height: 0; max-height: none; border-left: 0; border-top: 2px solid var(--accent); }
}

details.fine { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft); }
details.fine > summary {
  cursor: pointer; color: var(--ink-dim); font-size: 0.82rem; list-style: none;
  user-select: none; padding: 8px 13px;
}
details.fine > summary::before { content: "\25B8 "; color: var(--accent); }
details.fine[open] > summary::before { content: "\25BE "; }
details.fine > summary:hover { color: var(--accent); }
details.fine[open] { background: var(--panel); }
details.fine > *:not(summary) { margin: 0 13px 11px; }

/* busy overlay */
.busy-overlay {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 78%, transparent);
  z-index: 95; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(1.5px);
}
#busy-label { font-size: 0.95rem; font-weight: 600; }

/* inline notes inside control rows: kill the block margin so they align with the controls */
.rel-controls .muted-note { margin-top: 0; }

/* collapsible section cards, so long outputs can be folded away */
details.sect { padding: 0; }
details.sect > summary { list-style: none; cursor: pointer; user-select: none; padding: 13px 18px; }
details.sect > summary::-webkit-details-marker { display: none; }
details.sect > summary h5 { display: inline; margin: 0; }
details.sect > summary::before { content: "\25BE "; color: var(--accent); font-size: 0.75rem; }
details.sect:not([open]) > summary::before { content: "\25B8 "; }
details.sect > summary:hover h5 { color: var(--accent); }
details.sect > *:not(summary) { margin-left: 18px; margin-right: 18px; }
details.sect > *:last-child:not(summary) { margin-bottom: 14px; }

/* VedaCanvas: chooser chips, family grid, canvas, code */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  background: var(--bg); color: var(--ink-dim); border: 1px solid var(--border);
  border-radius: 14px; padding: 4px 12px; font-size: 0.8rem; cursor: pointer; font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.fam-grid { display: block; margin-top: 4px; }
.fam-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 13px 13px; cursor: pointer; text-align: left; font-family: inherit; color: var(--ink);
  display: flex; flex-direction: column; gap: 7px; align-items: stretch;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.fam-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.fam-card:hover .fc-icon { opacity: 1; }
.fam-card.active { border-color: var(--accent); background: var(--accent-soft); }
.fam-card.active .fc-icon { opacity: 1; }
.fc-head { display: flex; align-items: center; gap: 11px; }
.fc-icon {
  flex: 0 0 58px; width: 58px; height: 36px; opacity: 0.85;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; padding: 3px;
  color: var(--ink-dim);
}
.fam-card.active .fc-icon { background: var(--panel); border-color: var(--accent); }
.fam-card .fc-name { font-weight: 620; font-size: 0.9rem; line-height: 1.25; }
.fam-card .fc-why { color: var(--ink-dim); font-size: 0.775rem; line-height: 1.45; }
.seg { display: inline-flex; }
.seg-btn { border-radius: 0; }
.seg-btn:first-child { border-radius: 7px 0 0 7px; }
.seg-btn:last-child { border-radius: 0 7px 7px 0; border-left: 0; }
.seg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
/* the figure paints its own background from the chosen style, so the canvas
   stays out of the way: no white band around a dark chart */
.canvas-out {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; overflow: auto; min-height: 320px;
  display: flex; justify-content: center; align-items: flex-start;
}
.canvas-out svg { max-width: 100%; height: auto; border-radius: 4px; }
.canvas-out > div { max-width: 100%; }
.canvas-out > .muted-note { padding: 12px; }
#plotly-host { width: 100%; }
.code-out {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-family: Consolas, monospace; font-size: 0.8rem;
  line-height: 1.55; overflow-x: auto; white-space: pre; margin: 0; color: var(--ink);
}
.ctl-group { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; }
.ctl-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.ctl-row > label { flex: 0 0 108px; font-size: 0.78rem; color: var(--ink-dim); }
.ctl-row select, .ctl-row input[type="text"], .ctl-row input[type="number"] { flex: 1; min-width: 0; }
.ctl-row input[type="checkbox"] { flex: 0 0 auto; }
.tier-band {
  font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--ink-dim); margin: 16px 0 8px; display: flex; align-items: center; gap: 10px;
}
.tier-band::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.fam-grid-inner {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 10px; align-items: stretch;
}
.fc-static {
  display: block; font-size: 0.58rem; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-top: 2px;
}
.fam-card.off { opacity: 0.5; cursor: not-allowed; border-style: dashed; }
.fam-card.off:hover { border-color: var(--border); }
