/* ---------- Design tokens ---------- */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --text: #1f2430;
  --muted: #5f6675;
  --border: #e4ddd1;
  --accent: #d9572b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe5da;
  --teal: #1f7a74;
  --teal-soft: #d9efec;
  --good: #2f8a4c;
  --warn: #a8611a;
  --warn-soft: #fbecd9;
  --ring-track: #ece6dc;
  --shadow: 0 1px 2px rgba(31, 36, 48, 0.06), 0 6px 20px rgba(31, 36, 48, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --brand: "Instrument Serif", "Fraunces", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c;
    --surface: #1c1f27;
    --surface-2: #252935;
    --text: #eef0f4;
    --muted: #a3a9b7;
    --border: #323746;
    --accent: #f07a4f;
    --accent-ink: #1a0f0a;
    --accent-soft: #3b2219;
    --teal: #5cc4bb;
    --teal-soft: #173634;
    --good: #6bcf8a;
    --warn: #f0b072;
    --warn-soft: #3a2a17;
    --ring-track: #2c3140;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14161c;
  --surface: #1c1f27;
  --surface-2: #252935;
  --text: #eef0f4;
  --muted: #a3a9b7;
  --border: #323746;
  --accent: #f07a4f;
  --accent-ink: #1a0f0a;
  --accent-soft: #3b2219;
  --teal: #5cc4bb;
  --teal-soft: #173634;
  --good: #6bcf8a;
  --warn: #f0b072;
  --warn-soft: #3a2a17;
  --ring-track: #2c3140;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 0.4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 0.8em; }
a { color: var(--teal); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

.container { max-width: 1120px; margin: 0 auto; padding-block: 24px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); outline: none; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; font-weight: 700; color: var(--accent); margin-bottom: 8px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar__inner { max-width: 1120px; margin: 0 auto; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; margin-right: auto; }
.brand__mark { font-size: 1.4rem; }
.brand__text { display: flex; flex-direction: column; line-height: 1; }
.brand__name { font-family: var(--brand); font-weight: 400; font-size: 1.6rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand__sub { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tab { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.92rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.tab[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 0.72rem; padding: 0 7px; min-width: 20px; text-align: center; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; flex: none; }

@media (max-width: 560px) {
  .brand__mark, .brand__sub { display: none; }
  .brand__name { font-size: 1.15rem; white-space: normal; max-width: 6.5em; line-height: 0.95; }
  .tab { padding: 6px 10px; }
}

/* ---------- Buttons ---------- */
.btn { border: 1px solid transparent; border-radius: 999px; padding: 11px 20px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: transform 0.08s ease, background 0.15s ease; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.05); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 6px 12px; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: center; padding: 24px 0 8px; }
.hero__lead { font-size: 1.1rem; color: var(--muted); max-width: 52ch; }
.hero__art { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hero__tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.hero__tile span { display: block; font-size: 1.8rem; }
.hero__tile small { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.steps-preview { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 22px; color: var(--muted); font-size: 0.9rem; }
.steps-preview b { color: var(--text); }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; } }

/* ---------- Wizard ---------- */
.wizard { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 28px; max-width: 860px; margin: 8px auto 0; }
.progress { display: flex; gap: 6px; margin-bottom: 22px; }
.progress__seg { flex: 1; height: 6px; border-radius: 999px; background: var(--ring-track); overflow: hidden; }
.progress__seg.is-done { background: var(--accent); }
.progress__seg.is-current { background: linear-gradient(90deg, var(--accent) 50%, var(--ring-track) 50%); }
.wizard__head { margin-bottom: 18px; }
.wizard__foot { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; gap: 10px; flex-wrap: wrap; }
.field { margin-bottom: 22px; }
.field__label { font-weight: 700; margin-bottom: 10px; display: block; }
.field__hint { color: var(--muted); font-size: 0.9rem; font-weight: 400; }
@media (max-width: 560px) { .wizard { padding: 20px 16px; border-radius: 16px; } }

.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.choice-grid--wide { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.choice { position: relative; text-align: left; border: 1.5px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: border-color 0.15s, background 0.15s; min-height: 64px; }
.choice:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.choice[aria-pressed="true"], .choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.choice__icon { font-size: 1.5rem; }
.choice__title { font-weight: 700; }
.choice__sub { font-size: 0.85rem; color: var(--muted); }
.choice__level { position: absolute; top: 10px; right: 10px; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.choice[data-level="1"] .choice__level { background: var(--teal); color: var(--surface); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.chip--exclude[aria-pressed="true"] { border-color: var(--muted); background: var(--surface-2); text-decoration: line-through; color: var(--muted); }

.select { width: 100%; max-width: 360px; padding: 11px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.input { width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }

/* ---------- Results ---------- */
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 8px 0 18px; }
.summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.summary button { border: 1px dashed var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 0.82rem; color: var(--muted); cursor: pointer; }
.summary button:hover { color: var(--text); border-style: solid; }

.section { margin-top: 34px; }
.section__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.region-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.region-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; gap: 12px; align-items: center; cursor: pointer; text-align: left; box-shadow: var(--shadow); }
.region-card[aria-pressed="true"] { border-color: var(--accent); outline: 2px solid var(--accent); }
.region-card__rank { font-family: var(--display); font-size: 1.2rem; color: var(--muted); width: 22px; flex: none; }
.region-card__name { font-weight: 700; line-height: 1.25; }
.region-card__sub { font-size: 0.8rem; color: var(--muted); }
.region-card .ring { margin-left: auto; }

.ring { --v: 0; --size: 50px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; background: conic-gradient(var(--accent) calc(var(--v) * 1%), var(--ring-track) 0); display: grid; place-items: center; }
.ring::before { content: ""; grid-area: 1 / 1; width: calc(var(--size) - 10px); height: calc(var(--size) - 10px); border-radius: 50%; background: var(--surface); }
.ring span { grid-area: 1 / 1; position: relative; font-weight: 700; font-size: 0.9rem; }
.ring--lg { --size: 64px; }
.ring--lg span { font-size: 1.1rem; }

.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
@media (max-width: 400px) { .cards { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card--top { border-color: var(--accent); }
.card__head { display: flex; gap: 12px; align-items: flex-start; }
.card__flag { font-size: 2.2rem; line-height: 1; }
.card__title { flex: 1; min-width: 0; }
.card__title h3 { margin: 0; }
.card__meta { font-size: 0.85rem; color: var(--muted); }
.card__blurb { color: var(--muted); font-size: 0.95rem; margin: 0; }
.pill { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); margin-left: 6px; vertical-align: middle; }

.reasons { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 0.9rem; }
.reasons li { display: flex; gap: 8px; }
.reasons li::before { content: "✓"; color: var(--good); font-weight: 700; }
.reasons li.warn::before { content: "!"; color: var(--warn); }
.reasons li.warn { color: var(--warn); }

.facts { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.82rem; }
.fact { background: var(--surface-2); border-radius: 8px; padding: 3px 8px; color: var(--muted); }
.fact b { color: var(--text); font-weight: 600; }

.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.months span { font-size: 0.62rem; text-align: center; padding: 3px 0; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.months span.is-best { background: var(--teal-soft); color: var(--teal); font-weight: 700; }
.months span.is-sel { outline: 2px solid var(--accent); outline-offset: -2px; }

.itinerary { border-top: 1px dashed var(--border); padding-top: 12px; }
.itinerary__title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.itinerary__bar { display: flex; border-radius: 10px; overflow: hidden; height: 34px; }
.itinerary__seg { display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; color: #fff; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; border: 0; cursor: pointer; }
.itinerary__seg:nth-child(1) { background: #d9572b; }
.itinerary__seg:nth-child(2) { background: #1f7a74; }
.itinerary__seg:nth-child(3) { background: #7a5ab8; }
.itinerary__seg:nth-child(4) { background: #b8862b; }
.itinerary__legend { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.85rem; }
.itinerary__legend li { display: flex; align-items: center; gap: 6px; }
.itinerary__legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.itinerary__legend button { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.itinerary__legend button:hover { text-decoration: underline; }
.itinerary__pair { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

.city-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
details.more { min-width: 0; }
.city-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.city-row__main { flex: 1; min-width: 0; border: 0; background: none; text-align: left; cursor: pointer; padding: 0; }
.city-row__name { font-weight: 600; display: block; }
.city-row__blurb { font-size: 0.8rem; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-chip { font-weight: 700; font-size: 0.82rem; padding: 2px 8px; border-radius: 999px; background: var(--surface); flex: none; }

.heart { border: 0; background: none; cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 4px; flex: none; color: var(--muted); }
.heart[aria-pressed="true"] { color: var(--accent); }

.card__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

details.more summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--teal); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "▸ "; }
details.more[open] summary::before { content: "▾ "; }
details.more > *:not(summary) { margin-top: 10px; }

.top-cities { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.city-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.city-card__main { flex: 1; min-width: 0; border: 0; background: none; text-align: left; cursor: pointer; padding: 0; }
.city-card__name { font-weight: 700; }
.city-card__sub { font-size: 0.82rem; color: var(--muted); }
.city-card .ring { --size: 44px; }

/* ---------- Tag bars ---------- */
.tagbars { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; font-size: 0.85rem; }
.tagbar { height: 8px; border-radius: 999px; background: var(--ring-track); overflow: hidden; }
.tagbar span { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.tagbar.is-liked span { background: var(--accent); }

/* ---------- Explore ---------- */
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); position: sticky; top: 62px; z-index: 10; }
.filters label { font-size: 0.75rem; font-weight: 700; color: var(--muted); display: grid; gap: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.filters .select, .filters .input { max-width: none; padding: 9px 10px; }
@media (max-width: 860px) { .filters { grid-template-columns: 1fr 1fr; position: static; } .filters label:first-child { grid-column: 1 / -1; } }
.region-block { margin-top: 30px; }
.region-block__head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.region-block__icon { font-size: 1.6rem; }
.empty { text-align: center; padding: 50px 16px; color: var(--muted); }
.empty__icon { font-size: 2.4rem; }

/* ---------- Shortlist ---------- */
.compare-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.compare { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 0.9rem; }
.compare th, .compare td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.compare thead th { background: var(--surface-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.compare tbody tr:last-child td { border-bottom: 0; }
.dots { letter-spacing: 1px; color: var(--accent); white-space: nowrap; }
.dots i { color: var(--ring-track); font-style: normal; }

/* ---------- Detail dialog ---------- */
.detail { border: 0; padding: 0; border-radius: 20px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.detail::backdrop { background: rgba(10, 12, 18, 0.55); }
.detail__body { padding: 24px; display: grid; gap: 16px; }
.detail__close { position: absolute; top: 12px; right: 12px; }
.detail__hero { display: flex; gap: 14px; align-items: center; padding-right: 40px; }
.detail__hero .card__flag { font-size: 2.8rem; }
.temps { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 110px; }
.temps__col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; }
.temps__bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--ring-track); min-height: 4px; }
.temps__col.is-best .temps__bar { background: var(--teal); }
.temps__col.is-sel .temps__bar { background: var(--accent); }
.temps__val { font-size: 0.62rem; color: var(--muted); }
.temps__m { font-size: 0.62rem; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 0.78rem; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Toast & footer ---------- */
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translate(-50%, 30px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.footer { max-width: 1120px; margin: 0 auto; padding-block: 0 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); color: var(--muted); font-size: 0.82rem; text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Compare table becomes stacked cards on phones. */
@media (max-width: 680px) {
  table.compare { min-width: 0; }
  .compare thead { display: none; }
  .compare, .compare tbody, .compare tr, .compare td { display: block; width: 100%; }
  .compare tr { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .compare tbody tr:last-child { border-bottom: 0; }
  .compare td { border: 0; padding: 2px 0; }
  .compare td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 0.8rem; }
  .compare td:last-child { position: absolute; top: 10px; right: 10px; width: auto; }
  .compare td .ring { --size: 40px; }
}

/* Band above the sticky header on phones with a notch. */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
.share-box { display: grid; gap: 6px; max-width: 640px; margin-top: -4px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.footer__copy { margin: 6px 0 0; font-family: var(--brand); font-size: 1rem; color: var(--text); }
