:root {
  --bg: #f6f7f9; --panel: #fff; --line: #e4e7ec; --line2: #eef0f3;
  --text: #1d2433; --muted: #6b7385; --faint: #9aa1b0;
  --accent: #2f6fed; --accent-soft: #eaf1ff; --danger: #e5484d; --ok: #16a34a;
  --asm: #7c5cff; --asm-soft: #f1edff; --final: #10b981; --final-soft: #e7f8f1;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 30px rgba(16,24,40,.16);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body[data-layout] { overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

.topbar { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.topbar > * { flex: none; white-space: nowrap; }
.topbar > .spacer { flex: 1 1 0; min-width: 8px; }
.topbar > .title { flex: 0 1 auto; min-width: 60px; overflow: hidden; text-overflow: ellipsis; }
.brand { font-weight: 800; letter-spacing: -.2px; display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text); }
.brand small { font-weight: 600; color: var(--muted); }
.topbar .title { font-weight: 700; }
.topbar .tag { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 5px; }
.topbar .spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 11px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #255fd1; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f1f2f4; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.kbd { font: 11px ui-monospace, monospace; background: #f1f2f4; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted); }

.canvas { position: relative; overflow: hidden; background-color: #f4f5f7;
  background-image: radial-gradient(circle, #cfd4dc 1.1px, transparent 1.2px); touch-action: none; }
.canvas.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.world.animating { transition: transform .3s ease; }
.zoombar { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 3px; box-shadow: var(--shadow); z-index: 5; }
.zoombar button { border: 0; background: none; width: 30px; height: 28px; border-radius: 6px; color: var(--muted); font-size: 15px; }
.zoombar button:hover { background: #f1f2f4; color: var(--text); }
.zoombar .zl { min-width: 46px; font-size: 11px; display: grid; place-items: center; color: var(--muted); }

/* number inputs */
.num { width: 64px; text-align: right; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: #fff; }
.num:focus, .txt:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.txt { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; background: #fff; width: 100%; }
textarea.txt { resize: vertical; min-height: 56px; }

/* picker */
.picker { position: fixed; z-index: 1000; width: 300px; max-height: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.pk-head { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.picker input { flex: 1; min-width: 0; border: 0; padding: 10px 12px; outline: none; }
.pk-close { border: 0; background: none; width: 30px; height: 30px; margin-right: 4px; border-radius: 6px; color: var(--muted); font-size: 18px; line-height: 1; }
.pk-close:hover { background: #f1f2f4; color: var(--text); }
.pk-list { overflow: auto; padding: 4px 0; }
.pk-group { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); padding: 8px 12px 3px; }
.pk-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; }
.pk-item.active, .pk-item:hover { background: var(--accent-soft); }
.pk-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pk-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-sub { color: var(--faint); font-size: 11px; white-space: nowrap; }
.pk-empty { padding: 14px; color: var(--muted); }

/* nutrition label */
.nlabel { border: 1.5px solid #111; padding: 6px 8px; background: #fff; color: #111; font-family: Helvetica, Arial, sans-serif; max-width: 280px; }
.lb-title { font-size: 26px; font-weight: 900; letter-spacing: -.5px; line-height: 1; }
.lb-serv { display: flex; justify-content: space-between; font-size: 13px; border-top: 1px solid #111; margin-top: 4px; padding-top: 2px; }
.lb-thick { height: 8px; background: #111; margin: 3px 0; }
.lb-med { height: 4px; background: #111; margin: 2px 0; }
.lb-cal { display: flex; justify-content: space-between; align-items: baseline; font-weight: 900; }
.lb-cal span { font-size: 18px; } .lb-cal b { font-size: 28px; }
.lb-row { display: flex; justify-content: space-between; border-top: 1px solid #999; font-size: 12px; padding: 1.5px 0; }
.lb-row.sub { padding-left: 14px; }
.lb-row.right { justify-content: flex-end; border-top: 0; font-size: 11px; }
.lb-foot { font-size: 10px; color: #444; }
.lb-stmt { font-size: 11px; color: var(--muted); margin-top: 8px; max-width: 280px; }

/* tester */
.tester { position: fixed; left: 14px; bottom: 14px; z-index: 900; }
.ts-pill { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; box-shadow: var(--shadow); font-weight: 600; }
.ts-pill span { color: var(--muted); font-weight: 500; margin-left: 4px; }
.ts-panel { width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px; max-height: 70vh; overflow: auto; }
.ts-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ts-head span { color: var(--muted); font-size: 11px; flex: 1; }
.ts-x { border: 0; background: #f1f2f4; border-radius: 6px; width: 24px; height: 22px; }
.ts-lab { font-size: 11px; color: var(--muted); }
.ts-name, .ts-ans, .ts-cmt { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; margin: 3px 0 8px; }
.ts-list { padding-left: 18px; margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.ts-list li { margin: 3px 0; }
.ts-list li.done { text-decoration: line-through; color: var(--faint); }
.ts-list li.next { color: var(--text); font-weight: 600; }
.ts-go, .ts-ok { width: 100%; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px; font-weight: 600; }
.ts-ok { background: var(--ok); }
.ts-skip { background: #f1f2f4; border: 0; border-radius: 8px; padding: 8px 12px; }
.ts-row { display: flex; gap: 6px; margin-top: 8px; }
.ts-link { border: 0; background: none; color: var(--muted); font-size: 11px; text-decoration: underline; padding: 0; }
.ts-task { font-size: 14px; font-weight: 600; background: #fffbea; border: 1px solid #f5e1a4; border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.ts-meter { color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.ts-rate { display: flex; gap: 6px; } .ts-rate button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 0; font-weight: 700; }
.ts-rate button:hover { background: var(--accent); color: #fff; }
.ts-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); margin: 3px 0 8px; }
.ts-fin { text-align: center; padding: 10px; background: var(--final-soft); border-radius: 8px; }
.ts-fin-h { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.ts-next { font-size: 12.5px; line-height: 1.7; }
.ts-next a { font-weight: 600; }
.ts-export { width: 100%; margin-top: 10px; background: var(--final); color: #fff; border: 0; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 700; box-shadow: 0 2px 8px rgba(16,185,129,.35); }
.ts-export:hover { background: #0e9f6e; }
.ts-send { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; line-height: 1.45; }

/* layout switcher dropdown */
.lsw { position: relative; }
.lsw-btn { font-weight: 600; }
.lsw-letter { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; flex: none; }
.lsw-caret { color: var(--muted); font-size: 11px; margin-left: 2px; transition: transform .15s; }
.lsw.open .lsw-caret { transform: rotate(180deg); }
.lsw.open .lsw-btn { border-color: var(--accent); background: var(--accent-soft); }
.lsw-menu { display: none; position: fixed; width: 290px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 1100; }
.lsw.open .lsw-menu { display: block; }
.lsw-h { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); padding: 4px 8px 6px; }
.lsw-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 7px; text-decoration: none; color: var(--text); }
.lsw-item:hover { background: var(--accent-soft); }
.lsw-item span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.lsw-item small { color: var(--muted); font-size: 11.5px; }
.lsw-item .lsw-letter { background: #e7ebf2; color: var(--muted); }
.lsw-item.cur .lsw-letter { background: var(--accent); color: #fff; }
.lsw-check { color: var(--accent); font-weight: 800; width: 14px; }
.lsw-home { display: block; border-top: 1px solid var(--line2); margin-top: 4px; padding: 8px 8px 4px; font-size: 12px; color: var(--muted); text-decoration: none; }
.lsw-home:hover { color: var(--accent); }

/* Excel-style recipe tabs */
body.has-tabbar .gmain, body.has-tabbar .cmain, body.has-tabbar .smain { height: calc(100vh - 52px - 36px) !important; }
body.has-tabbar .tester { bottom: 50px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: 36px; background: #eef0f3; border-top: 1px solid var(--line); display: flex; align-items: stretch; z-index: 800; padding-left: 8px; }
.tb-add { width: 30px; margin: 5px 6px 5px 0; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 17px; line-height: 1; color: var(--accent); flex: none; }
.tb-add:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.tb-tabs { display: flex; overflow-x: auto; overflow-y: hidden; flex: 1; min-width: 0; scrollbar-width: thin; }
.tb-tab { display: flex; align-items: center; gap: 4px; padding: 0 6px 0 14px; max-width: 220px; border-right: 1px solid #dde1e7; color: var(--muted); cursor: pointer; user-select: none; flex: none; position: relative; }
.tb-tab:hover { background: #e4e7ec; color: var(--text); }
.tb-tab.active { background: #fff; color: var(--text); font-weight: 650; margin-top: -1px; box-shadow: inset 0 -3px 0 var(--accent); }
.tb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-x { border: 0; background: none; color: var(--faint); width: 18px; height: 18px; border-radius: 4px; padding: 0; font-size: 14px; line-height: 1; visibility: hidden; }
.tb-tab:hover .tb-x, .tb-tab.active .tb-x { visibility: visible; }
.tb-x:hover { background: #fde2e2; color: var(--danger); }
.tb-input { width: 170px; border: 1px solid var(--accent); border-radius: 4px; padding: 2px 5px; font-weight: 600; outline: none; }
.tb-hint { align-self: center; padding: 0 14px; color: var(--faint); font-size: 11px; white-space: nowrap; }
.tb-menu { position: fixed; z-index: 1001; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px; display: flex; flex-direction: column; min-width: 150px; }
.tb-menu button { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 5px; }
.tb-menu button:hover { background: var(--accent-soft); }
.tb-menu button.danger { color: var(--danger); } .tb-menu button.danger:hover { background: #fde2e2; }

.toast { position: fixed; left: 50%; top: 64px; transform: translate(-50%, -10px); background: #1d2433; color: #fff; padding: 7px 14px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 2000; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.nl-prompt-ov { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 3000; }
.nl-prompt { background: var(--panel); border-radius: 14px; padding: 24px; width: 360px; max-width: 90vw; box-shadow: var(--shadow-lg); }
.nl-prompt-label { font-weight: 600; margin-bottom: 10px; }
.nl-prompt-input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; outline: none; }
.nl-prompt-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.nl-prompt-btns { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
