/* Milch-Tracker — nachts bedienbar, einhändig, gedämpft. */

:root {
  --ink:        #0E131C;
  --surface:    #161D2A;
  --surface-2:  #1E2637;
  --line:       #2A3346;
  --milk:       #F1EEE5;
  --muted:      #808DA6;
  --oral:       #F2C063;
  --tube:       #6FA4D8;
  --spit:       #C57C7C;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --r: 14px;
  --pad: 16px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--milk);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body { padding-bottom: env(safe-area-inset-bottom); }

h1, h2 { font-weight: 600; letter-spacing: -0.01em; }

button, input, select { font: inherit; color: inherit; }
button { touch-action: manipulation; }

/* ── Anmeldung ───────────────────────────── */

.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--pad); }
.login-inner { width: 100%; max-width: 320px; text-align: center; }
.login-mark { width: 46px; color: var(--oral); margin-bottom: 20px; }
.login h1 { font-size: 28px; margin: 0 0 4px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 28px; }
.login .field { text-align: left; }
.login .btn { width: 100%; margin-top: 8px; }

/* ── Rahmen ──────────────────────────────── */

#app { max-width: 560px; margin: 0 auto; padding-bottom: 84px; }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad) 12px;
  font-size: 13px; color: var(--muted);
}
.bar-day { font-variant-numeric: tabular-nums; }
.bar-status { font-size: 12px; }
.bar-status[data-state="offline"] { color: var(--oral); }
.bar-status[data-state="pending"] { color: var(--tube); }

main { padding: 0 var(--pad); }

.section-head {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 28px 0 10px; font-weight: 600;
}
.section-head span { text-transform: none; letter-spacing: 0; font-weight: 400; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--pad);
}
.stack > * + * { margin-top: 12px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }

/* ── Timer ───────────────────────────────── */

.since { text-align: center; padding: 8px 0 20px; }
.since-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.since-value {
  display: block; font-family: var(--mono); font-size: 46px; font-weight: 500;
  letter-spacing: -0.03em; margin: 4px 0 2px; font-variant-numeric: tabular-nums;
}
.since-detail { font-size: 13px; color: var(--muted); }

/* ── Messsäule (Signature) ───────────────── */

.gauge-wrap { display: flex; gap: 20px; align-items: stretch; }
#gauge { flex: 0 0 116px; }
#gauge svg { display: block; width: 100%; height: auto; }

.legend { flex: 1; margin: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.legend > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 0; }
.legend dt { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.legend dd { margin: 0; font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.legend-total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px !important; }
.legend-total dt { color: var(--milk); font-weight: 600; }
.legend-total dd { font-size: 22px; font-weight: 600; }

.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot-oral { background: var(--oral); }
.dot-tube { background: var(--tube); }
.dot-spit { background: var(--spit); }

/* ── Buttons ─────────────────────────────── */

.btn {
  display: block; width: 100%; text-align: center; text-decoration: none;
  padding: 14px 18px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 16px; font-weight: 500; cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--oral); color: #241A05; border-color: transparent; font-weight: 600; }
.btn-big { padding: 18px; font-size: 17px; margin-top: 22px; }
.btn-ghost { background: transparent; color: var(--muted); font-size: 14px; padding: 11px; }
.btn-danger { background: transparent; color: var(--spit); border-color: var(--line); }
.btn-tube { color: var(--tube); border-color: var(--tube); }

.link { background: none; border: 0; padding: 8px 4px; color: var(--muted); font-size: 15px; cursor: pointer; }
.link-strong { color: var(--oral); font-weight: 600; }

/* ── Liste ───────────────────────────────── */

.feeds { list-style: none; margin: 0; padding: 0; }
.feeds li {
  display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 12px;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); margin-bottom: 8px; cursor: pointer;
}
.feed-time { font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.feed-parts { display: flex; gap: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.feed-parts span { display: flex; align-items: center; gap: 5px; }
.feed-total { font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.feed-note { grid-column: 2 / -1; font-size: 13px; color: var(--muted); font-style: italic; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 28px 0; }

/* ── Diagramme ───────────────────────────── */

#chart-week svg, #chart-oral svg, #chart-heat svg { display: block; width: 100%; height: auto; }
.chart-label { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.chart-pct { font-family: var(--mono); font-size: 8px; fill: var(--oral); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.tile-value { font-family: var(--mono); font-size: 22px; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.35; }

/* ── Tabs ────────────────────────────────── */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: rgba(14, 19, 28, .93);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: 0; padding: 15px 0 14px;
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.tab.is-active { color: var(--oral); font-weight: 600; }

/* ── Eingabe-Sheet ───────────────────────── */

.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto;
  background: var(--ink); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  max-width: 560px; margin: 0 auto;
  animation: rise .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sheet-panel { animation: none; }
  .btn:active { transform: none; }
}

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--ink); z-index: 1;
}
.sheet-head h2 { font-size: 16px; margin: 0; }
.sheet-body { padding: var(--pad) var(--pad) calc(28px + env(safe-area-inset-bottom)); }
.sheet-body > * + * { margin-top: 14px; }

.time-row { display: flex; flex-direction: column; gap: 8px; }
.time-row input {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 14px; width: 100%; font-family: var(--mono);
}
.time-quick { display: flex; gap: 6px; }
.time-quick button {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 0; font-size: 13px; color: var(--muted); cursor: pointer;
}
.time-quick button.is-active { border-color: var(--oral); color: var(--oral); }

/* Stepper */
.step { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.step-label { flex: 1; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.step-ctl { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.step-ctl button {
  width: 46px; height: 46px; background: none; border: 0;
  font-size: 22px; color: var(--milk); cursor: pointer; line-height: 1;
}
.step-ctl input {
  width: 58px; height: 46px; background: none; border: 0; text-align: center;
  font-family: var(--mono); font-size: 17px; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.step-ctl input::-webkit-outer-spin-button,
.step-ctl input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-unit { font-size: 13px; color: var(--muted); width: 20px; }

/* ── Formularfelder ──────────────────────── */

.field { display: block; margin-bottom: 14px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
}
.field input:focus-visible, .field select:focus-visible,
.btn:focus-visible, .tab:focus-visible, .link:focus-visible,
.step-ctl input:focus-visible, .step-ctl button:focus-visible {
  outline: 2px solid var(--oral); outline-offset: 2px;
}

.error { color: var(--spit); font-size: 14px; margin: 14px 0 0; }
.warn { color: var(--oral); font-size: 13px; margin: 0; }

/* ── Toast ───────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 60;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
}
