:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --fill: #ededed;
  --text: #171717;
  --muted: #666666;
  --line: #dedede;
  --period: #a62c36;
  --period-soft: #fde4e2;
  --peak: #6232a3;
  --peak-soft: #eee3fc;
  --fertile: #126788;
  --switch: #262626;
  --seg-on: #ffffff;

  --gap: 14px;
  --font: -apple-system, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --surface: #171717;
    --fill: #272727;
    --text: #f5f5f5;
    --muted: #ababab;
    --line: #363636;
    --period: #ff8a92;
    --period-soft: #3f1a18;
    --peak: #d6baff;
    --peak-soft: #322049;
    --fertile: #87d3f4;
    --switch: #bfbfbf;
    --seg-on: #626262;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #171717;
  --fill: #272727;
  --text: #f5f5f5;
  --muted: #ababab;
  --line: #363636;
  --period: #ff8a92;
  --period-soft: #3f1a18;
  --peak: #d6baff;
  --peak-soft: #322049;
  --fertile: #87d3f4;
  --switch: #bfbfbf;
  --seg-on: #626262;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line) transparent; scrollbar-gutter: stable; overflow-x: clip; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.4 var(--font);
  font-variant-numeric: tabular-nums;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--text); color: var(--bg); }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h1 { font-size: 2.125rem; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.0625rem; line-height: 1.3; font-weight: 600; }
h3 { font-size: .8125rem; font-weight: 400; color: var(--muted); }
button, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
svg { display: block; }
.sprite { position: absolute; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Rahmen */
.main { padding: max(16px, env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom)); max-width: 1020px; margin-inline: auto; overflow-x: clip; }
.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.split > div { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.head p { font-size: .9375rem; color: var(--muted); }
.preview-note { font-size: .8125rem; color: var(--muted); text-align: center; }

.nav {
  position: fixed; inset: auto max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); z-index: 5;
  max-width: 430px; margin-inline: auto; border-radius: 34px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  backdrop-filter: blur(24px) saturate(145%);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  padding: 4px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .14), 0 8px 24px rgb(0 0 0 / .16);
}
.brand { display: none; }
.nav-items { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.nav-items::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 25%;
  background: var(--fill); border-radius: 28px; pointer-events: none;
  transform: translateX(calc(var(--tab-position, 0) * 100%));
}
.nav-item {
  position: relative;
  display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 54px; padding: 2px; border-radius: 28px; overflow-wrap: anywhere;
  color: var(--muted); font-size: .6875rem; font-weight: 500;
  transition: color 80ms;
}
.nav-item[aria-current="page"] { color: var(--text); }

/* Bausteine */
.card { background: var(--surface); border-radius: 12px; padding: var(--gap); display: grid; gap: 10px; align-content: start; }
.btn {
  min-height: 50px; padding: 0 12px; border-radius: 12px; white-space: nowrap; width: 100%;
  font-weight: 600; transition: transform var(--spring-ms, 200ms) var(--spring-bounce, var(--ease)), background-color 100ms, opacity 100ms;
}
.btn:active:not(:disabled) { transform: scale(.97); transition-duration: 40ms; }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-quiet { background: var(--surface); color: var(--text); }
.btn:disabled { color: var(--muted); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--text); transition: background-color 100ms; }
.icon-btn[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.chip {
  min-height: 38px; padding: 0 14px; border-radius: 19px; background: var(--fill);
  font-size: .9375rem; white-space: nowrap;
  transition: transform var(--spring-ms, 200ms) var(--spring-bounce, var(--ease)), background-color 60ms, color 60ms;
}
.chip:active:not(:disabled) { transform: scale(.95); transition-duration: 40ms; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 500; }
.chip:disabled { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill); }
.seg button { min-height: 32px; padding-inline: 12px; border-radius: 7px; font-size: .875rem; font-weight: 500; transition: background-color 100ms; }
.seg button[aria-pressed="true"] { background: var(--seg-on); font-weight: 600; }
.note { font-size: .875rem; color: var(--muted); }
.link { color: var(--text); min-height: 44px; padding-inline: 8px; }

@media (hover: hover) {
  .nav-item:hover { color: var(--text); }
  .nav-item[aria-current="page"]:hover { color: var(--text); }
  .icon-btn:hover { background: var(--fill); }
  .chip:hover:not(:disabled):not([aria-pressed="true"]) { background: var(--line); }
  .btn-primary:hover { opacity: .9; }
  .day:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--muted); }
}

/* Heute */
.summary { background: var(--fill); padding: 20px; }
.summary-label { font-size: .875rem; color: var(--muted); }
.summary-value { font-size: clamp(1.65rem, 8vw, 2.6rem); line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.summary-date { font-size: .875rem; color: var(--muted); }
.forecast-button { grid-template-columns: minmax(0, 1fr) auto; text-align: left; align-items: center; }
.forecast-button > span:first-child > * { display: block; }
.forecast-edit { color: var(--muted); font-size: .875rem; }
.peak-summary { background: var(--fill); }
.peak-summary strong { font-size: 1.25rem; }
.entry-form label { display: grid; gap: 6px; }
.entry-form input, .entry-form select { width: 100%; min-height: 48px; color: var(--text); background: var(--fill); border: 1px solid var(--line); border-radius: 10px; padding: 8px; font: inherit; }
.entry-form [role="alert"]:empty { display: none; }
.cycle-start { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.list { background: var(--surface); border-radius: 12px; padding-inline: var(--gap); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 46px; border-top: .5px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row span:last-child { color: var(--muted); text-align: right; }
.list-row span.peak-value { color: var(--peak); font-weight: 500; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week .wd { display: block; font-size: .75rem; color: var(--muted); text-align: center; margin-bottom: 2px; }
.quick { display: grid; gap: 10px; }
.message { background: var(--fill); border-radius: 12px; padding: var(--gap); }
.curve-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.curve { width: 100%; height: auto; touch-action: pan-y; cursor: ew-resize; user-select: none; -webkit-user-select: none; overflow: visible; }
.curve path { fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.curve path.past { stroke: var(--muted); }
.curve path.period { stroke: var(--period); stroke-width: 5; }
.curve path.peak { stroke: var(--peak); stroke-width: 5; }
.curve path.grip { stroke: var(--muted); stroke-width: 1.6; stroke-linejoin: round; }
.curve circle { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.curve text { fill: var(--muted); font-size: 12px; font-weight: 500; }
.curve text.z-period { fill: var(--period); }
.curve text.z-peak { fill: var(--peak); }
#curve-label { fill: var(--text); font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.good { font-size: .9375rem; }
.good b { font-weight: 600; margin-right: 4px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.edit-bar .btn { width: auto; padding-inline: 24px; }

/* Kalender */
.day {
  position: relative; width: 100%; max-width: 44px; aspect-ratio: 1; margin-inline: auto; display: grid; place-items: center;
  border-radius: 50%; font-size: .9375rem;
  transition: transform var(--spring-ms, 200ms) var(--spring-bounce, var(--ease)), box-shadow 100ms, opacity 100ms;
}
.day:active { transform: scale(.9); transition-duration: 40ms; }
.day:disabled { opacity: .35; }
.day .zt { position: absolute; top: -2px; right: -1px; font-size: .625rem; line-height: 1.3; color: var(--muted); }
.day .mark { position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--muted); }
.day .mark.spot { background: var(--period); }
.day.fert::before { content: ''; position: absolute; width: 11px; height: 2px; bottom: 6px; border-radius: 2px; background: var(--fertile); }
.day.fert .mark { bottom: 2px; }
.day.pred { background: var(--period-soft); color: var(--period); }
.day.pred::after { content: ''; position: absolute; inset: 3px; border: 1px dashed var(--period); border-radius: 50%; pointer-events: none; }
.day.peak { background: var(--peak-soft); color: var(--peak); font-weight: 600; }
.day.period { background: var(--period); color: var(--bg); font-weight: 600; }
.day.period .mark { background: var(--bg); }
.day.today { text-decoration: underline; text-underline-offset: 3px; font-weight: 700; }
.day[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--text); }
.day.match { background: var(--text); color: var(--bg); }
.dimmed .day:not(.match) { opacity: .3; }
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-bar h2 { font-size: clamp(1.12rem, 5vw, 1.6rem); font-weight: 700; }
.home-month .cal-bar h1 { font-size: clamp(1.45rem, 6vw, 2.25rem); letter-spacing: -.045em; }
.home-month .cal-nav { flex-shrink: 0; }
.home-month .cal-nav .link { padding-inline: 4px; font-size: .875rem; }
.home-month .legend { padding-inline: 0; }
.home-month .cal-grid .day { min-height: 40px; }
.home-layout .summary { padding: 14px; }
.home-layout .summary-value { font-size: clamp(1.3rem, 6vw, 1.85rem); }
.calendar-surface { display: grid; gap: 12px; }
.calendar-key summary { color: var(--muted); font-size: .875rem; padding-block: 6px; cursor: pointer; }
.calendar-key .legend { margin-top: 8px; }
.day-detail { border: 1px solid var(--line); }
.day-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.cal-nav { display: flex; align-items: center; }
.cal-clip { overflow: hidden; margin: -4px; padding: 4px; }
.cal-strip { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.cal-strip .ghost { position: absolute; top: 0; width: 100%; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 6px; }
.cal-grid .wd { font-size: .75rem; color: var(--muted); text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8125rem; color: var(--muted); padding-inline: 4px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; }
.swatch.period { background: var(--period); }
.swatch.pred { background: var(--period-soft); border: 1px dashed var(--period); }
.swatch.peak { background: var(--peak); }
.swatch.fert { height: 3px; background: var(--fertile); }
.filter-row { display: flex; gap: 8px; overflow-x: auto; margin-inline: calc(var(--gap) * -1); padding-inline: var(--gap); scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.year { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mini { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; width: 100%; padding: 12px; border-radius: 12px; background: var(--surface); text-align: left; font-weight: 600; font-size: .875rem; }
.mini-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.mini-grid i { aspect-ratio: 1; border-radius: 50%; background: var(--fill); }
.mini-grid i.blank { background: none; }
.mini-grid i.period { background: var(--period); }
.mini-grid i.pred { border: 1px dashed var(--period); }
.mini-grid i.peak { background: var(--peak); }
.mini-grid i.today { box-shadow: 0 0 0 1.5px var(--text); }

/* Insights */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.facts dt { font-size: .8125rem; color: var(--muted); }
.facts dd { font-size: 1.25rem; font-weight: 600; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-size: .8125rem; font-weight: 400; color: var(--muted); padding-bottom: 4px; }
.table td { padding: 6px 0; border-top: .5px solid var(--line); }
.table td:last-child, .table th:last-child { text-align: right; }
.card ul { display: grid; gap: 8px; }
.stat { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; width: 100%; min-height: 44px; text-align: left; }
.stat b { font-weight: 600; }
.bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--text); }
.cycle { display: grid; gap: 6px; padding-block: 10px; border-top: .5px solid var(--line); }
.cycle:first-child { border-top: 0; padding-top: 0; }
.cycle-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cycle-top span { flex: 1; }
.cycle-top b { font-weight: 500; }
.cycle-top .link { min-height: 32px; font-size: .8125rem; padding-inline: 0; }
.cycle-bar { height: 8px; width: calc(var(--len) / var(--max) * 100%); border-radius: 4px; overflow: hidden; background: var(--fill); }
.cycle-bar i { display: block; height: 100%; width: calc(var(--days) / var(--len) * 100%); background: var(--text); }
.cycle.off .cycle-bar { opacity: .4; }
.cycle.off .cycle-top { color: var(--muted); }

/* Für dich */
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; cursor: pointer; }
.row-text { display: grid; }
.row small { font-size: .8125rem; color: var(--muted); line-height: 1.35; }
.row.off { cursor: not-allowed; }
.switch { appearance: none; flex: none; margin: 0; width: 51px; height: 31px; border-radius: 16px; background: var(--fill); position: relative; cursor: inherit; transition: background-color 150ms; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgb(0 0 0 / .25); transition: transform var(--spring-ms, 200ms) var(--spring-bounce, var(--ease)); }
.switch:checked { background: var(--switch); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; }
textarea {
  width: 100%; min-height: 84px; padding: 10px 12px; resize: vertical; font-size: 1rem;
  border: 0; border-radius: 10px; background: var(--fill); caret-color: var(--text);
}
textarea::placeholder { color: var(--muted); }

/* Eintragen */
.sheet {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: 560px; max-height: 90dvh; margin: 0 auto;
  border: 0; border-radius: 14px 14px 0 0; padding: 0;
  background: var(--bg); color: var(--text);
  overflow-y: auto; overscroll-behavior: contain; will-change: transform;
}
.sheet::backdrop { background: rgb(0 0 0 / .4); opacity: var(--p, 1); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 20px 8px 10px 16px; background: var(--bg); touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.grabber { position: absolute; top: 7px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--muted); opacity: .5; }
.sheet-head p { font-size: .875rem; color: var(--muted); }
.sheet-body { display: grid; gap: 18px; padding: 4px 16px calc(16px + env(safe-area-inset-bottom)); }
.group { display: grid; gap: 8px; }

.toast {
  position: fixed; z-index: 10; left: 16px; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom));
  max-width: 420px; margin-inline: auto; display: none; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 6px 6px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg);
}
.toast.show { display: flex; animation: rise var(--spring-ms, 200ms) var(--spring-bounce, var(--ease)) both; }
.toast button { min-height: 40px; padding: 0 10px; font-weight: 600; }
.toast button:focus-visible { outline-color: var(--bg); }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

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

@media (prefers-reduced-transparency: reduce) {
  .nav { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media (max-width: 359px) {
  .home-month .cal-bar h1 { font-size: 1.3rem; }
}

@media (min-width: 600px) {
  .year { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sheet { bottom: 24px; border-radius: 14px; }
}

@media (min-width: 900px) {
  .nav { inset: 0 auto 0 0; width: 200px; border-radius: 0; box-shadow: none; border: 0; border-right: .5px solid var(--line); padding: 24px 12px; background: var(--surface); }
  .brand { display: block; font-weight: 700; padding: 0 12px 16px; }
  .nav-items { grid-template-columns: 1fr; grid-auto-rows: 1fr; gap: 2px; }
  .nav-items::before {
    inset: 0 0 auto; width: auto; height: calc((100% - 6px) / 4); border-radius: 10px;
    transform: translateY(calc(var(--tab-position, 0) * (100% + 2px)));
  }
  .nav-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; font-size: .9375rem; border-radius: 10px; }
  .main { margin-left: 200px; padding: 28px 32px; max-width: none; }
  .page { max-width: 1020px; margin-inline: auto; }
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .year { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .toast { bottom: 24px; }
  .filter-row { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
}

