/* ====== Schritt-Tagebuch — eigenes Design: Aktiv-Orange + Frischgrün ====== */
:root {
  --orange: #ea580c;
  --orange-600: #c2410c;
  --orange-400: #fb923c;
  --green: #16a34a;
  --green-400: #4ade80;
  --green-200: #bbf7d0;

  --bg: #fff7ed;
  --bg-grad-1: #ffedd5;
  --bg-grad-2: #fef3c7;
  --surface: #ffffff;
  --surface-2: #fffaf5;
  --text: #1c1410;
  --muted: #8a6f5e;
  --line: #f1d9c4;
  --line-strong: #e7c4a6;
  --shadow: 0 8px 28px rgba(124, 45, 18, 0.10);
  --shadow-sm: 0 2px 10px rgba(124, 45, 18, 0.08);
  --ring: #fb923c;
  --track: #fde4cf;
  --good: #16a34a;
  --good-soft: #dcfce7;
  --radius: 18px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --bg: #1a120c;
  --bg-grad-1: #25160d;
  --bg-grad-2: #1f1810;
  --surface: #271a12;
  --surface-2: #2f2017;
  --text: #fdeede;
  --muted: #c4a78f;
  --line: #3c2a1d;
  --line-strong: #4d3522;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.4);
  --ring: #fb923c;
  --track: #3a271a;
  --good: #4ade80;
  --good-soft: #14321f;
  --orange: #fb7d3c;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 100% -8%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 480px at -10% 6%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  min-height: 100dvh;
  line-height: 1.5;
  padding:
    max(env(safe-area-inset-top), 0px)
    max(env(safe-area-inset-right), 0px)
    calc(max(env(safe-area-inset-bottom), 0px) + 24px)
    max(env(safe-area-inset-left), 0px);
  -webkit-text-size-adjust: 100%;
}

.sr-only {
  position: absolute; 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: 12px; top: -48px; z-index: 100;
  background: var(--orange); color: #fff; padding: 8px 14px; border-radius: 10px;
  text-decoration: none; transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ====== Header ====== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 16px clamp(14px, 4vw, 28px) 8px;
  max-width: 760px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-600));
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.brand-text { min-width: 0; }
.brand h1 {
  font-size: clamp(1.15rem, 4.6vw, 1.5rem); margin: 0; letter-spacing: -.02em;
  line-height: 1.1;
}
.brand-sub { margin: 0; font-size: .8rem; color: var(--muted); }

.header-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.icon-btn {
  display: grid; place-items: center;
  min-width: 44px; height: 44px; padding: 0 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  border-radius: 12px; cursor: pointer;
  transition: transform .12s ease, background .2s ease, border-color .2s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.96); }
.unit-pill { font-weight: 700; font-size: .85rem; color: var(--orange); }

.i-moon { display: none; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: block; }

/* ====== Layout / Cards ====== */
main {
  max-width: 760px; margin: 0 auto;
  padding: 6px clamp(14px, 4vw, 28px) 0;
  display: flex; flex-direction: column; gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: clamp(14px, 3.5vw, 20px);
}
.card-title {
  font-size: 1rem; margin: 0 0 4px; letter-spacing: -.01em;
}
.muted { color: var(--muted); font-size: .85rem; margin: 0; }

/* ====== Wochen-Navigation ====== */
.week-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
}
.nav-btn {
  width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto;
  border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--orange); font-size: 1.5rem; line-height: 1; cursor: pointer;
  transition: background .2s ease, transform .12s ease;
}
.nav-btn:hover { background: var(--track); }
.nav-btn:active { transform: scale(.95); }
.week-label { text-align: center; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.week-range { font-weight: 700; font-size: 1rem; }
.link-btn {
  background: none; border: none; color: var(--orange); cursor: pointer;
  font-size: .8rem; font-weight: 600; padding: 2px 4px; text-decoration: underline;
}

/* ====== Ziel-Karte ====== */
.goal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.goal-badge {
  background: var(--good-soft); color: var(--good);
  font-weight: 800; font-size: .95rem; padding: 6px 12px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto;
}
.goal-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.goal-input, .entry-input {
  flex: 1 1 120px; min-width: 0;
  font-size: 1.1rem; font-weight: 700;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
}
.goal-unit { color: var(--muted); font-size: .85rem; flex: 0 0 auto; }
.goal-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.preset {
  border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--text); padding: 8px 12px; border-radius: 999px; cursor: pointer;
  font-size: .85rem; font-weight: 600; transition: all .18s ease;
}
.preset:hover { border-color: var(--orange); color: var(--orange); }
.preset.active {
  background: linear-gradient(135deg, var(--orange-400), var(--orange)); color: #fff;
  border-color: transparent;
}

/* ====== Buttons ====== */
.btn {
  border: none; border-radius: 12px; cursor: pointer;
  font-size: .95rem; font-weight: 700; padding: 12px 18px;
  transition: transform .12s ease, filter .2s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--orange-400), var(--orange-600));
  color: #fff; box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { color: var(--orange); border-color: var(--orange); }

/* ====== Kennzahlen ====== */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
}
.stat-val { font-size: clamp(1.4rem, 6vw, 1.9rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.stat-key { font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat.streak {
  background: linear-gradient(135deg, rgba(234,88,12,.10), rgba(22,163,74,.10));
  border-color: var(--line-strong);
}
.stat.streak .stat-val { color: var(--orange); }

/* ====== Fortschritt ====== */
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.progress-pct { font-weight: 800; color: var(--orange); font-size: 1.05rem; }
.progress-track {
  margin-top: 10px; height: 16px; border-radius: 999px;
  background: var(--track); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--orange-400), var(--green));
  border-radius: 999px;
  transition: width .5s cubic-bezier(.22,.61,.36,1);
}
.progress-card .muted { margin-top: 8px; }

/* ====== Chart ====== */
.chart {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: clamp(4px, 1.6vw, 10px);
  align-items: end;
  height: 180px;
  margin-top: 8px;
  position: relative;
}
.bar-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  height: 100%; gap: 6px; position: relative; min-width: 0;
  background: none; border: none; cursor: pointer; padding: 0; font: inherit; color: inherit;
}
.bar-wrap {
  position: relative; width: 100%;
  flex: 1 1 auto; display: flex; align-items: flex-end; justify-content: center;
}
.bar {
  width: clamp(14px, 70%, 34px); border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--orange-400), var(--orange));
  min-height: 4px; transition: height .45s cubic-bezier(.22,.61,.36,1);
  box-shadow: var(--shadow-sm);
}
.bar.hit { background: linear-gradient(180deg, var(--green-400), var(--green)); }
.bar.empty { background: var(--track); box-shadow: none; }
.goal-line {
  position: absolute; left: 4%; right: 4%; height: 0; border-top: 2px dashed var(--orange-600);
  opacity: .7; pointer-events: none;
}
[data-theme="dark"] .goal-line { border-top-color: var(--orange-400); }
.bar-day { font-size: .72rem; font-weight: 700; color: var(--muted); }
.bar-day.today { color: var(--orange); }
.bar-val { font-size: .66rem; color: var(--muted); white-space: nowrap; }
.bar-cell:hover .bar { filter: brightness(1.06); }
.bar-cell.is-today .bar-wrap::after {
  content: ""; position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--orange);
}
.chart-legend {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: .75rem; color: var(--muted); margin: 12px 0 0;
}
.lg-bar, .lg-goal { display: inline-block; width: 16px; height: 10px; border-radius: 3px; }
.lg-bar { background: linear-gradient(180deg, var(--orange-400), var(--orange)); }
.lg-goal { border: 0; border-top: 2px dashed var(--orange-600); height: 0; width: 18px; }

/* ====== Tagesliste ====== */
.day-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.day-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.day-row.is-today { border-color: var(--orange); background: linear-gradient(135deg, rgba(234,88,12,.06), transparent); }
.day-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 140px; }
.day-name { font-weight: 700; }
.day-name .today-tag {
  font-size: .65rem; background: var(--orange); color: #fff;
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.day-sub { font-size: .78rem; color: var(--muted); }
.day-value { font-weight: 800; font-size: 1.05rem; margin-left: auto; }
.day-value.hit { color: var(--good); }
.day-edit {
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--orange); border-radius: 10px; padding: 8px 12px; cursor: pointer;
  font-weight: 700; font-size: .82rem; flex: 0 0 auto;
}
.day-edit:hover { background: var(--track); }

.footnote { text-align: center; color: var(--muted); font-size: .75rem; margin: 8px 0 0; padding: 0 8px; }

/* ====== Modal ====== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(28, 18, 12, .5);
  display: grid; place-items: center; padding: 16px;
  animation: fade .2s ease;
}
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.6); }
.modal {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  animation: pop .22s cubic-bezier(.22,.61,.36,1);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 8px;
}
.modal-head h3 { margin: 0; font-size: 1.15rem; }
.modal-close { min-width: 38px; height: 38px; }
.modal-body { padding: 4px 18px 8px; }
.field-label { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.entry-row { display: flex; gap: 8px; align-items: center; }
.entry-unit { color: var(--muted); font-size: .9rem; flex: 0 0 auto; }
.quick-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.qa-btn {
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--orange);
  border-radius: 999px; padding: 8px 12px; cursor: pointer; font-weight: 700; font-size: .82rem;
}
.qa-btn:hover { background: var(--track); }
.modal-foot {
  display: flex; gap: 10px; justify-content: space-between;
  padding: 8px 18px 18px;
}
.modal-foot .btn-primary { flex: 1 1 auto; }

/* ====== Toast ====== */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: 12px; font-weight: 600; font-size: .9rem;
  box-shadow: var(--shadow); z-index: 80; max-width: 90vw; text-align: center;
  opacity: 0; transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ====== Install ====== */
.install-fab {
  position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 70;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-600));
  color: #fff; border: none; border-radius: 999px;
  padding: 12px 18px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
}
.install-fab:active { transform: scale(.97); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ====== Responsive ====== */
@media (min-width: 560px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
