:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #14161a;
  --muted: #5d6573;
  --line: #dde1e7;
  --accent: #e8a400;
  --accent-ink: #1a1300;
  --good: #12924b;
  --good-bg: #e2f6ea;
  --bad: #c62f2f;
  --bad-bg: #fbe6e6;
  --warn: #9a6200;
  --warn-bg: #fff2d6;
  --info: #2557c7;
  --info-bg: #e3ebfc;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 10px rgb(0 0 0 / 4%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #eceef2;
    --muted: #9aa3b2;
    --line: #2b3039;
    --accent: #ffc22e;
    --accent-ink: #1a1300;
    --good: #41d17f;
    --good-bg: #123322;
    --bad: #ff6b6b;
    --bad-bg: #3a1717;
    --warn: #ffc65c;
    --warn-bg: #3a2c0d;
    --info: #7da2ff;
    --info-bg: #182543;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.top h1 { font-size: 28px; letter-spacing: -0.02em; margin: 0; flex: 1; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.live-dot.on { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); }

main { padding: 4px 16px calc(env(safe-area-inset-bottom) + 92px); }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabs[hidden], [hidden] { display: none !important; }
.tabs button {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; cursor: pointer;
}
.tabs .ic { font-size: 20px; line-height: 1.1; filter: grayscale(1); opacity: .75; }
.tabs button.active { color: var(--text); font-weight: 600; }
.tabs button.active .ic { filter: none; opacity: 1; }

/* cards & lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h2 { font-size: 17px; margin: 0 0 8px; }
.card h3 { font-size: 15px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.list { display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; padding: 34px 12px; color: var(--muted); }
.empty .big { font-size: 38px; display: block; margin-bottom: 6px; }

.item { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.item img.thumb, .item .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: contain; background: #fff; flex: none; display: grid; place-items: center; font-size: 26px; }
.item .title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.item .meta { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* forms */
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zoom-on-focus */
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.check { display: flex; gap: 10px; align-items: center; margin: 12px 0 4px; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 6px; }
.seg button { border: 0; background: none; font: inherit; font-size: 14px; color: var(--muted); padding: 7px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer; background: var(--accent); color: var(--accent-ink); text-decoration: none; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }

.banner { display: flex; gap: 12px; align-items: center; background: var(--warn-bg); color: var(--text); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.banner .ic { font-size: 22px; }
.banner.info { background: var(--info-bg); }

details.edit summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 6px; }

/* heatmap */
.heat { display: grid; grid-template-columns: 30px repeat(24, 1fr); gap: 2px; font-size: 10px; color: var(--muted); }
.heat .c { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.heat .lbl { align-self: center; }
.heat .hr { text-align: center; }

.spot-photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; margin-top: 8px; background: var(--surface-2); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
}

.login { min-height: 70dvh; display: grid; place-items: center; }
.login .card { width: 100%; max-width: 360px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 18px; }
