@font-face {
  font-family: "Bricolage";
  src: url("/static/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #EEF1F4;
  --card: #FFFFFF;
  --ink: #1E2A44;
  --text: #1E2430;
  --muted: #5E6878;
  --line: #D5DBE3;
  --done: #2F6650;
  --done-soft: #DCEBE3;
  --sun: #E8A93B;
  --sun-soft: #FBEFD6;
  --danger: #A23B32;
  --display: "Bricolage", "Avenir Next", system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --r-lg: 22px;
  --r-md: 14px;
  --tabbar-h: 64px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121722;
    --card: #1B2230;
    --ink: #C9D5F2;
    --text: #E7EBF2;
    --muted: #97A1B3;
    --line: #2A3344;
    --done: #5FB08B;
    --done-soft: #1F3A30;
    --sun: #F0BC5C;
    --sun-soft: #3A2F18;
    --danger: #E07A70;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 17px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 28px);
}

h1, h2, h3 { font-family: var(--display); color: var(--ink); margin: 0; line-height: 1.15; }
h1 { font-size: 2.1rem; font-weight: 750; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 650; }
p { margin: 0.4em 0; }
a { color: inherit; }
img { display: block; max-width: 100%; }

.muted { color: var(--muted); }
.lead { color: var(--muted); font-size: 1.02rem; max-width: 60ch; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 2px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

/* ------------------------------------------------------------ Flash */
.flash { padding: 12px 14px; border-radius: var(--r-md); margin: 0 0 16px; font-size: 0.95rem; }
.flash--error { background: color-mix(in srgb, var(--danger) 14%, var(--card)); color: var(--danger); }
.flash--ok { background: var(--done-soft); color: var(--done); }

/* ------------------------------------------------------------ Kopf */
.page-head { margin: 4px 0 20px; }
.page-head h1 { margin-bottom: 6px; }
.back {
  display: inline-block; margin: 0 0 14px; text-decoration: none; color: var(--muted); font-size: 0.95rem;
}
.back::before { content: "‹ "; font-size: 1.2em; }

.today-head { margin: 8px 0 22px; }
.today-head__day {
  font-size: clamp(2.8rem, 15vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.95;
}
.today-head__date { color: var(--muted); font-size: 1.05rem; margin-top: 6px; }

/* ------------------------------------------------------------ Karten */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px 18px 16px;
  margin: 0 0 14px;
}
.card--quiet { background: transparent; border: 1px solid var(--line); }
.card--sun { background: var(--sun-soft); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }

.empty { text-align: left; padding: 28px 4px; }
.empty h2 { font-size: 1.4rem; margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }

.pill {
  display: inline-block; font: 600 0.78rem/1 var(--body); padding: 5px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--text); vertical-align: middle;
  margin-right: 4px;
}
.pill--sun { background: var(--sun-soft); color: color-mix(in srgb, var(--sun) 60%, var(--text)); }
.pill--done { background: var(--done-soft); color: var(--done); }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 999px; border: 0;
  font: 600 1rem/1.2 var(--body); text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--ghost { background: color-mix(in srgb, var(--ink) 9%, transparent); color: var(--ink); }
.btn--done { background: var(--done); color: #fff; }
.btn--block { width: 100%; }
.btn:active { transform: scale(0.98); }
.link-btn {
  background: none; border: 0; padding: 6px 2px; color: var(--muted); font: 500 0.9rem var(--body);
  text-decoration: underline; cursor: pointer;
}
.link-btn--danger { color: var(--danger); }
.link { color: var(--ink); font-weight: 600; font-size: 0.95rem; }

[data-on], [data-off] { display: none; }
[aria-pressed="true"] [data-on], [aria-pressed="false"] [data-off] { display: inline; }

/* ------------------------------------------------------------ Formulare */
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.95rem; }
.field input {
  font: 400 1.05rem var(--body); padding: 13px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.95rem; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--ink); }

/* ------------------------------------------------------------ Login */
.is-login .page { padding-top: calc(env(safe-area-inset-top, 0px) + 14vh); }
.login__mark { font-size: 3.6rem; font-weight: 800; letter-spacing: -0.04em; }
.login__lead { color: var(--muted); margin: 8px 0 28px; max-width: 32ch; }

/* ------------------------------------------------------------ Titelbild */
.cover {
  position: relative; margin: 0 -16px; aspect-ratio: 3 / 2; overflow: hidden;
  background: var(--ink); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
@media (min-width: 672px) { .cover { margin: 0; border-radius: var(--r-lg); } }
.cover > img, .compare img { width: 100%; height: 100%; object-fit: cover; }
.cover figcaption {
  position: absolute; inset: auto 0 0 0; padding: 48px 18px 16px;
  background: linear-gradient(to top, rgba(10, 14, 24, 0.72), rgba(10, 14, 24, 0));
  color: #fff; pointer-events: none; display: grid; gap: 2px;
}
.cover--placeholder figcaption { background: none; }
.cover__kicker { font: 600 0.95rem var(--body); opacity: 0.9; }
.cover__title {
  font-family: var(--display); font-weight: 780; font-size: clamp(1.9rem, 8.5vw, 2.8rem);
  letter-spacing: -0.025em; line-height: 1.02;
}
.cover__sub { font-size: 0.95rem; opacity: 0.85; }

.tag {
  position: absolute; top: 14px; font: 700 0.78rem/1 var(--body); padding: 6px 10px; border-radius: 999px;
  background: rgba(10, 14, 24, 0.55); color: #fff; pointer-events: none;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tag--before { left: 14px; }
.tag--after { right: 14px; background: var(--done); }

.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
.photo-slot { display: grid; justify-items: center; gap: 0; }
.photo-slot form { margin: 0; width: 100%; }
.photo-slot .btn { width: 100%; min-height: 44px; font-size: 0.95rem; padding: 10px 12px; }
.is-uploading { opacity: 0.6; pointer-events: none; }

/* Vorher/Nachher-Vergleich */
.compare { position: relative; width: 100%; height: 100%; aspect-ratio: 3 / 2; overflow: hidden; touch-action: pan-y; }
.compare img { position: absolute; inset: 0; }
.compare__before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.compare__handle {
  position: absolute; top: 0; bottom: 0; left: var(--pos); width: 3px; margin-left: -1.5px;
  background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); pointer-events: none;
}
.compare__handle::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.compare__range {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize;
  -webkit-appearance: none; appearance: none;
}

/* ------------------------------------------------------------ Fortschritt */
.progress { display: grid; gap: 6px; margin: 16px 0; }
.progress__track { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 12%, transparent); overflow: hidden; }
.progress__fill { display: block; height: 100%; background: var(--done); border-radius: 99px; transition: width 0.35s ease; }
.progress__text { font-size: 0.88rem; color: var(--muted); }

/* ------------------------------------------------------------ Brief */
.letter {
  margin: 8px 0 18px; padding: 4px 0 4px 18px; border-left: 4px solid var(--sun);
  font-family: var(--display); font-size: 1.22rem; font-weight: 450; line-height: 1.4; color: var(--ink);
}

/* ------------------------------------------------------------ Aufgaben */
.tasks, .deadlines, .notes, .plain-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; cursor: pointer; }
.task input { position: absolute; opacity: 0; pointer-events: none; }
.task__box {
  flex: 0 0 26px; height: 26px; border-radius: 8px; border: 2px solid color-mix(in srgb, var(--ink) 35%, transparent);
  display: grid; place-items: center; transition: background 0.2s, border-color 0.2s;
}
.task input:checked + .task__box { background: var(--done); border-color: var(--done); }
.task input:checked + .task__box::after {
  content: ""; width: 7px; height: 13px; border: solid #fff; border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg);
}
.task input:focus-visible + .task__box { outline: 3px solid var(--sun); outline-offset: 2px; }
.task input:checked ~ .task__label { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.task__label small { display: block; margin-top: 2px; }
.tasks li + li, .deadlines li + li { border-top: 1px solid var(--line); }
.is-overdue strong { color: var(--danger); }
.overdue { color: var(--danger); font-style: normal; font-weight: 600; font-size: 0.85rem; margin-left: 4px; }

.notes li { position: relative; padding: 6px 0 6px 18px; color: var(--text); }
.notes li::before { content: ""; position: absolute; left: 2px; top: 0.95em; width: 6px; height: 6px; border-radius: 50%; background: var(--sun); }
.plain-list li { padding: 8px 0; }
.plain-list li + li { border-top: 1px solid var(--line); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ------------------------------------------------------------ Gewohnheit */
.habit-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.habit-day {
  aspect-ratio: 1; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--ink) 25%, transparent);
  background: none; color: var(--text); font: 600 0.85rem var(--body); cursor: pointer; padding: 0;
}
.habit-day[aria-pressed="true"] { background: var(--sun); border-color: var(--sun); color: #2A1E05; }
.habit-day:disabled { opacity: 0.35; cursor: default; }

.habit-card { background: var(--card); border-radius: var(--r-lg); margin: 0 0 14px; overflow: hidden; }
.habit-card__week { display: flex; gap: 12px; align-items: center; padding: 14px 16px; text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.habit-card__body { padding: 0 16px 16px; }
.habit-card__title { font-size: 1.4rem; margin-bottom: 4px; }
.habit-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 12px; padding: 14px 16px;
  border-radius: var(--r-md); border: 0; background: var(--sun-soft); color: var(--text);
  font: 650 1.05rem var(--body); cursor: pointer; text-align: left;
}
.habit-btn__dot { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--sun); flex: 0 0 26px; transition: background 0.2s; }
.habit-btn[aria-pressed="true"] { background: var(--sun); color: #2A1E05; }
.habit-btn[aria-pressed="true"] .habit-btn__dot { background: #fff; border-color: #fff; }

/* ------------------------------------------------------------ Tage */
.day { background: var(--card); border-radius: var(--r-lg); padding: 12px 16px 6px; margin: 0 0 12px; }
.day__link { display: flex; gap: 12px; align-items: center; text-decoration: none; padding-bottom: 4px; }
.day__date { display: block; font-family: var(--display); font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.day__meta { display: block; margin-top: 4px; }
.day__empty { padding: 6px 0 10px; }

.thumb { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 12px; overflow: hidden; background: var(--ink); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb--after { box-shadow: 0 0 0 2px var(--done); }

/* ------------------------------------------------------------ Journeys */
.journey-row { margin: 0 0 14px; }
.journey-row__link { display: block; background: var(--card); border-radius: var(--r-lg); padding: 18px; text-decoration: none; }
.journey-row__link h2 { font-size: 1.4rem; }
.strip { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.strip .thumb { width: 44px; height: 44px; border-radius: 10px; }

.timeline { list-style: none; margin: 0 0 18px; padding: 0; }
.timeline__item { position: relative; }
.timeline__link { display: flex; gap: 12px; align-items: center; padding: 10px 0; text-decoration: none; }
.timeline__num {
  flex: 0 0 34px; font-family: var(--display); font-weight: 800; font-size: 1.5rem; color: var(--muted); text-align: right;
}
.timeline__text { display: grid; gap: 2px; }
.timeline__title { font-family: var(--display); font-weight: 650; font-size: 1.1rem; color: var(--ink); }
.timeline__item + .timeline__item { border-top: 1px solid var(--line); }
.timeline__item.is-current .timeline__num { color: var(--sun); }
.timeline__item.is-complete .timeline__num { color: var(--done); }
.timeline .pill { justify-self: start; margin-top: 4px; }

.done-card .btn { margin-top: 10px; }
.pager { display: flex; justify-content: space-between; margin: 20px 0 0; }

.logout { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; font-size: 0.9rem; }

/* ------------------------------------------------------------ Erfolge */
.score { font-size: 1.05rem; color: var(--muted); }
.score__num { font-family: var(--display); font-weight: 800; font-size: 1.6rem; color: var(--done); }
.success { background: var(--card); border-radius: var(--r-lg); overflow: hidden; margin: 0 0 16px; }
.success .compare, .success__img { aspect-ratio: 3 / 2; width: 100%; object-fit: cover; }
.success__cap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 12px 16px; text-decoration: none; }

/* ------------------------------------------------------------ Tab-Leiste */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 6px);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  display: grid; justify-items: center; gap: 2px; min-width: 76px; padding: 6px 8px;
  text-decoration: none; color: var(--muted); font-size: 0.72rem; font-weight: 600;
}
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
