/* ---------- tokens ---------- */
:root {
  /* flipping tokens — redefined for dark mode below */
  --bg: #ede7d8;
  --bg-2: #e2dbc8;
  --surface: #f6f2e6;
  --text: #182420;
  --text-muted: #6b7d73;
  --moss: #3f5c45;
  --hairline: rgba(24, 36, 32, 0.14);
  --shadow: 0 10px 30px -18px rgba(18, 33, 31, 0.45);

  /* fixed tokens — the topbar / hero / tab bar are a deliberately
     always-dark "river at night" surface in both themes */
  --ink: #12211f;
  --ink-2: #1a2f2b;
  --on-ink: #f3ede0;
  --on-ink-muted: #8fa8a3;
  --cutthroat: #d9622b;
  --cutthroat-dim: #b5501f;

  --font-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --font-body: "Libre Franklin", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1b19;
    --bg-2: #16241f;
    --surface: #16241f;
    --text: #e7e2d2;
    --text-muted: #93a69d;
    --moss: #86a98c;
    --hairline: rgba(231, 226, 210, 0.12);
    --shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3 { margin: 0; }

.prose {
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 62ch;
}
.prose.small { font-size: 0.85rem; opacity: 0.85; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--moss);
  margin: 0 0 0.5rem;
  font-weight: 700;
}

/* ---------- app shell ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 1.1rem;
  background: var(--ink);
  color: var(--on-ink);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
  overflow: hidden;
  isolation: isolate;
}
.banner-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.4s ease;
  z-index: 0;
}
.banner-slide.active { opacity: 1; }
.banner-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(100deg, rgba(18, 33, 31, 0.72) 0%, rgba(18, 33, 31, 0.4) 55%, rgba(18, 33, 31, 0.7) 100%);
}
.brand-mark {
  position: relative;
  z-index: 2;
  width: 30px;
  height: 30px;
  color: var(--cutthroat);
  flex-shrink: 0;
}
.brand-text { position: relative; z-index: 2; flex: 1; min-width: 0; }
.brand-text h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1rem, 1.1rem + 1.5vw, 1.5rem);
  letter-spacing: 0.01em;
  line-height: 1.08;
  text-wrap: balance;
  color: var(--on-ink);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.brand-sub {
  position: relative;
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  color: var(--on-ink-muted);
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.chip {
  position: relative;
  z-index: 2;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--cutthroat);
  color: #fff8ef;
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
}

.panel { display: none; max-width: 640px; margin: 0 auto; }
.panel.active { display: block; animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.panel-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  margin-bottom: 0.15rem;
  color: var(--text);
}
.panel-sub {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 1.1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  color: var(--text);
}

/* ---------- countdown ---------- */
.hero-card {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  color: var(--on-ink);
  border-radius: 18px;
  padding: 1.4rem 1.3rem 1.6rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.hero-card .eyebrow { color: var(--on-ink-muted); }
.contour {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
}
.contour path {
  fill: none;
  stroke: rgba(217, 98, 43, 0.4);
  stroke-width: 1.4;
}
.contour path:nth-child(2) { stroke: rgba(159, 184, 182, 0.35); }
.contour path:nth-child(3) { stroke: rgba(217, 98, 43, 0.22); }

.trip-headline {
  position: relative;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 1.3rem + 3.5vw, 2.3rem);
  line-height: 1.04;
  text-wrap: balance;
  color: var(--on-ink);
}
.trip-date {
  position: relative;
  margin: 0.3rem 0 1.1rem;
  color: var(--on-ink-muted);
  font-size: 0.9rem;
}
.countdown-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.cd-unit {
  background: rgba(243, 237, 224, 0.08);
  border: 1px solid rgba(243, 237, 224, 0.16);
  border-radius: 10px;
  padding: 0.6rem 0.2rem;
  text-align: center;
}
.cd-num {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  color: var(--on-ink);
}
.cd-label {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-ink-muted);
  margin-top: 0.15rem;
}
.link-btn {
  position: relative;
  margin-top: 1rem;
  background: none;
  border: none;
  color: var(--cutthroat);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- weather ---------- */
.weather-now-loading { font-size: 0.85rem; color: var(--text-muted); }
.weather-now-main {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.weather-now-temp {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 2.6rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.weather-now-desc { font-size: 0.95rem; }
.weather-now-meta {
  margin-top: 0.6rem;
  display: flex;
  gap: 1.2rem;
  font-size: 0.8rem;
  color: var(--moss);
  font-family: var(--font-mono);
}
.forecast-row {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  -webkit-overflow-scrolling: touch;
}
.forecast-day {
  flex: 0 0 auto;
  width: 4.4rem;
  text-align: center;
  background: var(--bg-2);
  border-radius: 10px;
  padding: 0.55rem 0.3rem;
}
.forecast-day .fd-name {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--moss);
  font-weight: 700;
}
.forecast-day .fd-icon { font-size: 1.3rem; margin: 0.25rem 0; }
.forecast-day .fd-hi {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}
.forecast-day .fd-lo {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.normals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}
.normal-stat {
  text-align: center;
  background: var(--bg-2);
  border-radius: 10px;
  padding: 0.7rem 0.3rem;
}
.normal-num {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--cutthroat-dim);
}
.normal-label {
  display: block;
  font-size: 0.65rem;
  color: var(--moss);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}
.links-card { display: flex; flex-direction: column; gap: 0.5rem; }
.ext-link {
  color: var(--cutthroat-dim);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}
.ext-link:hover { text-decoration: underline; }

/* ---------- forms ---------- */
.add-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
input[type="text"], input[type="datetime-local"], textarea, select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  color: var(--text);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--cutthroat);
  outline-offset: 1px;
}
.add-form input[type="text"]:first-child { flex: 1; min-width: 0; }
.qty-input { width: 4.2rem !important; flex: 0 0 auto; }
.add-btn {
  background: var(--cutthroat);
  color: #fff8ef;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  width: 2.7rem;
  flex: 0 0 auto;
  cursor: pointer;
}
.add-btn:active { background: var(--cutthroat-dim); }
.add-btn-wide { width: 100%; font-size: 0.95rem; padding: 0.7rem; margin-top: 0.7rem; }

/* ---------- checklists ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.2rem;
  border-bottom: 1px solid var(--hairline);
}
.checklist li:last-child { border-bottom: none; }
.check-toggle {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 6px;
  border: 2px solid var(--moss);
  flex-shrink: 0;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff8ef;
}
.check-toggle.checked { background: var(--moss); }
.check-toggle svg { width: 0.9rem; height: 0.9rem; display: none; }
.check-toggle.checked svg { display: block; }
.item-main { flex: 1; min-width: 0; }
.item-text { font-size: 0.95rem; word-break: break-word; color: var(--text); }
.item-text.done { text-decoration: line-through; opacity: 0.5; }
.item-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; }
.item-qty {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--moss);
  background: var(--bg-2);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  flex-shrink: 0;
}
.claim-btn {
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--cutthroat);
  background: none;
  color: var(--cutthroat-dim);
  flex-shrink: 0;
  cursor: pointer;
  white-space: nowrap;
}
.claim-btn.claimed { background: var(--cutthroat); color: #fff8ef; border-color: var(--cutthroat); }
.del-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0.2rem;
}

.empty-state {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

/* ---------- flies ---------- */
.fly-form { margin-bottom: 1rem; }
.fly-form-row { margin-bottom: 0.6rem; }
.fly-form-row-split { display: flex; gap: 0.6rem; }
.fly-form-row-split select { flex: 1; }
textarea { resize: vertical; font-family: var(--font-body); }
.file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--moss);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font-size: 0.85rem;
  color: var(--moss);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}
.file-btn-wide { flex: 1; width: 100%; }
.file-btn input[type="file"] { display: none; }

.fly-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}
.fly-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}
.fly-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-2);
  display: block;
}
.fly-card-noimg {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.fly-card-noimg svg { width: 2rem; height: 2rem; }
.fly-card-body { padding: 0.65rem 0.7rem 0.8rem; }
.fly-card-name { font-weight: 700; font-size: 0.9rem; line-height: 1.2; color: var(--text); }
.fly-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  margin-top: 0.35rem;
}
.fly-badge.killer { background: #f0dcc9; color: #a4441a; }
.fly-badge.good { background: #dde6d5; color: #4c6b52; }
.fly-badge.meh { background: #e6e1d1; color: #7d7458; }
.fly-badge.dud { background: #e6d3d3; color: #8a4141; }
.fly-card-notes { font-size: 0.78rem; color: var(--text); opacity: 0.8; margin-top: 0.4rem; line-height: 1.4; }
.fly-card-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.4rem; }
.fly-card .del-btn { position: absolute; top: 0.4rem; right: 0.4rem; background: rgba(18,33,31,0.55); color: #fff; border-radius: 999px; width: 1.6rem; height: 1.6rem; }

/* ---------- photos ---------- */
.photo-form { display: flex; flex-direction: column; gap: 0.6rem; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- tab bar ---------- */
.tabbar {
  display: flex;
  background: var(--ink);
  padding: 0.35rem 0.2rem calc(0.35rem + env(safe-area-inset-bottom));
  position: sticky;
  bottom: 0;
  z-index: 20;
  box-shadow: 0 -6px 20px -12px rgba(0,0,0,0.4);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--on-ink-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0.1rem;
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab-btn.active { color: var(--cutthroat); }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 33, 31, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1.2rem;
}
.modal {
  background: var(--bg);
  color: var(--text);
  border-radius: 16px;
  padding: 1.4rem;
  max-width: 360px;
  width: 100%;
}
.modal h3 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.modal form { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.8rem; }
.field-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--moss);
  font-weight: 700;
  margin-bottom: -0.3rem;
}
.modal-actions { display: flex; justify-content: space-between; align-items: center; }

.lightbox-backdrop {
  background: rgba(10, 16, 15, 0.92);
  flex-direction: column;
}
.lightbox-backdrop img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 8px;
  object-fit: contain;
}
.lightbox-backdrop p {
  color: #f3ede0;
  margin-top: 0.8rem;
  font-size: 0.9rem;
  text-align: center;
}
.lightbox-close {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  right: 1rem;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  font-size: 1.1rem;
  cursor: pointer;
}

[hidden] { display: none !important; }

/* ---------- larger screens ---------- */
@media (min-width: 720px) {
  .fly-grid { grid-template-columns: repeat(3, 1fr); }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
}
