/* Railway Planner v2 — mobile-first UI layer (issue 0010).
   Data core stays shared.js/IndexedDB; this file styles the v2 pages only. */
:root {
  --bg: #0e141b;
  --bg-2: #121a23;
  --panel: #18222d;
  --panel-2: #1e2a37;
  --panel-3: #243444;
  --text: #e9eff6;
  --muted: #9db0c3;
  --line: #2c3b4a;
  --accent: #5aa9ff;
  --accent-2: #e0a030;
  --danger: #ff6b6b;
  --warn: #ffbe55;
  --ok: #6ed39b;
  --radius: 14px;
  --nav-h: 62px;
  --shadow: 0 6px 20px rgba(0,0,0,.25);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: system-ui, "Segoe UI", Arial, sans-serif; }
body { line-height: 1.4; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px); min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
a { color: #cfe3ff; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* App bar */
.appbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.appbar h1 { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .version { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; white-space: nowrap; }
.appbar .back-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
/* 0037 — the way out. Every planner page was a dead end: nothing linked back to the weather
   dashboard, so the only route was editing the URL (CR cr_ak3rxr_msoitn1u, 2026-08-11). */
.appbar .dash-link { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; white-space: nowrap; text-decoration: none; }
.appbar .dash-link:hover { color: var(--accent); border-color: var(--accent); }

/* Bottom navigation */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: stretch; justify-content: space-around; height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: rgba(14,20,27,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; }
.bottomnav a .icon { font-size: 20px; line-height: 1; }
.bottomnav a.active { color: var(--accent); }
.bottomnav a.capture-tab .icon { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; margin-top: -18px; border-radius: 50%; background: var(--accent); color: #08111a; font-size: 26px; font-weight: 800; box-shadow: var(--shadow); border: 3px solid var(--bg); }
.bottomnav a.capture-tab.active .icon { background: var(--accent-2); }

/* Layout */
.page { padding: 14px 14px 20px; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-head h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: #c9d9ea; }
.count-pill { font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.count-pill.hot { color: #ffd4d8; border-color: #5b2b31; background: #3c1f21; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); } .danger-text { color: var(--danger); }
.empty-box { padding: 14px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); background: #0d141c; font-size: 13px; }

/* Controls — 44px+ touch targets */
button { cursor: pointer; border: 1px solid var(--line); background: var(--accent); color: #08111a; border-radius: 11px; padding: 12px 14px; font-weight: 700; min-height: 44px; }
button.ghost { background: transparent; color: var(--text); font-weight: 600; }
button.danger { background: transparent; border-color: #5b2b31; color: #ffd4d8; }
button.tiny { min-height: 34px; padding: 6px 10px; font-size: 12px; border-radius: 8px; }
input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], select, textarea { width: 100%; background: #0d141c; color: var(--text); border: 1px solid var(--line); border-radius: 11px; padding: 12px; outline: none; min-height: 44px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(90,169,255,.15); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button-row > * { flex: 1; }
.button-row > .no-flex { flex: 0 0 auto; }

/* Segmented control */
.segmented { display: flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #0d141c; }
.segmented button { flex: 1; border: none; border-radius: 0; background: transparent; color: var(--muted); min-height: 44px; font-weight: 600; }
.segmented button.active { background: var(--accent); color: #08111a; font-weight: 800; }

/* Chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; background: #13202c; color: var(--text); cursor: pointer; min-height: 36px; }
.chip.selected { background: var(--accent); color: #08111a; border-color: var(--accent); font-weight: 700; }
.chip .x { opacity: .7; font-weight: 800; }

/* Badges */
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.3; white-space: nowrap; }
.badge.type { background: #233445; color: #cfe3ff; }
.badge.ok { background: #183425; color: var(--ok); }
.badge.due { background: #3d2f12; color: #ffd26e; }
.badge.late { background: #3c1f21; color: #ff9aa1; }
.badge.todo { background: #243446; color: #d3e5ff; }
.badge.planned { background: #21403b; color: #aaf0d0; }
.badge.done { background: #183425; color: var(--ok); }
.badge.deferred { background: #4d3721; color: #ffd2a6; }
.badge.p0 { background: #5b1d20; color: #ffb3b8; }
.badge.p1 { background: #4d3721; color: #ffd2a6; }

/* Cards / lists */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.item-card { display: block; background: #0d141c; border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--text); }
.item-card:active { background: var(--panel-2); }
.item-card .title-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.item-card .title-row strong { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.item-card .meta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.item-card .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.item-card.is-done { opacity: .6; }
/* 0030 — due buckets, matching v1's table rows. Border-left rather than an inset shadow
   here: these cards already carry a 1px border, and a shadow inside it reads as a seam. */
.item-card.due-today { background: #141d27; border-left: 3px solid var(--warn); }
.item-card.due-past { background: #1d1630; border-left: 3px solid #a06ee0; }
.item-card.due-tomorrow { background: #0f2119; border-left: 3px solid var(--ok); }
/* 0031 — the week ahead. */
.item-card.due-week { background: #101d2b; border-left: 3px solid var(--accent); }
.item-card.due-next-monday { background: #0e1721; border-left: 3px solid #7fbcff80; }
.quick-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.quick-actions button { flex: 1; min-height: 38px; padding: 8px 10px; font-size: 13px; }

/* Home stats */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat .value { font-size: 24px; font-weight: 800; }
.stat .label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 2px; }
.stat.alert .value { color: var(--danger); }

/* Asset picker (capture) */
.picker-results { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.picker-item { text-align: left; background: #0d141c; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); font-weight: 500; min-height: 44px; }
.picker-item .small { display: block; margin-top: 2px; }
.picker-item.selected { border-color: var(--accent); background: rgba(90,169,255,.12); }
.selected-asset { border: 1px solid var(--accent); border-radius: 12px; padding: 12px; background: rgba(90,169,255,.08); display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* Tabs (plan page) */
.tabbar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar button { flex: 0 0 auto; background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; min-height: 40px; font-size: 13px; font-weight: 700; }
.tabbar button.active { background: var(--accent); color: #08111a; border-color: var(--accent); }
.tabbar button .n { opacity: .8; font-weight: 800; margin-left: 4px; }

/* Collapsible filter drawer */
details.drawer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
details.drawer > summary { list-style: none; cursor: pointer; padding: 13px 14px; font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
details.drawer > summary::after { content: "▾"; color: var(--muted); }
details.drawer[open] > summary::after { content: "▴"; }
details.drawer .drawer-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.checkboxes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13px; }
.checkboxes label { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.checkboxes input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; }

/* Task editor */
.task-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.task-edit-grid label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.task-edit-grid input, .task-edit-grid select { min-height: 40px; padding: 8px 10px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 22px); transform: translateX(-50%) translateY(20px); background: var(--panel-3); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { border-color: #2c5a41; } #toast.err { border-color: #5b2b31; }

/* Misc */
.yaml-box, .log-box { min-height: 200px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.divider { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.file-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.compact-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #0d141c; }
.compact-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.compact-item.is-done { opacity: .6; text-decoration: line-through; }
.compact-item input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; margin-top: 2px; }

/* 0041 — same 44 px floor as every other target in v2. Column layout so the "remembered"
   note sits under the label instead of competing with it for width on a narrow screen. */
.desktop-escape { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; min-height:52px; padding:10px 14px; border:1px dashed var(--line); border-radius:12px; background:#0d141c; color:var(--text); font-weight:600; text-align:center; }

@media (min-width: 761px) {
  .page { max-width: 900px; }
  .form-grid { grid-template-columns: 1fr 1fr 1fr; }
  .task-edit-grid { grid-template-columns: repeat(4, 1fr); }
}
