:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --safe-bg: #0f172a;
  --radius: 20px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  --sev-1: #2563eb;
  --sev-2: #d97706;
  --sev-3: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; } /* beat element display rules below */
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  padding: 22px 20px 18px;
  border-radius: 0 0 28px 28px;
}
.hero-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.loc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); border: none; color: #fff;
  padding: 7px 12px; border-radius: 999px; font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.loc-btn:active { transform: scale(.97); }
.pin { font-size: 13px; }
.chev { opacity: .7; font-size: 11px; }
.hero-date { color: #cbd5e1; font-size: 13px; margin-top: 8px; }
.hero-weather { text-align: right; }
.hw-temp { font-size: 34px; font-weight: 700; line-height: 1; }
.hw-desc { font-size: 13px; color: #cbd5e1; margin-top: 2px; }
.hw-sub { font-size: 12px; color: #94a3b8; }
.hero-banner {
  margin-top: 14px; padding: 10px 14px; border-radius: 14px;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px;
  background: rgba(220,38,38,.18); border: 1px solid rgba(248,113,113,.4); color: #fecaca;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px; padding: 12px 14px 4px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg), var(--bg) 70%, transparent);
}
.tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 9px 4px; border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab span { font-size: 11px; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Panels ---------- */
#main { flex: 1; padding: 8px 14px 20px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 4px 14px; }
.panel-head h2 { font-size: 19px; font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Feed cards ---------- */
.feed { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: flex; gap: 14px; align-items: flex-start;
  text-decoration: none; color: inherit; border: 1px solid var(--line);
}
.card.tap { cursor: pointer; transition: transform .12s; }
.card.tap:active { transform: scale(.99); }
.card-ico {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 21px; background: #eff6ff;
}
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 15px; font-weight: 600; }
.card-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-meta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.tag.dist { background: #f1f5f9; color: var(--muted); }
.tag.sev-1 { background: #dbeafe; color: var(--sev-1); }
.tag.sev-2 { background: #fef3c7; color: var(--sev-2); }
.tag.sev-3 { background: #fee2e2; color: var(--sev-3); }
.tag.src { background: #f8fafc; color: #94a3b8; border: 1px solid var(--line); }

/* Safety panel gets a dark feel for the most severe items */
.card.danger { border-color: #fecaca; }
.card.danger .card-ico { background: #fee2e2; }

/* ---------- Forms / goals ---------- */
.add-form { display: flex; gap: 8px; margin-top: 14px; }
.add-form input[type=text] {
  flex: 1; border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; color: var(--ink);
}
.add-form select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 0 10px; font-size: 13px;
}
.add-form input:focus, .add-form select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.add-form button {
  background: var(--brand); color: #fff; border: none; border-radius: 12px;
  padding: 0 18px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.add-form button:active { background: var(--brand-ink); }

.goals { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.goal {
  display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.goal input { width: 20px; height: 20px; accent-color: var(--brand); flex-shrink: 0; }
.goal span { font-size: 14px; flex: 1; }
.goal.done span { text-decoration: line-through; color: var(--muted); }
.goal .del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 12px; text-align: center; }

/* Shared board UI */
.board-badge {
  font-size: 12px; font-weight: 700; color: #16a34a;
  background: #dcfce7; border-radius: 999px; padding: 3px 10px;
}
.tag.shared-tag { background: #dcfce7; color: #15803d; }
.tag.local-tag  { background: #f1f5f9; color: var(--muted); }
.own-post { border-color: #bfdbfe; }
.own-post .card-ico { background: #eff6ff; }

/* ---------- Footer ---------- */
.foot {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 16px; font-size: 13px; color: var(--muted);
}
.dot { color: var(--line); }
.link-btn { background: none; border: none; color: var(--brand); font-weight: 600; cursor: pointer; font-size: 13px; }

/* ---------- Skeletons ---------- */
.skeleton { background: linear-gradient(90deg, #e2e8f0 25%, #eef2f7 50%, #e2e8f0 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
.sk-weather { width: 90px; height: 44px; }
.sk-card { height: 74px; border-radius: var(--radius); margin-bottom: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.hero .skeleton { background: linear-gradient(90deg, rgba(255,255,255,.12) 25%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.12) 75%); background-size: 200% 100%; }

.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 36px 12px; }
.empty .big { font-size: 30px; display: block; margin-bottom: 8px; }

/* ---------- Sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 680px;
  border-radius: 24px 24px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: rise .25s ease;
}
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
.sheet h3 { font-size: 18px; margin-bottom: 14px; }
.big-btn {
  width: 100%; background: var(--brand); color: #fff; border: none; border-radius: 14px;
  padding: 14px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0; }
#place-form { display: flex; gap: 8px; }
#place-form input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
#place-form button { background: var(--ink); color: #fff; border: none; border-radius: 12px; padding: 0 18px; font-weight: 600; cursor: pointer; }
.place-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.place-results button {
  text-align: left; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; font-size: 14px; cursor: pointer; color: var(--ink);
}
.close { display: block; margin: 16px auto 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --surface: #131c2e; --ink: #e2e8f0; --muted: #94a3b8; --line: #243049; --shadow: 0 4px 20px rgba(0,0,0,.3); }
  .card-ico { background: #1e293b; }
  .tag.dist { background: #1e293b; }
  .tag.src { background: #131c2e; }
  .place-results button { background: #1e293b; }
}
