/* =====================================================================
   Kochtimer-Multi — app.css
   Palette: Küchen-Frisch · Tomatenrot #ef4444 + Kräutergrün #16a34a
   ===================================================================== */

:root {
  --tomato: #ef4444;
  --tomato-strong: #dc2626;
  --herb: #16a34a;
  --herb-strong: #15803d;

  /* Light (Standard) */
  --bg: #fff7f5;
  --bg-grad-a: #fff1ec;
  --bg-grad-b: #eefcf2;
  --surface: #ffffff;
  --surface-2: #fff6f3;
  --border: #f3d9d2;
  --border-soft: #f6e6e1;
  --text: #2a1c18;
  --text-soft: #7a6a64;
  --text-faint: #a89993;
  --shadow: 0 8px 26px rgba(190, 60, 40, 0.10);
  --shadow-sm: 0 2px 8px rgba(190, 60, 40, 0.08);
  --ring: rgba(239, 68, 68, 0.45);
  --chip-bg: #fff0eb;
  --chip-text: #b3331f;
  --track: #f1e3df;

  --accent: var(--tomato);
  --accent-2: var(--herb);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1714;
  --bg-grad-a: #161d18;
  --bg-grad-b: #1a1310;
  --surface: #18211d;
  --surface-2: #1f2924;
  --border: #2c3a33;
  --border-soft: #25312b;
  --text: #f3ece9;
  --text-soft: #b7c0bb;
  --text-faint: #7f8c86;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4);
  --ring: rgba(248, 113, 113, 0.6);
  --chip-bg: #2a211f;
  --chip-text: #ffb4a6;
  --track: #2a352f;
  --tomato: #f87171;
  --tomato-strong: #ef4444;
  --herb: #4ade80;
  --herb-strong: #22c55e;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 110% -8%, var(--bg-grad-b), transparent 60%),
    radial-gradient(900px 480px at -10% 0%, var(--bg-grad-a), transparent 55%),
    var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  padding:
    var(--safe-t)
    var(--safe-r)
    calc(var(--safe-b) + 8px)
    var(--safe-l);
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 8px; top: -60px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top .2s ease;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: calc(var(--safe-t) + 8px); }

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 18px 8px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 50px; height: 50px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--tomato), var(--herb));
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 1.32rem;
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform .12s ease, background .2s ease, border-color .2s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }

.theme-ico {
  width: 22px; height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--tomato) 0 46%, transparent 47%);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--tomato);
  position: relative;
}
[data-theme="dark"] .theme-ico {
  background: var(--surface);
  box-shadow: inset -6px -3px 0 0 var(--herb);
}

/* ---------- Layout ---------- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 6px 18px 10px;
  display: grid;
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-title {
  font-size: 1.02rem;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: "";
  width: 10px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(var(--tomato), var(--herb));
  flex: 0 0 auto;
}
.card-title.flush { margin-bottom: 0; }

/* ---------- Formular ---------- */
.field { display: grid; gap: 6px; }
.field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
}
.name-field { margin-bottom: 14px; }

input[type="text"],
input[type="number"] {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color .15s ease, box-shadow .15s ease, background .2s ease;
}
input::placeholder { color: var(--text-faint); }
input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.time-fields {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: end;
  gap: 8px;
}
.time-fields input { text-align: center; }
.time-sep {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-faint);
  padding-bottom: 8px;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 4px;
}
.chip {
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--chip-text);
  background: var(--chip-bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease, background .2s ease;
}
.chip:hover { border-color: var(--accent); }
.chip:active { transform: scale(.95); }

.form-error {
  margin: 12px 0 0;
  color: var(--tomato-strong);
  font-size: 0.86rem;
  font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform .12s ease, filter .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; margin-top: 16px; padding: 14px; font-size: 1.02rem; }

.btn-primary {
  background: linear-gradient(135deg, var(--tomato), var(--tomato-strong));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-soft {
  background: var(--herb);
  color: #fff;
}
.btn-soft:hover { filter: brightness(1.05); }
.btn-soft.is-running { background: var(--tomato); }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

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

button:focus-visible,
.switch input:focus-visible + .switch-track,
.chip:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

/* ---------- Liste / Grid ---------- */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.list-head .btn-ghost { padding: 8px 12px; font-size: 0.85rem; }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.empty {
  text-align: center;
  padding: 30px 18px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-soft);
}
.empty-ico { font-size: 2.6rem; }
.empty-title { font-weight: 700; color: var(--text); margin: 8px 0 4px; }
.empty-text { margin: 0; font-size: 0.9rem; }

/* ---------- Timer-Kachel ---------- */
.tile {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: grid;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.tile.is-running { border-color: color-mix(in srgb, var(--herb) 55%, var(--border)); }
.tile.is-done {
  border-color: var(--tomato);
  animation: tileBlink 1s steps(1, end) infinite;
}
@keyframes tileBlink {
  0%, 100% { background: var(--surface); }
  50% { background: color-mix(in srgb, var(--tomato) 16%, var(--surface)); }
}

.tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.tile-name {
  font-size: 1rem;
  margin: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.tile-del {
  width: 34px; height: 34px;
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--text-faint);
}
.tile-del:hover { color: var(--tomato); }

.dial {
  position: relative;
  width: 124px;
  margin: 2px auto 0;
}
.dial-svg { display: block; width: 124px; height: 124px; transform: rotate(-90deg); }
.dial-bg {
  fill: none;
  stroke: var(--track);
  stroke-width: 9;
}
.dial-fg {
  fill: none;
  stroke: var(--herb);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 326.7256;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .35s linear, stroke .3s ease;
}
.tile.is-done .dial-fg { stroke: var(--tomato); }
.tile.is-paused .dial-fg { stroke: var(--text-faint); }

.dial-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.time-left {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tile-status {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
  min-height: 1.1em;
}
.tile.is-running .tile-status { color: var(--herb-strong); }
.tile.is-done .tile-status { color: var(--tomato-strong); }

.tile-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.tile-actions .tile-toggle { padding: 10px; }
.tile-actions .tile-reset { padding: 10px 12px; }

/* ---------- Einstellungen-Leiste ---------- */
.settings-bar {
  max-width: 860px;
  margin: 16px auto 0;
  padding: 14px 18px;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 50px; height: 28px;
  border-radius: var(--radius-pill);
  background: var(--track);
  border: 1.5px solid var(--border);
  position: relative;
  transition: background .2s ease, border-color .2s ease;
  flex: 0 0 auto;
}
.switch-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease;
}
.switch input:checked + .switch-track {
  background: var(--herb);
  border-color: var(--herb);
}
.switch input:checked + .switch-track .switch-knob { transform: translateX(22px); }
.switch-label { font-size: 0.92rem; font-weight: 600; }

/* ---------- Toasts ---------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 16px);
  transform: translateX(-50%);
  display: grid;
  gap: 10px;
  width: min(440px, calc(100vw - 28px));
  z-index: 80;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-left: 5px solid var(--tomato);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastIn .25s ease;
}
.toast.is-out { animation: toastOut .25s ease forwards; }
.toast-ico { font-size: 1.3rem; flex: 0 0 auto; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; font-size: 0.94rem; }
.toast-text { font-size: 0.84rem; color: var(--text-soft); }
.toast-close {
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
  flex: 0 0 auto;
}
.toast-close:hover { background: var(--surface-2); color: var(--text); }

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

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 10, 8, 0.5);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  width: min(380px, 100%);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-title { margin: 0 0 8px; font-size: 1.1rem; }
.modal-text { margin: 0 0 18px; color: var(--text-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.78rem;
  padding: 24px 18px calc(var(--safe-b) + 12px);
}
.app-footer p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 11px; }
  .dial, .dial-svg { width: 104px; }
  .dial-svg { height: 104px; }
  .time-left { font-size: 1.25rem; }
  .brand-text h1 { font-size: 1.18rem; }
}

@media (min-width: 560px) {
  .creator form { display: grid; gap: 0; }
}

/* ---------- Zugänglichkeit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .tile.is-done {
    animation: none;
    background: color-mix(in srgb, var(--tomato) 12%, var(--surface));
  }
}
