:root {
  --bg: #faf8f5;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #5b6470;
  --line: #e3ded6;
  --accent: #9a3412;
  --visited: #c2410c;
  --transit: #fdba74;
  --danger: #b42318;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { min-height: 100vh; background: var(--bg); overflow-x: hidden; }
button, input { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 0.4rem 0.7rem; min-height: 36px; }
button:hover { border-color: #c9c1b5; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; color: var(--accent); text-decoration: underline; padding: 0.3rem 0; }
input { border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.6rem; min-height: 40px; width: 100%; background: #fff; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.loading { padding: 2rem; text-align: center; color: var(--muted); }

/* header */
.top { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.4rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); min-height: 52px; position: relative; z-index: 20; }
.brand { font-weight: 700; color: var(--accent); text-decoration: none; font-size: 1.1rem; white-space: nowrap; margin-right: auto; }
.top nav { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; order: 2; }
.top-right { display: flex; gap: 0.4rem; align-items: center; order: 3; }
.menu-toggle { display: none; align-items: center; gap: 0.4rem; }
.burger, .burger::before, .burger::after { display: block; width: 16px; height: 2px; background: currentColor; border-radius: 1px; position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -5px; }
.burger::after { top: 5px; }
@media (max-width: 960px) {
  .top { padding: 0.4rem 0.75rem; }
  .menu-toggle { display: inline-flex; }
  .top nav { display: none; order: 4; flex-basis: 100%; flex-direction: column; align-items: stretch; padding: 0.3rem 0 0.2rem; }
  .top.open nav { display: flex; }
  .top nav button { text-align: left; min-height: 42px; }
}
@media (max-width: 420px) {
  .menu-label { display: none; }
  .brand { font-size: 1rem; }
}
.top nav button.active { border-color: var(--accent); color: var(--accent); }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { border: none; border-radius: 0; min-width: 40px; }
.lang button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* auth */
.auth-page { max-width: 420px; margin: 2rem auto; padding: 0 1rem; }
.intro { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.auth { display: flex; flex-direction: column; gap: 0.8rem; }
.auth h1 { margin: 0 0 0.2rem; font-size: 1.4rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.auth-error { color: var(--danger); margin: 0; }
.notice { background: #fff7ed; border: 1px solid #fed7aa; padding: 0.5rem 0.8rem; border-radius: 8px; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 0.6rem 1rem; border-radius: 8px; z-index: 50; max-width: calc(100vw - 2rem); }

/* own view */
.own { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - 53px); }
.map-col { position: relative; min-width: 0; }
.side { overflow-y: auto; border-left: 1px solid var(--line); background: var(--card); padding: 0.8rem; }

/* map */
.map-area { position: relative; width: 100%; height: 100%; min-height: 300px; overflow: hidden; }
.map { position: absolute; inset: 0; }
.map-jumps { position: absolute; top: 8px; left: 8px; right: 140px; display: flex; flex-wrap: wrap; gap: 4px; z-index: 2; pointer-events: none; }
.map-jumps .jump { pointer-events: auto; font-size: 0.8rem; min-height: 30px; padding: 0.2rem 0.5rem; background: rgba(255,255,255,0.92); }
.map-toggle-wrap { position: absolute; top: 8px; right: 8px; z-index: 3; }
.map-toggle { font-weight: 600; background: var(--ink); color: #fff; border-color: var(--ink); min-height: 40px; padding: 0.4rem 0.8rem; box-shadow: 0 1px 4px rgba(0,0,0,0.25); }
.map-zoom { position: absolute; right: 8px; top: 60px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.map-download { position: absolute; right: 8px; bottom: 34px; z-index: 2; font-size: 0.85rem; min-height: 32px; padding: 0.2rem 0.6rem; background: rgba(255,255,255,0.95); }
.map-zoom-btn { width: 36px; height: 36px; padding: 0; font-size: 1.2rem; background: rgba(255,255,255,0.95); }
.map-legend { position: absolute; left: 8px; bottom: 8px; z-index: 2; background: rgba(255,255,255,0.95); border: 1px solid var(--line); border-radius: 8px; padding: 0.35rem 0.6rem; display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; max-width: calc(100% - 140px); align-items: center; font-size: 0.85rem; }
.legend-title { font-weight: 600; }
.legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.15); }
.map-tooltip { position: absolute; z-index: 4; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.35rem 0.6rem; font-size: 0.9rem; box-shadow: 0 2px 8px rgba(0,0,0,0.18); pointer-events: none; max-width: 260px; }
.map-tooltip.menu { pointer-events: auto; padding: 0.5rem; }
.menu-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.menu-close { border: none; min-height: 32px; min-width: 32px; font-size: 1.2rem; padding: 0; background: none; }
.menu-choices { display: flex; flex-direction: column; gap: 4px; }
.choice { display: flex; align-items: center; gap: 0.5rem; text-align: left; min-height: 40px; }
.choice[aria-pressed="true"] { border-color: var(--accent); font-weight: 600; }
.tip-visited { color: var(--visited); font-weight: 600; }
.tip-transit { color: #9a5b13; font-weight: 600; }
.maplibregl-ctrl-bottom-right { z-index: 2; }
.map-tooltip.menu { max-height: calc(100% - 16px); overflow-y: auto; min-width: 220px; }
.tip-mark { color: var(--accent); margin-left: 0.1rem; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem; margin: 0 0 0.5rem; font-size: 0.85rem; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }
.info-note { font-style: italic; }

/* footnotes in the lists */
.footnote { position: relative; display: inline-flex; }
.footnote-mark { border: none; background: none; color: var(--accent); font-weight: 700; padding: 0 0.3rem; min-height: 28px; min-width: 24px; font-size: 1rem; }
.footnote-text { position: absolute; top: 100%; left: 0; z-index: 5; width: max-content; max-width: min(280px, 70vw); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.35rem 0.55rem; font-size: 0.85rem; box-shadow: 0 2px 8px rgba(0,0,0,0.18); }

/* "About the data" */
body.modal-open { overflow: hidden; }
/* Below the header (z-index 20), so the menu and the language switch stay usable. */
.about-overlay { position: fixed; inset: 0; z-index: 15; background: rgba(20, 20, 20, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 70px 1rem 1.5rem; overflow-y: auto; }
.about-panel { background: var(--card); border-radius: var(--radius); max-width: 720px; width: 100%; padding: 1rem 1.2rem 1.2rem; box-shadow: 0 6px 30px rgba(0,0,0,0.3); overflow-wrap: anywhere; }
.about-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.about-head h2 { margin: 0; font-size: 1.3rem; }
.about-close { border: none; background: none; font-size: 1.5rem; min-width: 40px; min-height: 40px; padding: 0; }
.about-panel h3 { font-size: 1.05rem; margin: 1rem 0 0.4rem; }
.sources { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.source-name { font-weight: 600; color: var(--accent); }
.attribution { font-size: 0.9rem; }
.about-panel a { color: var(--accent); }
.footnotes { display: grid; grid-template-columns: minmax(0, 12rem) minmax(0, 1fr); gap: 0.3rem 0.8rem; margin: 0; font-size: 0.9rem; }
.footnotes dt { font-weight: 600; }
.footnotes dd { margin: 0; }
@media (max-width: 600px) {
  .about-overlay { padding: 53px 0 0; }
  .about-panel { border-radius: 0; min-height: 100%; padding: 0.8rem 1rem 1.5rem; }
  .footnotes { grid-template-columns: minmax(0, 1fr); }
  .footnotes dd { margin-bottom: 0.4rem; }
}

/* status dots, shared by lists and the touch menu */
.dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #b8aea0; background: transparent; }
[data-status="transit"] > .cycle .dot, .choice-transit .dot { background: var(--transit); border-color: #e59a52; }
[data-status="visited"] > .cycle .dot, .choice-visited .dot { background: var(--visited); border-color: var(--visited); }

/* stats */
.stats h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.stat { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.stat-label { font-weight: 600; }
.v-been { font-weight: 600; }
.sep { color: var(--muted); }
.v-visited { color: var(--visited); }
.v-transit { color: #9a5b13; }
.by-continent { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.by-continent summary { cursor: pointer; font-weight: 600; }
.by-continent table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 0.3rem; }
.by-continent th, .by-continent td { text-align: left; padding: 0.15rem 0.3rem; }

/* sharing */
.sharing { padding-bottom: 0.6rem; margin-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
.sharing h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.sharing-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; }
.sharing-status { margin: 0; font-weight: 600; }
.sharing-status::before { content: ''; display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.4rem; background: #8a8f98; vertical-align: 0.05rem; }
.sharing-status[data-state="users"]::before { background: #2f7d32; }
.sharing-status[data-state="link"]::before, .sharing-status[data-state="users-link"]::before { background: #c2410c; }
.make-private[hidden] { display: none; }
.toggle label { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; cursor: pointer; min-height: 36px; }
.toggle input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); }
.toggle p { margin: 0 0 0.4rem 1.75rem; }
.publish-link { display: block; overflow-wrap: anywhere; color: var(--accent); margin: 0.2rem 0 0.3rem 1.75rem; }
.publish-actions { display: flex; gap: 0.6rem; align-items: center; margin-left: 1.75rem; flex-wrap: wrap; }

/* users list and other users' maps */
.user-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; max-width: 420px; }
.user-link { width: 100%; text-align: left; font-weight: 600; }
.viewing h1 { font-size: 1.2rem; margin: 0.3rem 0 0.6rem; }

/* lists */
.lists { margin-top: 0.8rem; }
/* Wide screens show both lists, one under the other; narrow screens use the tabs. */
.tabs { display: none; gap: 0.3rem; margin-bottom: 0.5rem; }
.panel + .panel { margin-top: 1.2rem; }
.panel-title { font-size: 1.05rem; margin: 0 0 0.4rem; }
.tabs [role="tab"] { flex: 1; }
.tabs [aria-selected="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.panel input[type="search"] { margin-bottom: 0.4rem; }
.list { list-style: none; margin: 0; padding: 0; }
.group h3 { font-size: 0.95rem; margin: 0.8rem 0 0.2rem; color: var(--muted); }
.group ul { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 0.4rem; padding: 0.1rem 0; min-height: 36px; }
.row.nested { padding-left: 1.4rem; }
.row .cycle { border: none; background: none; padding: 0; min-height: 34px; min-width: 34px; display: inline-flex; align-items: center; justify-content: center; }
.row .cycle.readonly { cursor: default; }
.row .name { border: none; background: none; padding: 0.2rem 0.2rem; text-align: left; min-height: 32px; flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.row .status-text { margin-left: auto; }
.row .name:hover { text-decoration: underline; }
.status-text { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.no-match { margin: 0.5rem 0; }

/* admin */
.page { max-width: 900px; margin: 1rem auto; padding: 0 1rem; }
.invite-code { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.05em; }
.table-wrap { overflow-x: auto; }
.users { width: 100%; border-collapse: collapse; }
.users th, .users td { text-align: left; padding: 0.35rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pw-cell { display: flex; gap: 0.3rem; }
.pw-cell input { min-width: 140px; }

@media (max-width: 800px) {
  .own { display: block; height: auto; }
  .map-col { height: 60vh; min-height: 320px; }
  .side { border-left: none; border-top: 1px solid var(--line); overflow: visible; }
  .tabs { display: flex; }
  .panel.inactive, .panel-title { display: none; }
  .panel + .panel { margin-top: 0; }
  /* Phone map: the region buttons stay on one line that scrolls sideways inside the map;
     the download button sits under the zoom buttons; the legend sits bottom-left without
     its title and the credits are folded into their (i) button, so nothing overlaps. */
  .map-jumps { right: 118px; flex-wrap: nowrap; overflow-x: auto; pointer-events: auto; scrollbar-width: none; padding-bottom: 2px; }
  .map-jumps::-webkit-scrollbar { display: none; }
  .map-jumps .jump { font-size: 0.75rem; padding: 0.15rem 0.45rem; flex: none; white-space: nowrap; }
  .map-toggle { font-size: 0.85rem; padding: 0.3rem 0.6rem; min-height: 34px; }
  .map-zoom { top: 50px; }
  .map-download { top: 134px; bottom: auto; font-size: 0.75rem; min-height: 30px; padding: 0.15rem 0.45rem; }
  .map-legend { bottom: 6px; left: 6px; gap: 0.5rem; padding: 0.25rem 0.5rem; font-size: 0.8rem; max-width: calc(100% - 60px); }
  .map-legend .legend-title { display: none; }
  .maplibregl-ctrl-attrib.maplibregl-compact-show { max-width: calc(100% - 20px); }
  .map-tooltip.menu { left: 8px !important; right: 8px; top: auto !important; bottom: 8px; max-width: none; }
  .row .name { padding: 0.2rem 0.1rem; }
}

/* Feedback (Amendment 7): the form, and the admin's list. Feedback text is plain text. */
.feedback-panel { max-width: 560px; }
.feedback-form { display: flex; flex-direction: column; gap: 0.5rem; }
.feedback-kinds { border: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.feedback-kinds legend { font-weight: 600; padding: 0; margin-bottom: 0.3rem; }
.feedback-kind { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 36px; cursor: pointer; }
.feedback-kind input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.feedback-form .field span { font-weight: 600; }
.feedback-form textarea { font: inherit; width: 100%; box-sizing: border-box; padding: 0.5rem; border: 1px solid var(--line); border-radius: 8px; resize: vertical; min-height: 8rem; }
.feedback-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.feedback-list .feedback-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 14rem; vertical-align: top; }
.feedback-list td { vertical-align: top; }
.feedback-list tr.done td { color: var(--muted); }
.feedback-list .nowrap { white-space: nowrap; }
.done-toggle { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; min-height: 36px; }
.done-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
/* On a phone each feedback entry is a small card: user · date · type on one line, then the rest. */
@media (max-width: 600px) {
  .feedback-list thead { display: none; }
  .feedback-list, .feedback-list tbody, .feedback-list tr { display: block; width: auto; }
  .feedback-list tr { border-bottom: 1px solid var(--line); padding: 0.5rem 0; }
  .feedback-list td { display: block; border: none; padding: 0.1rem 0; }
  .feedback-list td:nth-child(-n+3) { display: inline-block; margin-right: 0.6rem; font-weight: 600; }
  .feedback-list td.feedback-text { min-width: 0; padding: 0.3rem 0; }
}
