/* ═══════════════════════════════════════════════════════════════
   Outline Playground  ·  CSS Design System
   Dark-first · Inspired by regex101.com × VS Code
   ═══════════════════════════════════════════════════════════════ */

/* ── Custom Properties (Dark) ─────────────────────────────────── */
:root {
  --bg:       #0d1117;
  --bg-2:     #161b27;
  --bg-3:     #1c2336;
  --bg-4:     #232d42;
  --bg-5:     #2a3550;

  --border:   #1e2d44;
  --border-2: #2e4060;

  --text:     #e2e8f0;
  --muted:    #7a90b8;
  --dim:      #3a5070;
  --faint:    #243045;

  --accent:   #4facfe;
  --accent-d: #0073e6;
  --green:    #4ade80;
  --green-d:  #15803d;
  --purple:   #c084fc;
  --orange:   #fb923c;
  --red:      #f87171;
  --yellow:   #fbbf24;

  --r:        6px;
  --r-sm:     4px;
  --r-lg:     10px;
  --shadow:   0 8px 32px rgba(0,0,0,.5);
  --shadow-sm:0 2px 8px rgba(0,0,0,.35);

  --header-h: 52px;
  --sidebar-w:272px;
  --results-w:480px;
  --fn-ui:    'Inter', system-ui, sans-serif;
  --fn-mono:  'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Light theme ────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:       #f5f7fb;
  --bg-2:     #ffffff;
  --bg-3:     #f0f4fa;
  --bg-4:     #e8edf7;
  --bg-5:     #dce3f0;
  --border:   #dde4f0;
  --border-2: #c4cfe0;
  --text:     #1e293b;
  --muted:    #566987;
  --dim:      #8fa0b8;
  --faint:    #e8edf7;
  --accent:   #0073e6;
  --green:    #15803d;
  --purple:   #7c3aed;
  --orange:   #c2410c;
  --red:      #dc2626;
  --yellow:   #b45309;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--fn-ui);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.header-left { flex: 0 0 auto; }
.header-center { flex: 1; display: flex; align-items: center; gap: 8px; justify-content: center; }
.header-right { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }

/* Logo */
.logo { display: flex; align-items: center; gap: 10px; }
.logo-svg { color: var(--accent); }
.hex-stroke { stroke: var(--accent); }
.logo-text-group { display: flex; flex-direction: column; line-height: 1.2; }
.logo-text { font-size: 15px; font-weight: 700; letter-spacing: -.3px; }
.logo-accent { color: var(--accent); }
.logo-sub { font-size: 10px; color: var(--muted); letter-spacing: .1px; }

.separator { width: 1px; height: 20px; background: var(--border-2); margin: 0 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; font-family: var(--fn-ui);
  cursor: pointer; border: none; transition: all .13s;
}
.btn-primary {
  background: linear-gradient(135deg, #4facfe, #00c8ff);
  color: #031a30;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,172,254,.4); }
.btn-primary:active { transform: none; filter: none; }

.btn-secondary {
  background: var(--bg-4); color: var(--text);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--bg-3); border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); border-color: var(--border-2); }

.btn-theme {
  background: none; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 5px 9px; cursor: pointer; color: var(--muted); font-size: 13px;
}
.btn-theme:hover { border-color: var(--accent); color: var(--accent); }

.header-link { color: var(--muted); display: flex; align-items: center; transition: color .12s; }
.header-link:hover { color: var(--accent); }
.header-brand {
  font-family: var(--fn-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  text-decoration: none;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  transition: background .14s, border-color .14s;
}
.header-brand:hover {
  background: rgba(79,172,254,.08);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Layout ─────────────────────────────────────────────────── */
.layout {
  flex: 1;
  display: flex;          /* flex instead of grid for resizable right panel */
  overflow: hidden;
  height: calc(100vh - var(--header-h));
}

.editor-panel {
  flex: 1 1 0;
  min-width: 200px;
}

.panel-resize-handle {
  flex: 0 0 5px;
  background: var(--border);
  cursor: col-resize;
  position: relative;
  transition: background .15s;
  z-index: 5;
}
.panel-resize-handle:hover,
.panel-resize-handle.dragging {
  background: var(--accent);
}
.panel-resize-handle::after {
  content: '';
  position: absolute;
  inset: 0 -4px;   /* wider hit-target */
}

.results-panel {
  flex: 0 0 var(--results-w);
  min-width: 200px;
  max-width: 80vw;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  min-width: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: width .2s ease;
}
.sidebar.collapsed { width: 0 !important; overflow: hidden; }
.sidebar-toggle {
  position: absolute; top: 50%; right: -10px;
  transform: translateY(-50%);
  width: 18px; height: 36px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 0 5px 5px 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); z-index: 10; transition: color .12s;
}
.sidebar-toggle:hover { color: var(--accent); }
.sidebar.collapsed .sidebar-toggle { right: -18px; transform: translateY(-50%) scaleX(-1); }

/* Sidebar tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1; padding: 9px 8px; font-size: 11px; font-weight: 600;
  background: none; border: none; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; transition: all .13s; letter-spacing: .1px;
}
.sidebar-tab:hover { color: var(--text); }
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Sidebar panels */
.sidebar-panel { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.sidebar-panel.active { display: flex; }

/* Category filter */
.cat-filter { display: flex; gap: 3px; flex-wrap: wrap; padding: 8px 8px 4px; }
.cat-btn {
  font-size: 10px; padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--border); background: none; color: var(--muted);
  cursor: pointer; transition: all .12s;
}
.cat-btn.active, .cat-btn:hover { background: var(--accent); color: #031a30; border-color: var(--accent); }
.cat-btn[data-cat="unique"] { color: #f9a825; border-color: rgba(249,168,37,.4); }
.cat-btn[data-cat="unique"].active, .cat-btn[data-cat="unique"]:hover { background: #f9a825; color: #1a1000; border-color: #f9a825; }

/* Example list */
.example-list { overflow-y: auto; flex: 1; padding: 4px 6px 8px; }
.example-item {
  padding: 9px 10px; border-radius: var(--r-sm);
  cursor: pointer; border: 1px solid transparent;
  transition: all .12s; margin-bottom: 3px;
}
.example-item:hover { background: var(--bg-3); border-color: var(--border); }
.example-item.active { background: rgba(79,172,254,.08); border-color: rgba(79,172,254,.4); }
.ex-meta { margin-bottom: 3px; }
.ex-cat {
  font-size: 9px; padding: 1px 5px; border-radius: 8px;
  background: var(--bg-4); color: var(--dim); text-transform: uppercase; letter-spacing: .4px;
}
.ex-title { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.ex-desc { font-size: 10px; color: var(--muted); line-height: 1.45; overflow-wrap: break-word; word-break: break-word; }
.loading-msg { padding: 20px; text-align: center; color: var(--muted); }

/* MySpace */
.myspace-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.myspace-hint { font-size: 10px; color: var(--dim); }
.myspace-save-group { display: flex; gap: 4px; align-items: center; }
.btn-save-new {
  font-size: 11px; padding: 3px 10px; border-radius: var(--r-sm);
  background: rgba(74,222,128,.12); color: var(--green);
  border: 1px solid rgba(74,222,128,.25); cursor: pointer; transition: all .12s;
}
.btn-save-new:hover { background: rgba(74,222,128,.22); }
.btn-save-as { font-size: 10px; padding: 2px 7px; opacity: .8; }

.snippet-list { overflow-y: auto; flex: 1; padding: 6px; }
.snippet-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border); margin-bottom: 4px;
  cursor: pointer; transition: all .12s;
}
.snippet-item:hover { background: var(--bg-3); border-color: var(--border-2); }
.snippet-active { border-color: var(--accent) !important; background: rgba(79,172,254,.06) !important; }
.snippet-left { flex: 1; overflow: hidden; }
.snippet-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet-date { font-size: 10px; color: var(--muted); margin-top: 2px; }
.snippet-actions { display: flex; gap: 4px; margin-left: 8px; }
.snippet-btn {
  font-size: 11px; padding: 2px 6px; background: none; border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; color: var(--muted); transition: all .12s;
}
.snippet-btn:hover { color: var(--text); border-color: var(--border-2); }
.snippet-run:hover { color: var(--accent); border-color: var(--accent); }
.snippet-del:hover { color: var(--red); border-color: var(--red); }

.empty-state { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.6; }
.empty-icon { font-size: 28px; margin-bottom: 8px; opacity: .5; }
.empty-hint { font-size: 11px; color: var(--dim); margin-top: 6px; }
.empty-hint kbd {
  background: var(--bg-4); border: 1px solid var(--border-2); border-radius: 3px;
  padding: 1px 4px; font-family: var(--fn-mono);
}

/* ── Editor Panel ────────────────────────────────────────────── */
.editor-panel {
  display: flex; flex-direction: column; overflow: hidden;
  background: #13172b;
}
[data-theme="light"] .editor-panel { background: #f8fafc; }


.editor-toolbar {
  display: flex; align-items: center; padding: 7px 12px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  gap: 10px; flex-shrink: 0;
}
.file-tab {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--fn-mono); font-size: 11px;
  color: var(--muted); background: var(--bg-3);
  padding: 3px 10px; border-radius: var(--r-sm) var(--r-sm) 0 0;
  border: 1px solid var(--border); border-bottom: none; position: relative; top: 1px;
}
.editor-status-area { flex: 1; text-align: center; }
.editor-status { font-size: 11px; color: var(--muted); font-weight: 500; }
.editor-status.status-running { color: var(--yellow); }
.editor-status.status-ok      { color: var(--green); }
.editor-status.status-error   { color: var(--red); }
.editor-status.status-warn    { color: var(--yellow); }

.editor-meta { display: flex; align-items: center; gap: 6px; }
#meta-lines { font-size: 10px; color: var(--dim); font-family: var(--fn-mono); }
.meta-sep { color: var(--dim); }
.editor-meta kbd {
  font-size: 10px; background: var(--bg-4); border: 1px solid var(--border-2);
  border-radius: 3px; padding: 1px 5px; font-family: var(--fn-mono); color: var(--muted);
}
.monaco-container { flex: 1; overflow: hidden; }

/* ── Results Panel ───────────────────────────────────────────── */
.results-panel {
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* width is controlled by JS drag; initial value via CSS var */
}

/* Tabs */
.result-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  flex-shrink: 0;
}
.result-tab {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 14px; font-size: 11px; font-weight: 600;
  color: var(--muted); background: none; border: none;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all .13s; white-space: nowrap;
}
.result-tab:hover { color: var(--text); }
.result-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-label { display: flex; align-items: center; gap: 4px; }
.tab-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 10px;
  background: var(--bg-4); color: var(--dim);
}
.tab-badge-error { background: rgba(248,113,113,.12); color: var(--red); }
.badge-has-count { background: rgba(79,172,254,.18); color: var(--accent); }
.badge-has-error { background: rgba(248,113,113,.2) !important; color: var(--red) !important; }

/* Tab content */
.tab-content { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.tab-content.active { display: flex; }

/* ── Inference Tab ───────────────────────────────────────────── */
/* Stats bar */
.stats-bar {
  display: flex; align-items: center; gap: 0;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg-3); flex-shrink: 0;
}
.stat { display: flex; align-items: baseline; gap: 3px; padding: 0 10px; }
.stat:first-child { padding-left: 0; }
.stat-val { font-size: 16px; font-weight: 700; color: var(--accent); font-family: var(--fn-mono); }
.stat-key { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat-sep { width: 1px; height: 22px; background: var(--border); }

/* ── README / Landing page ───────────────────────────────────── */
.inference-intro {
  display: flex; flex-direction: column;
  padding: 20px 20px 24px; flex: 1; overflow-y: auto; gap: 14px;
}
.readme-hero {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.readme-logo {
  font-size: 32px; color: var(--accent); font-weight: 700;
  font-family: var(--fn-mono); opacity: .85; flex-shrink: 0;
}
.readme-headline { display: flex; flex-direction: column; gap: 3px; }
.readme-name {
  font-size: 20px; font-weight: 700; color: var(--text);
  letter-spacing: -.3px;
}
.readme-tagline {
  font-size: 11px; color: var(--muted); font-weight: 400;
  line-height: 1.5;
}
.readme-lead {
  font-size: 12.5px; color: var(--muted); line-height: 1.7;
  padding: 0 2px;
}
.readme-lead strong { color: var(--text); font-weight: 600; }
.readme-section-title {
  font-size: 10px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: .5px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.readme-cards { display: flex; flex-direction: column; gap: 10px; }
.readme-card {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px;
  transition: border-color .15s;
}
.readme-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.readme-card-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; line-height: 1; }
.readme-card-body { display: flex; flex-direction: column; gap: 4px; }
.readme-card-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.readme-card-desc {
  font-size: 11.5px; color: var(--muted); line-height: 1.6;
}
.readme-card-desc code {
  font-family: var(--fn-mono); font-size: 11px;
  background: var(--hover); border-radius: 3px; padding: 0 4px;
  color: var(--accent);
}
.readme-card-desc em { color: var(--text); font-style: normal; font-weight: 500; }
.readme-cta {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--dim); padding-top: 4px;
}
.readme-cta strong { color: var(--text); }
.readme-cta kbd {
  font-size: 10px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px; font-family: var(--fn-mono); color: var(--muted);
}
.readme-cta-sep { color: var(--border); }

/* Symbol sections */
#inference-result { display: flex; flex-direction: column; flex: 1; }
.kind-section { border-bottom: 1px solid var(--border); }
.kind-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); background: var(--bg-3);
  border-bottom: 1px solid var(--border);
}
.kind-badge {
  font-size: 9px; padding: 1px 6px; border-radius: 10px;
}
.kind-let     { background: rgba(79,172,254,.15); color: var(--accent); }
.kind-var     { background: rgba(251,146,60,.15);  color: var(--orange); }
.kind-outline { background: rgba(192,132,252,.15); color: var(--purple); }

.sym-list { padding: 4px 8px 8px; }
.sym-empty { padding: 16px; text-align: center; color: var(--dim); font-size: 11px; }
.sym-row {
  display: grid; grid-template-columns: 1fr 1fr auto;
  align-items: center; padding: 6px 8px;
  border-radius: var(--r-sm); transition: background .1s;
  gap: 8px;
}
.sym-row:hover { background: var(--bg-3); }
.sym-left { display: flex; align-items: center; gap: 6px; overflow: hidden; }
.sym-name { font-family: var(--fn-mono); font-size: 12px; font-weight: 500; white-space: nowrap; }
.sym-kind-pill {
  font-size: 9px; padding: 1px 5px; border-radius: 8px; white-space: nowrap; flex-shrink: 0;
}
.sym-type { font-family: var(--fn-mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-loc { font-family: var(--fn-mono); font-size: 10px; color: var(--dim); white-space: nowrap; }

/* Type colours */
.ty-prim    { color: var(--accent); }
.ty-adt     { color: var(--purple); }
.ty-generic { color: var(--orange); }
.ty-arrow   { color: var(--muted); }
.ty-unknown { color: var(--dim); }
.ty-other   { color: var(--text); }

/* ── Output Tab ──────────────────────────────────────────────── */
#tab-output { padding: 14px; }
.output-card {
  display: flex; flex-direction: column; flex: 1;
}
.output-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; flex-shrink: 0;
}
.output-card-header span {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--dim);
}
.btn-copy {
  font-size: 10px; padding: 2px 8px; background: none;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; color: var(--muted); transition: all .12s;
}
.btn-copy:hover { border-color: var(--accent); color: var(--accent); }

.output-box {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px;
  font-family: var(--fn-mono); font-size: 14px; line-height: 1.65;
  color: var(--text); overflow-y: auto; white-space: pre-wrap; min-height: 80px;
}
.placeholder-text { color: var(--dim); font-style: italic; font-size: 12px; }
.out-value { color: var(--green); font-size: 16px; font-weight: 600; }
.out-error { color: var(--red); }

/* ── Errors Tab ──────────────────────────────────────────────── */
#tab-errors { padding: 10px; }
.no-errors-state { padding: 32px 20px; text-align: center; }
.no-errors-icon { font-size: 32px; color: var(--green); opacity: .6; margin-bottom: 8px; }
.no-errors-state > div:last-child { font-size: 12px; color: var(--muted); }

.diag-item {
  border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 8px;
  border-left: 3px solid;
}
.diag-error { border-left-color: var(--red); background: rgba(248,113,113,.06); border: 1px solid rgba(248,113,113,.18); border-left: 3px solid var(--red); }
.diag-warn  { border-left-color: var(--yellow); background: rgba(251,191,36,.06); border: 1px solid rgba(251,191,36,.18); border-left: 3px solid var(--yellow); }
.diag-kind {
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 5px;
}
.diag-error .diag-kind { color: var(--red); }
.diag-warn  .diag-kind { color: var(--yellow); }
.diag-msg {
  font-family: var(--fn-mono); font-size: 11px; line-height: 1.55;
  white-space: pre-wrap; color: var(--text);
}
.diag-loc {
  font-family: var(--fn-mono); font-size: 10px; color: var(--accent);
  margin-top: 5px; cursor: pointer; display: inline-block;
}
.diag-loc:hover { text-decoration: underline; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); padding: 24px; width: 360px; box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 700; margin-bottom: 16px;
}
.modal-close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 16px; transition: color .12s; padding: 2px 4px;
}
.modal-close:hover { color: var(--text); }
.modal-input {
  width: 100%; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); color: var(--text);
  font-family: var(--fn-ui); font-size: 14px; outline: none;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,172,254,.2); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.auth-tab {
  flex: 1;
  height: 32px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.auth-tab.active { background: rgba(79,172,254,.14); border-color: var(--accent); color: var(--accent); }
.auth-panel { padding-bottom: 4px; }
.auth-error { min-height: 18px; margin-top: 8px; color: var(--red); font-size: 12px; }
.auth-switch-row { margin-top: 8px; color: var(--muted); font-size: 12px; }
.auth-switch-link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 12px;
  font-weight: 600;
}
.auth-switch-link:hover { text-decoration: underline; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); padding: 10px 20px;
  font-size: 13px; font-weight: 500; color: var(--text);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 2000; white-space: nowrap;
}
.toast.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-ok    { border-color: rgba(74,222,128,.4); color: var(--green); }
.toast.toast-error { border-color: rgba(248,113,113,.4); color: var(--red); }

/* ── Scrollbars ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Monaco inline hints ─────────────────────────────────────── */
.inline-type-hint {
  color: #3a5a8a !important;
  font-style: italic;
  opacity: 0.65;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: .1px;
}
[data-theme="light"] .inline-type-hint { color: #7090c0 !important; }

/* ── Sym-row expandable ──────────────────────────────────────── */
.sym-row {
  cursor: pointer;
}
.sym-row:hover .sym-expand-hint { opacity: 1; }
.sym-expand-hint {
  font-size: 9px; color: var(--dim); margin-left: 4px; opacity: 0;
  transition: opacity .12s; white-space: nowrap;
}
.sym-type-truncated { max-width: 160px; }

/* ── Type detail modal ───────────────────────────────────────── */
.modal-wide { width: min(720px, 90vw); }
.type-detail-meta {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.type-detail-meta .sym-name { font-size: 15px; font-family: var(--fn-mono); font-weight: 600; }
.type-detail-meta .sym-kind-pill { font-size: 11px; padding: 2px 8px; }
.type-detail-meta .sym-loc { font-size: 11px; }
.type-detail-body {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px 20px;
  font-family: var(--fn-mono); font-size: 13px; line-height: 1.7;
  color: var(--text); overflow-y: auto; max-height: 55vh;
  white-space: pre-wrap; word-break: break-word;
}

/* ── Contribute example panel/modal ─────────────────────────── */
.contrib-footer {
  flex-shrink: 0;
  padding: 8px 8px;
  border-top: 1px solid var(--border);
}
.btn-contrib {
  width: 100%; padding: 7px 0; font-size: 11px; font-weight: 600;
  background: rgba(79,172,254,.08); color: var(--accent);
  border: 1px dashed rgba(79,172,254,.3); border-radius: var(--r-sm);
  cursor: pointer; transition: all .12s;
}
.btn-contrib:hover { background: rgba(79,172,254,.16); border-style: solid; }

.contrib-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.contrib-row { display: flex; flex-direction: column; gap: 4px; }
.contrib-row label { font-size: 11px; font-weight: 600; color: var(--muted); }
.field-hint { font-weight: 400; color: var(--dim); }
.contrib-code-preview {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px 12px;
  font-family: var(--fn-mono); font-size: 11px; line-height: 1.55;
  color: var(--text); overflow-y: auto; max-height: 160px;
  white-space: pre-wrap; word-break: break-word;
}

/* ── Console panel ───────────────────────────────────────────── */
.console-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.console-title {
  font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em;
  text-transform: uppercase;
}
.console-log-list {
  flex: 1; overflow-y: auto; padding: 4px 0;
  font-family: var(--fn-mono); font-size: 13px;
}
.console-empty {
  padding: 32px 20px; color: var(--dim); font-size: 12px; text-align: center;
}
.console-empty code {
  background: var(--hover); border-radius: 3px; padding: 1px 5px;
  font-family: var(--fn-mono); color: var(--accent); font-size: 11px;
}
.console-line {
  display: flex; align-items: baseline; gap: 8px;
  padding: 3px 14px; line-height: 1.6;
  border-left: 3px solid transparent;
}
.console-line:hover { background: var(--hover); }

/* log */
.console-log  { border-left-color: transparent; }
.console-log  .console-icon { color: var(--muted); }
.console-log  .console-text { color: var(--text); }

/* warn */
.console-warn { border-left-color: var(--yellow); background: rgba(251,191,36,.05); }
.console-warn .console-icon { color: var(--yellow); font-size: 12px; }
.console-warn .console-text { color: var(--yellow); }
.console-warn:hover          { background: rgba(251,191,36,.1); }

/* error */
.console-error { border-left-color: var(--red); background: rgba(248,113,113,.05); }
.console-error .console-icon { color: var(--red); font-size: 11px; font-weight: 700; }
.console-error .console-text { color: var(--red); }
.console-error:hover          { background: rgba(248,113,113,.1); }

.console-idx {
  font-size: 10px; color: var(--dim); min-width: 18px;
  text-align: right; flex-shrink: 0; user-select: none;
}
.console-icon {
  font-size: 13px; flex-shrink: 0; width: 14px; text-align: center;
  font-style: normal;
}
.console-text {
  white-space: pre-wrap; word-break: break-word; flex: 1;
}

/* ── Tutorial sidebar panel ──────────────────────────────────── */
.tut-search-wrap {
  padding: 10px 12px 6px;
}
.tut-search {
  width: 100%; box-sizing: border-box;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12px;
  padding: 5px 10px; outline: none;
  font-family: var(--fn-ui);
}
.tut-search:focus { border-color: var(--accent); }

.tut-chapter-list {
  flex: 1; overflow-y: auto; padding: 0 0 8px;
}

.tut-chapter { border-bottom: 1px solid var(--border); }

.tut-chapter-header {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 14px;
  background: none; border: none; cursor: pointer;
  color: var(--text); font-family: var(--fn-ui); font-size: 12.5px;
  font-weight: 600; text-align: left;
  transition: background .12s;
}
.tut-chapter-header:hover { background: var(--hover); }
.tut-ch-static { cursor: default; }
.tut-ch-static:hover { background: none; }
.tut-ch-icon { font-size: 14px; flex-shrink: 0; width: 20px; text-align: center; }
.tut-ch-title { flex: 1; }
.tut-ch-count {
  font-size: 10px; font-weight: 500; color: var(--muted);
  background: var(--bg3); border-radius: 10px;
  padding: 1px 6px;
}
.tut-ch-arrow {
  font-size: 14px; color: var(--muted); transition: transform .15s;
  margin-left: 2px;
}
.tut-ch-open > .tut-chapter-header .tut-ch-arrow { transform: rotate(90deg); }

.tut-lesson-list { padding: 2px 0 4px; }

.tut-lesson-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 14px 6px 28px;
  background: none; border: none; cursor: pointer;
  color: var(--dim); font-family: var(--fn-ui); font-size: 12px;
  text-align: left; transition: background .1s, color .1s;
}
.tut-lesson-item:hover { background: var(--hover); color: var(--text); }
.tut-ls-num {
  font-size: 10px; color: var(--muted); min-width: 16px;
  text-align: right; flex-shrink: 0; font-family: var(--fn-mono);
}
.tut-ls-title { flex: 1; line-height: 1.4; }

.tut-ls-active {
  color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 10%, transparent) !important;
  font-weight: 600;
}
.tut-ls-active .tut-ls-num { color: var(--accent); }

/* ── Lesson bar (above editor) ───────────────────────────────── */
.lesson-bar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 8px 16px;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg2));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  min-height: 0;
}
.lesson-bar-left {
  display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0;
}
.lesson-chapter-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-radius: 4px; padding: 2px 7px; white-space: nowrap; flex-shrink: 0;
  margin-top: 1px; letter-spacing: .02em;
}
.lesson-bar-text {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.lesson-title {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lesson-desc {
  font-size: 11px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.lesson-bar-right {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.lesson-nav-info {
  font-size: 11px; color: var(--muted); margin-right: 2px;
  font-family: var(--fn-mono);
}
.lesson-nav-btn {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-size: 16px; line-height: 1; padding: 2px 7px;
  cursor: pointer; transition: background .1s;
}
.lesson-nav-btn:hover:not(:disabled) { background: var(--hover); border-color: var(--accent); }
.lesson-nav-btn:disabled { opacity: .35; cursor: default; }
.lesson-exit-btn {
  background: none; border: none; color: var(--muted); font-size: 13px;
  cursor: pointer; padding: 4px 6px; border-radius: 4px;
  transition: color .1s, background .1s; margin-left: 4px;
}
.lesson-exit-btn:hover { color: var(--red); background: rgba(248,113,113,.1); }

/* ── Monaco inline diagnostic squiggles (via CSS class) ─────── */
.diag-underline-error {
  text-decoration: underline wavy var(--red);
  text-decoration-skip-ink: none;
}
.diag-underline-warn {
  text-decoration: underline wavy var(--yellow);
  text-decoration-skip-ink: none;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 960px) {
  :root { --sidebar-w: 240px; --results-w: 380px; }
}
@media (max-width: 720px) {
  :root { --sidebar-w: 0px; --results-w: 320px; }
  .sidebar { display: none; }
  .panel-resize-handle { display: none; }
  .separator { display: none; }
}
@media (max-width: 540px) {
  :root { --results-w: 100%; }
  .layout { flex-direction: column; }
  .editor-panel { flex: 1 1 50%; }
  .results-panel { flex: 0 0 50% !important; border-left: none; border-top: 1px solid var(--border); }
  .header-center .btn-infer, .header-center .btn-clear { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   User Auth & Comments  (appended)
   ══════════════════════════════════════════════════════════════ */

/* ── Login button ─────────────────────────────────────────────── */
.btn-login {
  height: 28px; padding: 0 14px; font-size: 12px; font-weight: 600;
  border-radius: var(--r-sm); border: 1px solid var(--accent);
  background: transparent; color: var(--accent); cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-login:hover { background: var(--accent); color: #fff; }

/* ── User chip ────────────────────────────────────────────────── */
.user-chip {
  display: flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.user-chip:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.user-avatar-icon { font-size: 13px; }

/* ── Auth modal content ────────────────────────────────────────── */
.auth-hint {
  font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 14px;
}
.auth-code-input {
  font-size: 22px !important; letter-spacing: 6px;
  text-align: center; font-family: var(--fn-mono) !important;
}
.auth-debug-box {
  margin-top: 10px; padding: 8px 12px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--yellow) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--yellow) 30%, transparent);
  font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.auth-debug-label { color: var(--muted); }
.auth-debug-code {
  font-family: var(--fn-mono); font-size: 16px; font-weight: 700;
  color: var(--yellow); letter-spacing: 4px;
}

/* ── Profile modal ─────────────────────────────────────────────── */
.profile-field {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px;
}
.profile-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.profile-value { font-size: 14px; color: var(--text); font-family: var(--fn-mono); }
.profile-hint  { font-size: 11px; color: var(--dim); margin-top: 4px; }

/* ── Danger button ─────────────────────────────────────────────── */
.btn-danger {
  height: 30px; padding: 0 14px; font-size: 12.5px; font-weight: 600;
  border-radius: var(--r-sm); border: 1px solid var(--red);
  background: transparent; color: var(--red); cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-danger:hover { background: var(--red); color: #fff; }

/* ── Comments tab ──────────────────────────────────────────────── */
.comments-login-prompt {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; height: 200px;
  color: var(--muted); font-size: 14px;
}
.comments-login-icon { font-size: 36px; }
.comments-login-text { font-size: 14px; color: var(--muted); }

/* Reactions row */
.comment-reactions {
  display: flex; gap: 10px; padding: 12px 14px 0;
}
.reaction-btn {
  display: flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 12px; border-radius: 15px;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.reaction-btn:hover { background: var(--bg-4); color: var(--text); }
.reaction-btn.active-like {
  background: color-mix(in srgb, var(--green) 15%, transparent);
  border-color: var(--green); color: var(--green);
}
.reaction-btn.active-dislike {
  background: color-mix(in srgb, var(--red) 15%, transparent);
  border-color: var(--red); color: var(--red);
}
.reaction-icon  { font-size: 14px; }
.reaction-count { font-family: var(--fn-mono); font-size: 12px; font-weight: 600; }

/* Compose box */
.comment-compose {
  display: flex; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.comment-textarea {
  flex: 1; resize: none; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text); font-size: 13px;
  font-family: var(--fn-ui); padding: 7px 10px; line-height: 1.5;
  transition: border-color .15s;
}
.comment-textarea:focus { outline: none; border-color: var(--accent); }
.btn-sm { height: 28px !important; padding: 0 12px !important; font-size: 12px !important; align-self: flex-end; }

/* Comment list */
.comment-list {
  overflow-y: auto; padding: 8px 0;
}
.comment-empty {
  padding: 24px 14px; text-align: center; color: var(--dim); font-size: 13px;
}
.comment-item {
  padding: 10px 14px; border-bottom: 1px solid var(--faint);
  display: flex; flex-direction: column; gap: 4px;
}
.comment-item:last-child { border-bottom: none; }
.comment-item-header {
  display: flex; align-items: center; justify-content: space-between;
}
.comment-author { font-size: 12px; font-weight: 600; color: var(--accent); }
.comment-time   { font-size: 11px; color: var(--dim); }
.comment-body   { font-size: 13px; color: var(--text); line-height: 1.5; }
.comment-reaction-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; padding: 2px 8px;
  border-radius: 12px; font-weight: 500;
}
.badge-like    { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.badge-dislike { color: var(--red);   background: color-mix(in srgb, var(--red)   12%, transparent); }
.comment-delete-btn {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-size: 11px; padding: 0 4px; opacity: 0; transition: opacity .15s, color .15s;
}
.comment-item:hover .comment-delete-btn { opacity: 1; }
.comment-delete-btn:hover { color: var(--red); }

/* ── MySpace server-sync additions ──────────────────────────────── */
.ms-user-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); margin-right: 5px; vertical-align: middle;
}
.btn-ms-login {
  display: inline-flex; align-items: center;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 4px; padding: 1px 7px; font-size: 11px; cursor: pointer;
  transition: background .15s;
}
.btn-ms-login:hover { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.snippet-meta { font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 4px; }
.snippet-synced { color: var(--accent); font-size: 11px; }

/* ── Comments tab header ─────────────────────────────────────── */
.comments-tab-header {
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--border);
}
.comments-context-title {
  font-size: 12px; font-weight: 600; color: var(--accent);
  letter-spacing: .03em;
}

.btn-lang-toggle {
  padding: 4px 10px; font-size: 11px; font-weight: 600; border-radius: var(--r-sm);
  background: var(--bg-4); color: var(--muted); border: 1px solid var(--border-2);
  cursor: pointer; transition: color .15s, border-color .15s; letter-spacing: .04em;
}
.btn-lang-toggle:hover { color: var(--text); border-color: var(--accent); }
