@font-face { font-family: "Jost"; src: url("fonts/jost/jost-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Jost"; src: url("fonts/jost/jost-700.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Jost"; src: url("fonts/jost/jost-300.ttf") format("truetype"); font-weight: 300; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --ink: #23201c;
  --ink-2: #5d574f;
  --ink-3: #8b847a;
  --line: #e4dfd7;
  --line-2: #d3ccc1;
  --accent: #a0522d;
  --accent-ink: #ffffff;
  --accent-soft: #f6e9e1;
  --ok: #2f7d4f;
  --warn: #9a6400;
  --err: #b3261e;
  --err-soft: #fbeceb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(35, 32, 28, .06), 0 2px 8px rgba(35, 32, 28, .05);
  --font: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

/* ── top bar ─────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
.brand p { margin: 0; font-size: 13px; color: var(--ink-2); }
.logo { width: 34px; height: 34px; fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; }
.logo circle { fill: var(--accent); }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── layout ──────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: minmax(360px, 460px) 1fr; height: calc(100vh - 61px); }
.panel { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--bg); }
#form { flex: 1; overflow-y: auto; padding: 14px 14px 4px; }
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px 18px; gap: 10px; }

/* ── cards ───────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 12px;
  margin-bottom: 12px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px; }
.num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink); font-size: 12px; letter-spacing: 0; }

.field { display: block; margin: 0 0 10px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.field.inline { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.field.inline > span { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; gap: 6px; }
.row input { flex: 1; min-width: 0; }
.hint { display: block; color: var(--ink-3); font-size: 12.5px; margin: 4px 0 0; }
.empty { color: var(--ink-3); font-size: 13.5px; margin: 10px 0; text-align: center; }

input[type=text], input[type=url], input[type=search], input[type=number], select {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=number] { appearance: textfield; }
.check { display: flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; margin: 4px 0; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

button, .button { cursor: pointer; border-radius: 7px; border: 1px solid transparent; padding: 7px 12px; background: none;
  font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary-soft { background: var(--accent-soft); color: var(--accent); }
.secondary { background: var(--surface); border-color: var(--line-2); }
.secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ghost { color: var(--ink-2); }
.ghost:hover { background: var(--surface-2); color: var(--ink); }
.small { padding: 4px 9px; font-size: 13px; }
.wide { width: 100%; margin-top: 10px; }
.icon { width: 28px; height: 28px; padding: 0; color: var(--ink-3); }
.icon:hover { background: var(--surface-2); color: var(--ink); }
.icon.del:hover { color: var(--err); }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border-radius: 0; padding: 5px 11px; font-size: 13.5px; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); }

.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12.5px; margin: 12px 0 10px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ── place search ────────────────────────────────────────── */
.search { position: relative; }
.search-results { position: absolute; z-index: 1000; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 280px; overflow: auto; }
.search-results li { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.search-results li small { display: block; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results li:hover, .search-results li.active { background: var(--accent-soft); }

/* ── stops ───────────────────────────────────────────────── */
.stops { list-style: none; margin: 12px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stop { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.stop.via { opacity: .75; border-style: dashed; }
.stop-main { display: flex; align-items: center; gap: 6px; padding: 5px 6px; }
.stop-badge { flex: none; display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; }
.stop-name { flex: 1; min-width: 0; padding: 5px 7px !important; }
.nights { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); }
.nights input { width: 46px !important; padding: 5px 4px !important; text-align: center; }
.stop-tools { display: flex; }
.stop-extra { padding: 4px 10px 10px 36px; border-top: 1px dashed var(--line); }
.stop-flags { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.coords { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sights { margin-top: 6px; }
.sights-title { font-size: 12.5px; color: var(--ink-2); }
.sight-list { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-wrap: wrap; gap: 5px; }
.sight-list li { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 14px; padding: 2px 4px 2px 9px; font-size: 13px; }
.sight-list li button { width: 20px; height: 20px; padding: 0; font-size: 11px; color: var(--ink-3); border-radius: 50%; }
.sight-list li button:hover { color: var(--err); background: var(--err-soft); }
.sight-add { display: flex; gap: 5px; }
.sight-add input { flex: 1; min-width: 0; }
.sight-add select { width: 120px; }

.route-summary { margin-top: 10px; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.route-summary table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.route-summary td { padding: 1px 0; }
.route-summary td:nth-child(2), .route-summary td:nth-child(3) { text-align: right; color: var(--ink-2); white-space: nowrap; padding-left: 8px; }
.route-summary .total { font-weight: 700; border-top: 1px solid var(--line); }
.route-summary .warn { color: var(--warn); font-size: 12.5px; margin: 6px 0 0; }

/* ── themes ──────────────────────────────────────────────── */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.theme { border: 2px solid transparent; border-radius: 8px; padding: 4px; background: none; display: flex; flex-direction: column;
  align-items: stretch; gap: 4px; font-size: 12px; color: var(--ink-2); white-space: normal; text-align: center; line-height: 1.2; }
.theme svg { width: 100%; height: auto; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.theme:hover { background: var(--surface-2); }
.theme[aria-checked=true] { border-color: var(--accent); color: var(--ink); font-weight: 600; }
.toggles { display: grid; grid-template-columns: 1fr; gap: 2px; }

/* ── products ────────────────────────────────────────────── */
.products { display: grid; gap: 6px; margin-bottom: 10px; }
.product { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; text-align: left; white-space: normal;
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; background: var(--surface); }
.product input { margin-top: 3px; accent-color: var(--accent); }
.product strong { font-size: 14px; }
.product small { grid-column: 2; color: var(--ink-3); font-size: 12.5px; }
.product.selected { border-color: var(--accent); background: var(--accent-soft); }
.badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 9px; font-size: 11px; background: var(--accent); color: #fff;
  vertical-align: 1px; font-weight: 500; }
.print-summary { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin-top: 8px; }
.print-summary b { color: var(--ink); font-weight: 600; }
.print-summary .warn { color: var(--warn); }

.actions { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.actions button { flex: 1; padding: 10px 12px; }

/* ── stage ───────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border-radius: 7px 7px 0 0; padding: 7px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { flex: 1; min-height: 0; overflow: auto; position: relative; }
#map { position: absolute; inset: 0; border-radius: var(--radius); border: 1px solid var(--line); }
.placeholder { display: grid; place-content: center; text-align: center; height: 100%; color: var(--ink-2); max-width: 520px; margin: 0 auto; padding: 20px; }

.poster-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 0 20px; }
.poster-figure img { max-width: 100%; max-height: calc(100vh - 250px); box-shadow: 0 4px 22px rgba(0,0,0,.22); background: #fff; }
.poster-figure figcaption { font-size: 13px; color: var(--ink-3); }
.download { margin: 0 auto 20px; max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); }
.download h3 { margin: 0 0 6px; font-size: 16px; }
.download dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 12px; font-size: 13.5px; }
.download dt { color: var(--ink-3); }
.download dd { margin: 0; }
.download a.primary { text-decoration: none; padding: 9px 16px; border-radius: 7px; display: inline-block; }

.themes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; padding: 8px 2px 20px; }
.themes-grid figure { margin: 0; cursor: pointer; text-align: center; font-size: 13px; color: var(--ink-2); border-radius: 8px; padding: 6px;
  border: 2px solid transparent; }
.themes-grid figure:hover { background: var(--surface); }
.themes-grid figure.selected { border-color: var(--accent); color: var(--ink); font-weight: 600; }
.themes-grid img { width: 100%; box-shadow: 0 2px 10px rgba(0,0,0,.18); display: block; margin-bottom: 6px; }

/* ── job and messages ────────────────────────────────────── */
.job { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); }
.job-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.job-step { color: var(--ink-2); font-size: 13.5px; margin-left: 6px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0 4px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.progress.indeterminate div { width: 30%; animation: slide 1.4s infinite ease-in-out; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }
.job details summary { cursor: pointer; font-size: 12.5px; color: var(--ink-3); }
.job pre { max-height: 220px; overflow: auto; background: #1f1d1a; color: #e9e4dc; font-size: 12px; padding: 8px 10px; border-radius: 6px;
  white-space: pre-wrap; margin: 6px 0 0; }
.message { border-radius: var(--radius); padding: 10px 14px; font-size: 14px; white-space: pre-wrap; }
.message.error { background: var(--err-soft); color: var(--err); border: 1px solid #f1c7c4; }
.message.info { background: var(--accent-soft); color: var(--ink); border: 1px solid #ecd3c4; }

.leaflet-container { font: 13px var(--font); }
.stop-marker { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 700; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.stop-marker.via { width: 14px; height: 14px; background: #fff; border: 2px solid var(--ink); font-size: 0; }
.stop-marker.end { background: var(--accent); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; }
  #form { overflow: visible; }
  .actions { position: sticky; bottom: 0; z-index: 1001; }
  .stage { min-height: 80vh; padding: 12px; }
  .tab-panel[data-panel=map] { min-height: 60vh; }
  .topbar { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .top-actions { flex-wrap: nowrap; gap: 0; }
  .top-actions .ghost { padding: 6px 8px; }
  .brand p { display: none; }
}
