/* BFTW Trip App */
:root {
  --navy: #0E2A47; --primary: #1E4E8C; --primary-dark: #163B6B; --primary-soft: #E8EEF7;
  --bg: #F3F4F6; --surface: #fff; --border: #E4E7EB; --line: #F0F1F3;
  --ink: #111827; --muted: #4B5563; --faint: #6B7280;
  --ok: #166534; --ok-bg: #DCFCE7; --warn: #92400E; --warn-bg: #FEF3C7; --danger: #B91C1C; --danger-bg: #FEE2E2;
  --radius: 14px; --shadow: 0 1px 2px rgba(17,24,39,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
h1, h2, h3, p { margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff; padding: calc(16px + env(safe-area-inset-top)) 16px 14px; display: flex; align-items: center; gap: 12px; }
.badge { width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; background: #fff; color: var(--navy); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-decoration: none; }
.badge-back { background: var(--primary); color: #fff; }
.badge-lg { width: 56px; height: 56px; border-radius: 14px; font-size: 14px; background: var(--navy); color: #fff; }
.topbar-text { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }
.topbar-sub { font-size: 12px; color: #B9C7D8; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; text-decoration: none; }
.topbar .avatar:hover { color: #fff; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; background: var(--primary-soft); color: var(--primary); }
.avatar-md { width: 36px; height: 36px; background: var(--primary-soft); color: var(--primary); }
.avatar-lg { width: 52px; height: 52px; font-size: 16px; }

/* Content */
.content { flex-grow: 1; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card-link { text-decoration: none; color: var(--ink); }
.card-link:hover { color: var(--ink); border-color: #CBD2DA; }
.card-danger { border-color: #FCA5A5; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 26px 18px; border-style: dashed; box-shadow: none; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 48px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: #FAFAFB; color: var(--ink); }
.list-row svg { color: #9CA3AF; flex-shrink: 0; }
.list-row.stack-tight, .list-row.stack-sm { flex-direction: column; align-items: flex-start; }
.align-start { align-items: flex-start; }
.align-stretch { align-items: stretch !important; }

.section-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 4px; }
.card .section-label { margin: 0; }
.h-lg { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.h-md { font-size: 16px; font-weight: 600; margin: 0 4px; }
.card .h-md { margin: 0; }
.h-sm { font-size: 15px; font-weight: 600; }
.room-code { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.accent { color: var(--primary); }
.danger { color: var(--danger); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.pre { white-space: pre-line; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.divider { height: 1px; background: var(--line); }

/* Layout helpers */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gap { gap: 12px; } .gap-sm { gap: 8px; } .wrap { flex-wrap: wrap; }
.grow { flex-grow: 1; min-width: 0; }
.push { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-tight { display: flex; flex-direction: column; gap: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--border); border-radius: 10px; overflow: hidden; margin-top: 14px; }
.stats-card { margin-top: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.stats > div { background: #F9FAFB; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stats-card > div { background: #fff; }
.stats strong { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats strong small { font-size: 13px; color: var(--muted); font-weight: 500; }
.stats span { font-size: 12px; color: var(--muted); }

/* Chips & dots */
.chip { display: inline-block; border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 600; background: #F3F4F6; color: var(--muted); white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-accent { background: var(--primary-soft); color: var(--primary); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot-accent { background: var(--primary); } .dot-warn { background: #C2410C; } .dot-ok { background: #16A34A; } .dot-muted { background: #D1D5DB; }
.todo { display: flex; align-items: center; gap: 10px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: #fff; color: #374151; border-color: #D1D5DB; }
.btn-secondary:hover { background: #F9FAFB; color: #374151; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 6px 4px; cursor: pointer; color: var(--primary); font-weight: 600; }
.btn-link.danger { color: var(--danger); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #93B4E0; outline-offset: 2px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea, form > input, form > select, .row > input, .row > select {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #D1D5DB; border-radius: 10px; background: #fff; color: var(--ink); font-size: 15px; font-weight: 400;
}
.row > select { width: auto; }
.field textarea { resize: vertical; }
.check-inline { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; }
.check-inline input { width: 20px; height: 20px; }
input[readonly] { background: #F9FAFB; }
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 28px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; margin-left: auto; font-weight: 600; color: var(--muted); }
details[open] > summary::after { content: "–"; }

/* Flash */
.flash { border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* Segmented tabs */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; background: #E5E7EB; border-radius: 10px; padding: 4px; }
.segmented a { min-height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; text-align: center; }
.segmented a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(17,24,39,.12); }

/* Schedule */
.day-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.day { flex: 0 0 auto; width: 46px; min-height: 56px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; }
.day span { font-size: 11px; font-weight: 600; }
.day strong { font-size: 16px; }
.day.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.slot { width: 72px; flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }

/* Headcount */
.count { display: flex; align-items: baseline; gap: 4px; }
.count strong { font-size: 30px; font-weight: 700; color: #B45309; }
.count.all strong { color: var(--ok); }
.count span { color: var(--muted); font-weight: 500; }
.bar { height: 6px; border-radius: 3px; background: #E5E7EB; overflow: hidden; }
.bar > div { height: 6px; background: #B45309; transition: width .2s; }
.bar.all > div { background: var(--ok); }
.check-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 52px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-row:last-child { border-bottom: 0; }
.check-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-row .box { width: 26px; height: 26px; flex-shrink: 0; border-radius: 6px; border: 2px solid #9CA3AF; display: flex; align-items: center; justify-content: center; color: transparent; }
.check-row input:checked + .box { background: var(--ok); border-color: var(--ok); color: #fff; }
.check-row input:focus-visible + .box { outline: 3px solid #93B4E0; outline-offset: 2px; }
.check-row .tag { font-size: 12px; font-weight: 600; color: var(--danger); }
.check-row .tag::after { content: "Missing"; }
.check-row input:checked ~ .tag { color: var(--ok); }
.check-row input:checked ~ .tag::after { content: "Here"; }

/* Tab bar */
.tabbar { position: sticky; bottom: 0; z-index: 10; background: #fff; border-top: 1px solid var(--border); padding: 6px 4px calc(8px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; min-height: 44px; color: var(--faint); font-size: 11px; font-weight: 500; text-decoration: none; }
.tabbar a.on { color: var(--primary); font-weight: 600; }

/* Join page */
body.join { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--navy); }
.join-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 28px 22px; display: flex; flex-direction: column; gap: 14px; }
.join-card h1 { font-size: 21px; }
.pin { letter-spacing: .5em; font-size: 22px !important; text-align: center; }
