/* Gridwork on the web iOS kit (src/ioskit/ios.css): system grey lists, a green tint, the grid drawn on a canvas. */
:root { --tint: #1f8a5b; --forest: #1f8a5b; --coral: #1f8a5b; --canvas: #f2f2f7;
  --g-line: #e2e2e7; --g-head: #f7f7f9; --g-headtx: #6e6e73; --g-sel: #1f8a5b; --g-selfill: rgba(31, 138, 91, 0.10); --g-cell: #fff; --g-text: #1c1c1e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tint: #34c27f; --forest: #34c27f; --coral: #34c27f; --canvas: #000;
  --g-line: #2c2c2e; --g-head: #1c1c1e; --g-headtx: #98989f; --g-sel: #34c27f; --g-selfill: rgba(52, 194, 127, 0.16); --g-cell: #111113; --g-text: #f2f2f7; } }
:root[data-theme="dark"] { --tint: #34c27f; --forest: #34c27f; --coral: #34c27f; --canvas: #000;
  --g-line: #2c2c2e; --g-head: #1c1c1e; --g-headtx: #98989f; --g-sel: #34c27f; --g-selfill: rgba(52, 194, 127, 0.16); --g-cell: #111113; --g-text: #f2f2f7; }

/* ---------- home ---------- */
.gw-hero { display: flex; flex-direction: column; gap: 4px; padding: 6px 4px 2px; }
.gw-hero h2 { font: 700 30px/1.12 var(--sys); letter-spacing: -0.02em; }
.gw-hero p { color: var(--text2); font-size: 15px; line-height: 20px; }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
.book { position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 0 0 10px; border-radius: 18px; background: var(--row); box-shadow: 0 0 0 .5px var(--sep); overflow: hidden; transition: transform .15s var(--ease); }
.book:active { transform: scale(0.98); }
.book .thumb { display: block; width: 100%; aspect-ratio: 4 / 3; background: var(--g-cell); border-bottom: .5px solid var(--sep); }
.book .nm { padding: 0 12px; font-weight: 600; font-size: 15px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book .dt { padding: 0 12px; font-size: 12px; color: var(--text2); }
.book .lock { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; }
.book.new { align-items: center; justify-content: center; min-height: 150px; color: var(--tint); font-weight: 600; gap: 8px; padding: 10px; }
.book.new .big { font-size: 34px; }
.tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tpl { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; background: var(--row); text-align: left; box-shadow: 0 0 0 .5px var(--sep); min-height: 58px; }
.tpl .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--c, var(--tint)); font-size: 18px; flex: none; }
.tpl .tx { display: flex; flex-direction: column; min-width: 0; }
.tpl .tx b { font-weight: 600; font-size: 15px; line-height: 19px; }
.tpl .tx span { font-size: 12px; color: var(--text2); line-height: 15px; }
.sec-title { font: 700 20px/1.2 var(--sys); margin: 8px 4px -4px; }
.cap-note { font-size: 13px; color: var(--text2); padding: 0 4px; }

/* ---------- the editor ---------- */
.screen.gw-ed { background: var(--g-cell); }
.gw-ed .screen-body { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
.fbar { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: .5px solid var(--sep); background: var(--grouped); }
.fbar .ref { flex: none; min-width: 64px; max-width: 120px; height: 34px; padding: 0 10px; border-radius: 10px; background: var(--fill2); font: 600 14px/34px ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fbar .fx { flex: none; color: var(--text2); font: italic 600 15px/1 Georgia, serif; width: 20px; text-align: center; }
.fbar .in { flex: 1; min-width: 0; height: 36px; border: 0; outline: none; border-radius: 10px; padding: 0 12px; background: var(--row); color: var(--text); font: 16px/36px var(--sys); box-shadow: inset 0 0 0 .5px var(--sep); }
.fbar .in:focus { box-shadow: inset 0 0 0 2px var(--tint); }
.fbar .ok { flex: none; }
.gw-host { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: var(--g-cell); }
.gw-host canvas { position: absolute; inset: 0; display: block; }
.gw-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: none; -webkit-overflow-scrolling: touch; outline: none; z-index: 2; }
.gw-size { pointer-events: none; }
.gw-charts { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.gw-chart { position: absolute; pointer-events: auto; background: var(--row); border-radius: 14px; box-shadow: 0 0 0 .5px var(--sep), 0 6px 20px rgba(0,0,0,.10); overflow: hidden; touch-action: none; }
.gw-chart.on { box-shadow: 0 0 0 2px var(--tint), 0 8px 26px rgba(0,0,0,.16); }
.gw-chart svg { display: block; width: 100%; height: 100%; }
.gw-chart .rz { position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; cursor: nwse-resize; display: none; }
.gw-chart.on .rz { display: block; }
.gw-chart.on .rz::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 10px; height: 10px; border-right: 2.5px solid var(--tint); border-bottom: 2.5px solid var(--tint); border-radius: 0 0 3px 0; }
.cell-ed { position: absolute; z-index: 4; margin: 0; border: 0; outline: 2px solid var(--g-sel); outline-offset: -1px; padding: 0 5px; background: var(--g-cell); color: var(--g-text); font: 14px/1 var(--sys); box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.tabs { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 10px calc(6px + var(--sab)); border-top: .5px solid var(--sep); background: var(--grouped); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; height: 32px; padding: 0 14px; border-radius: 16px; font-size: 14px; font-weight: 500; color: var(--text2); background: transparent; white-space: nowrap; }
.tab.on { background: var(--row); color: var(--text); font-weight: 600; box-shadow: 0 0 0 .5px var(--sep), 0 1px 4px rgba(0,0,0,.06); }
.tab.add { width: 32px; padding: 0; display: grid; place-items: center; color: var(--tint); font-size: 18px; }
.sum-chip { margin-left: auto; flex: none; font-size: 13px; color: var(--text2); padding: 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* the key row above the phone's keyboard while editing */
.keyrow { position: fixed; left: 0; right: 0; z-index: 30; display: none; gap: 6px; padding: 6px 8px; background: color-mix(in srgb, var(--grouped) 92%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: .5px solid var(--sep); overflow-x: auto; scrollbar-width: none; }
.keyrow::-webkit-scrollbar { display: none; }
.keyrow.on { display: flex; }
.keyrow button { flex: none; min-width: 40px; height: 40px; padding: 0 10px; border-radius: 10px; background: var(--row); box-shadow: 0 1px 0 rgba(0,0,0,.12); font: 600 17px/40px ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); }
.keyrow button.w { font: 600 14px/40px var(--sys); color: var(--tint); }
.keyrow button.ref { font: 600 14px/40px ui-monospace, "SF Mono", Menlo, monospace; color: var(--tint); }
/* autocomplete and the argument hint */
.ac { position: fixed; z-index: 35; min-width: 220px; max-width: min(420px, calc(100vw - 20px)); max-height: 240px; overflow-y: auto; border-radius: 16px; padding: 4px 0; background: var(--glass); -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8); box-shadow: 0 0 0 .5px var(--glass-edge), 0 12px 36px rgba(0,0,0,.2); display: none; }
.ac.on { display: block; }
.ac button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 7px 14px; text-align: left; min-height: 44px; justify-content: center; }
.ac button[aria-selected="true"], .ac button:hover { background: var(--fill2); }
.ac b { font: 600 14px/18px ui-monospace, "SF Mono", Menlo, monospace; }
.ac span { font-size: 12px; line-height: 15px; color: var(--text2); }
.ac .hint { padding: 8px 14px; font: 13px/18px ui-monospace, "SF Mono", Menlo, monospace; color: var(--text2); }
.ac .hint b { color: var(--text); }
.ac .hint .cur { color: var(--tint); font-weight: 700; }
/* the format sheet */
.fmt-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tbtn { min-width: 44px; height: 40px; padding: 0 12px; border-radius: 12px; background: var(--fill2); font-size: 17px; display: inline-grid; place-items: center; }
.tbtn[aria-pressed="true"] { background: var(--tint); color: #fff; }
.sw-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sw { position: relative; width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(127,127,127,.35) inset; }
.sw::after { content: ""; position: absolute; inset: -6px; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--row), 0 0 0 4px var(--tint); }
.sw.none { background: linear-gradient(135deg, var(--row) 45%, #ff3b30 45%, #ff3b30 55%, var(--row) 55%); }
.chart-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ctype { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px; background: var(--fill2); font-size: 12px; color: var(--text2); min-height: 72px; justify-content: center; }
.ctype svg { width: 34px; height: 26px; }
.ctype[aria-pressed="true"] { background: color-mix(in srgb, var(--tint) 16%, transparent); color: var(--tint); font-weight: 600; box-shadow: inset 0 0 0 2px var(--tint); }
.ctype .pro { font-size: 10px; font-weight: 700; color: var(--tint); }
.prev-chart { height: 220px; margin: 0 0 4px; border-radius: 18px; background: var(--row); overflow: hidden; }
.prev-chart svg { width: 100%; height: 100%; display: block; }
.err-tip { font-size: 13px; color: var(--red); padding: 6px 14px; }
.pro-pill { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; color: var(--tint); background: color-mix(in srgb, var(--tint) 14%, transparent); padding: 2px 7px; border-radius: 999px; vertical-align: 1px; }
.cf-rule { display: flex; align-items: center; gap: 10px; width: 100%; }
.cf-rule .chip { width: 26px; height: 18px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.2); }
.lockpad { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 40px 20px; text-align: center; }
.lockpad .big { font-size: 48px; color: var(--tint); }
.lockpad input { width: min(320px, 100%); height: 48px; border: 0; border-radius: 14px; padding: 0 16px; background: var(--row); color: var(--text); font-size: 17px; box-shadow: inset 0 0 0 .5px var(--sep); outline: none; }
.lockpad input:focus { box-shadow: inset 0 0 0 2px var(--tint); }

/* print: the used range as a table */
@media print {
  @page { size: auto; margin: 12mm; }
  #print-root { padding: 0 !important; }
  #print-root h1 { font: 700 16pt/1.2 -apple-system, system-ui, sans-serif; margin: 0 0 8px; }
  #print-root table { border-collapse: collapse; width: 100%; font: 9pt/1.3 -apple-system, system-ui, sans-serif; table-layout: auto; }
  #print-root td, #print-root th { padding: 2px 5px; vertical-align: top; }
  #print-root.lines td, #print-root.lines th { border: .5pt solid #bbb; }
  #print-root th { background: #f2f2f2; color: #555; font-weight: 600; }
  #print-root .chart { break-inside: avoid; margin: 12px 0; width: 100%; max-width: 640px; }
}

/* ---------- polish round (2026-11-06) ---------- */
/* the home screen: wider on computers, a search past six spreadsheets */
@media (min-width: 900px) { .home .col { max-width: 1100px; } .books { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } .tpls { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.home .search-field { margin: 2px 0 -2px; }
/* the formula bar's fx: the function browser */
.fbar .fx { border-radius: 8px; height: 34px; width: 30px; display: grid; place-items: center; }
.fbar .fx:active { background: var(--fill2); }
@media (hover: hover) { .fbar .fx:hover { background: var(--fill2); color: var(--tint); } }
/* a note on the selected cell */
.note-tip { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 13px; line-height: 18px; color: var(--text); background: color-mix(in srgb, #f0a020 12%, var(--grouped)); border-bottom: .5px solid var(--sep); }
.note-tip .sf { color: #c77d00; flex: none; }
.note-tip span { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 54px; overflow-y: auto; }
.note-tip .text-btn { flex: none; font-size: 13px; min-height: 30px; }
/* find and replace */
.findbar { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 6px 10px; background: var(--grouped); border-bottom: .5px solid var(--sep); }
.findbar .frow { display: flex; align-items: center; gap: 6px; color: var(--text2); }
.findbar .fq { flex: 1; min-width: 0; height: 34px; border: 0; outline: none; border-radius: 10px; padding: 0 10px; background: var(--row); color: var(--text); font: 16px/34px var(--sys); box-shadow: inset 0 0 0 .5px var(--sep); }
.findbar .fq:focus { box-shadow: inset 0 0 0 2px var(--tint); }
.findbar .fcount { flex: none; font-size: 13px; color: var(--text2); min-width: 54px; text-align: right; font-variant-numeric: tabular-nums; }
.findbar .icon-btn { width: 36px; height: 36px; margin: 0; border-radius: 10px; color: var(--text); }
.findbar .btn-bordered { flex: none; }
.findbar[data-opts]:not([data-opts=""])::after { content: attr(data-opts); font-size: 12px; color: var(--tint); padding: 0 4px 0 26px; }
/* zoom: the size while it changes */
.zoom-chip { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.7); color: #fff; font: 600 13px/18px var(--sys); opacity: 0; transition: opacity .25s; pointer-events: none; }
.zoom-chip.on { opacity: 1; }
.gw-chart { transform-origin: 0 0; }
.gw-scroll { touch-action: pan-x pan-y; }
/* the selection's stats and the saved mark, by the sheet tabs */
.sum-chip { margin-left: auto; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--text2); padding: 0 10px; height: 32px; border-radius: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sum-chip:active, .sum-chip:hover { background: var(--fill2); color: var(--text); }
.saved { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text2); padding: 0 4px; white-space: nowrap; }
.sum-chip[hidden] + .saved { margin-left: auto; }
.saved .sf { font-size: 14px; color: var(--green); }
.saved[data-state="error"] .sf { color: var(--red); } .saved[data-state="error"] { color: var(--red); }
.saved .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); animation: gw-pulse 1s ease-in-out infinite; }
@keyframes gw-pulse { 50% { opacity: .35; } }
.saved.quiet .tx { display: none; }
@media (max-width: 520px) { .saved .tx { display: none; } }
/* the function browser */
.fn-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: left; }
.fn-row b { font: 600 14px/19px ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); overflow-wrap: anywhere; }
.fn-row .what { font-size: 14px; line-height: 18px; color: var(--text2); }
.fn-row .ex { font: 12px/16px ui-monospace, "SF Mono", Menlo, monospace; color: var(--tint); overflow-wrap: anywhere; }
kbd { font: 600 13px/1 ui-monospace, "SF Mono", Menlo, monospace; padding: 4px 7px; border-radius: 6px; background: var(--fill2); color: var(--text); white-space: nowrap; }
/* higher contrast when asked for */
@media (prefers-contrast: more) {
  :root { --g-line: #a1a1a8; --g-headtx: #3a3a3c; --g-selfill: rgba(31, 138, 91, 0.2); }
  :root[data-theme="dark"] { --g-line: #6e6e73; --g-headtx: #d1d1d6; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --g-line: #6e6e73; --g-headtx: #d1d1d6; } }
@media (prefers-reduced-motion: reduce) { .saved .dot { animation: none; } .zoom-chip { transition: none; } }
/* 44 px to tap on touch screens, drawn as before */
@media (pointer: coarse) {
  .findbar .icon-btn { width: 44px; height: 44px; }
  .fbar .fx { position: relative; } .fbar .fx::after { content: ""; position: absolute; inset: -5px -7px; }
  .sum-chip { position: relative; } .sum-chip::after { content: ""; position: absolute; inset: -6px 0; }
  .note-tip .text-btn { min-height: 44px; }
}
