/* styles.css — Sheets' own clothes: Docs' (~/claude/docs/web/styles.css), the house's tokens with an
   accent of its own, a deep ledger green (never the house's --link blue, which means "this leaves").
   The grid is drawn on a canvas (grid.js) and stays white in dark mode, as Docs' paper does. */
:root {
  --bg: #e9ece9; --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: #16794a; --accent-ink: #ffffff; --accent-soft: rgba(22, 121, 74, .12);
  --ground: #d9dbe2;
  --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: #111412; --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: #5fd39a; --accent-ink: #062615; --accent-soft: rgba(95, 211, 154, .16);
    --ground: #2a2b31;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111412; --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: #5fd39a; --accent-ink: #062615; --accent-soft: rgba(95, 211, 154, .16);
  --ground: #2a2b31;
  --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 { width: 34px; height: 30px; border-radius: 4px; }
.docs .glyph::before { content: ""; position: absolute; inset: 4px; border-radius: 2px;
  background: linear-gradient(90deg, transparent 32%, #b6c9bc 32% 36%, transparent 36% 66%, #b6c9bc 66% 70%, transparent 70%),
              repeating-linear-gradient(#b6c9bc 0 1.5px, transparent 1.5px 5.5px); }
.docs .glyph::after { content: ""; position: absolute; left: 4px; right: 4px; top: 4px; height: 5px; background: #16794a; border-radius: 2px 2px 0 0; }
.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; }




/* ── 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; }
.ctx .tbtn { white-space: nowrap; }
/* 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; }
  .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 { width: 100%; padding: 8px 10px; font-size: 16px; }
}

/* 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; }

/* ── the spreadsheet ── */
.fbar { display: flex; align-items: stretch; gap: 0; border-top: 1px solid var(--line); background: var(--panel); min-height: 30px; }
.namebox { width: 92px; flex: none; font: 600 13px var(--font); color: var(--ink); background: var(--panel); border: 0; border-right: 1px solid var(--line); padding: 4px 8px; text-align: center; }
.namebox:focus { outline: 2px solid var(--accent); outline-offset: -2px; text-align: left; }
.fx { flex: none; font: italic 600 13px Georgia, serif; color: var(--dim); padding: 0 8px; display: flex; align-items: center; border-right: 1px solid var(--line); }
.fxin { flex: 1; min-width: 0; resize: none; border: 0; font: 13.5px/20px ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--ink); background: var(--panel);
        padding: 5px 8px; max-height: 90px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
.fxin:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.gridwrap { flex: 1; min-height: 0; position: relative; overflow: hidden; background: #fff; }
.gridwrap canvas { position: absolute; left: 0; top: 0; }
/* the native scroller over the canvas: it takes the wheel and the finger, and is see-through */
.gscroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; cursor: cell; z-index: 1; }
.gspace { position: relative; pointer-events: none; }
.addrows { position: absolute; z-index: 2; font-size: 13px; }
.ghandle { position: absolute; left: 0; top: 0; width: 22px; height: 22px; z-index: 3; touch-action: none; }
.ghandle::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #fff; border: 2.5px solid #16794a; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.celled { position: absolute; z-index: 4; margin: 0; resize: none; overflow: hidden; border: 2px solid #16794a; box-shadow: 0 2px 10px rgba(0,0,0,.18);
          background: #fff; color: #000; padding: 2px 3px; outline: none; white-space: pre-wrap; word-break: break-word; border-radius: 0; }
.keysink { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; resize: none; pointer-events: none; z-index: 0; font-size: 16px; }
.fnpop { position: absolute; z-index: 6; min-width: 260px; max-width: min(420px, calc(100% - 16px)); max-height: 260px; 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: 4px; }
.fnpop button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); padding: 6px 9px; border-radius: 6px; cursor: pointer; font: 13.5px var(--font); }
.fnpop button b { font: 600 13px ui-monospace, "SF Mono", Menlo, monospace; }
.fnpop button small { display: block; color: var(--dim); font-size: 12px; margin-top: 1px; }
.fnpop button.on { background: var(--accent-soft); }
.fnhint { position: absolute; z-index: 5; max-width: min(460px, calc(100% - 16px)); background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 9px;
          box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 7px 10px; font-size: 13px; pointer-events: none; }
.fnhint code { font: 600 12.5px ui-monospace, "SF Mono", Menlo, monospace; }
.fnhint code .cur { background: var(--accent-soft); color: var(--accent); border-radius: 3px; }
.fnhint small { display: block; color: var(--dim); margin-top: 3px; }
.fnhint.err { border-color: var(--bad); }
.tabsbar { flex: none; display: flex; align-items: center; gap: 4px; padding: 3px 8px calc(3px + env(safe-area-inset-bottom, 0px)); background: var(--panel); border-top: 1px solid var(--line); min-height: 38px; }
.ibtn.sm { width: 32px; height: 32px; } .ibtn.sm svg { width: 18px; height: 18px; }
.stabs { flex: 1; min-width: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; align-items: stretch; }
.stabs::-webkit-scrollbar { display: none; }
.stab { flex: none; font: 500 13.5px var(--font); color: var(--ink-2); background: none; border: 0; border-radius: 7px; padding: 7px 12px; cursor: pointer; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.stab:hover { background: var(--pill); }
.stab.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.stab.drop { box-shadow: inset 3px 0 0 var(--accent); }
.stats { flex: none; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; display: flex; gap: 12px; align-items: center; }
.stats .zoom { display: flex; align-items: center; gap: 4px; }
.stats .zoom button { border: 0; background: var(--pill); color: var(--ink); border-radius: 6px; width: 24px; height: 22px; cursor: pointer; font: 600 14px var(--font); }
.stats b { font-weight: 600; color: var(--ink); }
.tbtn .tx { font: 700 13px var(--font); letter-spacing: -.02em; }
.tsel.w-fmt { max-width: 130px; }
.nfgrid { display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; }
.sheet .preview-n { font: 15px ui-monospace, "SF Mono", Menlo, monospace; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; margin: 8px 0 0; min-height: 36px; }
.sheet .wide-in { width: 100%; font: 14px ui-monospace, "SF Mono", Menlo, monospace; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.fvals { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; padding: 4px; }
.fvals label { display: flex; gap: 8px; align-items: center; padding: 5px 6px; font-size: 14px; border-radius: 6px; }
.fvals label small { margin-left: auto; color: var(--dim); }
.pop.fpop { min-width: 260px; padding: 8px; }
.pop .fpop-acts { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.pop input.fsearch { width: 100%; font: 14px var(--font); padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.helpfn { max-height: 55vh; overflow-y: auto; }
.helpfn dt { font: 600 13px ui-monospace, "SF Mono", Menlo, monospace; margin-top: 8px; }
.helpfn dd { margin: 2px 0 0; color: var(--ink-2); font-size: 13.5px; }
.helpfn h4 { margin: 14px 0 2px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
@media (max-width: 760px) {
  .namebox { width: 64px; font-size: 16px; padding: 4px 4px; }
  .fxin { font-size: 16px; line-height: 22px; }
  .stats .wide { display: none; }
  .stats { gap: 8px; font-size: 11.5px; }
  .celled { font-size: 16px !important; }
  .fx { padding: 0 6px; }
}
