/* Winter Arc – Grundlagen: Farben, Layout, Navigation, Karten, Buttons, Formulare */
:root {
  color-scheme: dark;
  --bg: #16171a;
  --bg-2: #1b1d21;
  --card: #212328;
  --card-2: #292c32;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #f4f4f5;
  --text-2: #d4d4d8;
  --muted: #a3a3ad;
  --faint: #767783;
  --orange: #d97757;
  --orange-2: #eb9373;
  --orange-soft: rgba(217, 119, 87, 0.15);
  --on-orange: #1c1310;
  --blue: #5b9dff;
  --blue-2: #8dbbff;
  --blue-soft: rgba(91, 157, 255, 0.15);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.13);
  --green: #4ade80;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset, 0 12px 32px rgba(0, 0, 0, 0.32);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 500px at 50% -200px, rgba(217, 119, 87, 0.08), transparent 70%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
a { color: var(--orange-2); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 750; }
h3 { font-size: 15px; font-weight: 700; margin: 14px 0 6px; }
p { margin: 0 0 10px; }
.icon { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--orange-2); outline-offset: 2px; }

/* ---------- Rahmen ---------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 16px 32px; }
body.has-nav .shell { padding-bottom: calc(var(--nav-h) + 40px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding-top: env(safe-area-inset-top, 0px);
  margin: 0 -16px 8px; padding-left: 16px; padding-right: 16px;
  background: rgba(22, 23, 26, 0.82);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 850; font-size: 18px; letter-spacing: -0.02em; }
.brand-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--orange); color: var(--on-orange); }
.brand-icon svg { width: 22px; height: 22px; }
.topnav { display: none; }
.pill-rules { margin-left: auto; }

.bottomnav {
  position: fixed; z-index: 40;
  left: 12px; right: 12px; bottom: calc(10px + var(--safe-b));
  max-width: 520px; margin: 0 auto;
  display: flex; gap: 4px; padding: 6px;
  background: rgba(33, 35, 40, 0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-2); border-radius: 26px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.bottomnav[hidden] { display: none; }
.nav-item {
  flex: 1 1 0; min-width: 0; height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 20px; color: var(--faint); font-size: 10.5px; font-weight: 650;
  transition: background 0.2s, color 0.2s;
}
.nav-item .icon { width: 22px; height: 22px; }
.nav-item.active { background: var(--orange-soft); color: var(--orange-2); }

.offline-banner {
  position: sticky; top: calc(64px + env(safe-area-inset-top, 0px)); z-index: 25;
  margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.13); border: 1px solid rgba(251, 191, 36, 0.3); color: #fcd34d; font-size: 14px;
}
.view { outline: none; }
.view.enter { animation: fade-up 0.32s ease both; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 18px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--orange-2); }

/* ---------- Raster ---------- */
.dash, .grid-2 { display: grid; gap: 16px; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dash > *, .grid-2 > * { min-width: 0; }

/* ---------- Karten ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--orange-2); }
.center-card { max-width: 440px; margin: 40px auto; text-align: center; }

/* ---------- Buttons & Pillen ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; font-size: 15px; transition: transform 0.12s, background 0.2s, opacity 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; }
.btn-primary { background: var(--orange); color: var(--on-orange); }
.btn-primary:hover:not(:disabled) { background: var(--orange-2); }
.btn-ghost { background: var(--card-2); border-color: var(--line-2); color: var(--text); }
.btn-danger { background: var(--red-soft); border-color: rgba(248, 113, 113, 0.35); color: #fecaca; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn-lg { min-height: 56px; font-size: 17px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--card-2); border: 1px solid var(--line-2); color: var(--text);
}
.icon-btn:disabled { opacity: 0.35; }
.pills { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; max-width: 100%; }
.pills:empty { display: none; }
.pills.wrap { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; background: none; border: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 650; white-space: nowrap;
}
.pills.wrap .pill, .pill-rules { background: var(--card-2); border-color: var(--line-2); color: var(--text-2); }
.pill.on, .pill-rules.active { background: var(--orange); color: var(--on-orange); border-color: transparent; }
.pill .icon { width: 18px; height: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip .icon { width: 15px; height: 15px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--card-2); color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap;
}
.tag .icon { width: 14px; height: 14px; }
.tag-small { height: 20px; padding: 0 8px; font-size: 11px; vertical-align: middle; }
.tag-blue { background: var(--blue-soft); color: var(--blue-2); }
.tag-red { background: var(--red-soft); color: #fca5a5; }

/* ---------- Formulare ---------- */
.form .card { margin-bottom: 16px; }
.field { display: grid; gap: 6px; margin: 0 0 14px; min-width: 0; border: 0; padding: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 650; color: var(--text-2); padding: 0; margin-bottom: 6px; }
.field > span { margin-bottom: 0; }
.field em { font-style: normal; font-weight: 500; color: var(--faint); }
input:not([type="checkbox"]):not([type="radio"]), textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text); font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { padding: 12px 14px; resize: vertical; min-height: 72px; }
input:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
input[type="time"] { appearance: none; -webkit-appearance: none; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 12px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-check { position: relative; }
.pill-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill-check span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 52px; height: 44px; padding: 0 14px;
  border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text-2);
  font-weight: 650; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.pill-check input:checked + span { background: var(--orange); border-color: transparent; color: var(--on-orange); }
.pill-check input:focus-visible + span { outline: 2px solid var(--orange-2); outline-offset: 2px; }
.form-error { background: var(--red-soft); color: #fecaca; padding: 10px 14px; border-radius: 12px; font-size: 14px; margin: 0 0 14px; }
.notice { background: var(--blue-soft); border: 1px solid rgba(91, 157, 255, 0.28); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Laden & Animationen ---------- */
.loading { display: flex; justify-content: center; gap: 8px; padding: 80px 0; }
.loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); animation: blink 1s infinite ease-in-out; }
.loading span:nth-child(2) { animation-delay: 0.15s; }
.loading span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Grössere Bildschirme ---------- */
@media (min-width: 900px) {
  .shell { padding-left: 28px; padding-right: 28px; }
  body.has-nav .shell { padding-bottom: 48px; }
  .topbar { margin: 0 -28px 12px; padding-left: 28px; padding-right: 28px; }
  .topnav {
    display: flex; gap: 4px; margin: 0 auto; padding: 4px;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  }
  .topnav .nav-item { flex-direction: row; height: 40px; padding: 0 16px; gap: 8px; font-size: 14px; border-radius: 999px; color: var(--muted); }
  .topnav .nav-item .icon { width: 18px; height: 18px; }
  .topnav .nav-item.active { background: var(--orange); color: var(--on-orange); }
  .pill-rules { margin-left: 0; }
  .bottomnav { display: none !important; }
  h1 { font-size: 36px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .span-2 { grid-column: 1 / -1; }
  .dash { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
  .dash > .col-main { grid-row: span 2; }
  .dash > .col:nth-child(3) { grid-column: 2; }
}
@media (min-width: 1280px) {
  .dash { grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.95fr) minmax(0, 0.95fr); }
  .dash > .col-main { grid-row: auto; }
  .dash > .col:nth-child(3) { grid-column: 3; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
