/* ─── PDM Omni Design System — CI Colors ─────────────────────────────────── */
:root {
  /* PDM palette (immutable) */
  --pdm-maccha-100:    #F2FBF0;
  --pdm-avocado-100:   #E8F4E8;
  --pdm-blueberry-100: #E8E8FF;
  --pdm-pumpkin-500:   #FF7A59;
  --pdm-maccha-1000:   #211B1A;
  --pdm-smoothie-100:  #FCEBF5;
  --pdm-mint-100:      #E6F5F8;
  --pdm-butter-100:    #FFF8D6;
  --pdm-pumpkin-100:   #FFE9E5;
  --pdm-seaweed-100:   #D1FFF5;
  --pdm-blueberry-500: #6B66FF;
}

/* ─── Design tokens (semantic, mapped to PDM) ────────────────────────────── */
:root {
  color-scheme: dark;
  /* Dark theme — only PDM colors + color-mix between them */
  --bg:          var(--pdm-maccha-1000);
  --sidebar:     var(--pdm-maccha-1000);
  --surface:     color-mix(in srgb, var(--pdm-maccha-1000), var(--pdm-maccha-100) 8%);
  --surface-2:   color-mix(in srgb, var(--pdm-maccha-1000), var(--pdm-maccha-100) 14%);
  --border:      color-mix(in srgb, var(--pdm-maccha-1000), var(--pdm-maccha-100) 35%);
  --border-2:    color-mix(in srgb, var(--pdm-maccha-1000), var(--pdm-maccha-100) 20%);
  --accent:      var(--pdm-pumpkin-500);
  --accent-dim:  color-mix(in srgb, var(--pdm-pumpkin-500) 15%, transparent);
  --accent-glow: color-mix(in srgb, var(--pdm-pumpkin-500) 30%, transparent);
  --success:     var(--pdm-seaweed-100);
  --success-dim: color-mix(in srgb, var(--pdm-seaweed-100) 12%, transparent);
  --error:       #EF4444;
  --error-dim:   rgba(239,68,68,.12);
  --warn:        var(--pdm-butter-100);
  --warn-dim:    color-mix(in srgb, var(--pdm-butter-100) 12%, transparent);
  --text:        var(--pdm-maccha-100);
  --text-2:      color-mix(in srgb, var(--pdm-maccha-100), var(--pdm-maccha-1000) 35%);
  --text-3:      color-mix(in srgb, var(--pdm-maccha-100), var(--pdm-maccha-1000) 45%);
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
  --r:           6px;
  --r-sm:        4px;
  --r-lg:        10px;
  --sidebar-w:   300px;
  --topbar-h:    52px;
  --focus-ring:  0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Status colors (mapped to PDM where possible) */
  --status-draft:     var(--pdm-pumpkin-500);
  --status-approved:  var(--pdm-blueberry-500);
  --status-published: var(--pdm-seaweed-100);
  --status-archived:  color-mix(in srgb, var(--pdm-maccha-1000), var(--pdm-maccha-100) 50%);
}

/* ─── Light theme (PDM palette) ─────────────────────────────────────────── */
html:has(#theme-toggle:checked) {
  color-scheme: light;
  --bg:          var(--pdm-maccha-100);
  --sidebar:     var(--pdm-maccha-100);
  --surface:     var(--pdm-avocado-100);
  --surface-2:   color-mix(in srgb, var(--pdm-avocado-100), var(--pdm-maccha-1000) 8%);
  --border:      color-mix(in srgb, var(--pdm-maccha-1000), var(--pdm-maccha-100) 60%);
  --border-2:    var(--pdm-avocado-100);
  --accent:      var(--pdm-pumpkin-500);
  --accent-dim:  var(--pdm-pumpkin-100);
  --accent-glow: color-mix(in srgb, var(--pdm-pumpkin-500) 22%, transparent);
  --success:     var(--pdm-seaweed-100);
  --success-dim: color-mix(in srgb, var(--pdm-seaweed-100) 10%, transparent);
  --error:       #DC2626;
  --error-dim:   rgba(220,38,38,.10);
  --warn:        var(--pdm-butter-100);
  --text:        var(--pdm-maccha-1000);
  --text-2:      color-mix(in srgb, var(--pdm-maccha-1000), var(--pdm-maccha-100) 40%);
  --text-3:      color-mix(in srgb, var(--pdm-maccha-1000), var(--pdm-maccha-100) 55%);
}
html:has(#theme-toggle:checked) ::-webkit-scrollbar-thumb { background: var(--border); }
html:has(#theme-toggle:checked) ::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
html:has(#theme-toggle:checked) .code-wrap pre { color: var(--text-2); }
html:has(#theme-toggle:checked) .terminal { background: var(--surface); }
html:has(#theme-toggle:checked) .terminal .log { color: var(--text-2); }
html:has(#theme-toggle:checked) .log.i { color: #3D5FAD; }
/* WCAG 2.2 AA — light mode overrides */
html:has(#theme-toggle:checked) .nav-item.active .nav-name { color: var(--text); }
html:has(#theme-toggle:checked) .badge-accent { color: var(--text); }

/* ─── Material Symbols (Google Material Icons) ───────────────────────────── */
/* Only Google Material Icons allowed — .mi wraps an icon name like "logout". */
.mi {
  font-family: 'Material Symbols Outlined';
  font-weight: normal; font-style: normal;
  font-size: 18px; line-height: 1;
  letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; direction: ltr;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga';
  vertical-align: -4px;
  user-select: none;
}
.mi-sm  { font-size: 14px; vertical-align: -3px; }
.mi-md  { font-size: 20px; vertical-align: -5px; }
.mi-lg  { font-size: 40px; vertical-align: -10px; }
.mi-xl  { font-size: 56px; }
/* Status-tinted variants used in terminal-style log output */
.log .mi { font-size: 13px; vertical-align: -2px; margin-right: 2px; }

/* ─── Theme toggle (CSS-only via :has) ───────────────────────────────────── */
.theme-label { cursor: pointer; }
.theme-icon-light { display: none; }
html:has(#theme-toggle:checked) .theme-icon-dark { display: none; }
html:has(#theme-toggle:checked) .theme-icon-light { display: inline; }

@layer reset;

/* ─── Mode visibility (CSS-only, driven by html[data-mode]) ──────────────── */
:root[data-mode="dev"] .extract-panel,
:root[data-mode="dev"] #settings-btn,
:root[data-mode="dev"] .welcome-admin,
:root[data-mode="admin"] .welcome-dev { display: none; }

/* ─── Reset & base ──────────────────────────────────────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
}

/* ─── WCAG 2.2 AA — global focus indicator ───────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus-visible { outline: none; } /* inputs use box-shadow focus ring instead */

html, body {
  height: 100%; overflow: hidden; min-width: 900px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App shell ─────────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border-2);
  display: flex; flex-direction: column; overflow: hidden;
}

.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 14px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}

.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--pdm-pumpkin-500), var(--pdm-blueberry-500));
  display: flex; align-items: center; justify-content: center;
  font-size: inherit; flex-shrink: 0;
}

.brand-label { font-weight: 700; font-size: inherit; letter-spacing: -0.3px; }
.brand-logo { height: 36px; width: auto; color: var(--text); }

.brand-version {
  font-size: inherit; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 6px; flex-shrink: 0;
}

/* ─── Brand status indicators ───────────────────────────────────────────── */
.brand-indicators {
  margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}

/* Status dots — still used inside Settings cards for MCP/REST health. */
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  vertical-align: middle;
}
.status-dot.green   { background: var(--success); box-shadow: 0 0 0 2px var(--success-dim); }
.status-dot.yellow  { background: var(--warn);    box-shadow: 0 0 0 2px rgba(245,158,11,.15); }
.status-dot.red     { background: var(--error);   box-shadow: 0 0 0 2px var(--error-dim); }
.status-dot.grey    { background: var(--text-3); }
@keyframes pulse-si { 0%,100%{opacity:1} 50%{opacity:.35} }
.status-dot.checking { background: var(--text-3); animation: pulse-si 1.4s infinite; }

.settings-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 15px; padding: 3px 4px;
  border-radius: var(--r); line-height: 1;
  display: flex; align-items: center;
  transition: color .12s, background .12s;
}
.settings-btn:hover { color: var(--text); background: var(--surface); }
.settings-btn.active { color: var(--accent); }

/* ─── Extract form ──────────────────────────────────────────────────────── */
.extract-panel {
  padding: 12px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}

.extract-panel label {
  display: block; font-size: inherit; font-weight: 500;
  color: var(--text-2); margin-bottom: 4px; margin-top: 8px;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.extract-panel label:first-child { margin-top: 0; }

.input {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text); font-family: inherit; font-size: inherit;
  padding: 7px 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }

.btn-primary {
  width: 100%; margin-top: 10px;
  background: var(--accent); color: var(--pdm-maccha-1000); border: none;
  border-radius: var(--r); padding: 8px 12px;
  font-family: inherit; font-size: inherit; font-weight: 500;
  cursor: pointer; transition: opacity .15s, transform .1s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary:hover:not(:disabled) { opacity: .9; }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

/* ─── Nav ───────────────────────────────────────────────────────────────── */
.nav-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-group  { margin-bottom: 2px; }

.nav-group-header {
  padding: 8px 14px 4px;
  font-size: inherit; font-weight: 600; letter-spacing: .9px;
  text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; justify-content: space-between;
  user-select: none;
}

.nav-count {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 6px;
  font-size: 0.75em; font-weight: 500; color: var(--text-2);
}

.nav-list { list-style: none; }

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .12s, border-color .12s;
  user-select: none;
}
.nav-item:hover { background: var(--surface); }
.nav-item.active { background: var(--accent-dim); border-left-color: var(--accent); }

.nav-icon {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: inherit; flex-shrink: 0; color: var(--text-3);
  transition: background .12s, border-color .12s, color .12s;
}
.nav-item.active .nav-icon {
  background: var(--accent-dim); border-color: var(--accent-glow); color: var(--accent);
}

.nav-name {
  flex: 1; font-size: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item.active .nav-name { color: var(--accent); font-weight: 500; }

.nav-pill {
  font-size: 0.75em; font-weight: 500; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 5px; flex-shrink: 0;
}

.nav-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot-green   { background: var(--success); }
.dot-yellow  { background: var(--warn); }
.dot-red     { background: var(--error); }
.dot-muted   { background: var(--text-3); }
@keyframes pulse-run { 0%,100%{opacity:1} 50%{opacity:.3} }
.dot-running { background: var(--accent); animation: pulse-run 1.2s infinite; }

.nav-empty { padding: 10px 14px; font-size: inherit; color: var(--text-3); font-style: italic; }

/* ─── Main area ─────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  min-height: var(--topbar-h);
  padding: 6px 24px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0; flex-wrap: wrap;
}
.topbar-title  { font-size: 1.125em; font-weight: 600; letter-spacing: -.2px; }
.topbar-meta   { font-size: inherit; color: var(--text-2); }
.topbar-spacer { flex: 1; }

/* ─── Content area ──────────────────────────────────────────────────────── */
.content { flex: 1; overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.content > .welcome { padding: 24px; }
.content > .comp-detail,
.content > .page-detail { gap: 0; }

/* ─── Welcome screen ────────────────────────────────────────────────────── */
.welcome {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 10px; text-align: center;
}
.welcome-mark {
  width: 60px; height: 60px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-dim), var(--surface));
  border: 1px solid var(--border); margin-bottom: 6px;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.welcome h2 { font-size: 18px; font-weight: 600; }
.welcome p  { color: var(--text-2); font-size: inherit; max-width: 300px; line-height: 1.6; }

/* ─── Badge / chip ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: inherit; font-weight: 500; flex-shrink: 0;
}
.badge-accent   { background: var(--accent-dim);            color: var(--accent);  border: 1px solid var(--accent-glow); }
.badge-success  { background: var(--success-dim);           color: var(--success); border: 1px solid rgba(16,185,129,.25); }
.badge-warn     { background: rgba(245,158,11,.12);         color: var(--warn);    border: 1px solid rgba(245,158,11,.25); }
.badge-error    { background: var(--error-dim);             color: var(--error);   border: 1px solid rgba(239,68,68,.25); }
.badge-muted    { background: var(--surface-2);             color: var(--text-2);  border: 1px solid var(--border); }
.status-badge   { background: var(--status-bg); color: #fff; font-size: inherit; padding: 1px 6px; }

/* ─── Spinner ───────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 13px; height: 13px; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .65s linear infinite;
  display: inline-block;
}

/* ─── Component detail ──────────────────────────────────────────────────── */
.comp-detail { display: flex; flex-direction: column; gap: 18px; flex: 1; min-height: 0; overflow: hidden; }

.comp-hero {
  display: flex; align-items: flex-start; gap: 14px;
  padding-bottom: 18px; border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}
.comp-hero-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  background: var(--accent-dim); border: 1px solid var(--accent-glow);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.comp-hero-info h2 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.comp-hero-meta    { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.override-chip {
  font-family: var(--mono); font-size: 0.875em;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 7px; color: var(--text-2);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
  padding: 0 16px;
}
.tab {
  padding: 7px 14px; font-size: inherit; font-weight: 400;
  color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .12s; user-select: none; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

.tab-panel { display: none; flex-direction: column; flex: 1; min-height: 0; margin-top: 0; overflow: auto; }
.tab-panel.active { display: flex; }

/* ─── Preview frame ─────────────────────────────────────────────────────── */
.preview-wrap {
  flex: 1; min-height: 0;
  border-top: 1px solid var(--border); overflow: hidden; background: #fff;
}
.preview-wrap iframe { width: 100%; height: 100%; border: none; display: block; }

/* ─── Mustache preview iframe ───────────────────────────────────────────── */
.mustache-preview-wrap {
  flex: 1; min-height: 0;
  border-top: 1px solid var(--border); overflow: hidden; background: #fff; position: relative;
}
.mustache-preview-wrap iframe {
  width: 100%; height: 100%; border: none; display: block;
}
.mustache-preview-placeholder {
  flex: 1; min-height: 200px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-lg); border: 1px dashed var(--border);
  color: var(--text-3); font-size: inherit;
}

/* ─── Params bar (top-edge drag handle, see App._attachParamsBarResizer) ── */
.params-bar-wrap {
  position: relative;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  height: var(--params-bar-height, 200px);
  min-height: 48px; max-height: 80vh;
  overflow: hidden;
}
.params-bar-resize {
  position: absolute; top: 0; left: 0; right: 0;
  height: 6px; cursor: ns-resize; z-index: 3;
  background: transparent;
  touch-action: none;
  transition: background 120ms;
}
.params-bar-resize:hover,
.params-bar-resize.dragging { background: var(--accent); }
.params-bar {
  height: 100%; overflow-y: auto;
  background: var(--surface);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.params-bar thead th { position: sticky; top: 0; z-index: 1; }
.params-bar-table {
  width: 100%; border-collapse: collapse; font-size: inherit;
}
.params-bar-table th {
  font-size: inherit; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); padding: 7px 14px; text-align: left;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.params-bar-table td {
  padding: 5px 14px; border-bottom: 1px solid var(--border-2);
  vertical-align: middle; color: var(--text-2);
}
.params-bar-table tr:last-child td { border-bottom: none; }
.params-bar-table tr:hover td { background: var(--surface-2); }
.param-name {
  font-family: var(--mono); font-size: 0.875em; color: var(--text-2); white-space: nowrap;
}
.param-section-header {
  padding: 12px 14px 6px !important; border-top: 1px solid var(--border); font-size: inherit;
}
.param-input-text {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: var(--mono); font-size: 0.875em;
  padding: 3px 7px; width: 200px; outline: none;
}
.param-input-text:focus { border-color: var(--accent); }
.param-input-select {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: var(--mono); font-size: 0.875em;
  padding: 3px 6px; outline: none; cursor: pointer;
}
.param-input-select:focus { border-color: var(--accent); }
.param-input-check {
  width: 13px; height: 13px; cursor: pointer; accent-color: var(--accent);
}

/* ─── Code block ────────────────────────────────────────────────────────── */
.code-wrap {
  flex: 1; background: var(--sidebar); overflow: auto;
}
.code-wrap pre {
  padding: 16px; font-family: var(--mono); font-size: 1em;
  line-height: 1.75; color: #9AA4C8;
  white-space: pre-wrap; word-break: break-all;
  margin: 0;
}
.code-wrap pre[class*="language-"],
.code-wrap code[class*="language-"] {
  background: var(--sidebar); font-family: var(--mono); font-size: 1em;
  line-height: 1.75; tab-size: 2; margin: 0;
  white-space: pre-wrap; word-break: break-all;
}
html:has(#theme-toggle:checked) .code-wrap pre[class*="language-"],
html:has(#theme-toggle:checked) .code-wrap code[class*="language-"] {
  background: var(--sidebar);
}

/* ─── Props table ───────────────────────────────────────────────────────── */
.props-wrap { flex: 1; overflow: auto; }
.props-table { width: 100%; border-collapse: collapse; }
.props-table th {
  padding: 8px 14px; text-align: left;
  background: var(--surface); color: var(--text-2);
  font-size: inherit; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; border-bottom: 1px solid var(--border);
}
.props-table td { padding: 8px 14px; border-bottom: 1px solid var(--border-2); }
.props-table tr:last-child td { border-bottom: none; }
.props-table tr:hover td { background: var(--surface); }

.prop-val {
  font-family: var(--mono); font-size: 0.875em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
.prop-val.t { color: var(--success); border-color: rgba(16,185,129,.2); }
.prop-val.f { color: var(--error);   border-color: rgba(239,68,68,.2); }

/* ─── Log terminal ──────────────────────────────────────────────────────── */
.terminal {
  background: var(--pdm-maccha-1000); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); overflow-y: auto; flex: 1;
  padding: 14px 16px; max-height: 480px;
  font-family: var(--mono); font-size: 0.875em; line-height: 1.85;
}
.log   { color: var(--text-2); }
.log.s { color: var(--success); }
.log.e { color: var(--error); }
.log.i { color: #93C5FD; }

/* ─── Fade in ───────────────────────────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .18s ease both; }

/* ─── Page detail ───────────────────────────────────────────────────────── */
.page-detail { display: flex; flex-direction: column; gap: 18px; flex: 1; min-height: 0; overflow: hidden; }

/* ─── Shared surface primitives (design system) ─────────────────────────── */
/* Use .card / .card-header / .card-title / .card-desc / .form-row / .data-row
 * as the consolidated building blocks. Old `.settings-*` names remain as
 * aliases below so legacy templates keep working. */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.card-compact { padding: 12px 16px; gap: 8px; }

/* Single-row compact account header. */
.account-row {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-title {
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
}
.card-title .mi { font-size: 18px; color: var(--text-2); }
.card-desc  { font-size: 12px; color: var(--text-3); line-height: 1.55; }

.data-row {
  padding: 9px 12px;
  background: var(--sidebar); border: 1px solid var(--border-2);
  border-radius: var(--r); min-height: 36px;
  display: flex; align-items: center; gap: 8px;
}

.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row label {
  font-size: 11px; font-weight: 500; color: var(--text-3);
  letter-spacing: .2px;
}

.divider-text {
  display: flex; align-items: center; gap: 10px;
  font-size: 10px; color: var(--text-3); letter-spacing: .6px; text-transform: uppercase;
  margin: 2px 0;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--border-2);
}

.section-heading {
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-3); font-weight: 600;
  margin: 6px 0 -2px 2px;
}

/* Chip — compact status/role pill. Mirrors .badge but includes icon + colored dot. */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  font-size: 11px; font-weight: 500;
  border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2);
}
.chip .mi { font-size: 14px; vertical-align: -3px; }
.chip-green  { background: var(--success-dim); border-color: color-mix(in srgb, var(--success), transparent 70%); color: var(--success); }
.chip-yellow { background: var(--warn-dim);    border-color: color-mix(in srgb, var(--warn),    transparent 70%); color: color-mix(in srgb, var(--warn), var(--text) 40%); }
.chip-red    { background: var(--error-dim);   border-color: color-mix(in srgb, var(--error),   transparent 70%); color: var(--error); }
.chip-grey   { background: var(--surface-2);   border-color: var(--border); color: var(--text-3); }

/* Inline mono text — used for file paths, keys, IDs in prose. */
.mono-inline {
  font-family: var(--mono); font-size: 0.875em;
  background: var(--surface-2); border: 1px solid var(--border-2);
  padding: 1px 6px; border-radius: 3px; color: var(--text-2);
  word-break: break-all;
}

/* Admin list tables (whitelist, users). */
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed;
}
.admin-table thead th {
  text-align: left; font-weight: 500; color: var(--text-3);
  font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
  padding: 6px 8px 6px 10px;
  border-bottom: 1px solid var(--border-2);
}
.admin-table tbody td {
  padding: 8px 8px 8px 10px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table td.mono {
  font-family: var(--mono); font-size: 11.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-table .align-right { text-align: right; white-space: nowrap; }
/* Tight column widths so text + small selects don't squeeze email visibility. */
.admin-table col.c-role  { width: 88px; }
.admin-table col.c-when  { width: 130px; }
.admin-table col.c-act   { width: 96px; }

/* Compact input variant used inside tables. */
.input-sm {
  padding: 3px 8px !important; font-size: 11px !important; height: auto !important;
  min-width: 72px;
}

/* ─── Settings page ─────────────────────────────────────────────────────── */
.settings-page {
  display: flex; flex-direction: column; gap: 14px;
  padding: 24px 28px 48px;
  max-width: 1120px; width: 100%;
  overflow-y: auto; flex: 1;
  box-sizing: border-box;
}

.settings-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
}
.settings-grid.one-col { grid-template-columns: 1fr; }
@media (max-width: 1100px) {
  .settings-grid { grid-template-columns: 1fr; }
}

.btn-sm {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text-2); cursor: pointer;
  font-family: inherit; font-size: inherit; font-weight: 500;
  padding: 6px 12px;
  transition: background .12s, color .12s, border-color .12s;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-sm:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.btn-sm:disabled { opacity: .4; cursor: not-allowed; }

.btn-sm.accent {
  background: var(--accent-dim); border-color: var(--accent-glow); color: var(--accent);
}
.btn-sm.accent:hover:not(:disabled) {
  background: var(--accent); color: var(--pdm-maccha-1000); border-color: var(--accent);
}

/* Legacy: deprecated — kept so stray markup still renders sensibly. */
.settings-note { font-size: inherit; color: var(--text-3); padding: 10px 14px; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r); }

/* ─── Skip link ────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute; top: -100%; left: 16px;
  background: var(--accent); color: #fff;
  padding: 8px 16px; border-radius: var(--r);
  font-size: inherit; font-weight: 500; z-index: 9999;
  text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* ─── Focus-visible ring ───────────────────────────────────────────────── */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
/* Inputs already have their own focus style */
.input:focus-visible,
.param-input-text:focus-visible,
.param-input-select:focus-visible { box-shadow: 0 0 0 3px var(--accent-dim); }

/* ─── Reduced motion ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Screen-reader only ───────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ─── Utility: text ──────────────────────────────────────────────────── */
.text-error   { color: var(--error); }
.text-warn    { color: var(--warn); }
.text-success { color: var(--success); }
.text-muted   { color: var(--text-2); }
.text-dim     { color: var(--text-3); }
.text-accent  { color: var(--accent); }
.text-sm      { font-size: inherit; }
.text-xs      { font-size: inherit; }
.text-mono    { font-family: var(--mono); }

/* ─── Status badge ───────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  background: var(--status-bg, var(--status-draft));
  color: #fff; font-size: inherit; padding: 1px 6px;
  border-radius: var(--r-sm); line-height: 1.6;
}

/* ─── Version dot (sidebar) ──────────────────────────────────────────── */
.version-dot {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; flex-shrink: 0; margin-right: 4px;
}

/* ─── Download / export buttons ──────────────────────────────────────── */
.dl-btn {
  color: var(--accent); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: inherit; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-2, transparent); cursor: pointer;
}
.dl-btn:hover { background: var(--accent-dim); }
.dl-btn--primary {
  background: var(--accent); color: var(--pdm-maccha-1000);
  border-color: var(--accent); font-weight: 500;
}
.dl-btn--primary:hover { opacity: .9; }
.dl-btn[disabled], .dl-btn--disabled {
  color: var(--text-3); cursor: not-allowed; opacity: .5;
  pointer-events: none;
}

/* ─── Offscreen iframe (CSS extraction) ──────────────────────────────── */
.offscreen-frame {
  position: fixed; left: -9999px; top: -9999px;
  width: 800px; height: 600px;
  visibility: hidden; pointer-events: none;
}

/* ─── Job detail layout ──────────────────────────────────────────────── */
.job-detail {
  display: flex; flex-direction: column; gap: 14px; height: 100%;
}
.job-header {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: center; font-size: inherit; color: var(--text-2);
}
.job-log-wrap { flex: 1; }

/* ─── Param bar labels ───────────────────────────────────────────────── */
.param-label {
  color: var(--text-3); font-family: var(--mono);
  font-size: 0.875em; white-space: nowrap; padding-left: 14px;
}
.param-label--nested { padding-left: 22px; }
.param-type {
  color: var(--text-3); font-size: inherit; white-space: nowrap;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.param-type--multi { font-size: inherit; max-width: 140px; }
.param-slot-default {
  color: var(--text-3); font-size: inherit; margin-left: 4px;
}
.param-section-tag {
  font-size: inherit; color: var(--accent); margin-left: 2px;
}
.hero-error {
  color: var(--error); font-size: inherit; margin-left: 8px;
}

/* ─── Spinner (inline) ───────────────────────────────────────────────── */
.spinner-inline {
  display: inline-block; vertical-align: middle; margin-right: 4px;
}

/* ─── Settings status text ───────────────────────────────────────────── */
.settings-detail { font-size: inherit; }
.settings-code   { font-family: var(--mono); font-size: 0.875em; }

/* ─── Extraction error container ─────────────────────────────────────── */
.extract-error {
  padding: 32px; display: flex; flex-direction: column; gap: 10px;
}
.extract-error-msg {
  color: var(--error); display: flex; align-items: center; gap: 8px;
}

/* ─── Export actions bar ─────────────────────────────────────────────── */
.export-actions {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.export-label {
  color: var(--text-2); font-size: inherit; font-weight: 500;
}
