/* ============================================================
   Tankpreis-Checker — Ledger (Editorial), Rail-Navigation, Light/Dark
   ============================================================ */

:root {
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Schibsted Grotesk", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --radius: 3px;
}

html[data-theme="light"] {
  --bg: #f3f0e8;
  --surface: #faf8f2;
  --surface-2: #fffdf8;
  --line: #ddd6c6;
  --line-strong: #c7bda7;
  --ink: #1d1a15;
  --muted: #837b6b;
  --accent: #1f6f4a;
  --accent-soft: rgba(31, 111, 74, 0.1);
  --accent-ink: #ffffff;
  --down: #1f6f4a;
  --up: #ad4230;
}
html[data-theme="dark"] {
  --bg: #131210;
  --surface: #1a1813;
  --surface-2: #201d17;
  --line: #322e26;
  --line-strong: #46412f;
  --ink: #efe8d8;
  --muted: #9b9384;
  --accent: #63c194;
  --accent-soft: rgba(99, 193, 148, 0.13);
  --accent-ink: #0c1410;
  --down: #63c194;
  --up: #e3826b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body, .chrome, .navitem, .railbtn, .btn, .input, .watch, .station, .fuel-row,
.dialog, .delta, .price-tag, .chip, .toast {
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease),
    border-color 0.3s var(--ease);
}
a { color: var(--accent); }

/* ============================================================
   SHELL + RAIL
   ============================================================ */
.shell { display: flex; min-height: 100dvh; }

.chrome {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 92px;
  flex: none;
  padding: 20px 8px;
  gap: 6px;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand { display: flex; flex-direction: column; align-items: center; padding-bottom: 16px; }
.brand__mark { color: var(--accent); display: grid; place-items: center; }
.brand__mark svg { width: 30px; height: 30px; }
.brand__text { display: none; }
.brand__name { font-family: var(--font-display); font-style: italic; font-weight: 500; font-size: 18px; }
.brand__tag { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 6px; width: 100%; align-items: stretch; }

.navitem, .railbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 4px;
  border: 0;
  background: none;
  border-radius: 12px;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.navitem:hover, .railbtn:hover { color: var(--ink); }
.navicon { flex: none; display: grid; place-items: center; width: 22px; height: 22px; }
.navicon svg { width: 21px; height: 21px; }
.navlabel {
  font-size: 10px;
  line-height: 1.18;
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: anywhere;
}
.navitem[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; width: 100%; }

/* Theme-Icon je nach Modus */
.icon-sun, .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="light"] .icon-moon { display: block; }

/* ============================================================
   MAIN + SEITEN
   ============================================================ */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.main-inner { width: 100%; max-width: 680px; margin: 0 auto; padding: 34px 28px 100px; flex: 1; }

.page[hidden] { display: none; }
.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.pagehead__title { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 30px; letter-spacing: -0.02em; line-height: 1; }
.pagehead__sub { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }
.pagehead__actions { display: flex; gap: 8px; flex: none; }

.pagefoot {
  margin-top: 40px; padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px; text-align: center;
}
.pagefoot a { text-decoration: underline; text-underline-offset: 2px; }

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

code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12.5px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  appearance: none; cursor: pointer;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 9px 15px; border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink);
  transition: transform 0.06s var(--ease), border-color 0.18s, filter 0.18s, background 0.18s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--ghost:hover { color: var(--ink); border-color: var(--line-strong); }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--danger { color: var(--up); }
.btn--danger:hover { border-color: var(--up); }

/* ============================================================
   DASHBOARD — WATCH-KARTEN
   ============================================================ */
.watch-list { display: block; }
.watch { padding: 20px 0; border-bottom: 1px solid var(--line); }
.watch:last-child { border-bottom: none; }
.watch[data-active="false"] { opacity: 0.55; }
.watch__main { min-width: 0; }
.watch__head { margin-bottom: 12px; }
.watch__name { font-family: var(--font-display); font-weight: 500; font-size: 19px; letter-spacing: -0.01em; }
.watch__meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.fuel-rows { display: block; }
.fuel-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.fuel-row:last-child { border-bottom: none; }
.fuel-row__label { font-size: 13.5px; color: var(--muted); font-weight: 600; width: 96px; flex: none; }
.fuel-row__price { font-family: var(--font-display); font-weight: 500; font-size: 22px; font-variant-numeric: tabular-nums; }

.delta {
  font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; border: 1px solid transparent;
}
.delta.down { color: var(--down); border-color: color-mix(in srgb, var(--down) 32%, transparent); }
.delta.up { color: var(--up); border-color: color-mix(in srgb, var(--up) 32%, transparent); }
.delta.flat, .delta.first { color: var(--muted); border-color: var(--line); }

.spark { display: block; margin-left: auto; }
.spark--down { color: var(--down); }
.spark--up { color: var(--up); }

/* Watch-Karte: Aktionen rechts, Kopf links — als flex-Zeile */
.watch { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.watch__main { flex: 1; }
.watch__actions { display: flex; gap: 6px; flex: none; }

/* Änderungs-Historie */
.changes { margin-top: 12px; }
.changes summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.change-list { list-style: none; margin: 8px 0 0; padding: 0; }
.change-list li {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; padding: 8px 0;
  border-top: 1px solid var(--line);
}
.change-time { color: var(--muted); width: 100px; flex: none; font-variant-numeric: tabular-nums; }
.change-fuel { color: var(--muted); width: 78px; flex: none; }
.change-station { flex: 1; min-width: 0; color: var(--muted); }
.change-station b { color: var(--ink); font-weight: 600; }
.change-price { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 15px; margin-left: auto; }
.change-list .delta { margin-left: 0; }

/* ============================================================
   SUCHE + STATIONEN
   ============================================================ */
.search-controls { display: grid; gap: 14px; margin: 20px 0 8px; }
.latlng { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.input {
  flex: 1 1 140px; min-width: 0;
  background: transparent; border: none;
  border-bottom: 1px solid var(--line-strong);
  padding: 8px 0; border-radius: 0;
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-bottom: 2px solid var(--accent); }
.latlng .rad { flex: 0 0 64px; }

#searchStatus { margin: 14px 0 0; }
.results { display: block; margin-top: 8px; }

.station {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.station:last-child { border-bottom: none; }
.station__info { min-width: 0; }
.station__name { font-family: var(--font-display); font-weight: 500; font-size: 17px; }
.station__addr { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.station__prices { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.price-tag {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); white-space: nowrap;
}
.price-tag b { font-variant-numeric: tabular-nums; margin-left: 3px; color: var(--ink); }
.station__col { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; flex: none; }
.station__dist { font-family: var(--font-display); font-weight: 600; color: var(--accent); font-size: 15px; white-space: nowrap; }

/* ============================================================
   VERLAUF
   ============================================================ */
.logday { margin-top: 22px; }
.logday:first-child { margin-top: 8px; }
.logday__date {
  margin: 0 0 4px;
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: 15px; color: var(--muted);
}

/* ============================================================
   EINSTELLUNGEN — FORMULAR
   ============================================================ */
.field {
  display: grid;
  gap: 10px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.pagehead + .field { margin-top: 28px; }
.field > label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.field .input { width: 100%; }
.field__hint { color: var(--muted); font-size: 12px; margin: 0; }
.readline {
  display: flex; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.readline:last-of-type { border-bottom: none; }
.readline span { color: var(--muted); }

.setup { margin-top: 0; }
.setup__title { font-family: var(--font-display); font-weight: 500; font-size: 20px; letter-spacing: -0.01em; margin: 0 0 10px; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.9; font-size: 14px; }
.steps strong { color: var(--ink); }

/* ============================================================
   DIALOG
   ============================================================ */
.dialog {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  padding: 0;
  width: min(440px, 92vw);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.dialog::backdrop { background: rgba(10, 9, 6, 0.5); backdrop-filter: blur(2px); }
.dialog form { padding: 24px; display: grid; gap: 8px; }
.dialog h3 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 21px; }
.field-label { font-size: 13px; font-weight: 600; margin-top: 12px; }
.fuel-options { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13px;
  cursor: pointer;
}
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chip__price { color: var(--muted); font-variant-numeric: tabular-nums; }
.dialog #chatIdInput { border-bottom: 1px solid var(--line-strong); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 12px 18px; border-radius: 8px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  font-size: 14px; z-index: 50;
}
.toast--error { border-color: var(--up); color: var(--up); }

/* ============================================================
   ANIMATION
   ============================================================ */
@keyframes pagein { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.page:not([hidden]) { animation: pagein 0.4s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, .page:not([hidden]) { animation: none !important; transition: none !important; }
}

/* ============================================================
   RESPONSIVE — Rail wird zur oberen Leiste
   ============================================================ */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .chrome {
    flex-direction: row; align-items: center;
    width: auto; height: auto;
    padding: 8px 14px; gap: 8px;
    border-right: none; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand { flex-direction: row; padding: 0 8px 0 0; }
  .brand__text { display: block; }
  .nav { flex-direction: row; width: auto; }
  .navitem, .railbtn { flex-direction: row; gap: 8px; width: auto; padding: 9px 12px; }
  .navlabel { font-size: 13px; }
  .navitem[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
  .rail-foot { margin-top: 0; margin-left: auto; flex-direction: row; width: auto; }
  .railbtn .navlabel { display: none; }
  .main-inner { padding: 24px 18px 80px; }
  .pagehead { flex-direction: column; align-items: flex-start; }
  .station { flex-direction: column; align-items: stretch; }
  .station__col { flex-direction: row; align-items: center; justify-content: space-between; }
  .watch { flex-direction: column; }
  .watch__actions { align-self: flex-end; }
}
