/* theme.css: Fstab Check. "Machine-room clipboard": cool paper, ink, one deep-teal accent,
   every path and directive in monospace. Signature: the gate rail at the top of the verdict
   card (mount → gate → ExecStart). Loaded after styles.css; tokens first, components after.
   Contrast ratios are noted against --surface (light: #ffffff, dark: #171d21). */

:root {
  color-scheme: light;
  /* Palette (light) */
  --bg: #f2f4f3;            /* page */
  --surface: #ffffff;       /* panels, fields */
  --raised: #e8eceb;        /* ad slot, code chips, worked example */
  --text: #17202a;          /* 16.4:1 on surface, 14.9:1 on bg */
  --muted: #4a5560;         /* 7.6:1 on surface, 6.9:1 on bg */
  --border: #c9d0d3;        /* hairlines, not text */
  --border-strong: #8a959c; /* field borders: 3.1:1 for UI contrast */
  --accent: #0f6b6b;        /* 6.3:1 with white */
  --accent-hover: #0b5858;
  --accent-active: #084646;
  --accent-text: #0f6b6b;   /* links: 6.3:1 on surface, 5.8:1 on bg */
  --accent-tint: #e2f0ef;
  --on-accent: #ffffff;
  --success: #1d6b3a;       /* 6.5:1 on surface, 5.9:1 on success-tint */
  --success-tint: #e7f3eb;
  --warning: #8a5300;       /* 6.3:1 on surface, 6.0:1 on warning-tint */
  --warning-edge: #d99a1e;  /* edges and rail only, never text */
  --warning-tint: #fcf2df;
  --danger: #b42318;        /* 6.6:1 on surface, 5.8:1 on danger-tint */
  --danger-tint: #fcebe9;

  /* Type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --t-label: 0.8125rem;  /* 13px caps labels */
  --t-small: 0.9375rem;  /* 15px hints, evidence, notes */
  --t-body: 1.0625rem;   /* 17px body */
  --t-h3: 1.125rem;      /* 18px */
  --t-h2: 1.375rem;      /* 22px, verdict title */
  --t-h1: clamp(1.75rem, 4.5vw, 2.5rem);

  /* Space */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Shape */
  --r-s: 6px; --r-m: 10px; --r-l: 14px;
  --shadow-1: 0 1px 2px rgb(23 32 42 / 0.06), 0 2px 8px rgb(23 32 42 / 0.06);
  --shadow-2: 0 8px 28px rgb(23 32 42 / 0.16);
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);

  /* Motion */
  --fast: 160ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --column: 66rem;
  --measure: 42rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101518;
    --surface: #171d21;
    --raised: #1f272c;
    --text: #e6ebee;          /* 14.6:1 on surface */
    --muted: #a3afb8;         /* 7.7:1 on surface */
    --border: #2e383f;
    --border-strong: #5d6a73; /* 3.0:1 UI contrast */
    --accent: #5fc4bd;        /* 8.3:1 with on-accent */
    --accent-hover: #7dd3cd;
    --accent-active: #4fb0a9;
    --accent-text: #6fcdc6;   /* 9.3:1 on surface */
    --accent-tint: #15302f;
    --on-accent: #0a1f1e;
    --success: #6fd08f;       /* 9.0:1 on surface */
    --success-tint: #142a1c;
    --warning: #f2b84b;       /* 9.4:1 on surface */
    --warning-edge: #c98d1a;
    --warning-tint: #2e2210;
    --danger: #ff8a80;        /* 7.5:1 on surface */
    --danger-tint: #3a1714;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4), 0 2px 8px rgb(0 0 0 / 0.3);
    --shadow-2: 0 10px 32px rgb(0 0 0 / 0.55);
  }
}

/* ---------- Base ---------- */
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
header, main, footer { max-width: var(--column); padding-left: var(--s5); padding-right: var(--s5); }
header { border-bottom: 1px solid var(--border); padding-top: var(--s2); padding-bottom: var(--s2); }
.brand { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text); font-size: var(--t-h3); letter-spacing: -0.01em; }
/* Brand mark: a drive slot with a teal gate bar, same drawing as icons/favicon.svg. */
.brand::before {
  content: ""; width: 22px; height: 22px; flex: none;
  border: 2px solid var(--text); border-radius: var(--r-s);
  background:
    linear-gradient(var(--accent), var(--accent)) 50% 50% / 3px 100% no-repeat,
    linear-gradient(var(--text), var(--text)) 3px 50% / 5px 2px no-repeat;
  box-sizing: border-box;
}
header nav a { color: var(--muted); text-decoration: none; padding: 0 var(--s3); border-radius: var(--r-s); transition: color var(--fast) var(--ease); }
header nav a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

h1 { font-size: var(--t-h1); letter-spacing: -0.02em; margin: var(--s6) 0 var(--s3); }
h2 { font-size: var(--t-h2); line-height: 1.25; letter-spacing: -0.01em; margin: var(--s7) 0 var(--s3); }
h3 { font-size: var(--t-h3); line-height: 1.3; margin: var(--s5) 0 var(--s1); }
.lede { color: var(--muted); font-size: 1.125rem; max-width: var(--measure); margin: 0 0 var(--s5); }
main > p, main > ul, main > ol, main > h3 { max-width: var(--measure); }
main li + li { margin-top: var(--s2); }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.9em; }
main p code, main li code {
  background: var(--raised); border-radius: 4px; padding: 0.05em 0.35em;
}

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-s); }

/* ---------- Tool panel ---------- */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  padding: var(--s5);
  margin: 0 0 var(--s6);
}
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); }
.field { min-width: 0; }
.field > label, .label {
  display: flex; align-items: baseline; gap: var(--s2);
  font-size: var(--t-label); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text); margin: 0 0 var(--s1);
}
.field > label .file-name { font-family: var(--font-mono); text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent-text); }
.hint { margin: 0 0 var(--s2); font-size: var(--t-small); color: var(--muted); line-height: 1.45; min-height: 2.9em; }
.hint code { background: var(--raised); border-radius: 4px; padding: 0 0.3em; }

textarea {
  display: block; width: 100%; min-height: 15rem;
  padding: var(--s3);
  font: 0.875rem/1.6 var(--font-mono);
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border-strong); border-radius: var(--r-m);
  resize: vertical; tab-size: 8; white-space: pre; overflow-wrap: normal; overflow-x: auto;
  transition: border-color var(--fast) var(--ease);
}
textarea::placeholder { color: var(--muted); opacity: 0.8; }
textarea:hover { border-color: var(--text); }
textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); border-radius: var(--r-m); }

.field-error { min-height: 1.5em; margin: var(--s1) 0 0; font-size: var(--t-small); font-weight: 600; color: var(--danger); }
.field-error:not(:empty)::before { content: "✕ "; font-weight: 700; } /* text glyph, not emoji */
.field.invalid textarea, .field.invalid select { border-color: var(--danger); border-width: 2px; background: var(--danger-tint); }

.run-row {
  display: grid; grid-template-columns: minmax(16rem, 22rem) 1fr; gap: var(--s5);
  align-items: start; margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border);
}
.run-row .hint { min-height: 1.45em; }

select {
  appearance: none; -webkit-appearance: none;
  display: block; width: 100%; min-height: 48px;
  padding: 0 calc(var(--s6) + var(--s2)) 0 var(--s3);
  font: 600 0.9375rem/1.2 var(--font-mono);
  color: var(--text);
  background:
    linear-gradient(45deg, transparent 50%, var(--text) 50%) calc(100% - 20px) 50% / 6px 6px no-repeat,
    linear-gradient(-45deg, transparent 50%, var(--text) 50%) calc(100% - 14px) 50% / 6px 6px no-repeat,
    var(--surface);
  border: 1.5px solid var(--border-strong); border-radius: var(--r-m);
  cursor: pointer; text-overflow: ellipsis;
  transition: border-color var(--fast) var(--ease);
}
select:hover { border-color: var(--text); }
select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); border-radius: var(--r-m); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin: calc(var(--t-label) * 1.55 + var(--s1)) 0 0; }
.actions .quiet { margin-left: auto; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  min-height: 44px; padding: 0 var(--s4);
  border-radius: var(--r-m); border: 1.5px solid transparent;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
button:active { transform: translateY(1px); }
.actions button.primary, button.primary {
  min-height: 48px; padding: 0 var(--s5);
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
  box-shadow: var(--shadow-1);
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:active { background: var(--accent-active); border-color: var(--accent-active); }
.actions button.secondary, button.secondary { background: var(--surface); color: var(--accent-text); border-color: var(--accent); }
button.secondary:hover { background: var(--accent-tint); }
button.secondary:active { background: var(--accent-tint); border-color: var(--accent-active); }
.actions button.quiet, button.quiet { background: transparent; color: var(--muted); border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
button.quiet:hover { color: var(--text); background: var(--raised); }
button.quiet:active { background: var(--border); }

#status { min-height: 1.6em; margin: var(--s4) 0 0; font-size: var(--t-small); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
#status.error { color: var(--danger); }
#status.ok { color: var(--text); }
#output { margin-top: var(--s3); min-height: 9rem; font-variant-numeric: tabular-nums; }
#output:focus { outline: none; }
#output:focus-visible { box-shadow: var(--ring); border-radius: var(--r-l); }

/* ---------- Empty state ---------- */
.empty-state {
  display: flex; gap: var(--s4); align-items: flex-start;
  min-height: 9rem; padding: var(--s5);
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-l);
  color: var(--muted);
}
.empty-state svg { flex: none; width: 40px; height: 40px; color: var(--border-strong); }
.empty-state strong { display: block; color: var(--text); font-size: var(--t-body); margin-bottom: var(--s1); }
.empty-state p { margin: 0; font-size: var(--t-small); max-width: var(--measure); }

/* ---------- Verdict card ---------- */
.verdict {
  --tone: var(--text); --tone-tint: var(--raised); --tone-edge: var(--border-strong);
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--tone-edge);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  padding: var(--s5) var(--s5) var(--s4);
  animation: verdict-in 180ms var(--ease) both;
}
.verdict.tone-open { --tone: var(--danger); --tone-tint: var(--danger-tint); --tone-edge: var(--danger); }
.verdict.tone-guarded { --tone: var(--success); --tone-tint: var(--success-tint); --tone-edge: var(--success); }
.verdict.tone-unknown { --tone: var(--warning); --tone-tint: var(--warning-tint); --tone-edge: var(--warning-edge); }
@keyframes verdict-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.verdict-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.verdict-head h2 { margin: 0; font-size: var(--t-h2); color: var(--tone); }
.chip {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 var(--s2);
  font-size: var(--t-label); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--tone); background: var(--tone-tint); border: 1px solid currentColor; border-radius: 999px;
}
.verdict .path { font-family: var(--font-mono); font-size: var(--t-small); color: var(--muted); margin: 0 0 var(--s4); overflow-wrap: anywhere; }
.verdict .path b { color: var(--text); font-weight: 700; }
.explain { margin: 0 0 var(--s4); max-width: 46rem; }
.explain code, .evidence code, .fix code, .note code { font-family: var(--font-mono); font-size: 0.875em; background: var(--raised); border-radius: 4px; padding: 0.05em 0.35em; overflow-wrap: anywhere; }

/* Signature: the gate rail. mount node, wire, gate, wire, ExecStart node. */
.gate-rail {
  display: grid; grid-template-columns: minmax(0, auto) minmax(24px, 1fr) auto minmax(24px, 1fr) auto;
  align-items: center; gap: 0;
  margin: 0 0 var(--s4); padding: var(--s3) var(--s4);
  background: var(--tone-tint); border-radius: var(--r-m);
  font-family: var(--font-mono); font-size: var(--t-small);
}
.gate-rail .node {
  padding: var(--s1) var(--s3); border-radius: var(--r-s);
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.gate-rail .node.mount { border-style: dashed; color: var(--muted); } /* the mount is assumed absent */
.gate-rail .node.mount::after { content: " · absent"; font-size: var(--t-label); }
.gate-rail .wire { height: 3px; background: var(--tone); }
.gate-rail .gate {
  padding: var(--s1) var(--s3); border-radius: var(--r-s);
  font-weight: 700; letter-spacing: 0.06em; font-size: var(--t-label);
  color: var(--on-accent); background: var(--tone); border: 1.5px solid var(--tone);
}
[data-gate="open"] .gate { color: var(--danger); background: var(--surface); border-style: dashed; }
[data-gate="blocked"] .wire:last-of-type,
[data-gate="skipped"] .wire:last-of-type,
[data-gate="failed"] .wire:last-of-type {
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 12px);
}
[data-gate="blocked"] .node.exec,
[data-gate="skipped"] .node.exec,
[data-gate="failed"] .node.exec { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }
[data-gate="unknown"] .wire { background: repeating-linear-gradient(90deg, var(--warning-edge) 0 6px, transparent 6px 12px); }
@media (prefers-color-scheme: dark) {
  .verdict.tone-guarded .gate, .verdict.tone-unknown .gate { color: var(--bg); }
}

/* Evidence: two columns, one per paste, line badges in mono. */
.evidence { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin: 0 0 var(--s4); }
.evidence > div { min-width: 0; border-top: 1px solid var(--border); padding-top: var(--s3); }
.evidence h3 { margin: 0 0 var(--s2); font-size: var(--t-label); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text); }
.evidence ul { list-style: none; margin: 0; padding: 0; }
.evidence li { display: grid; grid-template-columns: 4.5rem 1fr; gap: var(--s2); align-items: baseline; font-size: var(--t-small); margin: 0 0 var(--s2); }
.evidence li + li { margin-top: 0; }
.ln {
  justify-self: start; font-family: var(--font-mono); font-size: var(--t-label); font-weight: 700;
  color: var(--accent-text); background: var(--accent-tint); border-radius: 4px; padding: 0 var(--s2);
  white-space: nowrap;
}
.evidence .none { color: var(--muted); font-style: italic; }
.evidence .none::before { content: "— "; font-style: normal; }

.fix {
  margin: 0 0 var(--s4); padding: var(--s3) var(--s4);
  border-radius: var(--r-m); background: var(--accent-tint); color: var(--text); font-size: var(--t-small);
}
.fix strong { color: var(--accent-text); }
.note { margin: 0; font-size: var(--t-small); color: var(--muted); max-width: 46rem; }
.note strong { color: var(--text); }

/* ---------- Worked example ---------- */
.example {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  padding: var(--s5); margin: var(--s4) 0 var(--s5);
}
.example .pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin: 0 0 var(--s4); }
.example figure { margin: 0; min-width: 0; }
.example figcaption { font-size: var(--t-label); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: var(--s1); }
.example pre {
  margin: 0; padding: var(--s3); background: var(--raised); border-radius: var(--r-m);
  font-size: 0.8125rem; line-height: 1.6; overflow-x: auto;
}
.example pre mark { background: var(--warning-tint); color: var(--text); box-shadow: inset 3px 0 var(--warning-edge); padding: 0 0.2em; }
.example .outcome { display: flex; gap: var(--s3); align-items: baseline; margin: 0 0 var(--s2); font-size: var(--t-small); }
.example .outcome .chip.tone-open { --tone: var(--danger); --tone-tint: var(--danger-tint); }
.example .outcome .chip.tone-guarded { --tone: var(--success); --tone-tint: var(--success-tint); }

/* ---------- Template parts, styled to fit (sizes untouched) ---------- */
.ad-slot { background: var(--raised); border: 1px solid var(--border); }
.ad-label { color: var(--muted); opacity: 1; }
.house-card { background: var(--surface); border: 1px solid var(--border); }
.house-card:hover { border-color: var(--accent); }
.consent { background: var(--surface); color: var(--text); border-color: var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-2); }
.consent button { border-color: var(--accent); color: var(--accent-text); background: var(--surface); }
.consent button:hover { background: var(--accent-tint); }
footer { opacity: 1; color: var(--muted); border-top: 1px solid var(--border); padding-top: var(--s5); padding-bottom: var(--s6); }
footer a { color: var(--accent-text); }

/* ---------- Phone ---------- */
@media (max-width: 52rem) {
  header, main, footer { padding-left: var(--s4); padding-right: var(--s4); }
  .tool { padding: var(--s4); border-radius: var(--r-m); }
  .fields, .run-row, .evidence, .example .pair { grid-template-columns: 1fr; }
  .fields { gap: var(--s3); }
  textarea { min-height: 11rem; }
  .hint { min-height: 0; }
  .actions { margin-top: 0; }
  .actions button.primary { flex: 1 1 100%; }
  .actions .secondary { flex: 1 1 auto; }
  .actions .quiet { margin-left: 0; }
  .gate-rail { grid-template-columns: 1fr; justify-items: start; gap: var(--s1); }
  .gate-rail .wire { width: 3px; height: 12px; margin-left: var(--s4); }
  [data-gate="blocked"] .wire:last-of-type,
  [data-gate="skipped"] .wire:last-of-type,
  [data-gate="failed"] .wire:last-of-type,
  [data-gate="unknown"] .wire { background: repeating-linear-gradient(180deg, var(--border-strong) 0 4px, transparent 4px 8px); }
  .gate-rail .node { max-width: 100%; }
  .evidence li { grid-template-columns: 4rem 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  button:active { transform: none; }
}
