:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1b1e2b;
  --muted: #6b7083;
  --line: #e3e5ee;
  --primary: #1d2b64;
  --accent: #f2b632;
  --good: #2f8a4e;
  --park: var(--primary);
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --card: #1c1f2b;
    --text: #eceef5;
    --muted: #9aa0b5;
    --line: #2c3040;
    --primary: #8ea4ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
code { font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

.app-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
  padding: calc(.75rem + env(safe-area-inset-top)) 1rem .75rem;
  background: var(--primary); color: #fff;
}
@media (prefers-color-scheme: dark) { .app-header { background: #1d2b64; } }
.app-header h1 { font-size: 1.15rem; margin: 0; }
.app-header .muted { color: #c9d0ee; font-size: .85rem; }

.screen { max-width: 680px; margin: 0 auto; padding: .75rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: .75rem;
}
.stack { display: flex; flex-direction: column; gap: .6rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row > * { flex: 1; }
.row.end { justify-content: flex-end; }
.row.end > * { flex: 0 0 auto; }

input, select {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; width: 100%;
}
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
label.toggle { flex-direction: row; align-items: center; margin: .75rem 0; }
label.toggle input { width: auto; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: .6rem 1rem;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #10142a; } }
.btn.big { padding: .9rem 1.4rem; font-size: 1.05rem; margin-top: .5rem; }
.btn.block { display: block; width: 100%; margin-top: .75rem; }
.btn.link { background: none; border: none; color: var(--muted); text-decoration: underline; }

/* Chips */
.chips { display: flex; gap: .4rem; padding: .25rem 0; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; }
.chip {
  flex: 0 0 auto; font: inherit; font-size: .9rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: .4rem .8rem; white-space: nowrap;
}
.chip.on { background: var(--park); border-color: var(--park); color: #fff; }
.chip .x { margin-left: .35rem; opacity: .7; padding: 0; font-size: .85rem; text-decoration: none; }

.toolbar { margin: .4rem 0; }

/* Item list */
.cat-heading { margin: 1rem 0 .4rem; font-size: .95rem; color: var(--muted); }
.item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .55rem .6rem .55rem .8rem; margin-bottom: .4rem;
}
.item.done { border-left: 4px solid var(--park); }
.item.retired { opacity: .6; }
.item .info { flex: 1; min-width: 0; cursor: pointer; }
.item .name { font-weight: 600; }
.item .meta { font-size: .8rem; color: var(--muted); }
.item .count {
  min-width: 2rem; text-align: center; font-weight: 700; color: var(--park);
}
.btn-did {
  font: inherit; font-weight: 700; cursor: pointer; border: none; border-radius: 10px;
  background: var(--park); color: #fff; padding: .55rem .8rem; min-width: 4.2rem;
}
.btn-did:active { transform: scale(.96); }

/* History */
.day-heading { margin: 1rem 0 .4rem; font-weight: 700; }
.log-row {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .5rem .7rem; margin-bottom: .35rem;
}
.log-row .dot { width: .6rem; height: .6rem; border-radius: 50%; flex: 0 0 auto; }
.log-row .info { flex: 1; min-width: 0; }
.log-row .del { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }

/* Stats */
.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: .6rem; }
.segmented button { flex: 1; font: inherit; padding: .5rem; border: none; background: var(--card); color: var(--text); cursor: pointer; }
.segmented button.on { background: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .segmented button.on { color: #10142a; } }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: .75rem; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; }
.tile .num { font-size: 1.6rem; font-weight: 800; }
.tile .lbl { font-size: .8rem; color: var(--muted); }

.bar-row { display: grid; grid-template-columns: 7.5rem 1fr 3.2rem; gap: .5rem; align-items: center; margin: .35rem 0; font-size: .9rem; }
.bar { height: .7rem; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--park); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }

.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; align-items: end; height: 110px; margin-top: .5rem; }
.months .m { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .65rem; color: var(--muted); }
.months .m i { display: block; width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 1px; }
.months .m b { font-size: .65rem; color: var(--text); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { padding: .4rem .3rem; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
tr.clickable { cursor: pointer; }

ol.top { margin: 0; padding-left: 1.4rem; }
ol.top li { margin: .2rem 0; }
details summary { cursor: pointer; font-weight: 600; }
details ul { margin: .4rem 0 0; padding-left: 1.2rem; columns: 2; font-size: .88rem; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; font: inherit; font-size: .75rem; background: none; border: none; color: var(--muted);
  padding: .5rem 0 .6rem; display: flex; flex-direction: column; align-items: center; gap: .1rem; cursor: pointer;
}
.tabbar button span { font-size: 1.25rem; }
.tabbar button.active { color: var(--primary); font-weight: 700; }

/* Dialogs & toast */
dialog { border: none; border-radius: var(--radius); padding: 1rem; width: min(92vw, 420px); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(80px + env(safe-area-inset-bottom));
  background: #1b1e2b; color: #fff; border-radius: 999px; padding: .6rem .6rem .6rem 1rem;
  display: flex; gap: .75rem; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  max-width: 92vw;
}
.toast button { font: inherit; font-weight: 700; color: var(--accent); background: none; border: none; cursor: pointer; }
.code { font-family: ui-monospace, monospace; letter-spacing: .1em; font-size: 1.1rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------- Park theming ----------
   app.js sets --park, --grad-a, --grad-b, --accent and --hero-img on <body>
   when a park is open, so the header, buttons and tab bar all take its colors. */
body { --grad-a: #2c3f8f; --grad-b: #1d2b64; --hero-img: none; }
body.in-park .app-header { background: linear-gradient(90deg, var(--grad-a), var(--grad-b)); }
body.in-park .tabbar button.active { color: var(--park); }
body.in-park { --primary: var(--park); }
.app-header, .park-hero, .btn-did, .chip { transition: background .3s, border-color .3s; }

.home-title { margin: .5rem .25rem 1rem; font-size: 1.35rem; }
.park-grid { display: grid; grid-template-columns: 1fr; gap: .75rem; }
@media (min-width: 560px) { .park-grid { grid-template-columns: 1fr 1fr; } }
.park-card {
  position: relative; display: flex; align-items: center; gap: 1rem; width: 100%;
  min-height: 108px; padding: 1rem; border: none; border-radius: 20px; cursor: pointer;
  color: #fff; text-align: left; font: inherit; overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0,0,0,.55), rgba(0,0,0,.2)),
    var(--hero-img) var(--hero-pos, center) / cover no-repeat,
    linear-gradient(135deg, var(--grad-a), var(--grad-b));
  box-shadow: 0 6px 18px rgba(20, 20, 60, .18);
}
.park-card:active { transform: scale(.985); }
.park-card img { width: 72px; height: 72px; border-radius: 18px; flex: 0 0 auto; box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.park-card .pname { font-size: 1.25rem; font-weight: 800; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.park-card .pmeta { font-size: .85rem; opacity: .92; margin-top: .15rem; }
.park-card .pbar { height: 6px; background: rgba(255,255,255,.3); border-radius: 999px; margin-top: .5rem; overflow: hidden; }
.park-card .pbar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.park-hero {
  position: relative; display: flex; align-items: flex-end; gap: .9rem;
  margin: -.75rem -.75rem .75rem; padding: 3.2rem 1rem 1.1rem; min-height: 190px; color: #fff;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.05) 30%, rgba(0,0,0,.55)),
    var(--hero-img) var(--hero-pos, center) / cover no-repeat,
    linear-gradient(135deg, var(--grad-a), var(--grad-b));
}
@media (min-width: 680px) { .park-hero { margin: 0 0 .75rem; border-radius: 0 0 20px 20px; } }
.park-hero h2 { font-size: 1.6rem; margin: 0; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.hero-icon { width: 76px; height: 76px; border-radius: 20px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.hero-progress { font-size: .9rem; opacity: .95; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.hero-back {
  position: absolute; top: .7rem; left: .7rem; font: inherit; font-weight: 600; cursor: pointer;
  border: none; border-radius: 999px; padding: .35rem .8rem; color: #fff; background: rgba(0,0,0,.3);
  backdrop-filter: blur(6px);
}
.cat-heading .small { font-weight: 400; }

/* Item photos */
.item { padding-left: .5rem; }
.thumb {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; cursor: pointer;
  background: color-mix(in srgb, var(--park) 12%, var(--card));
}
.thumb.none { display: grid; place-items: center; font-size: 1.4rem; }
.dlg-photo { width: calc(100% + 2rem); margin: -1rem -1rem 0; height: 200px; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; }

/* Tags on items */
.tag {
  display: inline-block; margin-left: .35rem; padding: .05rem .45rem; border-radius: 999px;
  font-size: .7rem; font-weight: 600; vertical-align: middle; background: var(--line); color: var(--muted);
}
.tag.closed { background: #6b7083; color: #fff; }
.tag.season { background: #e7f6ec; color: #1f6b3a; }
@media (prefers-color-scheme: dark) { .tag.season { background: #1f3a2a; color: #9fe0b5; } }

/* Who's here today */
.here { padding: .6rem .8rem; margin-bottom: .5rem; }
.here .chips { padding-bottom: 0; }
.here-hint { opacity: .8; }

/* Trips */
.trip-now { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.trip-pill {
  display: inline-block; margin: 0 0 .5rem; padding: .3rem .8rem; border-radius: 999px;
  background: color-mix(in srgb, var(--park) 14%, var(--card)); color: var(--park); font-weight: 600; font-size: .9rem;
}
.trip-ask { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .6rem .8rem; }
.trip-ask span { flex: 1; font-weight: 600; }
.small-btn { padding: .35rem .7rem; font-size: .85rem; }
.trip-card { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.trip-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .4rem; }
.trip-name { font-weight: 800; font-size: 1.1rem; }
.trip-parks { display: flex; gap: .25rem; }
.trip-parks img { width: 28px; height: 28px; border-radius: 8px; }
.trip-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.trip-head h2 { margin: 0; }
.day-list { list-style: none; padding-left: .5rem; margin: .4rem 0 .6rem; columns: 1 !important; }
.day-list li { padding: .25rem 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .9rem; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; }

/* Badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; margin: .5rem 0; }
.badge {
  text-align: center; padding: .6rem .3rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); opacity: .65; filter: grayscale(.8);
}
.badge.earned { opacity: 1; filter: none; background: color-mix(in srgb, var(--accent, #f2b632) 22%, var(--card)); border-color: var(--accent, #f2b632); }
.b-icon { font-size: 1.7rem; }
.b-name { font-size: .78rem; font-weight: 700; line-height: 1.15; margin-top: .2rem; }
.b-sub { font-size: .7rem; color: var(--muted); margin-top: .15rem; }
.b-bar { height: 4px; background: var(--line); border-radius: 999px; margin: .3rem .4rem 0; overflow: hidden; }
.b-bar i { display: block; height: 100%; background: var(--primary); }

/* Log dialog extras */
.flags { justify-content: flex-start; }
.flags > * { flex: 0 0 auto; }
#dlg-fav.on { background: #f2b632; border-color: #f2b632; color: #3a2a00; }
#dlg-wish.on { background: #e2554f; border-color: #e2554f; color: #fff; }
.user-photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin-bottom: .4rem; }
.file-btn { flex-direction: row; display: inline-flex; align-items: center; gap: .35rem; font-size: 1rem; cursor: pointer; }
.row > .file-btn { flex: 0 0 auto; }
.btn.danger { color: #c0392b; margin-right: auto; }
.tag.fav { background: #fff3cd; color: #8a6200; }
.tag.wish { background: #fde2e1; color: #a12a24; }
@media (prefers-color-scheme: dark) { .tag.fav { background: #4a3b10; color: #ffd75e; } .tag.wish { background: #4a1f1d; color: #ffb3ae; } }

/* History rows are tappable */
.log-row { cursor: pointer; }
.log-row .chev { color: var(--muted); font-size: 1.3rem; }
.log-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }

/* Five tabs */
.tabbar button { font-size: .7rem; }
dialog { max-height: 90vh; overflow-y: auto; }
