/* Lubada. A quiet ledger: paper and ink, one restrained accent, brass for the hurdle line.
   Desktop: fixed sidebar + content. Phone: top bar + bottom tab bar. */
/* Palettes. Stone is the default; Jade is the first look; Graphite is plain black and white with amber.
   Each palette has a light and a dark set. Mode (auto/light/dark) and palette are set in Settings > Appearance. */
:root {
  --bg: #f4f3f0; --surface: #ffffff; --sunk: #eceae5; --ink: #1c1b19; --muted: #6a665f; --line: #dedbd4; --line-strong: #c9c5bb;
  --accent: #2f3e6b; --accent-ink: #ffffff; --accent-soft: #e1e5f1; --brass: #8a6d2f;
  --up: #1d7546; --down: #b1382c; --warn: #96580a; --warn-soft: #f7ecd9; --stop: #b0261d; --stop-soft: #f9e2df; --ok: #1d7546; --ok-soft: #e0f1e6; --info: #2c5a86; --info-soft: #e2ebf5;
  --f-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "Noto Serif", Georgia, serif;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --radius: 12px; --shadow: 0 1px 2px rgb(28 27 25 / 6%), 0 4px 16px rgb(28 27 25 / 4%);
  --side: 236px; --tabbar: 64px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f0f10; --surface: #171718; --sunk: #1e1e20; --ink: #e8e6e1; --muted: #9a968d; --line: #2a2a2c; --line-strong: #38383b;
  --accent: #9fb0e6; --accent-ink: #0f0f10; --accent-soft: #232a40; --brass: #d2ad63;
  --up: #6cc58f; --down: #ff8e81; --warn: #e6aa55; --warn-soft: #33281a; --stop: #ff8a80; --stop-soft: #3a1e1b; --ok: #6cc58f; --ok-soft: #183026; --info: #8db8e2; --info-soft: #1b2a3a;
  --shadow: none; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0f0f10; --surface: #171718; --sunk: #1e1e20; --ink: #e8e6e1; --muted: #9a968d; --line: #2a2a2c; --line-strong: #38383b;
  --accent: #9fb0e6; --accent-ink: #0f0f10; --accent-soft: #232a40; --brass: #d2ad63;
  --up: #6cc58f; --down: #ff8e81; --warn: #e6aa55; --warn-soft: #33281a; --stop: #ff8a80; --stop-soft: #3a1e1b; --ok: #6cc58f; --ok-soft: #183026; --info: #8db8e2; --info-soft: #1b2a3a;
  --shadow: none; color-scheme: dark; }
/* Jade */
:root[data-palette="jade"] { --bg: #f3f5f4; --surface: #ffffff; --sunk: #edf1ef; --ink: #13201b; --muted: #5a6862; --line: #dce3df; --line-strong: #c4cec9; --accent: #17594f; --accent-soft: #dcebe6; --brass: #96773a; }
@media (prefers-color-scheme: dark) { :root[data-palette="jade"]:not([data-theme="light"]) { --bg: #0c1210; --surface: #131b18; --sunk: #19231f; --ink: #e2eae6; --muted: #93a29b; --line: #25302b; --line-strong: #33403a; --accent: #6bbcab; --accent-soft: #1b3530; --brass: #c8a35a; } }
:root[data-palette="jade"][data-theme="dark"] { --bg: #0c1210; --surface: #131b18; --sunk: #19231f; --ink: #e2eae6; --muted: #93a29b; --line: #25302b; --line-strong: #33403a; --accent: #6bbcab; --accent-soft: #1b3530; --brass: #c8a35a; }
/* Graphite */
:root[data-palette="graphite"] { --bg: #f5f5f5; --surface: #ffffff; --sunk: #ececec; --ink: #161616; --muted: #666666; --line: #e0e0e0; --line-strong: #cbcbcb; --accent: #2b2b2b; --accent-soft: #e8e8e8; --brass: #a8711a; }
@media (prefers-color-scheme: dark) { :root[data-palette="graphite"]:not([data-theme="light"]) { --bg: #0b0b0b; --surface: #141414; --sunk: #1b1b1b; --ink: #ececec; --muted: #9b9b9b; --line: #2a2a2a; --line-strong: #3a3a3a; --accent: #dcdcdc; --accent-soft: #272727; --brass: #e0a84a; } }
:root[data-palette="graphite"][data-theme="dark"] { --bg: #0b0b0b; --surface: #141414; --sunk: #1b1b1b; --ink: #ececec; --muted: #9b9b9b; --line: #2a2a2a; --line-strong: #3a3a3a; --accent: #dcdcdc; --accent-soft: #272727; --brass: #e0a84a; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font: 600 28px/1.15 var(--f-display); letter-spacing: -0.01em; }
h2 { font: 600 15px/1.3 var(--f-body); }
h3 { font: 600 14px/1.3 var(--f-body); }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; width: 100%; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 13px; } .strong { font-weight: 600; } .block { display: block; } .nowrap { white-space: nowrap; }
.up { color: var(--up); } .down { color: var(--down); }
.right { text-align: right; } .grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .wrap { flex-wrap: wrap; } .end { justify-content: flex-end; margin-bottom: 12px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.label { font-size: 12.5px; color: var(--muted); }
.lede { color: var(--muted); max-width: 72ch; margin: -6px 0 18px; }
.ico { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 500 14px var(--f-body); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 14px; cursor: pointer; min-height: 38px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--stop); border-color: var(--stop); color: var(--surface); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); border-color: var(--line); }
.btn.small { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
input, select, textarea { font: 15px var(--f-body); color: var(--ink); background: var(--sunk); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; min-width: 0; }
input[type=number] { font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
input:disabled, select:disabled, textarea:disabled { opacity: .75; }
textarea { resize: vertical; line-height: 1.45; }
textarea.copy { font-size: 14px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field .unit { color: var(--muted); font-weight: 400; margin-left: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field.span, .check.span { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check.danger input { accent-color: var(--stop); }
.form { display: grid; gap: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.form-error { color: var(--stop); background: var(--stop-soft); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* ---- pills */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; line-height: 1.6; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.stop { background: var(--stop-soft); color: var(--stop); } .pill.info { background: var(--info-soft); color: var(--info); }
.pill.muted { background: var(--sunk); color: var(--muted); }

/* ---- shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.sidebar nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.nav-item:hover { background: var(--sunk); color: var(--ink); text-decoration: none; }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.who { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: 14px; }
.who .muted { margin-left: auto; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 20px var(--f-display); letter-spacing: .01em; color: var(--ink); padding: 0 8px; }
.brand.big { font-size: 30px; padding: 0; }
.mark { width: 30px; height: 30px; }
.brand.big .mark { width: 40px; height: 40px; }
.mark-bg { fill: var(--accent); }
.mark-l { fill: var(--accent-ink); }
.mark-t { fill: var(--brass); }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.main { padding: 28px 36px 64px; max-width: 1240px; width: 100%; outline: none; }
.view { display: grid; gap: 18px; }
.tabbar { display: none; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; margin-right: 6px; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- page */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: -8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 12px; min-width: 0; box-shadow: var(--shadow); align-content: start; }
.card.flush { padding: 0; gap: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head.pad, .pad { padding: 16px 20px; }
.card-head select { width: auto; }
.card.notice { border-color: var(--warn); background: var(--warn-soft); box-shadow: none; }
.card.notice.stop { border-color: var(--stop); background: var(--stop-soft); }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.scroll-x { overflow-x: auto; }
.empty { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 36px 24px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty p { color: var(--muted); max-width: 52ch; }

/* ---- overview */
.hero-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.hero { gap: 6px; }
.big { font: 600 34px/1.1 var(--f-display); letter-spacing: -0.01em; }
.big2 { font-size: 22px; font-weight: 600; }
.kv-row { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.kv-row > div { display: grid; }
.hero.attention .big { color: var(--warn); }
.attn { list-style: none; margin: 0; padding: 0; display: grid; }
.attn-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); color: var(--ink); }
.attn li:last-child .attn-item { border-bottom: 0; }
.attn-item:hover { text-decoration: none; background: var(--sunk); }
.attn-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--info); }
.attn-item.warn .dot { background: var(--warn); } .attn-item.stop .dot { background: var(--stop); }
.attn-text { display: grid; flex: 1; min-width: 0; }
.attn-item .ico { color: var(--muted); }
.sleeves { display: grid; gap: 14px; }
.sleeve { display: grid; gap: 5px; }
.sleeve-top { display: flex; align-items: baseline; gap: 10px; }
.sleeve-top .num { margin-left: auto; }
.bar { position: relative; height: 10px; background: var(--sunk); border-radius: 6px; overflow: hidden; }
.bar .band { position: absolute; top: 0; bottom: 0; background: var(--accent-soft); }
.bar .fill { position: absolute; left: 0; top: 3px; bottom: 3px; background: var(--accent); border-radius: 3px; }
.bar .fill.outside { background: var(--warn); }
.bar .target { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--brass); }
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }

/* ---- tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--sunk); white-space: nowrap; }
.table th.right, .table td.right { text-align: right; }
.table td.num { white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 8px 10px; }
.card > .table.compact td:first-child, .card > .table.compact th:first-child { padding-left: 0; }
.card > .table.compact td:last-child, .card > .table.compact th:last-child { padding-right: 0; }
.table tr.group th { background: transparent; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); padding-top: 18px; }
.table tr.group th span:last-child { float: right; font-weight: 500; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--sunk); }
.table tr.reversal td, .table tr.reversed td { color: var(--muted); }
.table tr.reversed td:first-child { text-decoration: line-through; }
.table td.detail { max-width: 360px; overflow-wrap: anywhere; }
.table.compare th[scope=row] { color: var(--muted); font-weight: 500; width: 240px; }
.table.compare td.best { background: var(--accent-soft); font-weight: 600; }
.table.compare thead th { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }
.letter { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 12px; margin-right: 8px; }

/* ---- holding detail */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--surface); padding: 12px 16px; display: grid; gap: 2px; }
.stat .num { font-size: 17px; font-weight: 600; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13.5px; } .dl dd { margin: 0; }
.dl.cols { grid-template-columns: max-content 1fr max-content 1fr; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.timeline li { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }
.timeline .pill { min-width: 64px; justify-content: center; text-transform: capitalize; }

/* ---- charts */
.chart-wrap { display: grid; gap: 8px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 11.5px var(--f-body); font-variant-numeric: tabular-nums; }
.chart .line { stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .line.s0 { stroke: var(--accent); }
.chart .line.ref { stroke: var(--brass); stroke-dasharray: 5 4; stroke-width: 1.6; }
.chart .area { fill: var(--accent); opacity: .08; }
.chart .end { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .ref { stroke: var(--brass); stroke-dasharray: 4 3; }
.chart .range { stroke: var(--accent); stroke-width: 8; stroke-linecap: round; opacity: .3; }
.chart .base { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .exp { fill: var(--accent); }
.chart .row-label { fill: var(--ink); font: 600 14px var(--f-body); }
.chart .val { fill: var(--ink); font: 600 12px var(--f-body); font-variant-numeric: tabular-nums; }
.chart-empty { color: var(--muted); padding: 30px 0; text-align: center; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend .key::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--accent); margin-right: 6px; vertical-align: 3px; }
.legend .key.ref::before { background: var(--brass); }
.legend .key.range::before { height: 7px; opacity: .35; vertical-align: 1px; }
.legend .key.base::before { width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); vertical-align: -1px; }
.legend .key.exp::before { width: 9px; height: 9px; border-radius: 1px; transform: rotate(45deg); vertical-align: 0; }

/* ---- ideas */
.idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.idea { cursor: pointer; gap: 10px; }
.idea:hover { border-color: var(--line-strong); }
.idea h3 { font: 600 18px/1.25 var(--f-display); }
.idea-top { display: flex; align-items: center; gap: 8px; }
.idea-top .muted { margin-left: auto; }
.pick { display: inline-flex; padding: 2px; }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.idea-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.idea-nums > div { display: grid; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.idea-form { display: grid; gap: 18px; }
.result-col { position: sticky; top: 20px; display: grid; gap: 18px; }
.result-card.blocked { border-color: var(--stop); }
.r-lines { display: grid; }
.r-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.r-line:last-child { border-bottom: 0; }
.r-line input.model { width: 200px; }
.cases { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 8px 12px; align-items: center; }
.checks { display: grid; gap: 10px; }
.memo { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; max-width: 70ch; }
.reading { max-width: 78ch; font-size: 15px; }

/* ---- orders */
.ticket-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.ticket.filled, .ticket.cancelled { opacity: .72; }
.ticket-head { display: flex; gap: 12px; align-items: center; }
.ticket-head h3 { font: 600 17px var(--f-display); }
.side { flex: none; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 4px 8px; border-radius: 6px; }
.side.buy { background: var(--ok-soft); color: var(--ok); } .side.sell { background: var(--info-soft); color: var(--info); }
.ticket-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ticket-nums > div { display: grid; }
.checks-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13.5px; }
.checks-list li { display: flex; gap: 8px; align-items: flex-start; }
.checks-list li.ok { color: var(--muted); } .checks-list li.ok .ico { color: var(--ok); }
.checks-list li.warn .ico { color: var(--warn); } .checks-list li.stop { color: var(--stop); }

/* ---- tabs inside a page */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab-link { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab-link:hover { color: var(--ink); text-decoration: none; }
.tab-link.on { color: var(--accent); border-bottom-color: var(--accent); }
.count { font-size: 11.5px; font-weight: 700; background: var(--sunk); color: var(--muted); border-radius: 999px; padding: 0 7px; line-height: 1.6; }

/* ---- property */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--sunk); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.col h3 { display: flex; justify-content: space-between; padding: 4px 4px 2px; font-size: 13px; color: var(--muted); }
.job { text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; display: grid; gap: 4px; cursor: pointer; }
.job:hover { border-color: var(--accent); }
.job.urgent { border-left: 3px solid var(--stop); }
.deadlines { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.deadline { grid-template-columns: 64px 1fr auto; align-items: center; gap: 16px; }
.deadline .when { display: grid; text-align: center; border-right: 1px solid var(--line); padding-right: 12px; }
.deadline .when .num { font: 600 24px var(--f-display); }
.deadline.warn .when .num { color: var(--warn); } .deadline.stop .when .num { color: var(--stop); }
.lease { display: grid; gap: 12px; }
.job-sheet { display: grid; gap: 14px; }
.add-note { display: grid; gap: 8px; }
.menu { display: grid; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; font: 500 16px var(--f-body); color: var(--ink); cursor: pointer; text-align: left; }
.menu-item:hover { text-decoration: none; color: var(--accent); }

/* ---- sheets and toasts */
dialog.sheet { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgb(0 0 0 / 25%); }
dialog.sheet.wide { width: min(760px, calc(100vw - 32px)); }
dialog.sheet::backdrop { background: rgb(10 16 14 / 45%); }
dialog.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog.sheet header h2 { font: 600 19px var(--f-display); }
.sheet-body { padding: 18px 20px 22px; display: grid; gap: 14px; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 100; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgb(0 0 0 / 20%); transition: opacity .4s; }
.toast.bad { background: var(--stop); color: #fff; } .toast.warn { background: var(--warn); color: #fff; }
.toast.out { opacity: 0; }

/* ---- sign-in */
.gate { min-height: 100vh; display: grid; place-content: center; gap: 16px; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.gate-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px; width: min(420px, calc(100vw - 32px)); display: grid; gap: 16px; box-shadow: var(--shadow); }
.gate-card.plain { width: min(280px, calc(100vw - 48px)); padding: 0; background: none; border: 0; box-shadow: none; }
.gate-card.plain .btn { min-height: 46px; font-size: 15px; background: transparent; color: var(--muted); border-color: var(--line-strong); }
.gate-card.plain .btn:hover { color: var(--ink); border-color: var(--muted); filter: none; }
.gate-foot { text-align: center; font-size: 13px; }

/* ---- phone */
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .result-col { position: static; order: -1; } .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero.attention { grid-column: 1 / -1; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
    padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); }
  .topbar .brand { padding: 0; }
  .topbar .mark { width: 28px; height: 28px; }
  .top-title { font: 600 18px var(--f-display); flex: 1; visibility: hidden; }
  .topbar .brand { font-size: 18px; gap: 8px; }
  .main { padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(var(--tabbar) + 32px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .page-head h1 { font-size: 24px; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
  .tab { display: grid; justify-items: center; gap: 2px; font: 500 11px var(--f-body); color: var(--muted); background: none; border: 0; padding: 4px 0; cursor: pointer; }
  .tab:hover { text-decoration: none; }
  .tab.on { color: var(--accent); }
  .two-col, .hero-grid { grid-template-columns: 1fr; }
  .big { font-size: 30px; }
  .hide-s { display: none; }
  .table th, .table td { padding: 10px 10px; }
  dialog.sheet, dialog.sheet.wide { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .sheet-body { padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
  #toasts { bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom, 0px)); }
  .dl.cols { grid-template-columns: max-content 1fr; }
  .ticket-list, .idea-grid { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(5, minmax(240px, 82vw)); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .r-line input.model { width: 150px; }
}
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } .deadline { grid-template-columns: 52px 1fr; } .deadline .btn { grid-column: 1 / -1; } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .toast { transition: none; } }

/* ---- link pages */
details { border-top: 1px solid var(--line); padding-top: 12px; }
details summary { cursor: pointer; padding: 4px 0 10px; }
details[open] summary { margin-bottom: 6px; }
.form-ok { color: var(--ok); background: var(--ok-soft); padding: 8px 12px; border-radius: 8px; }
.gate-card h2 { font: 600 20px var(--f-display); }

/* connections, prices, decision trail, statements */
.list li.stack { flex-direction: column; align-items: stretch; gap: 6px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.bad-text { color: var(--stop); } .warn-text { color: var(--warn); }
.steps { margin: 4px 0 14px; padding-left: 20px; } .steps li { margin: 3px 0; }
.mono, .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.code { background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; max-height: 320px; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--sunk); }
.break + .break { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }

/* appearance */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 12px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice-body { display: grid; gap: 4px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.choice input:checked + .choice-body { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatches { display: flex; gap: 4px; } .swatches i { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line-strong); }
.stmt dt { font-weight: 600; margin-top: 12px; } .stmt dd { margin: 2px 0 0; color: var(--muted); }
.search-box { width: 100%; margin-bottom: 10px; }
