/* Layout: one phone-first column. Each day is a station on a line: a station-name board on top
   (previous / next day on the band, like a platform sign), stops strung on a route line below. */
:root{
  --bg:#EDF0F4; --surface:#FFFFFF; --sunk:#E3E8EE; --ink:#14213A; --muted:#566379; --line:#D3DAE3;
  --accent:#0E7A4E; --accent-ink:#FFFFFF; --soft:#DDEFE6;
  --sight:#0E7A4E; --food:#C96A00; --transport:#2563C9; --stay:#7450C0; --other:#6B7688;
  --danger:#B3261E;
  --display:"Zen Kaku Gothic New","Hiragino Sans","Yu Gothic",system-ui,sans-serif;
  --mono:"IBM Plex Mono",ui-monospace,"SF Mono",Menlo,monospace;
  --r:12px;
  /* Capacitor injects --safe-area-inset-* on Android; browsers provide env(). */
  --sat:var(--safe-area-inset-top,env(safe-area-inset-top,0px)); --sab:var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px));
}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){
  --bg:#0C1320; --surface:#162034; --sunk:#111A2B; --ink:#E8EDF5; --muted:#98A5BB; --line:#2A3650;
  --accent:#3CBC84; --accent-ink:#04231A; --soft:#14342A;
  --sight:#3CBC84; --food:#F0A040; --transport:#6FA0F5; --stay:#A98BEA; --other:#98A5BB;
  --danger:#F2857D; color-scheme:dark } }
:root[data-theme="dark"]{
  --bg:#0C1320; --surface:#162034; --sunk:#111A2B; --ink:#E8EDF5; --muted:#98A5BB; --line:#2A3650;
  --accent:#3CBC84; --accent-ink:#04231A; --soft:#14342A;
  --sight:#3CBC84; --food:#F0A040; --transport:#6FA0F5; --stay:#A98BEA; --other:#98A5BB;
  --danger:#F2857D; color-scheme:dark }

*{box-sizing:border-box}
body{background:var(--bg);color:var(--ink);font-family:var(--display);font-size:16px;line-height:1.5}
body::before{content:"";position:fixed;inset:0 0 auto;height:var(--sat);z-index:10;background:var(--surface)}
button,input,select,textarea{font:inherit;color:inherit}
a{color:var(--accent)}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
h1,h2,h3,h4,p{margin:0}
h1,h2,h3{text-wrap:balance}

.wrap{max-width:720px;margin:0 auto;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
header.top{position:sticky;top:var(--sat);z-index:9;background:var(--surface);border-bottom:1px solid var(--line)}
.brand{display:flex;align-items:center;gap:10px;padding-block:12px 6px}
.brand h1{font-size:1.1rem;font-weight:900;letter-spacing:.01em;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-wrap:nowrap}
.tabs{display:flex;gap:2px}
.tabs button{flex:1;background:none;border:0;border-bottom:3px solid transparent;padding:8px 4px 9px;font-weight:700;font-size:.92rem;color:var(--muted);cursor:pointer}
.tabs button[aria-selected="true"]{color:var(--ink);border-bottom-color:var(--accent)}
main{padding-block:18px calc(48px + var(--sab));display:flex;flex-direction:column;gap:18px}
section.panel{display:flex;flex-direction:column;gap:18px}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:9px 16px;border-radius:var(--r);border:1.5px solid var(--line);background:var(--surface);font-weight:700;font-size:.92rem;cursor:pointer;text-decoration:none;color:var(--ink)}
.btn:hover{border-color:var(--muted)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.small{min-height:36px;padding:6px 12px;font-size:.86rem}
.btn.danger{color:var(--danger)}
.btn:disabled{opacity:.5;cursor:default}
.row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
.grow{flex:1;min-width:0}
.muted{color:var(--muted)}
.small{font-size:.86rem}
.mono{font-family:var(--mono);font-variant-numeric:tabular-nums}
.note{font-size:.84rem;color:var(--muted);border-left:3px solid var(--line);padding-left:10px}
.banner{background:var(--sunk);border-radius:var(--r);padding:10px 12px;font-size:.88rem;color:var(--muted)}
.ro .w{display:none!important}

/* day rail */
.rail{display:flex;gap:6px;overflow-x:auto;padding-bottom:4px;scrollbar-width:thin}
.rail button{flex:none;display:flex;align-items:center;gap:8px;padding:6px 12px 6px 6px;border-radius:999px;border:1.5px solid var(--line);background:var(--surface);cursor:pointer;font-weight:700;font-size:.86rem}
.rail button .code{font-family:var(--mono);font-weight:600;font-size:.74rem;width:30px;height:30px;border-radius:50%;border:2.5px solid var(--accent);display:grid;place-items:center}
.rail button[aria-current="true"]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.rail button[aria-current="true"] .code{background:var(--bg);color:var(--ink)}
.rail button.add{padding:6px 14px;color:var(--muted);border-style:dashed}

/* station board */
.board{background:var(--surface);border:1.5px solid var(--line);border-radius:var(--r);overflow:hidden}
.board-main{padding:14px 16px 12px;display:flex;flex-direction:column;gap:2px}
.board-meta{display:flex;gap:10px;align-items:center;font-family:var(--mono);font-size:.8rem;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
.board h2{font-size:1.9rem;font-weight:900;line-height:1.15;overflow-wrap:anywhere}
.board .sub{color:var(--muted);font-weight:500}
.band{display:flex;justify-content:space-between;gap:8px;background:var(--accent);color:var(--accent-ink);padding:0 6px;min-height:38px}
.band button{background:none;border:0;color:inherit;font-weight:700;font-size:.86rem;padding:8px 10px;cursor:pointer;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.band button:disabled{opacity:.45;cursor:default}

/* route line */
.stops{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.stop{display:grid;grid-template-columns:3.3rem 22px minmax(0,1fr);column-gap:8px}
.stop .t{font-family:var(--mono);font-variant-numeric:tabular-nums;font-size:.86rem;font-weight:500;padding-top:3px;text-align:right;color:var(--muted)}
.stop .rl{position:relative}
.stop .rl::before{content:"";position:absolute;left:9px;top:0;bottom:0;width:4px;background:var(--line)}
.stop:first-child .rl::before{top:10px}
.stop:last-child .rl::before{bottom:calc(100% - 14px)}
.stop .dot{position:absolute;left:3px;top:5px;width:16px;height:16px;border-radius:50%;background:var(--bg);border:4px solid var(--c,var(--other))}
.stop.done .dot{background:var(--c,var(--other))}
.stop .body{padding-bottom:18px;min-width:0;display:flex;flex-direction:column;gap:3px}
.stop .ttl{font-weight:700;font-size:1.02rem;overflow-wrap:anywhere}
.stop.done .ttl{text-decoration:line-through;color:var(--muted)}
.stop .kind{font-family:var(--mono);font-size:.7rem;text-transform:uppercase;letter-spacing:.08em;color:var(--c,var(--other));font-weight:600}
.stop .place,.stop .notes{font-size:.9rem;color:var(--muted);overflow-wrap:anywhere;white-space:pre-wrap}
.stop .acts{display:flex;flex-wrap:wrap;gap:4px 14px;margin-top:2px}
.lk{background:none;border:0;padding:4px 0;font-weight:700;font-size:.84rem;color:var(--accent);cursor:pointer;text-decoration:none}
.lk:hover{text-decoration:underline}
.leg{display:grid;grid-template-columns:3.3rem 22px minmax(0,1fr);column-gap:8px}
.leg .rl{position:relative}
.leg .rl::before{content:"";position:absolute;left:9px;top:0;bottom:0;width:4px;background:repeating-linear-gradient(var(--line) 0 4px,transparent 4px 8px)}
.leg .lk{font-size:.78rem;color:var(--muted);padding:0 0 12px;text-align:left}
.t-sight{--c:var(--sight)} .t-food{--c:var(--food)} .t-transport{--c:var(--transport)} .t-stay{--c:var(--stay)} .t-other{--c:var(--other)}

.empty{background:var(--surface);border:1.5px dashed var(--line);border-radius:var(--r);padding:22px 18px;display:flex;flex-direction:column;gap:12px}
.empty h2{font-size:1.4rem;font-weight:900}
.empty ol{margin:0;padding-left:1.2em;color:var(--muted);font-size:.92rem}

/* forms */
label.f,div.f{display:flex;flex-direction:column;gap:6px;font-size:.84rem;font-weight:700;color:var(--muted);min-width:0}
input:not([type=checkbox]):not([type=radio]):not([type=file]),select,textarea{width:100%;min-height:46px;padding:10px 12px;border-radius:10px;border:1.5px solid var(--line);background:var(--surface);color:var(--ink);font-size:1rem;font-weight:500}
input::placeholder,textarea::placeholder{color:var(--muted);opacity:.7}
textarea{min-height:84px;resize:vertical;line-height:1.4}
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:14px}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{border:1.5px solid var(--line);background:var(--surface);border-radius:999px;padding:8px 14px;font-size:.86rem;font-weight:700;cursor:pointer}
.chip[aria-pressed="true"]{background:var(--soft);border-color:var(--accent)}
.card{background:var(--surface);border:1.5px solid var(--line);border-radius:var(--r);padding:18px;display:flex;flex-direction:column;gap:14px}
.card h3{font-size:1.1rem;font-weight:900}
.results{display:flex;flex-direction:column;gap:10px}
.find{border-top:1.5px solid var(--line);padding-top:12px;display:flex;flex-direction:column;gap:4px}
.find:first-child{border-top:0;padding-top:0}
.find h4{font-size:1.02rem;font-weight:700;overflow-wrap:anywhere}
.find .meta{font-family:var(--mono);font-size:.76rem;color:var(--food);text-transform:uppercase;letter-spacing:.05em}
.prose{display:flex;flex-direction:column;gap:8px;overflow-wrap:anywhere}
.prose ul,.prose ol{margin:0;padding-left:1.25em;display:flex;flex-direction:column;gap:4px}
.prose h4{font-size:1rem;font-weight:900;margin-top:4px}
.prose code{font-family:var(--mono);font-size:.9em}
.msg{display:flex;flex-direction:column;gap:4px}
.msg .who{font-family:var(--mono);font-size:.7rem;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}
.msg.me .prose{background:var(--soft);border-radius:var(--r);padding:8px 12px;align-self:flex-start}
details.cheat summary{cursor:pointer;font-weight:900}
details.cheat dl{margin:10px 0 0;display:grid;gap:8px}
details.cheat dt{font-weight:700}
details.cheat dd{margin:0;color:var(--muted);font-size:.92rem}

dialog{border:0;padding:0;background:var(--surface);color:var(--ink);border-radius:18px;width:min(560px,calc(100vw - 20px));margin:calc(var(--sat) + 12px) auto auto;max-height:calc(100dvh - var(--sat) - var(--sab) - 24px);overflow-y:auto;overscroll-behavior:contain}
dialog::backdrop{background:rgba(8,12,22,.55)}
.sheet{padding:20px;display:flex;flex-direction:column;gap:14px}
.sheet h3{font-size:1.25rem;font-weight:900}
.sheet .foot{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;margin-top:4px}
.preview{background:var(--sunk);border-radius:8px;padding:10px 12px;max-height:38vh;overflow:auto;font-size:.9rem;display:flex;flex-direction:column;gap:8px}
.preview b{display:block}
.preview ul{margin:2px 0 0;padding-left:1.2em;color:var(--muted)}
#toast{position:fixed;left:50%;bottom:calc(18px + var(--sab));transform:translateX(-50%);background:var(--ink);color:var(--bg);padding:9px 16px;border-radius:14px;font-weight:700;font-size:.88rem;z-index:20;max-width:calc(100vw - 32px)}
@media (prefers-reduced-motion:no-preference){ .thinking::after{content:"";display:inline-block;width:1.2em;text-align:left;animation:dots 1.2s steps(4,end) infinite} }
@keyframes dots{0%{content:""}25%{content:"."}50%{content:".."}75%{content:"..."}}

/* check-in */
.herebar{display:flex;align-items:center;gap:10px;background:var(--surface);border:1.5px solid var(--line);border-radius:var(--r);padding:8px 12px;font-size:.9rem}
.herebar .pin{flex:none;width:12px;height:12px;border-radius:50%;background:var(--transport);box-shadow:0 0 0 4px color-mix(in srgb,var(--transport) 25%,transparent)}
.herebar.off .pin{background:var(--line);box-shadow:none}
.stop.here .dot{box-shadow:0 0 0 4px color-mix(in srgb,var(--transport) 30%,transparent)}
.stop .herelabel{font-family:var(--mono);font-size:.7rem;text-transform:uppercase;letter-spacing:.08em;font-weight:600;color:var(--transport)}
label.check{display:flex;gap:8px;align-items:flex-start;font-size:.92rem;font-weight:500}
label.check input{width:18px;height:18px;margin-top:3px;flex:none}

/* diffs, proposals, history */
.diff{display:flex;flex-direction:column;gap:10px;font-size:.9rem}
.diff b{display:block}
.diff ul{list-style:none;margin:4px 0 0;padding:0;display:flex;flex-direction:column;gap:2px}
.diff li{padding:2px 8px;border-left:3px solid transparent;overflow-wrap:anywhere}
.diff li.add{border-color:var(--sight);background:color-mix(in srgb,var(--sight) 12%,transparent)}
.diff li.chg{border-color:var(--food);background:color-mix(in srgb,var(--food) 12%,transparent)}
.diff li.del{border-color:var(--danger);color:var(--muted);text-decoration:line-through}
.diff li.same{color:var(--muted)}
.diff .tag{font-family:var(--mono);font-size:.7rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);text-decoration:none;display:inline-block}
.proposal{border:1.5px solid var(--accent);border-radius:var(--r);padding:12px;display:flex;flex-direction:column;gap:10px;background:var(--surface)}
.proposal .head{font-family:var(--mono);font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:var(--accent);font-weight:600}
.proposal.closed{border-color:var(--line)}
.proposal.closed .head{color:var(--muted)}
.hist{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;max-height:56vh;overflow:auto}
.hist li{display:flex;gap:10px;align-items:flex-start;padding:10px 0;border-top:1.5px solid var(--line)}
.hist li:first-child{border-top:0}
.hist .what{font-weight:700;overflow-wrap:anywhere}
.hist .meta{font-family:var(--mono);font-size:.74rem;color:var(--muted)}

/* money */
.tabs button{font-size:.86rem;padding-inline:2px}
.eyebrow{font-family:var(--mono);font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);font-weight:600}
.settle{font-size:1.35rem;font-weight:900;line-height:1.25;display:flex;flex-wrap:wrap;gap:4px 12px;justify-content:space-between}
.settle .mono{color:var(--accent)}
.tbl{overflow-x:auto}
.tbl table{border-collapse:collapse;width:100%;font-size:.9rem}
.tbl th{font-family:var(--mono);font-size:.7rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);font-weight:600;text-align:right;padding:4px 0 4px 12px}
.tbl td{text-align:right;padding:6px 0 6px 12px;border-top:1.5px solid var(--line);font-family:var(--mono);font-variant-numeric:tabular-nums;white-space:nowrap}
.tbl th:first-child,.tbl td:first-child{text-align:left;padding-left:0;font-family:var(--display);font-weight:700}
.neg{color:var(--danger)}
.pos{color:var(--accent)}
.exday{font-family:var(--mono);font-size:.74rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);padding-top:6px}
.exrow{display:flex;gap:12px;align-items:flex-start;width:100%;text-align:left;background:none;border:0;border-top:1.5px solid var(--line);padding:10px 0;cursor:pointer}
.exrow b{display:block;overflow-wrap:anywhere}
.exrow .meta{font-size:.82rem;color:var(--muted);overflow-wrap:anywhere}
.exrow .amt{font-family:var(--mono);font-variant-numeric:tabular-nums;text-align:right;white-space:nowrap;font-weight:600}
.exrow .amt small{display:block;font-weight:400;color:var(--muted)}
.exrow.gone b,.exrow.gone .amt{text-decoration:line-through;color:var(--muted)}
.exlist{display:flex;flex-direction:column}

/* standalone app: setup gate, GPS status and confirm cards */
.gate .tabs,.gate #btnHistory,.gate #btnImport{display:none}
.herebar .gps{display:block;font-size:.78rem;color:var(--muted);margin-top:2px}
.confirm{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;background:var(--soft);border:1.5px solid var(--accent);border-radius:var(--r);padding:10px 12px}
.thinking:disabled{opacity:.7}
.members{display:flex;flex-direction:column}
.member{display:flex;gap:10px;align-items:flex-start;padding:10px 0;border-top:1.5px solid var(--line)}
.member:first-child{border-top:0}
.member .grow{display:flex;flex-direction:column;gap:4px}
.member .meta{font-family:var(--mono);font-size:.74rem;color:var(--muted)}
.member.ask{background:var(--soft);border-radius:8px;padding:10px;border-top:0}

/* app shell: one Menu button instead of three; History and Import live in the menu */
.app #btnHistory,.app #btnImport{display:none}
.sheethead{display:flex;align-items:center;justify-content:space-between;gap:12px}
.sec{display:flex;flex-direction:column;gap:12px;padding-top:18px;border-top:1.5px solid var(--line)}
.sec>h4{font-family:var(--mono);font-size:.74rem;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);font-weight:600}
.sec p{line-height:1.55}
.inline{display:flex;gap:8px}
.inline input{flex:1;min-width:0}
.btn.wide{width:100%}
.state{display:inline-block;font-family:var(--mono);font-size:.72rem;text-transform:uppercase;letter-spacing:.06em;font-weight:600;padding:2px 8px;border-radius:999px;background:var(--sunk);color:var(--muted)}
.state.on{background:var(--soft);color:var(--accent)}

/* first run: one decision per screen */
.onb{display:flex;flex-direction:column;gap:14px}
.onb h2{font-size:1.5rem;font-weight:900;line-height:1.2}
.onb p{line-height:1.55}
.hero{padding:12px 2px 6px;display:flex;flex-direction:column;gap:8px}
.hero h2{font-size:1.8rem}
.choice{display:flex;align-items:center;gap:14px;width:100%;text-align:left;padding:18px;border:1.5px solid var(--line);border-radius:var(--r);background:var(--surface);cursor:pointer}
.choice:hover{border-color:var(--muted)}
.choice .grow{display:flex;flex-direction:column;gap:4px}
.choice strong{font-size:1.08rem;font-weight:900}
.choice .grow span{color:var(--muted);font-size:.9rem;line-height:1.45}
.choice .chev{font-size:1.5rem;color:var(--muted);line-height:1}
.lk.back{align-self:flex-start;color:var(--muted);padding:0}
.seg{display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;background:var(--sunk);border-radius:12px}
.seg button{border:0;background:none;min-height:40px;border-radius:9px;font-weight:700;font-size:.92rem;color:var(--muted);cursor:pointer}
.seg button[aria-pressed="true"]{background:var(--surface);color:var(--ink);box-shadow:0 1px 3px rgba(8,12,22,.18)}
.pw{position:relative;display:block}
.pw input{padding-right:64px}
.pw .lk{position:absolute;right:4px;top:50%;transform:translateY(-50%);padding:8px 10px}

/* receipt photos */
.shot{display:flex;gap:12px;align-items:center;background:var(--sunk);border-radius:10px;padding:10px}
.shot img{flex:none;width:64px;height:64px;object-fit:cover;border-radius:8px}
img.receipt{display:block;max-width:100%;border-radius:10px;align-self:center}
