/* ============================================================
   FastenZeit – Design-Tokens
   Light-Theme auf :root, Dark-Overrides im Media Query.
   ============================================================ */
:root {
  /* Farben */
  --bg: #f4f8f6;
  --surface: #ffffff;
  --surface-alt: #e9f1ee;
  --border: #d5e2dd;
  --text: #17302b;
  --text-muted: #58706a;
  --accent: #0e7c6b;          /* Fastenphase */
  --accent-soft: #d7ede8;
  --eat: #c2660a;             /* Essensfenster */
  --eat-soft: #f7e6d2;
  --danger: #b3372f;
  --ring-track: #dde8e4;
  --shadow: 0 2px 10px rgba(23, 48, 43, 0.08);

  /* Kalender-Intensitäten */
  --cal-0: #e6eeeb;
  --cal-1: #a9d8cd;
  --cal-2: #4aa993;
  --cal-3: #0e7c6b;

  /* Typografie */
  --font-head: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;

  /* Layout */
  --radius: 14px;
  --gap: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1514;
    --surface: #16211f;
    --surface-alt: #1d2b28;
    --border: #2b3d39;
    --text: #e4efec;
    --text-muted: #92aaa4;
    --accent: #3fcdb4;
    --accent-soft: #123c35;
    --eat: #e8a04c;
    --eat-soft: #3a2a14;
    --danger: #e57368;
    --ring-track: #24332f;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);

    --cal-0: #1c2926;
    --cal-1: #24564c;
    --cal-2: #2f8b78;
    --cal-3: #3fcdb4;
  }
}

/* ============================================================
   Basis
   ============================================================ */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-head);
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--gap) 2rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ============================================================
   Header & Footer
   ============================================================ */
.app-header {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem var(--gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-text h1 { margin: 0; }

.tagline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem var(--gap) 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.app-footer nav {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

/* ============================================================
   Karten, Buttons, Formulare
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.badge {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  vertical-align: middle;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 120ms ease, background-color 120ms ease;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}
.btn-primary:not(:disabled):hover { filter: brightness(1.08); }

.btn-primary.ending {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}
.btn-ghost:not(:disabled):hover { background: var(--surface-alt); }

.btn-lg { padding: 0.8rem 2rem; font-size: 1.05rem; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

select, input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

select:focus, input:focus, .btn:focus-visible, .link-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.form-error { color: var(--danger); font-size: 0.85rem; }

.section-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   Disclaimer
   ============================================================ */
.disclaimer {
  max-width: 640px;
  margin: 0 auto 1rem;
  padding: 0.85rem 1rem;
  margin-left: var(--gap);
  margin-right: var(--gap);
  background: var(--eat-soft);
  border: 1px solid var(--eat);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

@media (min-width: 680px) {
  .disclaimer { margin-left: auto; margin-right: auto; }
}

/* ============================================================
   Timer & Ring
   ============================================================ */
.protocol-row { margin-bottom: 1.25rem; }
.custom-hours { margin-top: 0.75rem; max-width: 180px; }

.ring-wrap {
  position: relative;
  width: min(78vw, 320px);
  margin: 0 auto;
}

.ring { display: block; width: 100%; height: auto; }

.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 16;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 703.7 703.7; /* 2 * PI * 112 */
  stroke-dashoffset: 703.7;
  transition: stroke-dashoffset 900ms linear, stroke 400ms ease;
}

.ring-progress.eating { stroke: var(--eat); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.2rem;
}

.phase-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.phase-label.eating { color: var(--eat); }

.time-main {
  margin: 0.15rem 0;
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.time-sub {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.time-percent {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.timer-meta {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.meta-item { text-align: center; }
.meta-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.meta-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.timer-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ============================================================
   Meilensteine
   ============================================================ */
.milestones {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.milestone {
  display: grid;
  grid-template-columns: 2rem 3.2rem 1fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.milestone .check {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: transparent;
}

.milestone.reached {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.milestone.reached .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}

.milestone .hours { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============================================================
   Statistiken & Kalender
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.stat-tile {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.5rem;
  text-align: center;
}

.stat-value {
  display: block;
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 7px;
  background: var(--cal-0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.cal-day.level-1 { background: var(--cal-1); color: var(--text); }
.cal-day.level-2 { background: var(--cal-2); color: #ffffff; }
.cal-day.level-3 { background: var(--cal-3); color: #ffffff; }
.cal-day.today { border-color: var(--accent); }
.cal-head {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 2px;
}

.calendar-legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

.legend-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 4px;
  display: inline-block;
  margin-left: 0.6rem;
}
.legend-swatch:first-child { margin-left: 0; }
.legend-swatch.level-0 { background: var(--cal-0); border: 1px solid var(--border); }
.legend-swatch.level-1 { background: var(--cal-1); }
.legend-swatch.level-2 { background: var(--cal-2); }
.legend-swatch.level-3 { background: var(--cal-3); }

/* ============================================================
   Gewichts-Log
   ============================================================ */
.weight-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  align-items: end;
  margin: 0.75rem 0 1rem;
}

.weight-form label { margin-bottom: 0; align-self: end; }
.weight-form label[for="weight-date"] { grid-column: 1; grid-row: 1; }
.weight-form label[for="weight-kg"]   { grid-column: 2; grid-row: 1; }
.weight-form #weight-date { grid-column: 1; grid-row: 2; }
.weight-form #weight-kg   { grid-column: 2; grid-row: 2; }
.weight-form button { grid-column: 1 / -1; grid-row: 3; }

@media (min-width: 480px) {
  .weight-form { grid-template-columns: 1fr 1fr auto; }
  .weight-form button { grid-column: 3; grid-row: 2; }
}

.chart-wrap { width: 100%; }
#weight-chart { width: 100%; display: block; }

.weight-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
}

.weight-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  background: var(--surface-alt);
}

.weight-list .del {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.1rem 0.3rem;
}

/* ============================================================
   Ad-Slot
   ============================================================ */
.ad-slot {
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.ad-hint {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================
   Modals
   ============================================================ */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 420px;
  width: calc(100vw - 2rem);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.modal::backdrop { background: rgba(10, 20, 18, 0.55); }

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.feature-list { padding-left: 1.2rem; margin: 0.75rem 0; }
.feature-list li { margin-bottom: 0.3rem; }
.price { font-size: 1.1rem; }

/* ============================================================
   Hilfe / Erste Schritte
   ============================================================ */
.help-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.help-steps {
  margin: 0.75rem 0 0;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.help-steps li::marker {
  color: var(--accent);
  font-weight: 600;
}

.help-subtitle { margin-top: 1.1rem; margin-bottom: 0.35rem; }

.help-know {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.help-know li { margin-bottom: 0.3rem; }

/* ============================================================
   Reduzierte Bewegung
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .ring-progress { transition: none; }
}
