/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
  transition: background 0.2s, color 0.2s;
}

/* ── Theme variables ── */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface2: #e5e5ea;
  --text: #1c1c1e;
  --text2: #6c6c70;
  --text3: #aeaeb2;
  --accent: #007aff;
  --accent-faint: #e1ecff;
  --visited: #34c759;
  --weather: #ff9500;
  --border: #d1d1d6;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 14px rgba(0,0,0,.09);
  --r: 16px;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #000;
    --surface: #1c1c1e;
    --surface2: #2c2c2e;
    --text: #fff;
    --text2: #8e8e93;
    --text3: #48484a;
    --accent: #0a84ff;
    --accent-faint: #0a1e3d;
    --visited: #30d158;
    --weather: #ff9f0a;
    --border: #38383a;
    --shadow: 0 1px 3px rgba(0,0,0,.25), 0 4px 14px rgba(0,0,0,.3);
  }
}

html[data-theme="dark"] {
  --bg: #000;
  --surface: #1c1c1e;
  --surface2: #2c2c2e;
  --text: #fff;
  --text2: #8e8e93;
  --text3: #48484a;
  --accent: #0a84ff;
  --accent-faint: #0a1e3d;
  --visited: #30d158;
  --weather: #ff9f0a;
  --border: #38383a;
  --shadow: 0 1px 3px rgba(0,0,0,.25), 0 4px 14px rgba(0,0,0,.3);
}

html[data-theme="light"] {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface2: #e5e5ea;
  --text: #1c1c1e;
  --text2: #6c6c70;
  --text3: #aeaeb2;
  --accent: #007aff;
  --accent-faint: #e1ecff;
  --visited: #34c759;
  --weather: #ff9500;
  --border: #d1d1d6;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 14px rgba(0,0,0,.09);
}

/* ── Layout ── */
#app {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Header ── */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-inner {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hbtn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
}
.hbtn:hover { background: var(--surface2); color: var(--text); }
.hbtn:active { background: var(--border); }
.hbtn svg { width: 20px; height: 20px; }
.hbtn.hidden { display: none; }

.filter-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.tab {
  border: none;
  background: none;
  padding: 5px 13px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.progress-text {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Location banner ── */
.loc-banner {
  background: var(--accent-faint);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.loc-banner.hidden { display: none; }

.banner-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
}
.banner-row svg { width: 17px; height: 17px; flex-shrink: 0; }
.banner-row span { flex: 1; }

.banner-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.banner-btn:active { opacity: 0.8; }

/* ── List ── */
#list {
  padding: 12px 16px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.25s ease;
  animation: fadeUp 0.2s ease both;
}

.card[data-visited="true"] {
  opacity: 0.55;
}

.card[data-visited="true"] .card-name {
  text-decoration: line-through;
  text-decoration-color: var(--text3);
}

/* green left accent when visited */
.card[data-visited="true"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--visited);
  border-radius: var(--r) 0 0 var(--r);
  pointer-events: none;
}

.card-body {
  padding: 14px 14px 12px 16px;
}

/* top row: title + visit button */
.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.card-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.2px;
  flex: 1;
}

.card-desc {
  font-size: 13.5px;
  color: var(--text2);
  line-height: 1.45;
  overflow: hidden;
  max-height: 0;
  margin-bottom: 0;
  transition: max-height 0.25s ease, margin-bottom 0.25s ease;
}

.card[data-expanded="true"] .card-desc {
  max-height: 120px;
  margin-bottom: 12px;
}

/* ── Pin button ── */
.pin-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.pin-btn:hover { color: var(--text2); background: var(--surface2); }
.pin-btn:active { background: var(--border); }
.pin-btn svg { width: 16px; height: 16px; }

.pin-path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  transition: fill 0.15s, stroke 0.15s;
}
.card[data-pinned="true"] .pin-btn { color: var(--accent); }
.card[data-pinned="true"] .pin-path { fill: currentColor; stroke: currentColor; }

/* ── Description toggle button ── */
.desc-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.desc-btn:hover { color: var(--text2); background: var(--surface2); }
.desc-btn:active { background: var(--border); }
.desc-btn svg { width: 16px; height: 16px; }
.card[data-expanded="true"] .desc-btn { color: var(--accent); }

.wx-icon {
  width: 22px;
  height: 22px;
  color: var(--weather);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wx-icon svg { width: 16px; height: 16px; }

/* ── Card footer: compass + visit btn ── */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.compass-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* SVG compass */
.compass-svg {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.c-ring {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}

.c-north { fill: var(--accent); }
.c-south { fill: var(--text3); }

.c-dot {
  fill: var(--surface);
  stroke: var(--text3);
  stroke-width: 1;
}

.c-needle {
  transform-origin: 21px 21px;
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.geo-info {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 52px;
}

.geo-dist {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.geo-dir {
  font-size: 12px;
  color: var(--text2);
  margin-top: 1px;
}

/* ── Card footer actions ── */
.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Nav button ── */
.nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--accent-faint);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn:hover { background: var(--accent); color: #fff; }
.nav-btn:active { opacity: 0.75; }
.nav-btn svg { width: 16px; height: 16px; }

/* ── Visit toggle button ── */
.visit-btn {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.visit-btn:hover { background: var(--surface2); }
.visit-btn:active { background: var(--border); }

.visit-svg {
  width: 26px;
  height: 26px;
  display: block;
}

.v-ring {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
  transition: fill 0.2s, stroke 0.2s;
}

.v-check {
  fill: none;
  stroke: var(--text3);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 18;
  stroke-dashoffset: 18;
  transition: stroke-dashoffset 0.3s ease 0.05s, stroke 0.2s;
}

.card[data-visited="true"] .v-ring {
  fill: var(--visited);
  stroke: var(--visited);
}

.card[data-visited="true"] .v-check {
  stroke: #fff;
  stroke-dashoffset: 0;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
  font-size: 15px;
}

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 0; }