:root {
  --bg: #ffffff;
  --bg-elev: #fafafa;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --text: #0a0a0a;
  --text-soft: #262626;
  --muted: #6b7280;
  --brand: #16a34a;
  --brand-dark: #15803d;
  --accent: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-strong: 0 4px 16px rgba(0, 0, 0, 0.08), 0 16px 48px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-lg: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --bg-elev: #111111;
    --panel: #161616;
    --panel-strong: #1c1c1c;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f5f5;
    --text-soft: #d4d4d4;
    --muted: #9ca3af;
    --brand: #22c55e;
    --brand-dark: #16a34a;
    --accent: #fbbf24;
    --danger: #ef4444;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-strong: 0 4px 16px rgba(0, 0, 0, 0.5), 0 16px 48px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }
.shell, .auth-view, .app-view { min-height: 100vh; }

.auth-view {
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg-elev);
}

.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}

/* Headers — system fonts, modern weights */
.brand-block h1,
.topbar h2,
.section-header h3,
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-block h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar h2 { font-size: 20px; }
.section-header h3 { font-size: 15px; font-weight: 600; }

.brand-block p,
.section-header p,
.status-inline,
.status-panel,
.empty-state,
.sessions-list small {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Auth */
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0 14px;
}

.auth-tab,
.primary-button,
.secondary-button {
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.auth-tab,
.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
}

.auth-tab:hover,
.secondary-button:hover {
  background: var(--bg-elev);
  border-color: var(--text-soft);
}

.auth-tab.active,
.primary-button {
  background: var(--brand);
  color: #ffffff;
  border: 1px solid var(--brand);
}

.primary-button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.auth-form { display: grid; gap: 10px; }
.auth-tabs.two { grid-template-columns: repeat(2, 1fr); }
.auth-hint { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

input,
select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.status-panel { margin-top: 14px; min-height: 24px; }

/* App view */
.app-view { padding: 0; background: var(--bg); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.user-badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 12px;
  font-family: var(--font-mono);
  max-width: min(38vw, 460px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Top tab navigation */
.tab-nav {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 65px;
  z-index: 9;
}

.tab-btn {
  background: none;
  border: none;
  font: inherit;
  font-weight: 500;
  color: var(--muted);
  padding: 12px 16px;
  cursor: pointer;
  position: relative;
  transition: color 120ms ease;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--brand);
}

.tab-panel { display: none; padding: 20px 24px; }
.tab-panel.active { display: block; }

/* Two-column inside a tab: sidebar + main */
.tab-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

.tab-layout.no-sidebar { grid-template-columns: 1fr; }

.sidebar-card,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.main-panel { display: grid; gap: 18px; }
.details-panel { display: grid; }

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-header p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.sessions-list { display: grid; gap: 8px; }

.session-item {
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
  text-align: left;
  width: 100%;
}

.session-item:hover { border-color: var(--text-soft); background: var(--panel-strong); }
.session-item.active {
  border-color: var(--brand);
  background: var(--panel-strong);
  box-shadow: inset 3px 0 0 var(--brand);
}

.session-item h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.session-item small {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metric-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.metric-card strong {
  display: block;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.metric-card span { font-size: 12px; color: var(--muted); }

.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.status-inline { margin-top: 10px; min-height: 18px; font-size: 13px; }

.graph-root {
  width: 100%;
  min-height: 640px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
}

.details-content { display: grid; gap: 12px; }

.detail-card {
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 14px;
}

.detail-card h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.detail-list { display: grid; gap: 6px; font-size: 13px; }

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.detail-list span { color: var(--muted); }
.detail-list strong { font-weight: 500; font-family: var(--font-mono); font-size: 12px; }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* Frame browser */
.frame-list { flex: 1; overflow-y: auto; display: grid; gap: 12px; }
.frame-card { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 14px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); }
.frame-img { aspect-ratio: 16 / 9; border-radius: 8px; background: var(--panel); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; overflow: hidden; }
.frame-img img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.frame-card figcaption { display: grid; gap: 8px; align-content: start; font-size: 13px; }
.frame-card h5 { margin: 0; font-size: 13px; font-weight: 600; }
.frame-card ul { margin: 0; padding-left: 18px; }
@media (max-width: 720px) { .frame-card { grid-template-columns: 1fr; } }

/* Graph node-kind checkboxes */
.node-kind-filter { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; margin: 0; font-size: 13px; }
.node-kind-filter legend { padding: 0 4px; font-size: 12px; color: var(--muted); }
.node-kind-filter label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.node-kind-filter label.is-empty { opacity: 0.5; cursor: default; }
.kind-swatch { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--line); }
.kind-skill { background: #94a3b8; border-radius: 50%; }
.kind-competency { background: #64748b; border-radius: 3px; width: 18px; }
.kind-gee { background: #ff9966; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); border: 0; }
.kind-ollila { background: #00BCD4; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); border: 0; }
.kind-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.kind-help { flex-basis: 100%; margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* Parents report: reads like a printed letter, on white in both themes. */
.parent-report-shell { background: var(--panel); border-radius: 16px; padding: 16px; width: min(860px, 95vw); height: 90vh; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.parent-report-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.parent-report { flex: 1; overflow-y: auto; background: #fff; color: #1d1d1f; border-radius: 10px; padding: 40px 48px; font-size: 15px; line-height: 1.55; }
.parent-report header { border-bottom: 2px solid #1d1d1f; padding-bottom: 12px; margin-bottom: 20px; }
.parent-report .eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #6e6e73; margin: 0 0 4px; }
.parent-report h1 { font-size: 26px; margin: 0; }
.parent-report .meta { color: #6e6e73; font-size: 13px; margin: 6px 0 0; }
.parent-report h2 { font-size: 16px; margin: 26px 0 8px; }
.parent-report .lead { font-size: 16px; }
.parent-report .groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.parent-report .group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: #6e6e73; margin: 0 0 6px; }
.parent-report ul { margin: 0; padding-left: 18px; }
.parent-report li { margin: 0 0 6px; }
.parent-report .hint { color: #6e6e73; font-size: 13px; }
.parent-report .session-row { border-top: 1px solid #e5e5ea; padding: 8px 0; }
.parent-report footer { margin-top: 28px; padding-top: 12px; border-top: 1px solid #e5e5ea; color: #6e6e73; font-size: 12px; }
@media (max-width: 720px) { .parent-report { padding: 24px 20px; } }
@media print {
  body.printing-parent-report > *:not(#parent-report-modal) { display: none !important; }
  body.printing-parent-report #parent-report-modal { position: static !important; display: block !important; background: none !important; }
  body.printing-parent-report .parent-report-shell { width: auto; height: auto; padding: 0; box-shadow: none; background: none; }
  body.printing-parent-report .parent-report-toolbar { display: none; }
  body.printing-parent-report .parent-report { overflow: visible; padding: 0; border-radius: 0; }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-soft);
}

.empty-state {
  padding: 18px;
  border-radius: var(--radius);
  border: 1px dashed var(--line-strong);
  background: var(--bg-elev);
  color: var(--muted);
  font-size: 13px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 1100px) {
  .tab-layout { grid-template-columns: 240px 1fr; }
}

@media (max-width: 900px) {
  .tab-layout { grid-template-columns: 1fr; }
  .metric-grid, .controls-grid { grid-template-columns: 1fr 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .tab-nav { top: 0; overflow-x: auto; }
}

@media (max-width: 640px) {
  .metric-grid, .controls-grid, .auth-tabs { grid-template-columns: 1fr; }
  .graph-root { min-height: 420px; }
  .tab-panel { padding: 16px; }
}
