/* Parkuhr-Erinnerung — Signal Orange #f97316 + Anthrazit */

:root {
  --orange: #f97316;
  --orange-bright: #fb923c;
  --orange-deep: #c2410c;
  --orange-soft: rgba(249, 115, 22, 0.14);

  --danger: #dc2626;
  --danger-deep: #991b1b;
  --ok: #16a34a;

  /* Dunkelmodus = Standard (Anthrazit) */
  --bg: #18181b;
  --bg-2: #1f1f23;
  --card: #26262b;
  --card-2: #2e2e34;
  --line: #3a3a41;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);

  --radius: 16px;
  --radius-sm: 10px;
  --gap: 16px;
  --tap: 48px;
}

[data-theme="light"] {
  --bg: #f4f4f5;
  --bg-2: #e9e9ec;
  --card: #ffffff;
  --card-2: #f7f7f8;
  --line: #d6d6db;
  --text: #1c1c1f;
  --text-muted: #5b5b66;
  --orange-soft: rgba(249, 115, 22, 0.12);
  --shadow: 0 8px 24px rgba(24, 24, 27, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

img { max-width: 100%; height: auto; display: block; }

/* Fokus-States */
:focus-visible {
  outline: 3px solid var(--orange-bright);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--orange);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
  border-radius: 0 0 8px 0;
  font-weight: 700;
}
.skip-link:focus { left: 0; }

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-deep) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  flex: 0 0 auto;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  margin: 1px 0 0;
  font-size: 0.74rem;
  opacity: 0.9;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.btn-icon {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn-icon:hover { background: rgba(0, 0, 0, 0.32); }
.btn-icon:active { transform: scale(0.94); }

/* Theme-Icon Logik */
.ico-moon { display: none; }
[data-theme="light"] .ico-sun { display: none; }
[data-theme="light"] .ico-moon { display: block; }

/* ===== Main ===== */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ===== Card ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: "";
  width: 4px; height: 18px;
  background: var(--orange);
  border-radius: 4px;
}

/* ===== Countdown ===== */
.countdown-card {
  text-align: center;
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(249, 115, 22, 0.16), transparent 60%),
    var(--card);
  border-color: rgba(249, 115, 22, 0.35);
}
.countdown-state {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--orange-bright);
  margin-bottom: 6px;
}
.countdown-time {
  font-size: clamp(3rem, 18vw, 5.2rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  word-break: break-word;
}
.countdown-meta { margin-top: 8px; font-size: 0.95rem; }
.countdown-controls {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Zustände */
.countdown-card.is-warning {
  border-color: var(--orange);
  animation: pulseWarn 1s ease-in-out infinite;
}
.countdown-card.is-warning .countdown-state { color: var(--orange); }
.countdown-card.is-expired {
  border-color: var(--danger);
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(220, 38, 38, 0.22), transparent 60%),
    var(--card);
}
.countdown-card.is-expired .countdown-state { color: var(--danger); }
.countdown-card.is-expired .countdown-time { color: var(--danger); }

@keyframes pulseWarn {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 4px var(--orange-soft), var(--shadow); }
}

.progress-wrap { margin-top: 14px; }
.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-bright));
  border-radius: 999px;
  transition: width 0.5s linear;
}

/* ===== Forms ===== */
.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 0; }
label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 7px;
}
input[type="number"],
input[type="text"],
input[type="time"],
input[type="file"] {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  font-family: inherit;
}
input[type="file"] { padding: 10px 14px; }
input::placeholder { color: var(--text-muted); }
input:focus { border-color: var(--orange); }

.hint, .small { font-size: 0.8rem; color: var(--text-muted); margin: 6px 0 0; }
.muted { color: var(--text-muted); }

/* Segmented control */
.seg {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
  gap: 4px;
}
.seg-btn {
  flex: 1;
  min-height: 42px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.92rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn.is-active {
  background: var(--orange);
  color: #fff;
}

/* Presets */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.preset {
  flex: 1 1 auto;
  min-width: 80px;
  min-height: 44px;
  border: 1px solid var(--orange);
  background: var(--orange-soft);
  color: var(--orange-bright);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.preset:hover { background: rgba(249, 115, 22, 0.22); }
.preset:active { transform: scale(0.96); }

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  min-height: var(--tap);
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 8px 14px; font-size: 0.9rem; }

.btn-primary {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-deep) 100%);
  color: #fff;
  margin-top: 4px;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: var(--card-2);
  color: var(--text);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg-2); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); }

/* Photo preview */
.photo-preview {
  margin-top: 10px;
  position: relative;
}
.photo-preview img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-bottom: 8px;
}

/* Info list */
.info-list { margin: 0; }
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.info-row:last-child { border-bottom: none; }
.info-row dt { color: var(--text-muted); font-size: 0.9rem; flex: 0 0 auto; }
.info-row dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
  min-width: 0;
}

/* Settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-num {
  width: 84px !important;
  flex: 0 0 auto;
  text-align: center;
}

/* Switch */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.slider::before {
  content: "";
  position: absolute;
  height: 22px; width: 22px;
  left: 4px; top: 4px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.switch input:checked + .slider { background: var(--orange); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--orange-bright); outline-offset: 2px; }

.footer-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 4px 0 8px;
}

/* ===== Toasts ===== */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(94vw, 460px);
  pointer-events: none;
}
.toast {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 5px solid var(--orange);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-weight: 600;
  pointer-events: auto;
  animation: toastIn 0.25s ease;
}
.toast.is-out { animation: toastOut 0.3s ease forwards; }
.toast.alarm { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--orange); }
.toast.ok { border-left-color: var(--ok); }
.toast-title { display: block; font-weight: 800; margin-bottom: 2px; }
.toast-body { font-weight: 500; font-size: 0.92rem; color: var(--text-muted); }

@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(16px); } }

/* ===== Alarm-Overlay (Blinken) ===== */
.alarm-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  background: rgba(249, 115, 22, 0.35);
}
.alarm-overlay.active {
  animation: flash 0.8s steps(2, start) infinite;
}
.alarm-overlay.expired {
  background: rgba(220, 38, 38, 0.4);
}
@keyframes flash {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  width: min(94vw, 420px);
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}
.modal-title { margin: 0 0 8px; font-size: 1.15rem; }
.modal-msg { margin: 0 0 18px; color: var(--text-muted); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ===== Responsive ===== */
@media (max-width: 380px) {
  .app-main { padding: 12px; }
  .card { padding: 15px; }
  .brand-text h1 { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .alarm-overlay.active { animation: none; opacity: 1; }
  .countdown-card.is-warning { animation: none; }
}
