:root {
  --blue: #0762bc;
  --blue-dark: #054a8e;
  --blue-light: #e6effa;
  --gold: #ffcc00;
  --gold-light: #fff6cc;
  --green: #22b24c;
  --green-dark: #1a8f3c;
  --red: #d63a2f;
  --red-light: #fdecea;
  --silver: #eeeeee;
  --text: #1a2230;
  --muted: #5d6878;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #d9dee7;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 32, 60, 0.12);
  --blue-deep: #06335f;
  --on-dark: #f1f6fc;
  --on-dark-muted: #a9c3e2;
  --f-display: "Oswald", "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 17px;
}

/* Oswald (SIL Open Font License), lokal eingebunden – funktioniert auch offline */
@font-face {
  font-family: "Oswald";
  font-weight: 200 700;
  font-display: swap;
  src: url(/fonts/oswald-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: "Oswald";
  font-weight: 200 700;
  font-display: swap;
  src: url(/fonts/oswald-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+2C60-2C7F, U+A720-A7FF;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */

.topbar {
  position: relative;
  overflow: hidden;
  background: var(--blue-deep);
  color: var(--on-dark);
  border-bottom: 3px solid var(--gold);
  padding-top: env(safe-area-inset-top);
}
/* Echte Flurkarte (ALKIS) als Hintergrund, links hinter Wappen und Titel ausgeblendet */
.topbar .flurkarte {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% 50%;
  pointer-events: none;
  user-select: none;
}
.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(6, 51, 95, 0.96) 0, rgba(6, 51, 95, 0.8) 150px, rgba(6, 51, 95, 0) min(62%, 420px));
}
.topbar-inner { z-index: 1; }
.attribution {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  margin: 28px 0 0;
}
.topbar-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 16px;
}
.topbar .crest { height: 54px; width: auto; display: block; flex-shrink: 0; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35)); }
.brand-text {
  flex: 1;
  min-width: 0;
  font: 600 1.35rem/1.05 var(--f-display);
  text-shadow: 0 1px 6px rgba(6, 51, 95, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text small {
  display: block;
  margin-top: 4px;
  font: 500 0.68rem/1 var(--f-display);
  letter-spacing: 0.16em;
  color: var(--on-dark-muted);
}
.chip {
  font: 500 0.8rem/1 var(--f-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--on-dark);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 9px 10px;
  white-space: nowrap;
  text-decoration: none;
  background: none;
  flex-shrink: 0;
}
a.chip:hover, button.chip:hover { background: rgba(255, 255, 255, 0.08); }
.icon-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--on-dark);
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.on { background: var(--gold); border-color: var(--gold); color: var(--blue-deep); }
@media (max-width: 370px) {
  .chip.optional { display: none; }
}

/* ---------- Ortsteil-Umschalter ---------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px 8px;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
}
.tab {
  border: 2px solid var(--blue-deep);
  background: #fff;
  color: var(--blue-deep);
  border-radius: 8px;
  min-height: 56px;
  font: 600 1.1rem/1 var(--f-display);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.tab[aria-selected="true"] { background: var(--blue-deep); color: #fff; box-shadow: inset 0 -3px 0 var(--gold); }
.tab .badge { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: 0; }
.badge {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 13px;
  background: var(--gold);
  color: var(--blue-dark);
  font-size: 0.85rem;
  display: inline-grid;
  place-items: center;
}
.badge.alert { background: var(--red); color: #fff; }

/* ---------- Liste ---------- */

main { max-width: 720px; margin: 0 auto; padding: 4px 16px calc(env(safe-area-inset-bottom) + 96px); }

.section-title {
  font: 500 0.85rem/1.2 var(--f-display);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 18px 4px 8px;
}
.section-title.overdue { color: var(--red); }

.job {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 8px solid var(--silver);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 14px 14px;
  margin-bottom: 10px;
  min-height: 76px;
}
.job:active { transform: scale(0.99); background: var(--blue-light); }
.job.overdue { border-left-color: var(--red); }
.job.today { border-left-color: var(--gold); }
.job.soon { border-left-color: var(--green); }
.job.later, .job.paused { border-left-color: #b8c0cc; }
.job .body { flex: 1; min-width: 0; }
.job .title { font-size: 1.12rem; font-weight: 700; }
.job .tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--blue-light);
  color: var(--blue-dark);
  vertical-align: 3px;
  white-space: nowrap;
}
.job .meta {font-size: 0.88rem; color: var(--muted); margin-top: 2px; }
.job .meta strong { color: var(--red); }
.job .go {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--green);
  color: var(--green);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.job .go svg { width: 24px; height: 24px; }

details.more { margin-top: 6px; }
details.more > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 4px;
  font-weight: 700;
  color: var(--blue);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}
.empty .big { font-size: 1.3rem; font-weight: 700; color: var(--green-dark); margin-bottom: 4px; }

.banner {
  max-width: 720px;
  margin: 10px auto 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--gold-light);
  border: 1px solid var(--gold);
  font-size: 0.9rem;
}
.banner-wrap { padding: 0 16px; }

/* ---------- Bottom-Sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, 0.45);
  z-index: 40;
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  background: #fff;
  border-radius: 20px 20px 0 0;
  max-height: 94vh;
  overflow-y: auto;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 16px);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.2);
  max-width: 720px;
  margin: 0 auto;
}
.sheet .grip { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 10px; }
.sheet h2 { margin: 0 0 4px; font-size: 1.35rem; }
.sheet .info { color: var(--muted); font-size: 0.9rem; margin-bottom: 10px; }
.sheet .note {
  background: var(--gold-light);
  border-left: 4px solid var(--gold);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  white-space: pre-wrap;
  margin-bottom: 8px;
}
.sheet h3 { font-size: 0.95rem; margin: 16px 0 8px; color: var(--muted); font-weight: 700; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.choice {
  min-height: 54px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fff;
  font-weight: 700;
  font-size: 1rem;
  padding: 4px;
}
.choice[aria-pressed="true"] { border-color: var(--blue); background: var(--blue); color: #fff; }
.choice .std { display: block; font-size: 0.7rem; font-weight: 600; opacity: 0.8; }

.stepper {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.stepper .val { text-align: center; font-size: 1.2rem; font-weight: 700; }
.stepper .val.none { color: var(--muted); font-weight: 400; font-size: 0.95rem; }

.next-date { margin-top: 8px; font-size: 0.95rem; color: var(--muted); }
.next-date strong { color: var(--text); }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  border: 0;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 16px;
}
.btn svg { width: 26px; height: 26px; }
.btn-done { background: var(--green); color: #fff; min-height: 66px; font-size: 1.3rem; margin-top: 18px; }
.btn-done:disabled { background: #b8c9bd; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--blue-light); color: var(--blue-dark); }
.btn-ghost { background: transparent; color: var(--muted); margin-top: 6px; }
.btn-danger { background: var(--red-light); color: var(--red); }

.note-toggle { background: none; border: 0; color: var(--blue); font-weight: 600; padding: 12px 0 0; }
textarea.note-input {
  width: 100%;
  min-height: 70px;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 8px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  max-width: 560px;
  margin: 0 auto;
  z-index: 50;
  background: var(--text);
  color: #fff;
  border-radius: 14px;
  padding: 10px 10px 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.toast span { flex: 1; }
.toast button {
  background: var(--gold);
  color: var(--blue-dark);
  border: 0;
  border-radius: 10px;
  min-height: 48px;
  padding: 0 16px;
  font-weight: 700;
}

/* ---------- PIN ---------- */

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(var(--blue-deep) 0 42%, var(--bg) 42%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  padding: 24px 20px;
  text-align: center;
}
.login-card img { width: 84px; margin-top: -64px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25)); }
.login-card h1 { font: 600 1.5rem/1.1 var(--f-display); text-transform: uppercase; letter-spacing: 0.06em; margin: 12px 0 4px; }
.login-card p { margin: 0 0 14px; color: var(--muted); }
.pin-dots { display: flex; justify-content: center; gap: 12px; height: 22px; margin-bottom: 16px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--blue); }
.pin-dots span.filled { background: var(--blue); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  min-height: 64px;
  border-radius: 14px;
  border: 0;
  background: var(--blue-light);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue-dark);
}
.keypad button.ok { background: var(--green); color: #fff; font-size: 1.1rem; }
.error { color: var(--red); min-height: 1.4em; margin-top: 10px; font-weight: 600; }
.login-card input[type="password"] {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.spinner { text-align: center; padding: 40px; color: var(--muted); }

#intervals .choice { font-size: 0.92rem; line-height: 1.15; }
