:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text2: #6e6e73;
  --accent: #4f46e5;
  --accent2: #7c3aed;
  --border: rgba(0, 0, 0, 0.08);
  --star: #f5b100;
  --danger: #d70015;
  --tabbar-h: 64px;
  --shadow: 0 1px 2px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.05);
  /* City palette — validated (dataviz six checks); Brussels orange carries a
     light-mode contrast WARN, so it must always appear next to a text label. */
  --c-london: #e0342c;
  --c-brussels: #e8850c;
  --c-paris: #0a84ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --text2: #98989f;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 1px 2px rgba(0,0,0,0.3);
    --c-brussels: #d97706; /* dark-mode step, validated against #1c1c1e */
  }
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

main { max-width: 720px; margin: 0 auto; }

h1 { font-size: 2rem; padding: 18px 16px 10px; letter-spacing: -0.02em; }
h2 { font-size: 0.85rem; text-transform: uppercase; color: var(--text2); padding: 18px 16px 6px; letter-spacing: 0.03em; }

.panel { display: none; padding-bottom: calc(var(--tabbar-h) + 24px); }
.panel.active { display: block; animation: panel-in 0.25s ease; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Today ---------- */
.hero {
  margin: 14px 16px 12px;
  border-radius: 22px;
  padding: 26px 22px;
  color: #fff;
  background:
    radial-gradient(120% 160% at 85% -20%, rgba(255,255,255,0.28), transparent 45%),
    linear-gradient(135deg, var(--accent), var(--accent2) 60%, #a855f7);
  box-shadow: 0 8px 28px rgba(79, 70, 229, 0.35);
}
.hero-kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; }
.hero-title { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; margin: 2px 0; }
.hero-sub { font-size: 0.95rem; opacity: 0.9; }
.hero-chip {
  display: inline-block; margin-top: 14px; padding: 7px 14px; border-radius: 999px;
  background: rgba(255,255,255,0.18); backdrop-filter: blur(6px);
  font-size: 0.88rem; font-weight: 650; border: 1px solid rgba(255,255,255,0.25);
}
.hero-chip:empty { display: none; }

.sync-pill {
  display: block; margin: 0 16px 12px; width: calc(100% - 32px);
  border: none; border-radius: 12px; padding: 11px 14px; text-align: left;
  background: var(--card); color: var(--text2); font-size: 0.86rem; font-weight: 550;
  cursor: pointer; box-shadow: var(--shadow);
}
.sync-pill.ok { color: #1d8a3e; }
.sync-pill.error { color: var(--danger); }
@media (prefers-color-scheme: dark) { .sync-pill.ok { color: #34c759; } }

.today-label { font-size: 0.85rem; text-transform: uppercase; color: var(--text2); padding: 8px 16px 2px; letter-spacing: 0.03em; font-weight: 650; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 12px 16px; }
.stat-tile { background: var(--card); border-radius: 16px; padding: 14px 12px; box-shadow: var(--shadow); }
.stat-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); }
.stat-value { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.02em; margin-top: 2px; }
.stat-value small { font-size: 0.95rem; font-weight: 600; color: var(--text2); }

.card { background: var(--card); border-radius: 16px; margin: 12px 16px; padding: 16px; box-shadow: var(--shadow); }
.card-title { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); margin-bottom: 12px; }

.prog-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.prog-label { min-width: 108px; font-size: 0.88rem; font-weight: 600; }
.prog-track { flex: 1; height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.prog-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.prog-num { min-width: 44px; text-align: right; font-size: 0.82rem; font-variant-numeric: tabular-nums; color: var(--text2); }

/* ---------- Controls ---------- */
.controls { padding: 0 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.controls-row { display: flex; gap: 8px; align-items: stretch; }
#search, .text-input {
  width: 100%; padding: 11px 14px; border: none; border-radius: 12px;
  background: var(--card); color: var(--text); font-size: 1rem;
  box-shadow: var(--shadow);
}
.text-input { background: var(--bg); box-shadow: none; margin-bottom: 12px; }
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 3px; flex: 1; box-shadow: var(--shadow); }
.seg button {
  flex: 1; border: none; background: transparent; padding: 8px 4px; border-radius: 9px;
  font-size: 0.85rem; color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background 0.15s ease;
}
.seg button.on { background: var(--accent); color: #fff; }
.icon-btn {
  border: none; border-radius: 12px; background: var(--card); color: var(--text2);
  font-size: 1.2rem; padding: 0 14px; cursor: pointer; box-shadow: var(--shadow);
}
.icon-btn.on { color: var(--star); }

/* ---------- Sights ---------- */
.city-header { padding: 16px 16px 6px; font-size: 0.9rem; font-weight: 600; color: var(--text2); }
.card-list { margin: 0 16px; background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.sight-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s ease;
}
.sight-row:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.sight-row:last-child { border-bottom: none; }
.sight-row.visited { opacity: 0.55; }
.badge {
  width: 36px; height: 36px; min-width: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.sight-info { flex: 1; min-width: 0; }
.sight-name { font-weight: 600; }
.sight-name .check { color: #34c759; font-size: 0.85em; margin-left: 4px; }
.sight-sub { font-size: 0.8rem; color: var(--text2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.star-btn { border: none; background: none; font-size: 1.4rem; color: var(--border); cursor: pointer; padding: 4px; transition: transform 0.15s ease; }
.star-btn:active { transform: scale(1.3); }
.star-btn.on { color: var(--star); }
.empty { text-align: center; color: var(--text2); padding: 48px 24px; }

/* ---------- Map ---------- */
.map-seg { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 500; max-width: 480px; margin: 0 auto; }
#panel-map { position: relative; padding-bottom: 0; }
#map { height: calc(100dvh - var(--tabbar-h)); }
.pin {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 0.95rem; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  border: 2px solid #fff;
}
.pin.fav { outline: 3px solid var(--star); }

/* ---------- Itinerary ---------- */
.day-card { margin: 10px 16px; background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.day-head { display: flex; gap: 12px; align-items: center; }
.day-date {
  min-width: 52px; text-align: center; border-radius: 12px; padding: 6px 4px;
  font-weight: 750; font-size: 1.2rem; line-height: 1.1;
}
.day-date small { display: block; font-size: 0.6rem; letter-spacing: 0.05em; }
.day-title { flex: 1; }
.day-title input[type="text"] {
  width: 100%; border: none; background: transparent; color: var(--text);
  font-size: 1.05rem; font-weight: 650; padding: 2px 0;
}
.day-meta { display: flex; gap: 8px; margin-top: 2px; }
.day-meta select, .day-meta input[type="date"] {
  border: none; background: var(--bg); color: var(--text2); border-radius: 6px;
  font-size: 0.78rem; padding: 2px 6px;
}
.day-card ul { list-style: none; margin-top: 10px; padding: 0; }
.day-card li { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.day-card li input[type="checkbox"] { width: 18px; height: 18px; accent-color: #34c759; }
.day-card li input[type="text"] {
  flex: 1; border: none; background: transparent; color: var(--text); font-size: 0.92rem; padding: 2px 0;
}
.day-card li.done input[type="text"] { text-decoration: line-through; color: var(--text2); }
.mini-btn { border: none; background: none; color: var(--text2); cursor: pointer; font-size: 0.95rem; padding: 2px 6px; }
.add-activity { display: flex; gap: 8px; margin-top: 6px; }
.add-activity input {
  flex: 1; border: none; background: var(--bg); border-radius: 8px;
  padding: 7px 10px; color: var(--text); font-size: 0.9rem;
}
.day-notes {
  width: 100%; margin-top: 10px; border: none; background: var(--bg); border-radius: 8px;
  padding: 8px 10px; color: var(--text); font-size: 0.88rem; font-family: inherit; resize: vertical; min-height: 34px;
}
.row-buttons { display: flex; gap: 10px; padding: 14px 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; border: none; background: var(--accent); color: #fff;
  border-radius: 12px; padding: 11px 16px; font-size: 0.95rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.3);
}
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); box-shadow: none; }
.file-btn { margin: 4px 16px 0; }

/* ---------- Docs ---------- */
.doc-list { margin: 0 16px; background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); text-decoration: none; }
.doc-row:last-child { border-bottom: none; }
.doc-icon { width: 36px; height: 36px; min-width: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1rem; background: var(--accent); color: #fff; }
.doc-icon.pdf { background: #e0342c; }
.doc-icon.img { background: #0a84ff; }
.doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { color: var(--text2); font-size: 0.8rem; padding: 14px 16px 0; line-height: 1.45; }
.hint code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* ---------- Guide ---------- */
.guide-group { margin: 10px 16px; }
.guide-group > .g-title { font-size: 0.9rem; font-weight: 600; color: var(--text2); padding: 8px 0 6px; }
.guide-group details { background: var(--card); border-bottom: 1px solid var(--border); padding: 12px 14px; }
.guide-group details:first-of-type { border-radius: 16px 16px 0 0; }
.guide-group details:last-of-type { border-radius: 0 0 16px 16px; border-bottom: none; }
.guide-group details:only-of-type { border-radius: 16px; }
.guide-group summary { font-weight: 600; cursor: pointer; }
.guide-group details p { margin-top: 8px; color: var(--text2); font-size: 0.92rem; line-height: 1.45; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabbar-h);
  display: flex; background: color-mix(in srgb, var(--card) 85%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); z-index: 1000;
}
.tabbar button {
  flex: 1; border: none; background: none; color: var(--text2); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.64rem;
}
.tabbar button .glyph { font-size: 1.25rem; }
.tabbar button.on { color: var(--accent); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 2000;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal.hidden, .hidden { display: none; }
.modal-card {
  background: var(--card); width: 100%; max-width: 560px; max-height: 82dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up 0.25s ease;
}
@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
.modal-card h3 { font-size: 1.3rem; margin-bottom: 8px; }
.chips { display: flex; gap: 8px; margin-bottom: 10px; }
.chip { font-size: 0.75rem; font-weight: 600; border-radius: 999px; padding: 4px 10px; }
.modal-card .summary { margin-bottom: 12px; line-height: 1.45; color: var(--text2); font-size: 0.92rem; }
.tipbox {
  display: flex; gap: 8px; background: rgba(245, 177, 0, 0.12); border-radius: 12px;
  padding: 10px 12px; font-size: 0.9rem; margin-bottom: 14px; line-height: 1.4;
}
.dir-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.dir-buttons a {
  text-align: center; text-decoration: none; padding: 11px 8px; border-radius: 12px;
  font-weight: 600; font-size: 0.9rem;
}
.dir-buttons a.primary { background: var(--accent); color: #fff; }
.dir-buttons a.secondary { background: var(--bg); color: var(--accent); }
.toggle-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle-buttons.single { grid-template-columns: 1fr; }
.toggle-buttons button {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 12px; padding: 10px 8px; font-weight: 600; font-size: 0.9rem; cursor: pointer;
}
.toggle-buttons button.on { border-color: transparent; }
.toggle-buttons button.star.on { background: rgba(245, 177, 0, 0.2); color: #a87b00; }
.toggle-buttons button.visit.on { background: rgba(52, 199, 89, 0.18); color: #1d8a3e; }
@media (prefers-color-scheme: dark) {
  .toggle-buttons button.star.on { color: var(--star); }
  .toggle-buttons button.visit.on { color: #34c759; }
}
.close-x { position: sticky; top: 0; float: right; border: none; background: var(--bg); color: var(--text2); width: 30px; height: 30px; border-radius: 50%; font-size: 1rem; cursor: pointer; }
