:root {
  --bg: #111316;
  --surface: #1a1d22;
  --surface-2: #23272e;
  --text: #eef0f3;
  --muted: #9aa3ad;
  --border: #2e333b;
  --accent: #f26b1d;
  --danger: #e5484d;
  --line: #e4572e;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; }
h3 { font-size: 1rem; }
p { margin: .25rem 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

.banner { background: #6b3a00; color: #ffe2bf; padding: .6rem 1rem; font-size: .9rem; text-align: center; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1rem; background: rgba(17, 19, 22, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; letter-spacing: .02em; text-decoration: none; }
.logo { width: 22px; height: 22px; border-radius: 50%; border: 5px solid var(--accent); background: #fff; }
.auth { display: flex; align-items: center; gap: .5rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; }
.who { font-size: .9rem; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .who { display: none; } }

.wrap { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* Buttons and inputs */
.btn {
  appearance: none; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600;
  padding: .6rem 1.1rem; min-height: 44px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { padding: .35rem .8rem; min-height: 36px; font-size: .9rem; }
.btn.big { padding: .85rem 1.5rem; font-size: 1.05rem; }
.link { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; cursor: pointer; font: inherit; }

input:not([type=radio]):not([type=file]):not([type=checkbox]), textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: .65rem .75rem; font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; margin: .75rem 0; font-size: .9rem; color: var(--muted); }
label > input, label > textarea { margin-top: .3rem; }

.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; margin-top: 1rem; }
.grow { flex: 1; min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; }

.pill { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.live { background: var(--danger); color: #fff; }

/* Home */
.hero { padding: 2.5rem 0 1rem; }
.hero h1 { font-size: clamp(2rem, 7vw, 3rem); }
.hero p { max-width: 34rem; margin-bottom: 1.25rem; }
.cards { display: grid; gap: .75rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.ev-card { display: flex; gap: .9rem; align-items: center; padding: .9rem; text-decoration: none; }
.ev-card:hover { border-color: var(--line); }
.ev-body { display: flex; flex-direction: column; min-width: 0; }
.line-badge {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--line); color: #fff; font-weight: 800; font-size: .95rem;
}
.line-badge.big { width: 60px; height: 60px; font-size: 1.2rem; }

/* Create dialog */
dialog { width: min(520px, calc(100% - 2rem)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
fieldset { border: 0; padding: 0; margin: 1rem 0 0; }
legend { font-size: .9rem; color: var(--muted); margin-bottom: .3rem; }
.seg-choice label { display: flex; gap: .5rem; align-items: baseline; color: var(--text); margin: .4rem 0; }
.seg-choice small { color: var(--muted); }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { margin: 0; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 32px; height: 32px; border-radius: 50%; background: var(--c); border: 3px solid transparent; cursor: pointer; }
.swatch input:checked + span { border-color: #fff; }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); }

/* Event page */
.event-head { display: flex; gap: 1rem; align-items: flex-start; padding-top: 1rem; }
.event-head h1 { font-size: 1.6rem; }
.rec { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; margin-right: .3rem; }
@keyframes blink { 50% { opacity: .2; } }
.req { padding: .4rem 0; border-bottom: 1px solid var(--border); }

#map { height: 340px; border-radius: var(--radius); border: 1px solid var(--border); margin-top: 1rem; z-index: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .6rem; }
.stats div { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .5rem; text-align: center; }
.stats strong { display: block; font-size: 1.05rem; }
.stats span { font-size: .75rem; color: var(--muted); }

.peers { display: flex; flex-wrap: wrap; gap: .4rem; margin: .7rem 0; }
.peer { background: var(--surface-2); border-radius: 999px; padding: .25rem .7rem; font-size: .9rem; }
.peer small { color: var(--muted); }
.peer.connected { box-shadow: inset 0 0 0 2px #2bb673; }

.photo-pick { display: inline-block; margin: 0 0 .6rem; }
.photo-pick input { position: absolute; opacity: 0; width: 1px; }
.photo-pick span { display: inline-block; border: 1px dashed var(--border); border-radius: 10px; padding: .55rem 1rem; color: var(--text); cursor: pointer; }
.photo-pick input:focus-visible + span { outline: 2px solid var(--accent); }
.preview { display: block; max-height: 180px; border-radius: 10px; margin-bottom: .6rem; }
#postForm > * { margin-bottom: .6rem; }

/* Journey: a transit line. Time | line with station dot | stop card */
.timeline { list-style: none; margin: 1rem 0; padding: 0; position: relative; }
.timeline li { position: relative; display: grid; grid-template-columns: 58px 28px 1fr; }
.timeline li::before { /* the line itself */
  content: ""; position: absolute; left: 58px; top: 0; bottom: 0; width: 8px; margin-left: 10px;
  background: var(--line);
}
.timeline li:first-child::before { top: 22px; }
.timeline li:last-child::before { bottom: calc(100% - 22px); }
.timeline .when { padding-top: .9rem; font-size: .85rem; font-weight: 700; text-align: right; padding-right: .4rem; font-variant-numeric: tabular-nums; }
.timeline .dot {
  position: relative; z-index: 1; width: 20px; height: 20px; margin: .95rem 0 0 4px;
  border-radius: 50%; background: #fff; border: 4px solid var(--line);
}
.timeline .start .dot, .timeline .end .dot { width: 26px; height: 26px; margin: .8rem 0 0 1px; border-width: 6px; }
.timeline .card { margin: .4rem 0 .4rem .5rem; padding: .7rem .85rem; }
.timeline .kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.timeline .place { font-weight: 800; font-size: 1.05rem; }
.timeline .card img { display: block; width: 100%; max-height: 420px; object-fit: cover; border-radius: 10px; margin: .5rem 0; }
.timeline .by { margin-top: .3rem; }
.timeline .seg span { grid-column: 3; padding: .2rem 0 .2rem .5rem; font-size: .8rem; color: var(--muted); }
.timeline .day span, .timeline .day { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.timeline .day { display: block; padding: .6rem 0 .2rem 104px; }
.timeline .seg { min-height: 2rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  background: #fff; color: #111; padding: .7rem 1rem; border-radius: 10px; max-width: calc(100% - 2rem); z-index: 2000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  #map { height: 280px; }
}

/* ---------- Reporting, inbox, admin ---------- */
.foot { text-align: center; padding: 2rem 1rem; font-size: .85rem; color: var(--muted); }
.banner a { color: inherit; }
.inbox-link, .admin-link { font-size: .9rem; text-decoration: none; padding: .3rem .5rem; border-radius: 8px; }
.inbox-link:hover, .admin-link:hover { background: var(--surface-2); }
.count { display: inline-block; min-width: 1.3rem; margin-left: .3rem; padding: 0 .35rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; }
.head-actions { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; }
.person { text-decoration: none; border-bottom: 1px dotted var(--muted); color: inherit; }
.cat-list label { display: flex; gap: .5rem; align-items: baseline; color: var(--text); margin: .35rem 0; }
.cat-list a { color: var(--muted); }
label.check { display: flex; gap: .5rem; align-items: baseline; color: var(--text); }
select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: .5rem .6rem; font: inherit; width: 100%; margin-top: .3rem; }
.row select { width: auto; margin: 0; }
dialog.sheet { width: min(560px, calc(100% - 2rem)); max-height: 85vh; }
dialog.sheet.wide { width: min(760px, calc(100% - 2rem)); }
.comments { list-style: none; padding: 0; margin: .75rem 0; max-height: 45vh; overflow: auto; }
.comments li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
#commentForm { margin-top: .5rem; flex-wrap: nowrap; }
.note.unread { border-color: var(--accent); }
.note { padding: .9rem; }
.prose h2 { margin-top: 2rem; }
.prose h3 { margin-top: 1.2rem; scroll-margin-top: 70px; }
.prose p { color: #d5d9de; }
.pill.warn { background: #6b3a00; color: #ffd9a8; }

.wrap.wide { max-width: 1100px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: .5rem 0 1rem; overflow-x: auto; }
.tab { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: .7rem 1rem; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; margin: .5rem 0 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem; }
.kpi strong { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .8rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.insights { margin: .3rem 0; padding-left: 1.2rem; }
.insights li { margin: .3rem 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { flex-wrap: nowrap; }
.search { max-width: 260px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.on { fill: rgba(255, 255, 255, .04); }
.chart-tip { position: fixed; z-index: 3000; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; font-size: .85rem; }
.report-row { display: flex; flex-direction: column; gap: .25rem; text-align: left; color: var(--text); font: inherit; padding: .85rem; cursor: pointer; width: 100%; }
.report-row:hover { border-color: var(--accent); }
.snippet { font-style: italic; color: #d5d9de; }
.quote { border-left: 4px solid var(--accent); padding: .4rem .8rem; background: var(--surface-2); border-radius: 0 10px 10px 0; }
.quote img { display: block; max-width: 100%; max-height: 300px; border-radius: 8px; margin: .5rem 0; }

/* ---------- Sign-in, installer ---------- */
.wrap.narrow { max-width: 440px; }
.wide-btn { width: 100%; margin-top: .5rem; }
.ok-msg { border-color: #2bb673; }
.err-msg { border-color: var(--danger); }
.google-box { text-align: center; display: grid; justify-items: center; gap: .5rem; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { padding: .35rem 0; }
.checks li > span { display: inline-block; width: 1.2rem; font-weight: 700; }
.checks .pass > span { color: #2bb673; }
.checks .fail > span { color: var(--danger); }
.checks .warn > span { color: #f3a712; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 6px; }
