/* styles.css — Docs' own clothes. The house's tokens (myjp.ca/login/ui.css, copied, not imported:
   ui.css also lays out its own pages' body) and an accent of its own, a deep ink blue (never the
   house's --link blue, which means "this leaves"). A document's own look is content.css + the
   styles generated from the document; the paper stays white in dark mode. */
:root {
  --bg: #e9e9ee; --panel: #ffffff; --panel-2: #f4f4f7; --line: rgba(60, 60, 67, .16); --line-2: rgba(60, 60, 67, .28);
  --ink: #000000; --ink-2: #3c3c43; --dim: #8a8a8e; --dim-2: #b0b0b6; --pill: #efeff0;
  --good: #1a9e4b; --warn: #b8730a; --bad: #e5322b; --link: #007aff;
  --accent: #2d4fa3; --accent-ink: #ffffff; --accent-soft: rgba(45, 79, 163, .12);
  --ground: #d9dbe2; --paper-shadow: 0 1px 3px rgba(0,0,0,.12), 0 8px 28px rgba(0,0,0,.10);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --r-card: 16px; --r-mid: 11px; --r-tile: 8px;
  --font: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-round: "SF Pro Rounded", ui-rounded, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --sb: 0px; --kb: 0px; --zoom: 1; --glass-t: 0px;
  color-scheme: light;
}
/* dark: the device's choice unless Settings → Appearance pins Light; or pinned Dark (data-theme, set
   by bootguard.js before the first paint). The two blocks hold the same tokens. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111114; --panel: #1c1c1e; --panel-2: #2c2c2e; --line: rgba(84, 84, 88, .48); --line-2: rgba(120, 120, 128, .6);
    --ink: #ffffff; --ink-2: #d7d7db; --dim: #98989f; --dim-2: #6c6c70; --pill: #2c2c2e;
    --good: #30d158; --warn: #ffd60a; --bad: #ff453a; --link: #0a84ff;
    --accent: #8fa8ff; --accent-ink: #0b1430; --accent-soft: rgba(143, 168, 255, .16);
    --ground: #2a2b31; --paper-shadow: 0 1px 3px rgba(0,0,0,.6), 0 8px 28px rgba(0,0,0,.5);
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111114; --panel: #1c1c1e; --panel-2: #2c2c2e; --line: rgba(84, 84, 88, .48); --line-2: rgba(120, 120, 128, .6);
  --ink: #ffffff; --ink-2: #d7d7db; --dim: #98989f; --dim-2: #6c6c70; --pill: #2c2c2e;
  --good: #30d158; --warn: #ffd60a; --bad: #ff453a; --link: #0a84ff;
  --accent: #8fa8ff; --accent-ink: #0b1430; --accent-soft: rgba(143, 168, 255, .16);
  --ground: #2a2b31; --paper-shadow: 0 1px 3px rgba(0,0,0,.6), 0 8px 28px rgba(0,0,0,.5);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, a, label, input, select { touch-action: manipulation; }

/* THE STAGE (IOS.md §25, News' measure/seat): the document never scrolls under a finger. Installed,
   the body is the screen tall and held scrolled by the status bar's height (app.js seat). */
html { overflow: hidden; overscroll-behavior: none; background: var(--bg); }
body { margin: 0; position: relative; height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg); color: var(--ink);
       font: 15px/1.4 var(--font); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
/* IOS.md §1: installed, iOS blurs ~20px PAST the status bar; Docs' header is a short padded row (not a 52px bar
   with its contents centred), so the band is added to every screen's and sheet's top (docs-v7). */
@media (display-mode: standalone) {
  :root { --sb: calc(100lvh - 100dvh); --glass-t: 20px; }
  body { height: 100vh; height: 100lvh; height: var(--stage-h, 100lvh); }
}
#stage { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding-top: calc(var(--sb) + env(safe-area-inset-top, 0px) + var(--glass-t)); }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* ── buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px/1 var(--font); padding: 9px 14px;
       border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.ghost { background: var(--pill); color: var(--ink); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.big { font-size: 17px; padding: 14px 34px; border-radius: 13px; }
.btn.quiet { background: none; color: var(--dim); }
.btn:disabled { opacity: .45; cursor: default; }
.ibtn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: 9px;
        background: none; color: var(--ink); cursor: pointer; flex: none; }
.ibtn svg { width: 22px; height: 22px; }
.ibtn:hover { background: var(--pill); }

/* ── doors ── */
.door { position: absolute; inset: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
        text-align: center; padding: 40px 24px; }
.doormark { width: 84px; height: 84px; border-radius: 19px; box-shadow: var(--shadow); }
.lockup { margin: 18px 0 26px; font-weight: 800; letter-spacing: -.03em; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.lockup .lm, .hlock .lm { font-size: 17px; color: var(--dim); font-weight: 700; letter-spacing: -.01em; }
.lc { color: var(--accent); }
.lockup .ls { font-size: 44px; }
.note { color: var(--dim); max-width: 360px; font-size: 14px; margin: 16px auto 0; }
.note.big { font-size: 16px; color: var(--ink-2); margin-bottom: 20px; }

/* ── the documents screen ── */
.hbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hlock { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; margin-right: auto; }
.hlock img { width: 34px; height: 34px; border-radius: 8px; }
.hlock > span { display: flex; flex-direction: column; line-height: 1; }
.hlock .lm { font-size: 11px; }
.hlock b { font-size: 21px; letter-spacing: -.02em; }
.hsearch { flex: 1 1 220px; max-width: 360px; }
.hsearch input, .field { width: 100%; font: 15px var(--font); padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.hbtns { display: flex; gap: 8px; align-items: center; }
.list-wrap { max-width: 860px; margin: 0 auto; padding: 14px 16px calc(40px + var(--kb) + env(safe-area-inset-bottom, 0px)); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 7px 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14px; }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.docs { list-style: none; margin: 0; padding: 0; background: var(--panel); border-radius: var(--r-card); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.docs:empty { display: none; }
.docs li { display: flex; align-items: center; gap: 12px; padding: 0 8px 0 0; border-top: 1px solid var(--line); }
.docs li:first-child { border-top: 0; }
.docs .open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none; }
.docs .glyph { width: 30px; height: 38px; flex: none; border-radius: 3px; background: #fff; border: 1px solid var(--line-2); position: relative; }
.docs .glyph::before { content: ""; position: absolute; left: 6px; right: 6px; top: 8px; height: 14px;
  background: repeating-linear-gradient(#b9bfcc 0 2px, transparent 2px 5px); }
.docs .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs .m { color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.docs .acts { display: flex; gap: 4px; flex: none; }
.docs .acts .btn { padding: 7px 10px; font-size: 13px; }
.empty, .bin-note { color: var(--dim); text-align: center; margin: 30px 0; }
.bin-note { margin: 0 0 12px; text-align: left; font-size: 13.5px; }
.addr { text-align: center; color: var(--dim-2); font-size: 12px; margin: 26px 0 0; }

/* ── the editor ── */
.ebar { background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 3; flex: none; }
.erow { display: flex; align-items: center; gap: 6px; padding: 6px 10px 2px; }
.title-in { flex: 1; min-width: 60px; font: 600 16px var(--font); color: var(--ink); background: none; border: 1px solid transparent; border-radius: 8px; padding: 5px 8px; }
.title-in:hover, .title-in:focus { border-color: var(--line); outline: none; background: var(--panel-2); }
.savestate { font-size: 12.5px; color: var(--dim); white-space: nowrap; padding: 0 6px; }
.savestate.err { color: var(--bad); font-weight: 600; }
.menubar { display: flex; gap: 2px; padding: 0 8px; }
.menubar > button { font: 14px var(--font); color: var(--ink); background: none; border: 0; padding: 5px 9px; border-radius: 6px; cursor: pointer; }
.menubar > button:hover, .menubar > button.open { background: var(--pill); }
.toolbar { display: flex; align-items: center; gap: 2px; padding: 4px 8px 6px; flex-wrap: wrap; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 5px; }
.tbtn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 6px; border: 0; border-radius: 7px;
      background: none; color: var(--ink); font: 600 14px var(--font); cursor: pointer; }
.tbtn:hover { background: var(--pill); }
.tbtn.on { background: var(--accent-soft); color: var(--accent); }
.tbtn:disabled { opacity: .35; cursor: default; background: none; }
.tbtn svg { width: 19px; height: 19px; }
.tbtn .sw { display: block; width: 18px; height: 4px; border-radius: 1px; margin-top: 1px; }
.tbtn.col { flex-direction: column; gap: 0; }
.tsel { font: 14px var(--font); color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; height: 30px; padding: 0 6px; max-width: 150px; }
.tsel.w-size { width: 64px; }
.fontbtn { display: inline-flex; align-items: center; gap: 4px; width: 150px; cursor: pointer; text-align: left; }
.fontbtn .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.fontbtn svg { width: 14px; height: 14px; flex: none; color: var(--dim); }
.fontbtn.open { border-color: var(--accent); }
.pop .mi .fprev { font-size: 17px; line-height: 1.25; }
.ctx { display: inline-flex; align-items: center; gap: 2px; padding-left: 4px; margin-left: 4px; border-left: 2px solid var(--accent-soft); }
.ctx-label { font-size: 12px; color: var(--accent); font-weight: 700; margin: 0 4px; }
.findbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 10px 8px; border-top: 1px solid var(--line); }
.findbar input[type="text"] { flex: 1 1 160px; font: 14px var(--font); padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.findbar .n { font-size: 12.5px; color: var(--dim); min-width: 64px; }
.findbar label { font-size: 13px; color: var(--ink-2); display: inline-flex; gap: 4px; align-items: center; }

.ework { flex: 1; min-height: 0; display: flex; }
.ground { background: var(--ground); flex: 1; }
.paper { background: #fff; color: #000; margin: 28px auto calc(60px + var(--kb)); box-shadow: var(--paper-shadow); zoom: var(--zoom);
         width: var(--paper-w, 8.5in); padding: var(--pad-t, 1in) var(--pad-r, 1in) var(--pad-b, 1in) var(--pad-l, 1in); min-height: 4in; }
.paper .ProseMirror { outline: none; min-height: 2in; caret-color: #000; position: relative; word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces;
  -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; }   /* prosemirror-view's style/prosemirror.css */
.paper .ProseMirror pre { white-space: pre-wrap; }
.paper .ProseMirror li { position: relative; }
.paper .ProseMirror-hideselection *::selection { background: transparent; }
.paper .ProseMirror-hideselection { caret-color: transparent; }
.paper .ProseMirror [draggable][contenteditable=false] { user-select: text; }
.paper .ProseMirror-selectednode { outline: 2px solid #2d4fa3; outline-offset: 2px; }
.paper .find-hit { background: #ffe58a; }
.paper .find-cur { background: #ff9e3d; }
.paper .pagebreak, .paper .colbreak { height: auto; margin: 10pt 0; text-align: center; position: relative; }
.paper .pagebreak { border-top: 2px dashed #9aa3b8; }
.paper .colbreak { border-top: 1px dashed #b8bfcc; }
.paper .pagebreak::after, .paper .colbreak::after { content: attr(data-label); position: relative; top: -.75em; background: #fff; padding: 0 8px;
  font: 600 10px/1.5 var(--font); letter-spacing: .06em; text-transform: uppercase; color: #7d869c; }
.paper .sect { outline: 1px dashed #d4d8e2; outline-offset: 4px; }
.paper .toc { border: 1px solid #dfe3ea; border-radius: 6px; padding: 8pt 10pt; background: #fafbfd; cursor: default; }
.paper figure img { pointer-events: none; }
.paper img:not([src]) { min-height: 60px; background: #eef0f5; }
.paper .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: -2px; width: 4px; background: #6b8cff; pointer-events: none; }
.paper.resize-cursor { cursor: col-resize; }
.paper .selectedCell::after { content: ""; position: absolute; inset: 0; background: rgba(45, 79, 163, .15); pointer-events: none; }
.paper .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; }
.paper .ProseMirror-gapcursor::after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: gapblink 1.1s steps(2, start) infinite; }
.paper .ProseMirror-focused .ProseMirror-gapcursor { display: block; }
@keyframes gapblink { to { visibility: hidden; } }
.paper .ProseMirror .tableWrapper { overflow-x: auto; }

.side { width: 240px; flex: none; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 12px 10px; font-size: 13.5px; }
#reveal { border-right: 0; border-left: 1px solid var(--line); width: 280px; font: 12.5px/1.45 ui-monospace, "SF Mono", Menlo, monospace; }
.side h3 { font: 700 11px var(--font); letter-spacing: .07em; text-transform: uppercase; color: var(--dim); margin: 4px 4px 8px; }
.side .ol-item { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); font: 13.5px var(--font); padding: 5px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .ol-item:hover { background: var(--pill); }
.side .ol-item.l0 { font-weight: 700; } .side .ol-item.l1 { font-weight: 600; }
.side .ol-item.l2 { padding-left: 18px; } .side .ol-item.l3 { padding-left: 30px; } .side .ol-item.l4 { padding-left: 42px; }
.side .ol-item.l5 { padding-left: 54px; } .side .ol-item.l6 { padding-left: 66px; }
.side .muted { color: var(--dim); padding: 4px 6px; }
.code { border-radius: 5px; padding: 3px 6px; margin: 2px 0; background: var(--panel-2); border-left: 3px solid var(--accent); word-break: break-word; }
.code.mark { border-left-color: var(--warn); }
.code small { color: var(--dim); }

.status { flex: none; display: flex; gap: 14px; align-items: center; padding: 5px 14px calc(5px + env(safe-area-inset-bottom, 0px)); font-size: 12.5px;
          color: var(--ink-2); background: var(--panel); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.status .zoom { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.status .zoom button { border: 0; background: var(--pill); color: var(--ink); border-radius: 6px; width: 24px; height: 22px; cursor: pointer; font: 600 14px var(--font); }

/* ── menus, popovers, sheets ── */
.pop { position: absolute; z-index: 20; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; background: var(--panel);
       border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 34px rgba(0,0,0,.22); padding: 5px; }
.pop .mi { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; color: var(--ink); font: 14px var(--font);
           padding: 7px 10px; border-radius: 6px; cursor: pointer; text-align: left; }
.pop .mi:hover:not(:disabled), .pop .mi:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.pop .mi:disabled { color: var(--dim-2); cursor: default; }
.pop .mi .k { margin-left: auto; color: var(--dim); font-size: 12.5px; }
.pop .mi:hover:not(:disabled) .k { color: inherit; opacity: .8; }
.pop .mi .chk { width: 14px; flex: none; text-align: center; }
.pop .hr { height: 1px; background: var(--line); margin: 4px 6px; }
.pop .ph { font: 700 11px var(--font); letter-spacing: .07em; text-transform: uppercase; color: var(--dim); padding: 8px 10px 4px; }
.pop .swatches { display: grid; grid-template-columns: repeat(6, 28px); gap: 6px; padding: 6px; }
.pop .swatches button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line-2); cursor: pointer; }
.pop .swrow { display: flex; gap: 8px; align-items: center; padding: 4px 6px 6px; font-size: 13px; }

.sheet-wrap { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.32); display: flex; align-items: flex-start; justify-content: center;
              padding: calc(var(--sb) + 40px) 12px 12px; overflow-y: auto; }
.sheet { background: var(--panel); color: var(--ink); width: min(560px, 100%); border-radius: var(--r-card); box-shadow: 0 20px 60px rgba(0,0,0,.3);
         padding: 18px 18px 16px; margin-bottom: calc(24px + var(--kb)); }
.sheet h2 { margin: 0 0 12px; font-size: 19px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.sheet h2 .x { margin-left: auto; }
.sheet .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.sheet p { margin: 0 0 10px; color: var(--ink-2); }
.sheet .grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 12px; align-items: center; }
.sheet .grid label { font-size: 13.5px; color: var(--ink-2); }
.sheet .grid input, .sheet .grid select { font: 14px var(--font); padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); min-width: 0; }
.sheet .three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.sheet .three input, .stylesplit input[type=text], .stylesplit select:not([size]) { min-width: 0; width: 100%; font: 14px var(--font); padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.stylesplit select[size] { border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font: 14px var(--font); }
.ctx .tbtn { white-space: nowrap; }
.sheet .grid.m4 { grid-template-columns: repeat(4, max-content minmax(0, 1fr)); }
.stylesplit { display: grid; grid-template-columns: minmax(140px, 200px) minmax(0, 1fr); gap: 14px; }
.stylesplit select[size] { width: 100%; }
/* a finger needs a taller row than a pointer */
@media (pointer: coarse) {
  .pop .mi { min-height: 42px; font-size: 15px; }
  .pop .mi .fprev { font-size: 18px; }
}
.sheet fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; margin: 10px 0 0; }
.sheet legend { font-size: 12.5px; color: var(--dim); padding: 0 4px; }
.sheet .hint { font-size: 12.5px; color: var(--dim); margin: 6px 0 0; }
.sheet .err { color: var(--bad); font-size: 13.5px; margin: 8px 0 0; }
.hist { list-style: none; padding: 0; margin: 0; max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.hist li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); }
.hist li:first-child { border-top: 0; }
.hist .w { flex: 1; min-width: 0; }
.hist .w b { display: block; font-size: 14px; }
.hist .w small { color: var(--dim); }
.hist .now { color: var(--accent); font-weight: 700; font-size: 12px; }
.preview { border: 1px solid var(--line); border-radius: 10px; max-height: 40vh; overflow: auto; background: #fff; padding: 14px 18px; margin-top: 10px; font-size: 13px; }
.rows { background: var(--panel-2); border-radius: 12px; overflow: hidden; margin: 0 0 12px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink);
       text-decoration: none; font: 15px var(--font); text-align: left; cursor: pointer; }
.row:first-child { border-top: 0; }
.row .row-k { flex: 1; min-width: 0; }
.row .row-k small { display: block; color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.row .row-v { color: var(--dim); }
.row.danger { color: var(--bad); }
.sec { font: 700 12px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); margin: 16px 4px 6px; }
.meter { height: 8px; border-radius: 4px; background: var(--pill); overflow: hidden; margin: 8px 0 4px; }
.meter > i { display: block; height: 100%; background: var(--accent); }
details.tech { background: var(--panel-2); border-radius: 12px; padding: 0 14px; margin: 0 0 12px; }
details.tech summary { padding: 12px 0; cursor: pointer; list-style: none; display: flex; }
details.tech summary::after { content: "›"; margin-left: auto; color: var(--dim); }
details.tech[open] summary::after { transform: rotate(90deg); }
details.tech dl { margin: 0 0 12px; font-size: 13px; }
details.tech dl div { display: flex; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); }
details.tech dt { color: var(--dim); width: 110px; flex: none; }
details.tech dd { margin: 0; overflow-wrap: anywhere; }
.lockrow { font-weight: 800; letter-spacing: -.02em; }
.toast { position: absolute; left: 50%; bottom: calc(46px + env(safe-area-inset-bottom, 0px) + var(--kb)); transform: translateX(-50%); z-index: 40;
         background: #1c1c1e; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.toast button { margin-left: 10px; border: 0; background: none; color: #9db4ff; font: 600 14px var(--font); cursor: pointer; }

#bootfail { position: fixed; inset: 0; z-index: 2147483647; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); color: var(--ink); text-align: center; }
#bootfail > div { max-width: 360px; }
#bootfail button { font: 600 16px var(--font); padding: 12px 32px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); }
#bootfail small { display: block; margin-top: 20px; font-size: 12px; opacity: .55; overflow-wrap: anywhere; }

/* ── small screens: the toolbar folds to what fits, the menus live behind ☰ ── */
.phone-only { display: none; }
@media (max-width: 760px) {
  .phone-only { display: inline-flex; }
  .menubar { display: none; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar .wide { display: none; }
  .side { position: absolute; z-index: 4; top: 0; bottom: 0; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  #outline { left: 0; } #reveal { right: 0; }
  .ework { position: relative; }
  .paper { width: auto !important; margin: 0; padding: 18px 16px 40px !important; min-height: 100%; box-shadow: none; zoom: 1; }
  .ground { background: #fff; }
  .status { font-size: 11.5px; gap: 10px; }
  .status .wide { display: none; }
  .hbar { gap: 8px; padding: 8px 12px; }
  .hsearch { order: 3; flex-basis: 100%; max-width: none; }
  .docs .acts .wide { display: none; }
  .sheet-wrap { padding: calc(var(--sb) + env(safe-area-inset-top, 0px) + var(--glass-t) + 10px) max(8px, env(safe-area-inset-right, 0px)) 8px max(8px, env(safe-area-inset-left, 0px)); }
  .sheet { padding: 16px 14px 14px; }
  .sheet .acts .btn { padding: 11px 16px; font-size: 15px; }
  /* iOS zooms the page into any field under 16px: every field on a phone is 16px */
  .sheet input:not([type=checkbox]):not([type=radio]):not([type=color]), .sheet .grid select, .sheet select, .sheet textarea, .findbar input[type="text"], .hsearch input, .title-in, .toolbar .tsel { font-size: 16px; }
  .sheet .grid { grid-template-columns: max-content minmax(0, 1fr); }
  .sheet .grid input, .sheet .grid select, .sheet .three input, .stylesplit input[type=text], .stylesplit select { width: 100%; padding: 8px 10px; font-size: 16px; }
  .sheet .grid.m4 { grid-template-columns: repeat(2, max-content minmax(0, 1fr)); }
  .sheet .three { grid-template-columns: minmax(0, 1fr); }
  .stylesplit { grid-template-columns: minmax(0, 1fr); }
  .stylesplit select[size], .stylesplit select:not([size]) { font-size: 16px; }
  .stylesplit select[size] { min-height: 0 !important; height: auto; }
  .toolbar .ctx { order: -1; padding-left: 0; margin-left: 0; border-left: 0; padding-right: 4px; margin-right: 4px; border-right: 2px solid var(--accent-soft); }
}

/* Settings → Appearance: System · Light · Dark */
.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--pill); gap: 2px; flex: none; }
.seg button { border: 0; background: transparent; color: var(--ink-2); font: 500 13px var(--font); padding: 6px 12px; border-radius: 7px; cursor: pointer; min-height: 32px; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.pop .swatches button.on { outline: 2px solid var(--accent); outline-offset: 1px; }
