:root {
  --bg: #12181F;
  --surface: #1B232C;
  --surface-2: #232D38;
  --surface-3: #2A3541;
  --ink: #F3F1EC;
  --muted: #93A0AC;
  --teal: #4FBBA0;
  --teal-dark: #BFE9DD;
  --teal-pale: rgba(79, 187, 160, 0.14);
  --coral: #E8845B;
  --coral-pale: rgba(232, 132, 91, 0.16);
  --tan: #D9B98A;
  --tan-dark: #E7CFA6;
  --tan-pale: rgba(217, 185, 138, 0.14);
  --border: #2A3541;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

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

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  position: relative;
  background: var(--bg);
  transform: translateZ(0);
}

@media (min-width: 481px) {
  .app-shell { box-shadow: 0 0 60px rgba(0,0,0,0.4); }
}

button { font-family: inherit; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top-bar-brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  letter-spacing: 0.03em;
  color: var(--ink);
}
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px 10px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); flex-shrink: 0; }
.status-pill.offline .status-dot { background: var(--coral); }

main {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px calc(84px + var(--safe-bottom));
}

.app-eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tan);
  font-weight: 700;
  margin: 16px 0 4px;
}
.app-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

.hero { margin: 0 -20px; position: relative; }
.hero-illustration { width: 100%; height: 190px; display: block; object-fit: cover; object-position: center 40%; }
.hero-placeholder-note {
  position: absolute; left: 20px; bottom: 10px; font-size: 11px; color: rgba(255,255,255,0.75);
  margin: 0; background: rgba(0,0,0,0.35); padding: 3px 8px; border-radius: 999px;
}

.continue-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}
.continue-card-text { display: flex; flex-direction: column; gap: 2px; }
.continue-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.continue-day { font-family: Georgia, serif; font-size: 19px; font-weight: 700; }
.continue-title { font-size: 13.5px; color: var(--muted); }
.continue-arrow { width: 20px; height: 20px; color: var(--teal); flex-shrink: 0; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.stat-num { font-family: Georgia, serif; font-size: 19px; font-weight: 700; display: block; }
.stat-label { font-size: 10.5px; color: var(--muted); display: block; margin-top: 2px; }

.section-label {
  font-size: 13px;
  color: var(--muted);
  margin: 18px 0 8px;
  font-weight: 600;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}
.quick-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 4px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--ink);
  cursor: pointer;
}
.quick-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--teal-pale);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
}
.quick-icon svg { width: 18px; height: 18px; }

.progress-row { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 6px; }
.progress-row .label { font-size: 13px; color: var(--muted); }
.progress-row .value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tide-svg { width: 100%; height: 28px; display: block; }

.day-pills-row { display: flex; align-items: center; gap: 8px; }
.day-pills-row .day-pills { flex: 1; margin-top: 12px; }
.day-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.day-pills::-webkit-scrollbar { display: none; }

.day-pill {
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.day-pill.active { border-color: var(--coral); color: var(--coral); background: var(--coral-pale); }
.day-pill.done { background: var(--teal-pale); color: var(--teal-dark); border-color: transparent; }
.day-pill.done.active { border-color: var(--coral); }

.reorder-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  margin-top: 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.reorder-btn svg { width: 18px; height: 18px; }

.context-line { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }

.reorder-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 20;
  align-items: flex-end;
}
.reorder-overlay.show { display: flex; }
.reorder-sheet {
  background: var(--surface);
  width: 100%;
  max-height: 78vh;
  border-radius: 20px 20px 0 0;
  padding: 16px 20px calc(20px + var(--safe-bottom));
  overflow-y: auto;
}
.reorder-head { display: flex; justify-content: space-between; align-items: center; }
.reorder-title { font-size: 16px; font-weight: 700; margin: 0; }
.reorder-done { border: none; background: none; color: var(--teal); font-weight: 700; font-size: 15px; cursor: pointer; padding: 4px 2px; }
.reorder-hint { font-size: 13px; color: var(--muted); margin: 6px 0 14px; line-height: 1.4; }
.reorder-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.reorder-row:last-child { border-bottom: none; }
.reorder-pos { width: 26px; height: 26px; border-radius: 8px; background: var(--teal-pale); color: var(--teal-dark); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.reorder-label { flex: 1; font-size: 14.5px; }
.reorder-arrows { display: flex; gap: 6px; }
.reorder-arrow { width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.reorder-arrow:disabled { opacity: 0.3; cursor: default; }
.reorder-arrow svg { width: 16px; height: 16px; }
.reorder-delete { color: var(--muted); }
.reorder-delete:not(:disabled):hover { color: var(--coral); }
.reorder-hidden-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 18px 0 4px; }
.reorder-row-hidden { opacity: 0.75; }
.add-back-btn { border: 1.5px dashed var(--border); background: none; color: var(--teal); font-size: 12.5px; font-weight: 600; border-radius: 8px; padding: 6px 10px; cursor: pointer; }

.stop-row, .list-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.stop-row:last-child, .list-row:last-child { border-bottom: none; }
.stop-text { font-size: 15px; line-height: 1.4; padding-top: 1px; }
.stop-sub { font-size: 12.5px; color: var(--muted); display: block; margin-top: 2px; }
.stop-row.checked .stop-text { color: var(--muted); text-decoration: line-through; }

.chk {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer;
  background: var(--surface-2); margin-top: 1px;
}
.chk.on { background: var(--teal); border-color: var(--teal); }
.chk svg { width: 14px; height: 14px; opacity: 0; }
.chk.on svg { opacity: 1; }

.heart-btn {
  width: 28px; height: 28px; border: none; background: none; color: var(--border);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; margin-top: 1px;
}
.heart-btn svg { width: 18px; height: 18px; }
.heart-btn.on { color: var(--coral); }
.heart-btn.on svg { fill: var(--coral); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin: 14px 0; }

.tide-card {
  background: var(--teal-pale); border-radius: 14px; padding: 14px 16px; margin: 16px 0 14px;
  display: flex; gap: 12px; align-items: flex-start;
}
.tide-card .headline { font-weight: 700; color: var(--teal-dark); font-size: 14.5px; margin: 0; }
.tide-card .sub { color: var(--teal-dark); font-size: 13px; margin: 3px 0 0; opacity: 0.85; }

.tip-card { background: var(--tan-pale); border-radius: 14px; padding: 14px 16px; margin: 0 0 14px; display: flex; gap: 12px; align-items: flex-start; }
.tip-card .headline { font-weight: 700; color: var(--tan-dark); font-size: 14.5px; margin: 0; }
.tip-card .sub { color: var(--tan-dark); font-size: 13px; margin: 3px 0 0; opacity: 0.85; }

.offline-note { font-size: 12px; color: var(--muted); margin: -2px 0 8px; line-height: 1.4; }

.route-diagram-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 4px; }
#route-diagram { width: 100%; height: auto; display: block; }
.route-diagram-note { font-size: 11.5px; color: var(--muted); text-align: center; margin: 6px 0 0; }

.edit-row { padding: 8px 0; }
.edit-row .stop-text-wrap { flex: 1; min-width: 0; }
.list-input {
  display: block; width: 100%; border: none; border-bottom: 1px dashed var(--border);
  background: transparent; font-family: inherit; font-size: 15px; color: var(--ink); padding: 3px 0; outline: none;
}
.list-input.sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.list-input:focus { border-bottom: 1px solid var(--teal); }
.list-input.checked-input { color: var(--muted); text-decoration: line-through; }
.list-input::placeholder { color: var(--muted); opacity: 0.6; }

.row-delete {
  width: 30px; height: 30px; border: none; background: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; border-radius: 8px;
}
.row-delete svg { width: 16px; height: 16px; }
.row-delete:hover { background: var(--surface-2); color: var(--coral); }

.add-item-btn {
  width: 100%; margin-top: 10px; padding: 11px; border-radius: 10px; border: 1.5px dashed var(--border);
  background: none; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
}
.add-item-btn:hover { border-color: var(--teal); color: var(--teal); }

.map-link-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.map-link-row:last-child { border-bottom: none; }
.map-link-name { font-size: 15px; flex: 1; min-width: 0; }
.map-app-btns { display: flex; gap: 6px; flex-shrink: 0; }
.map-app-btn {
  width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--teal); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; text-decoration: none;
}
.map-app-btn:active { background: var(--teal-pale); }
.map-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); margin: 0 0 8px; }

.more-menu { margin-top: 8px; }
.more-row {
  width: 100%; display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 14px; margin-bottom: 8px;
  color: var(--ink); font-size: 15px; cursor: pointer;
}
.more-row-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); color: var(--teal); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.more-row-icon svg { width: 16px; height: 16px; }
.more-row-text { flex: 1; text-align: left; }
.more-row-chevron { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }

.more-back { display: flex; align-items: center; gap: 4px; background: none; border: none; color: var(--teal); font-size: 14px; font-weight: 600; cursor: pointer; padding: 8px 0 4px; }
.more-back svg { width: 16px; height: 16px; }

.offline-status-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 4px 16px; margin-bottom: 20px; }
.status-line { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.status-line:last-child { border-bottom: none; }
.status-line svg { width: 16px; height: 16px; color: var(--teal); flex-shrink: 0; }
.status-line .status-line-label { flex: 1; }
.status-line .status-line-detail { font-size: 12px; color: var(--muted); }

.favorites-group-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 18px 0 4px; }
.favorites-empty { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.favorites-empty svg { width: 34px; height: 34px; color: var(--border); margin-bottom: 10px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.undo-toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(76px + var(--safe-bottom));
  background: var(--surface-3); color: var(--ink); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: none; align-items: center; justify-content: space-between; gap: 12px; font-size: 13.5px; z-index: 30;
}
.undo-toast.show { display: flex; }
.undo-toast #undo-toast-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.undo-toast button { border: none; background: none; color: var(--teal); font-weight: 700; font-size: 13.5px; cursor: pointer; flex-shrink: 0; }

nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: var(--safe-bottom);
}
.tab-btn {
  flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px 8px; font-size: 10.5px; color: var(--muted); cursor: pointer;
}
.tab-btn.active { color: var(--teal); }
.tab-btn svg { width: 21px; height: 21px; }

.offline-banner { display: none; background: var(--tan); color: #221B0F; text-align: center; font-size: 12.5px; font-weight: 600; padding: 6px 10px; }
.offline-banner.show { display: block; }
