/* Fonts: IBM Plex Sans and Mono, self-hosted (SIL OFL 1.1, see fonts/OFL.txt). Barlow Condensed is not bundled:
   the display stack falls back to Arial Narrow / system condensed faces. */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400 600; font-display: swap; src: url('/notes/fonts/ibm-plex-sans-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400 600; font-display: swap; src: url('/notes/fonts/ibm-plex-sans-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/notes/fonts/ibm-plex-mono-400-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/notes/fonts/ibm-plex-mono-400-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/notes/fonts/ibm-plex-mono-500-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/notes/fonts/ibm-plex-mono-500-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Design tokens: copied from the dashboard (report/index.html). */
:root {
  --bg: #eceeec;          /* drawing-sheet paper, cool concrete */
  --surface: #f8f9f7;
  --surface-2: #e2e6e4;
  --ink: #14181b;
  --ink-2: #434d56;
  --muted: #5b666f;
  --line: #c6cdcf;
  --line-strong: #8f9aa1;
  --accent: #0a6ea6;      /* water */
  --accent-ink: #075a88;
  --accent-soft: #d2e7f3;
  --steel: #55626d;
  --hazard: #c98a0b;      /* safety amber */
  --hazard-soft: #f6e6c2;
  --ok: #23824f;
  --warn: #b7770a;
  --crit: #c23b2c;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif-condensed, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 70ch;
  --radius: 3px;
  --w-pwr: #9b2e20; --w-24v: #2a78d6; --w-0v: #1d3557; --w-pe: #008300; --w-ana: #d55181;
  --w-galv: #cfd6d9; --w-duct: #f1f3f1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1215; --surface: #151a1e; --surface-2: #1d2429; --ink: #e5eaed; --ink-2: #aeb8bf; --muted: #7e8991;
    --line: #2a3238; --line-strong: #4b565e; --accent: #47aee6; --accent-ink: #7cc6ef; --accent-soft: #10324a; --steel: #8e9ba6;
    --hazard: #eaa92d; --hazard-soft: #3a2d10; --ok: #46b57a; --warn: #e3a33a; --crit: #e2604f;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9;
    --w-pwr: #e2604f; --w-24v: #3987e5; --w-0v: #a9bde0; --w-pe: #46b57a; --w-ana: #e87ba4;
    --w-galv: #232c32; --w-duct: #36424a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --w-pwr: #e2604f; --w-24v: #3987e5; --w-0v: #a9bde0; --w-pe: #46b57a; --w-ana: #e87ba4;
  --w-galv: #232c32; --w-duct: #36424a;
  --bg: #0e1215; --surface: #151a1e; --surface-2: #1d2429; --ink: #e5eaed; --ink-2: #aeb8bf; --muted: #7e8991;
  --line: #2a3238; --line-strong: #4b565e; --accent: #47aee6; --accent-ink: #7cc6ef; --accent-soft: #10324a; --steel: #8e9ba6;
  --hazard: #eaa92d; --hazard-soft: #3a2d10; --ok: #46b57a; --warn: #e3a33a; --crit: #e2604f;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; text-wrap: balance; margin: 0; line-height: 1.12; }
h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 700; letter-spacing: 0; }
h2 { font-size: clamp(24px, 3vw, 30px); }
h3 { font-size: 20px; }
p { margin: 0; max-width: var(--measure); }
a { color: var(--accent-ink); }
code, .mono { font-family: var(--font-mono); font-size: 0.88em; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.stack > * + * { margin-top: 14px; }

/* page frame */
.sheet { max-width: 1100px; margin: 0 auto; padding: 16px 16px 64px; }
.titleblock { border: 1.5px solid var(--ink); background: var(--surface); display: flex; flex-wrap: wrap; align-items: stretch; }
.titleblock .tb-main { flex: 1 1 320px; padding: 16px 20px; min-width: 0; }
.titleblock .tb-side { flex: 0 1 auto; border-left: 1.5px solid var(--ink); padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.titleblock .sub { margin-top: 6px; color: var(--ink-2); font-size: 14.5px; }
@media (max-width: 720px) { .titleblock .tb-side { flex-basis: 100%; border-left: 0; border-top: 1.5px solid var(--ink); justify-content: flex-start; } }
nav.main { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 14px; border-bottom: 1px solid var(--line-strong); }
nav.main a { padding: 8px 12px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; min-height: 40px; display: inline-flex; align-items: center; }
nav.main a:hover { color: var(--ink); }
nav.main a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
main { margin-top: 20px; min-width: 0; }
.part-head { display: flex; align-items: baseline; gap: 10px 14px; border-bottom: 1.5px solid var(--ink); padding-bottom: 8px; margin: 28px 0 14px; flex-wrap: wrap; }
.part-head:first-child { margin-top: 0; }
.part-head .grow { flex: 1; }

/* panels, forms, buttons */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.authcard { max-width: 440px; margin: 40px auto 0; }
.authcard a { display: inline-block; padding: 4px 0; }
.authcard h1 { font-size: 34px; margin-bottom: 4px; }
form.f { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label, .lbl { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 9px 10px; min-height: 42px; width: 100%; min-width: 0; }
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
input[type="checkbox"] { width: auto; min-height: 0; padding: 0; margin: 0 6px 0 0; vertical-align: middle; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.btn { font: inherit; font-weight: 600; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px 14px; min-height: 42px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #06141d; } }
:root[data-theme="dark"] .btn.primary { color: #06141d; }
.btn.danger { color: var(--crit); border-color: var(--crit); background: transparent; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 13.5px; }
.btn.link { background: none; border-color: transparent; color: var(--accent-ink); text-decoration: underline; padding-inline: 4px; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.alert { border: 1px solid var(--crit); border-left-width: 4px; background: var(--surface); padding: 10px 12px; border-radius: var(--radius); }
.alert.ok { border-color: var(--ok); }
.alert.info { border-color: var(--accent); }

/* autosave: the sentence next to a commit button, and the status line under it */
.draftline { display: grid; gap: 2px; min-width: 0; }
.draftline .hint { max-width: var(--measure); }
.save-status { min-height: 1.5em; margin: 0; font-size: 13.5px; font-weight: 500; color: var(--muted); overflow-wrap: anywhere; }
.save-status[data-state="saved"] { color: var(--ok); }
.save-status[data-state="retrying"], .save-status[data-state="conflict"], .save-status[data-state="local_only"] { color: var(--warn); }
.save-status[data-state="signed_out"], .save-status[data-state="failed"], .save-status[data-state="read_only"], .save-status[data-state="too_large"] { color: var(--crit); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 12px; line-height: 1; padding: 4px 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface); white-space: nowrap; }
/* an id inside a chip (BOM line, drawing no.) keeps the chip's own size */
.chip.mono { font-size: 12px; }
.chip.crit { color: var(--crit); border-color: var(--crit); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.info { color: var(--accent-ink); border-color: var(--accent); }
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.fill.crit { background: var(--crit); color: #fff; }
.chip.fill.warn { background: var(--hazard); color: #1b1300; border-color: var(--hazard); }

/* sections overview */
.secgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.sec { font: inherit; text-align: left; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--radius); padding: 8px 10px; cursor: pointer; display: grid; gap: 6px; min-height: 64px; align-content: space-between; }
.sec:hover { border-color: var(--ink-2); }
.sec.crit { border-left-color: var(--crit); }
.sec.warn { border-left-color: var(--hazard); }
.sec.info { border-left-color: var(--accent); }
.sec[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.sec .no { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.sec .name { font-weight: 500; line-height: 1.25; }
.sec .chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px; }

/* filters and list */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; margin-bottom: 12px; }
.notelist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.notelist li + li { border-top: 1px solid var(--line); }
.noterow { display: grid; gap: 4px; padding: 10px 14px; color: inherit; text-decoration: none; }
.noterow:hover { background: var(--surface-2); }
.noterow .t { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.noterow .meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 13px; color: var(--muted); }
.noterow .snip { color: var(--ink-2); font-size: 14px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* note detail */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); margin: 12px 0; }
.facts > div { background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 12px; min-width: 0; }
.facts b { display: block; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.facts span { overflow-wrap: anywhere; }
.body { white-space: pre-wrap; overflow-wrap: anywhere; max-width: var(--measure); }
.replies { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.reply { border-left: 3px solid var(--line-strong); padding: 6px 0 6px 12px; }
.reply .who { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }

/* tables (admin) */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; vertical-align: middle; padding: 8px 10px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { white-space: nowrap; font-family: var(--font-mono); font-weight: 500; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
details summary { cursor: pointer; padding: 6px 0; font-weight: 500; }

@media (max-width: 520px) {
  .opt { display: none; }
  body { font-size: 15px; }
  .sheet { padding-inline: 12px; }
  .panel { padding: 12px; }
  .secgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .authcard { margin-top: 16px; }
}

/* touch screens: 44 px targets (textarea is already 150 px high). Note-view links get a 44 px hit area. */
@media (pointer: coarse) {
  input, select, .btn, .btn.small, nav.main a { min-height: 44px; }
  .sheet p > a:not(.btn), .actions > a:not(.btn), .authcard a { display: inline-flex; align-items: center; min-height: 44px; }
}
