/* ── Tokens ── */
:root {
  --bg: #f8f7f4;
  --bg-card: #ffffff;
  --bg-subtle: #f2f0eb;
  --bg-input: #f2f0eb;
  --text-primary: #1a1917;
  --text-secondary: #6b6762;
  --text-muted: #a09c97;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.14);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
  --accent: #2d6a4f;
  --accent-light: #e8f5f0;
  --accent-text: #1a4a36;
  --need-color: #c0392b; --need-bg: #fff5f5; --need-border: #fecaca;
  --nice-color: #d97706; --nice-bg: #fffbeb; --nice-border: #fde68a;
  --bonus-color: #2563eb; --bonus-bg: #eff6ff; --bonus-border: #bfdbfe;
  --radius-sm: 10px; --radius-md: 16px; --radius-lg: 24px;
  --header-height: 64px;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
}

/* Dark mode defaults (system) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131210; --bg-card: #1e1d1b; --bg-subtle: #252320; --bg-input: #252320;
    --text-primary: #f0ede8; --text-secondary: #9a9590; --text-muted: #5c5854;
    --border: rgba(255,255,255,0.07); --border-strong: rgba(255,255,255,0.12);
    --shadow-card: 0 2px 12px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
    --shadow-modal: 0 20px 60px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.3);
    --accent: #52b788; --accent-light: #1a3329; --accent-text: #74c69d;
    --need-color: #f87171; --need-bg: #2a1515; --need-border: #7f1d1d;
    --nice-color: #fbbf24; --nice-bg: #261e0a; --nice-border: #78350f;
    --bonus-color: #60a5fa; --bonus-bg: #0f1a2e; --bonus-border: #1e3a5f;
  }
}

/* Forced dark */
:root[data-theme="dark"] {
  --bg: #131210; --bg-card: #1e1d1b; --bg-subtle: #252320; --bg-input: #252320;
  --text-primary: #f0ede8; --text-secondary: #9a9590; --text-muted: #5c5854;
  --border: rgba(255,255,255,0.07); --border-strong: rgba(255,255,255,0.12);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.3);
  --accent: #52b788; --accent-light: #1a3329; --accent-text: #74c69d;
  --need-color: #f87171; --need-bg: #2a1515; --need-border: #7f1d1d;
  --nice-color: #fbbf24; --nice-bg: #261e0a; --nice-border: #78350f;
  --bonus-color: #60a5fa; --bonus-bg: #0f1a2e; --bonus-border: #1e3a5f;
}

/* Forced light */
:root[data-theme="light"] {
  --bg: #f8f7f4; --bg-card: #ffffff; --bg-subtle: #f2f0eb; --bg-input: #f2f0eb;
  --text-primary: #1a1917; --text-secondary: #6b6762; --text-muted: #a09c97;
  --border: rgba(0,0,0,0.08); --border-strong: rgba(0,0,0,0.14);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
  --accent: #2d6a4f; --accent-light: #e8f5f0; --accent-text: #1a4a36;
  --need-color: #c0392b; --need-bg: #fff5f5; --need-border: #fecaca;
  --nice-color: #d97706; --nice-bg: #fffbeb; --nice-border: #fde68a;
  --bonus-color: #2563eb; --bonus-bg: #eff6ff; --bonus-border: #bfdbfe;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text-primary); min-height: 100vh; min-height: 100dvh; overscroll-behavior: none; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }
input, textarea { font-family: var(--font-body); }
img { max-width: 100%; display: block; }

/* ── Views ── */
#app { position: relative; }
.view { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; }
.view.active { display: flex; }

/* ── Header ── */
.app-header { background: var(--bg); padding: env(safe-area-inset-top, 0) 0 0; z-index: 100; }
.app-header.sticky { position: sticky; top: 0; backdrop-filter: blur(16px); background: color-mix(in srgb, var(--bg) 88%, transparent); border-bottom: 1px solid var(--border); }
.header-content { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; min-height: var(--header-height); }
.app-eyebrow { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; }
.app-title { font-family: var(--font-display); font-size: 28px; color: var(--text-primary); line-height: 1; }
.view-title { font-family: var(--font-display); font-size: 22px; flex: 1; text-align: center; line-height: 1.2; }
.header-actions { display: flex; gap: 4px; align-items: center; }
.shop-header-center { flex: 1; text-align: center; }
.shop-eyebrow { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }

/* ── Icon button ── */
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-primary); transition: background 0.15s; }
.icon-btn:active { background: var(--bg-subtle); }
.shop-mode-btn { color: var(--accent); }

/* ── Home ── */
.home-main { flex: 1; padding: 16px 20px 40px; overflow-y: auto; }
.lists-grid { display: flex; flex-direction: column; gap: 12px; }
.list-card { background: var(--bg-card); border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-card); border: 1px solid var(--border); display: flex; align-items: center; gap: 16px; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; -webkit-tap-highlight-color: transparent; }
.list-card:active { transform: scale(0.98); }
.list-card-emoji { font-size: 32px; flex-shrink: 0; }
.list-card-info { flex: 1; min-width: 0; }
.list-card-name { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-card-meta { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.list-card-arrow { color: var(--text-muted); flex-shrink: 0; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { font-family: var(--font-display); font-size: 26px; margin-bottom: 10px; }
.empty-state p { color: var(--text-secondary); line-height: 1.6; margin-bottom: 28px; }

/* ── Buttons ── */
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; padding: 12px 24px; border-radius: 50px; transition: opacity 0.15s, transform 0.1s; }
.btn-primary:active { opacity: 0.85; transform: scale(0.97); }
.btn-ghost { color: var(--text-secondary); font-weight: 500; font-size: 15px; padding: 12px 20px; border-radius: 50px; transition: background 0.15s; }
.btn-ghost:active { background: var(--bg-subtle); }
.btn-ghost.btn-danger { color: var(--need-color); }
.btn-small { font-size: 13px; font-weight: 600; color: var(--accent); padding: 6px 14px; border-radius: 50px; border: 1.5px solid var(--accent); transition: background 0.15s; }
.btn-small:active { background: var(--accent-light); }

/* ── List detail ── */
.list-main { flex: 1; overflow-y: auto; padding-bottom: 60px; }
.tier-section { margin: 0; }
.tier-header { display: flex; align-items: center; gap: 10px; padding: 20px 20px 12px; position: sticky; top: var(--header-height); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); z-index: 10; }
.tier-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tier-label { font-size: 12px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; flex: 1; }
.tier-actions { display: flex; gap: 4px; }
.tier-action-btn { font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 4px 10px; border-radius: 50px; border: 1px solid var(--border-strong); transition: color 0.15s, border-color 0.15s; }
.tier-action-btn:active { color: var(--text-primary); }

.tier-need .tier-dot { background: var(--need-color); }
.tier-need .tier-label { color: var(--need-color); }
.tier-nice .tier-dot { background: var(--nice-color); }
.tier-nice .tier-label { color: var(--nice-color); }
.tier-bonus .tier-dot { background: var(--bonus-color); }
.tier-bonus .tier-label { color: var(--bonus-color); }

.tier-notes-area { margin: 0 20px 8px; background: var(--bg-subtle); border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer; border: 1px dashed var(--border-strong); }
.tier-notes-text { font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.tier-photos-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.tier-photo-thumb { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; cursor: pointer; border: 1.5px solid var(--border); }

.criteria-list { display: flex; flex-direction: column; gap: 1px; padding: 0 20px 4px; }
.criterion-item { background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border); overflow: hidden; margin-bottom: 8px; }
.criterion-main { display: flex; align-items: flex-start; gap: 12px; padding: 14px; cursor: pointer; }
.criterion-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; font-size: 14px; }
.tier-need .criterion-icon { background: var(--need-bg); color: var(--need-color); }
.tier-nice .criterion-icon { background: var(--nice-bg); color: var(--nice-color); }
.tier-bonus .criterion-icon { background: var(--bonus-bg); color: var(--bonus-color); }
.criterion-text { flex: 1; }
.criterion-name { font-weight: 500; font-size: 15px; line-height: 1.3; }
.criterion-note { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.criterion-edit-icon { color: var(--text-muted); flex-shrink: 0; margin-top: 2px; }
.criterion-photos-row { display: flex; gap: 6px; padding: 0 14px 12px 58px; flex-wrap: wrap; }
.criterion-photo-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; cursor: pointer; border: 1.5px solid var(--border); }
.add-criterion-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px 14px; font-size: 14px; color: var(--text-muted); border-radius: var(--radius-sm); border: 1px dashed var(--border-strong); transition: color 0.15s, border-color 0.15s; background: transparent; margin-bottom: 4px; }
.add-criterion-btn:active { color: var(--accent); border-color: var(--accent); }

/* ── Score Banner ── */
.score-banner { display: flex; align-items: center; gap: 20px; padding: 20px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.score-ring-wrap { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.score-ring { width: 80px; height: 80px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-subtle); stroke-width: 6; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 213.6; stroke-dashoffset: 213.6; transition: stroke-dashoffset 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), stroke 0.3s; }
.score-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--text-primary); }
.score-meta { flex: 1; }
.score-verdict { font-family: var(--font-display); font-size: 20px; line-height: 1.2; margin-bottom: 6px; }
.score-breakdown { font-size: 12px; color: var(--text-muted); }

/* ── Shop mode ── */
.shop-main { flex: 1; overflow-y: auto; padding-bottom: 60px; }
.shop-tier-section { margin-bottom: 4px; }
.shop-tier-header { display: flex; align-items: center; gap: 8px; padding: 18px 20px 8px; }
.shop-tier-label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.shop-criteria { display: flex; flex-direction: column; gap: 8px; padding: 0 20px; }
.shop-criterion { display: flex; align-items: flex-start; gap: 14px; background: var(--bg-card); border-radius: var(--radius-sm); padding: 14px; border: 1.5px solid var(--border); cursor: pointer; transition: border-color 0.2s, background 0.2s; -webkit-tap-highlight-color: transparent; }
.shop-criterion.met { border-color: var(--accent); background: var(--accent-light); }
.shop-criterion.not-met { border-color: var(--need-color); background: var(--need-bg); opacity: 0.8; }
.shop-check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border-strong); display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; color: transparent; transition: background 0.2s, border-color 0.2s; }
.shop-criterion.met .shop-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.shop-criterion.not-met .shop-check { background: var(--need-color); border-color: var(--need-color); color: #fff; }
.shop-criterion-text { flex: 1; }
.shop-criterion-name { font-weight: 500; font-size: 15px; }
.shop-criterion-note { font-size: 13px; color: var(--text-secondary); margin-top: 3px; line-height: 1.45; }
.shop-tier-need .shop-tier-label { color: var(--need-color); }
.shop-tier-nice .shop-tier-label { color: var(--nice-color); }
.shop-tier-bonus .shop-tier-label { color: var(--bonus-color); }
.shop-tier-need .tier-dot { background: var(--need-color); }
.shop-tier-nice .tier-dot { background: var(--nice-color); }
.shop-tier-bonus .tier-dot { background: var(--bonus-color); }

/* ── Modals ── */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(4px); padding-bottom: env(safe-area-inset-bottom, 0); }
.modal { background: var(--bg-card); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 28px 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; animation: slide-up 0.28s cubic-bezier(0.34, 1.4, 0.64, 1); }
@keyframes slide-up { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-family: var(--font-display); font-size: 22px; margin-bottom: 18px; }
.modal-input { width: 100%; padding: 13px 16px; background: var(--bg-input); border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 16px; color: var(--text-primary); margin-bottom: 12px; outline: none; transition: border-color 0.15s; -webkit-appearance: none; }
.modal-input:focus { border-color: var(--accent); }
.emoji-input { font-size: 22px; }
.modal-textarea { width: 100%; padding: 13px 16px; background: var(--bg-input); border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 15px; color: var(--text-primary); margin-bottom: 16px; outline: none; resize: none; line-height: 1.55; transition: border-color 0.15s; -webkit-appearance: none; }
.modal-textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }

/* ── Settings modal ── */
.settings-section { margin-bottom: 24px; }
.settings-label { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.theme-picker { display: flex; gap: 8px; }
.theme-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-strong); font-size: 13px; font-weight: 500; color: var(--text-secondary); background: var(--bg-subtle); transition: border-color 0.15s, color 0.15s; }
.theme-btn:active { background: var(--bg-input); }
.theme-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.theme-icon { font-size: 20px; }
.settings-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; background: var(--bg-subtle); border-radius: var(--radius-sm); font-size: 15px; font-weight: 500; color: var(--text-primary); transition: background 0.15s; border: 1px solid var(--border); }
.settings-row:active { background: var(--bg-input); }
.settings-row.danger { color: var(--need-color); }
.settings-credit { font-size: 12px; color: var(--text-muted); text-align: center; margin: 8px 0 20px; letter-spacing: 0.02em; }

/* ── Photos ── */
.photo-section { margin-bottom: 16px; }
.photo-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.photo-thumb-wrap { position: relative; }
.photo-thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; cursor: pointer; border: 1.5px solid var(--border); }
.photo-remove { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; background: var(--need-color); color: #fff; border-radius: 50%; font-size: 13px; display: flex; align-items: center; justify-content: center; line-height: 1; }
.add-photo-btn { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--accent); padding: 8px 14px; border-radius: 50px; border: 1.5px solid var(--accent); cursor: pointer; transition: background 0.15s; }
.add-photo-btn:active { background: var(--accent-light); }
.hidden-file { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

/* ── Menu modal ── */
.modal-menu { padding: 16px; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 8px; font-size: 16px; font-weight: 500; color: var(--text-primary); border-bottom: 1px solid var(--border); transition: background 0.15s; }
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--bg-subtle); border-radius: 10px; }
.menu-item.danger { color: var(--need-color); }

/* ── Photo lightbox ── */
.modal-photo { background: rgba(0,0,0,0.95); border-radius: 0; padding: 0; display: flex; align-items: center; justify-content: center; min-height: 100vh; position: relative; }
.modal-photo img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.photo-close { position: absolute; top: 20px; right: 20px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.15); color: #fff; display: flex; align-items: center; justify-content: center; z-index: 10; }

/* ── Utilities ── */
.hidden { display: none !important; }
.verdict-pass { color: var(--need-color); }
.verdict-consider { color: var(--nice-color); }
.verdict-go { color: var(--accent); }
.verdict-strong { color: var(--accent); }

/* ── Install Banner ── */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 300;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
  animation: slide-up 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.install-banner-inner {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
}
.install-icon { font-size: 36px; flex-shrink: 0; }
.install-text { flex: 1; }
.install-text strong { display: block; font-size: 16px; font-weight: 600; margin-bottom: 3px; }
.install-text span { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.install-dismiss {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.install-action-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 600; font-size: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  transition: opacity 0.15s;
}
.install-action-btn:active { opacity: 0.85; }

/* iOS steps */
.ios-steps { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.ios-step {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; color: var(--text-secondary); line-height: 1.4;
}
.ios-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ios-share-icon { font-size: 16px; }

/* ── Toast ── */
.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 16px);
  left: 50%; transform: translateX(-50%) translateY(-80px);
  background: var(--text-primary);
  color: var(--bg);
  font-size: 14px; font-weight: 500;
  padding: 10px 20px;
  border-radius: 50px;
  white-space: nowrap;
  z-index: 400;
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.3s;
  pointer-events: none;
  opacity: 0;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
