:root {
  --bg: #eef0f2; --panel: #ffffff; --ink: #1d2329; --muted: #66707a; --line: #d5dae0;
  --accent: #f26a1b; --accent-ink: #ffffff; --sel: #1f6feb; --sel-soft: #e3eeff;
  --barw: 60px; --subw: 248px; --bannerh: 50px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #15191d; --panel: #1f252b; --ink: #e8ecef; --muted: #9aa5b0; --line: #333c45; --sel-soft: #1b2c47;
} }
:root[data-theme="dark"] { --bg: #15191d; --panel: #1f252b; --ink: #e8ecef; --muted: #9aa5b0; --line: #333c45; --sel-soft: #1b2c47; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; display: grid; grid-template-rows: var(--bannerh) 1fr; grid-template-columns: 1fr var(--barw); }
#banner { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; gap: 6px; padding: 0 8px; padding-top: env(safe-area-inset-top); overflow-x: auto; scrollbar-width: none; }
#banner .title { font-weight: 700; letter-spacing: .04em; white-space: nowrap; margin-right: auto; font-size: 15px; }
#banner .title small { font-weight: 500; opacity: .85; letter-spacing: 0; margin-left: 6px; }
#banner button { background: rgba(255,255,255,.18); border: 0; border-radius: 8px; height: 36px; min-width: 40px; padding: 0 10px; color: #fff; font-weight: 600; white-space: nowrap; }
#banner > * { flex: none; }
#banner button.primary { position: sticky; right: 0; box-shadow: -10px 0 10px var(--accent); }
#banner button:disabled { opacity: .4; }
#banner button.primary { background: #fff; color: var(--accent); }
#stagewrap { position: relative; overflow: hidden; background: #c9ced3; }
#stage { position: absolute; inset: 0; }
#bar { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; align-items: stretch; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); scrollbar-width: none; }
#bar .tabs { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
#bar .tab { border: 0; background: none; padding: 7px 2px; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
#bar .tab.on { color: var(--accent); background: var(--sel-soft); }
#bar .tool { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px; font-size: 9.5px; line-height: 1.1; color: var(--ink); border-left: 3px solid transparent; }
#bar .tool svg { width: 24px; height: 24px; }
#bar .tool.on { background: var(--sel-soft); border-left-color: var(--sel); color: var(--sel); }
#bar .tool .num { font-size: 8.5px; color: var(--muted); }
#bar hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; width: auto; }
#sub { position: absolute; top: var(--bannerh); right: var(--barw); width: min(var(--subw), calc(100vw - var(--barw) - 16px)); max-height: calc(100% - var(--bannerh) - 12px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-right: 0; border-radius: 12px 0 0 12px; box-shadow: -6px 6px 22px rgba(0,0,0,.18); padding: 10px 12px 12px; z-index: 5; }
#sub h3 { margin: 0 0 2px; font-size: 14px; display: flex; align-items: center; gap: 6px; }
#sub h3 .num { font-size: 11px; color: var(--muted); font-weight: 600; }
#sub .tip { font-size: 12px; color: var(--muted); margin: 0 0 8px; line-height: 1.35; }
#sub .sec { margin-top: 10px; }
#sub .sec > label, #sub .lbl { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
#sub .lbl .pid { font-weight: 600; text-transform: none; letter-spacing: 0; }
#sub .collapse { float: right; border: 0; background: none; font-size: 18px; line-height: 1; padding: 0 2px; color: var(--muted); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 4px; font-size: 12px; font-weight: 600; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--sel); color: #fff; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 10px; font-size: 12px; }
.chip.on { border-color: var(--sel); background: var(--sel-soft); color: var(--sel); font-weight: 700; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 8px 10px; font-size: 13px; font-weight: 600; }
.btn.primary { background: var(--sel); border-color: var(--sel); color: #fff; }
.btn.danger { color: #c62828; }
#corner { position: absolute; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; z-index: 3; }
#corner button { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
#hint { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: rgba(20,24,28,.86); color: #fff; font-size: 13px; padding: 7px 12px; border-radius: 999px; pointer-events: none; max-width: calc(100% - 24px); text-align: center; display: none; z-index: 3; }
#hint.on { display: block; }
#toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2329; color: #fff; font-size: 14px; padding: 9px 14px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 6; }
#toast.on { opacity: 1; }
#drawer { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; justify-content: flex-end; }
#drawer[hidden] { display: none; }
#drawer .pane { width: min(460px, 100%); height: 100%; background: var(--panel); overflow-y: auto; padding: 14px 16px 30px; }
#drawer h2 { margin: 0 0 4px; font-size: 18px; }
#drawer .fam { margin-top: 16px; }
#drawer .fam h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
#drawer .prt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
#drawer .prt .id { font-weight: 800; min-width: 34px; color: var(--accent); }
#drawer .prt .nm { font-weight: 600; font-size: 14px; }
#drawer .prt .ds { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
#drawer .prt .ctl { margin-left: auto; display: flex; align-items: center; }
.sw { width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; border: 0; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.sw.on { background: #22a447; }
.sw.on::after { left: 21px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .box { background: var(--panel); border-radius: 14px; padding: 16px; width: min(420px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal h3 { margin: 0 0 8px; }
.modal input, .modal select, .modal textarea { width: 100%; font: inherit; font-size: 16px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); margin: 4px 0 10px; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
@media (max-width: 560px) { :root { --barw: 56px; --subw: 230px; --bannerh: 46px; } #banner .title small { display: none; } }
/* phones: options open as a short sheet along the bottom so the plans stay visible */
@media (max-width: 600px) {
  #sub { top: auto; bottom: 0; left: 0; right: var(--barw); width: auto; max-height: 40vh; border-radius: 14px 14px 0 0; border: 1px solid var(--line); border-bottom: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 22px rgba(0,0,0,.18); }
  #app:has(#sub:not([hidden])) #corner { bottom: calc(40vh + 10px); }
}
