:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f2430;
  --line: #2a303c;
  --text: #e9edf5;
  --muted: #98a2b3;
  --accent: #4ea1ff;
  --accent-2: #ffb454;
  --danger: #ff6b6b;
  --ok: #45d483;
  --radius: 14px;
  --tab-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Heebo", system-ui, sans-serif;
  overscroll-behavior-y: none;
  overflow-x: hidden;
  width: 100%;
}

body {
  min-height: 100dvh;
  padding-top: calc(54px + env(safe-area-inset-top));
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(54px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(15, 17, 21, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.icon-btn {
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
}

.chev { color: var(--muted); font-size: 12px; }

.view { padding: 14px 14px 24px; max-width: 780px; margin: 0 auto; }

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(15, 17, 21, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 20;
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}

.tabbar a span { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--accent); }

h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 20px 0 10px; }
p.muted, .muted { color: var(--muted); }
small { color: var(--muted); }
small, p, div { overflow-wrap: anywhere; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  max-width: 100%;
}

.card.tight { padding: 11px 12px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

input, select, textarea, button {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
}

input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
}

textarea { min-height: 92px; resize: vertical; }
input[type="date"], input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  direction: ltr;
  text-align: right;
}

input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-fields-wrapper,
input[type="date"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-year-field,
input[type="time"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit-fields-wrapper,
input[type="time"]::-webkit-datetime-edit-text,
input[type="time"]::-webkit-datetime-edit-hour-field,
input[type="time"]::-webkit-datetime-edit-minute-field,
input[type="time"]::-webkit-datetime-edit-ampm-field {
  direction: ltr;
  unicode-bidi: plaintext;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  background: var(--accent);
  color: #06121f;
  border: 0;
  border-radius: 11px;
  padding: 12px 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.warn { background: var(--danger); color: #1b0707; }
.btn:disabled { opacity: .5; }

.chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text);
}

.chip.on { background: var(--accent); color: #06121f; border-color: transparent; font-weight: 600; }
.tag { font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 2px 7px; }

.pill-row { display: flex; gap: 7px; flex-wrap: wrap; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.day-card summary {
  cursor: pointer;
  list-style: none;
}
.day-card summary::-webkit-details-marker,
.day-card summary::marker { display: none; content: ""; }
.day-card .chev { transition: transform 0.15s ease; display: inline-block; }
.day-card[open] .chev { transform: rotate(180deg); }

.timeline { position: relative; padding-inline-start: 18px; }
.timeline::before {
  content: "";
  position: absolute;
  inset-inline-start: 4px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--line);
}

.tl-item { position: relative; margin-bottom: 12px; }
.tl-item::before {
  content: "";
  position: absolute;
  inset-inline-start: -18px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
}
.tl-item[data-type="meal"]::before { background: var(--accent-2); }
.tl-item[data-type="transfer"]::before, .tl-item[data-type="rest"]::before { background: var(--muted); }

.time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); font-size: 14px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

.map-page {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 54px - var(--tab-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: -14px -14px -24px;
}

.map-toolbar { flex: 0 0 auto; margin-bottom: 10px; }

.map-wrap { flex: 1; min-height: 0; overflow: hidden; }
#map { height: 100%; width: 100%; overflow: hidden; }

.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

.banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.banner-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.banner-title { font-weight: 700; margin-bottom: 3px; }
.banner-text { color: var(--muted); font-size: 13px; line-height: 1.5; }
.banner.warn .banner-icon { background: rgba(255, 180, 84, .16); }
.banner.warn .banner-title { color: var(--accent-2); }
.banner.error .banner-icon { background: rgba(255, 107, 107, .16); }
.banner.error .banner-title { color: var(--danger); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.travel-loader {
  position: relative;
  width: var(--tl-size, 64px);
  height: var(--tl-size, 64px);
  margin: 2px auto 8px;
}
.travel-loader-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px dashed var(--line);
}
.travel-loader-globe {
  position: absolute;
  inset: 16%;
  width: 68%;
  height: 68%;
  color: var(--accent);
  animation: tl-spin 7s linear infinite;
}
.travel-loader-orbit {
  position: absolute;
  inset: 0;
  animation: tl-spin 2.6s linear infinite;
}
.travel-loader-plane {
  position: absolute;
  top: -4%;
  left: 50%;
  width: 26%;
  height: 26%;
  transform: translateX(-50%) rotate(45deg);
  color: var(--accent-2);
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .4));
}
@keyframes tl-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .travel-loader-globe, .travel-loader-orbit { animation: none; }
}

.status { font-size: 12px; }
.status.pending { color: var(--accent-2); }
.status.done { color: var(--ok); }
.status.error { color: var(--danger); }

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #eef1f7;
    --line: #dde2ec;
    --text: #131722;
    --muted: #5d6880;
  }
  .topbar, .tabbar { background: rgba(246, 247, 251, .9); }
}
