:root {
  --bg: #f5f3ef;
  --panel: #ffffff;
  --line: #e4e0d8;
  --ink: #1f2328;
  --ink-soft: #6b6f76;
  --accent: #0f766e;
  --accent-soft: #e3f3f1;
  --warm: #e76f51;
  --warn: #b45309;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
a { color: var(--accent); }
.muted { color: var(--ink-soft); margin: 0; }
.small { font-size: 13px; }
.spacer { flex: 1; }
.warn { color: var(--warn); }

/* ── Buttons & Formulare ───────────────────── */

button, .btn {
  font: inherit;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--danger); padding-left: 0; }
button:disabled { opacity: .35; cursor: default; filter: none; }

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
  text-decoration: none;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  flex: 1;
}

input, select, textarea {
  font: inherit;
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
  font-weight: 400;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
textarea { resize: vertical; }

/* ── Dialoge ───────────────────────────────── */

dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(20, 24, 28, .45); }
dialog form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
dialog .row { display: flex; gap: 10px; flex-wrap: wrap; }
dialog .row label { min-width: 120px; }
dialog .actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.coords-hint { margin: -6px 0 0; font-size: 13px; color: var(--accent); min-height: 1em; }
.coords-hint.warn { color: var(--warn); }

/* ── Waehrungsrechner ─────────────────────── */

.fx-row { display: flex; gap: 8px; }
.fx-row input { flex: 1; font-size: 20px; font-weight: 600; min-width: 0; }
.fx-row select { flex: 1; min-width: 0; }
#fx-dialog .swap { align-self: center; padding: 4px 14px; margin: -4px 0; }
.fx-rate { margin: 0; }
.fx-quick { border-collapse: collapse; font-size: 14px; }
.fx-quick td { padding: 3px 8px 3px 0; border-bottom: 1px solid var(--line); }
.fx-quick td:first-child { text-align: right; }
.fx-quick td:nth-child(2) { color: var(--ink-soft); }
.fx-source { margin: 0; }

/* ── Adressvorschlaege ─────────────────────── */

.ac { position: relative; }
.ac-list {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}
.ac-list li {
  padding: 7px 9px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-weight: 400;
}
.ac-list li span { font-size: 12px; color: var(--ink-soft); }
.ac-list li:hover, .ac-list li.active { background: var(--accent-soft); }

/* ── Topbar ────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: rgba(245, 243, 239, .94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; }
.topbar h1 img { flex: none; }
.topbar .title { min-width: 0; }
.topbar .title h1, .topbar .title p {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .title p { font-size: 13px; }
.topbar .back { font-size: 22px; text-decoration: none; color: var(--ink); padding: 4px 6px; }

/* ── Login ─────────────────────────────────── */

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  align-items: center;
}
.login-card label { width: 100%; text-align: left; }
.login-card button { width: 100%; }
.login-card .error { color: var(--danger); margin: 0; }

/* ── Uebersicht ────────────────────────────── */

.home-main { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }
.home-main section { margin-bottom: 28px; }
.home-main h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin-bottom: 12px; }
.trip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.trip-card {
  position: relative;
  display: block;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  color: inherit;
  text-decoration: none;
  border-left: 5px solid var(--accent);
  transition: transform .12s ease;
}
.trip-card:hover { transform: translateY(-2px); }
.trip-card.now { border-left-color: var(--warm); }
.trip-card h3 { font-size: 18px; margin-bottom: 4px; }
.trip-card .badge {
  position: absolute; top: 12px; right: 12px;
  background: var(--warm); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}
.empty { color: var(--ink-soft); }

/* ── Reiseansicht ──────────────────────────── */

.day-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.day-tabs button {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  line-height: 1.2;
}
.day-tabs button small { color: var(--ink-soft); font-weight: 400; font-size: 12px; }
.day-tabs button em {
  position: absolute; top: -6px; right: -6px;
  font-style: normal; font-size: 11px;
  background: var(--warm); color: #fff;
  border-radius: 999px; min-width: 18px; height: 18px;
  display: grid; place-items: center; padding: 0 5px;
}
.day-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.day-tabs button.active small { color: rgba(255, 255, 255, .85); }

.trip-layout { display: flex; flex-direction: column; }

#map {
  height: 40vh;
  min-height: 240px;
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;  /* Liste scrollt unter der Karte durch */
  border-bottom: 1px solid var(--line);
}

.day-panel { padding: 14px 14px 80px; }
.day-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.day-head > div { flex: 1; }
.day-head h2 { font-size: 18px; }
.day-head p { font-size: 13px; }

.gmaps-links { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.gmaps-links a {
  font-size: 13px; text-decoration: none; font-weight: 600;
  background: var(--accent-soft); padding: 4px 10px; border-radius: 999px;
}

.day-list { list-style: none; margin: 0; padding: 0; }
.day-list li { margin: 0; }

.home-row {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 14px;
  border: 1px dashed var(--accent);
}
.leg {
  font-size: 13px;
  color: var(--ink-soft);
  padding: 6px 0 6px 26px;
  border-left: 3px dotted var(--accent);
  margin-left: 14px !important;
}
.hint { background: #fff7ed; color: var(--warn); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px !important; }
.day-list .empty { padding: 20px 4px; }

.stop {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  cursor: pointer;
}
.stop + .stop { margin-top: 8px; }
.stop .num {
  flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
}
.stop .body { flex: 1; min-width: 0; }
.stop .line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.stop .name { font-size: 16px; }
.stop .time {
  font-weight: 700; font-size: 13px; color: var(--accent);
  background: var(--accent-soft); padding: 1px 7px; border-radius: 6px;
}
.stop .time.est { color: var(--ink-soft); background: var(--bg); font-weight: 600; }
.stop .tools { display: grid; grid-template-columns: repeat(2, 32px); gap: 4px; }
.stop.done { opacity: .6; }
.stop.done .name { text-decoration: line-through; }
.stop.done .num { background: var(--ink-soft); }

.notes { margin-top: 6px; }
.notes summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.notes div {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  background: #fffbea;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 6px;
}

/* Karten-Pins */
.pin {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}
.pin.home { background: var(--warm); font-size: 15px; }
.pin.idea { background: #7c6f9b; }
.pin.done { background: #9aa0a6; }

/* Kartenstil-Umschalter */
.map-style {
  display: flex;
  background: #fff;
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
}
.map-style button {
  background: transparent;
  color: var(--ink);
  padding: 4px 11px;
  font-size: 13px;
}
.map-style button.active { background: var(--accent); color: #fff; }
.leaflet-container { font: inherit; background: #e9e6df; }
.leaflet-container .leaflet-control-attribution { font-size: 10px; line-height: 1.4; }
.satellite { background: #2b2f2a; }

/* Planen-Dialog */
label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; color: var(--ink); font-size: 14px; }
label.check input { width: auto; margin-top: 3px; }
.plan-preview { display: flex; flex-direction: column; gap: 10px; max-height: 45dvh; overflow-y: auto; }
.plan-preview section { background: var(--bg); border-radius: 10px; padding: 8px 12px; }
.plan-preview h3 { font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.plan-preview ol { margin: 4px 0 0; padding-left: 22px; font-size: 14px; }
.plan-preview em { font-style: normal; font-size: 11px; font-weight: 700; color: #fff; background: var(--warm); border-radius: 999px; padding: 0 6px; }
.plan-preview p { margin: 0; }
.day-head button { padding: 8px 12px; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 3000;
  transform: translate(-50%, 30px);
  opacity: 0; pointer-events: none;
  background: #1f2328; color: #fff;
  padding: 10px 16px; border-radius: 10px;
  max-width: calc(100vw - 32px);
  transition: all .2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }
#toast.show { pointer-events: auto; }
#toast button { margin-left: 10px; padding: 4px 12px; background: #fff; color: var(--ink); }

@media (max-width: 440px) {
  .wide-only { display: none; }
}

/* ── Desktop: Liste links, Karte rechts ───── */

@media (min-width: 900px) {
  .trip-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .trip-layout { flex: 1; flex-direction: row-reverse; min-height: 0; }
  #map { flex: 1; height: auto; top: 0; border-bottom: 0; border-left: 1px solid var(--line); }
  .day-panel { width: 440px; overflow-y: auto; padding-bottom: 40px; }
}
