/* Gota: mobile-first. White text on accent backgrounds uses --accent-dark (AA). */
:root {
  --accent: #1e88e5; --accent-dark: #1565c0; --bg: #f5f8fb; --surface: #fff;
  --text: #1b2430; --muted: #5b6675; --track: #dde6ef; --danger: #b3261e; --radius: 14px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4; background: var(--bg); color: var(--text);
}
button, input { font: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h2 { font-size: 1.1rem; margin: 24px 0 8px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Header and main */
.app-header { padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; background: var(--accent-dark); color: #fff; }
.app-name { display: block; max-width: 480px; margin: 0 auto; font-size: 1.25rem; font-weight: 700; }
main#app { max-width: 480px; margin: 0 auto; padding: 16px 16px calc(104px + env(safe-area-inset-bottom)); }
.error { color: var(--danger); font-weight: 600; margin: 8px 0; }
.hint { color: var(--muted); font-size: 0.9rem; margin-top: 24px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* Buttons and inputs (44px minimum touch targets) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px;
  border: 1px solid transparent; border-radius: 12px; font-weight: 600; cursor: pointer;
}
.btn--primary { background: var(--accent-dark); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--accent-dark); border-color: var(--accent-dark); }
.btn--big { width: 100%; min-height: 56px; font-size: 1.1rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.login label { display: block; font-weight: 600; margin: 16px 0 6px; }
.login input, .custom input {
  min-height: 44px; padding: 8px 12px; font-size: 1rem; border: 1px solid #9aa7b5; border-radius: 12px; background: var(--surface);
}
.login input { display: block; width: 100%; }
.profiles { display: grid; gap: 12px; margin-top: 16px; }

/* Ring */
.today-ring { display: flex; justify-content: center; }
.ring { position: relative; width: min(200px, 70vw); aspect-ratio: 1; margin: 8px 0 16px; }
.ring__svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { stroke: var(--track); }
.ring__progress { stroke: var(--accent); transition: stroke-dashoffset 0.3s ease; }
.ring__text {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 0 24px;
}
.ring__amount { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring__pct { color: var(--muted); font-size: 1.5rem; font-weight: 700; }

/* Partner card (under the ring on Today); the actions row is empty until the nudge button lands */
.ring--sm { width: 72px; margin: 0; flex: none; }
.partner-card { display: flex; align-items: center; gap: 16px; margin: 0 0 16px; }
.partner-card__body { flex: 1; min-width: 0; }
.partner-card .partner-card__name { margin: 0 0 2px; font-size: 1.05rem; overflow-wrap: anywhere; }
.partner-card__total { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.partner-card__last { margin: 2px 0 0; color: var(--muted); }
.partner-card__actions:empty { display: none; }
.partner-card__actions { margin-top: 8px; }
.partner-card__hint { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

/* Offline banner, right under the header (dark text on amber: well above AA) */
.offline-banner { margin: 0; padding: 10px 16px; background: #fff3cd; color: var(--text); font-weight: 600; text-align: center; border-bottom: 1px solid #e0b84a; }

/* iOS install tip, above the main content */
.install-banner {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px;
  background: #e3f2fd; color: var(--text); border-bottom: 1px solid #90caf9; font-size: 0.95rem;
}
.install-banner p { flex: 1; margin: 0; }
.install-banner__close {
  min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--accent-dark);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}

/* Presets and custom amount */
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.custom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.custom label { width: 100%; font-weight: 600; }
.custom input { flex: 1; min-width: 0; }
.custom .error { width: 100%; }

/* Entries */
.entries { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.entry { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 4px 8px 4px 16px; border-bottom: 1px solid var(--track); }
.entry:last-child { border-bottom: 0; }
.entry__time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4ch; }
.entry__amount { flex: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.entry__saving { color: var(--muted); font-style: italic; }
.icon-btn {
  display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--danger); cursor: pointer;
}
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Bottom tab bar */
.tabs {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 480px); z-index: 10;
  display: flex; background: var(--surface); border-top: 1px solid var(--track); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 12px 8px;
  color: var(--muted); font-weight: 600; text-decoration: none;
}
.tabs a[aria-current="page"] { color: var(--accent-dark); box-shadow: inset 0 3px 0 var(--accent-dark); }

/* Toast, above the tab bar */
.toast {
  position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 4px; width: min(calc(100% - 32px), 440px); padding: 12px 16px;
  border-radius: 12px; background: var(--text); color: #fff; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.toast--show { opacity: 1; pointer-events: auto; }
.toast__action {
  min-height: 44px; margin-left: auto; padding: 0 8px; border: 0; background: transparent;
  color: #90caf9; font-weight: 700; cursor: pointer;
}

/* History: the chart is sized by its viewBox; met days are full accent, missed days faded */
.history h2, .card h2 { margin: 0 0 12px; }
.streak { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; }
.streak--none { color: var(--muted); font-weight: 600; }
.average { color: var(--muted); text-align: center; margin: 12px 0 0; }
.chart { margin: 0; padding: 12px 8px 8px; background: var(--surface); border-radius: var(--radius); }
.chart__svg { display: block; width: 100%; height: auto; }
.bar { fill: var(--accent); }
.bar--missed { fill-opacity: 0.35; }
.bar--today { fill: var(--accent-dark); fill-opacity: 1; }
.goal-line { stroke: var(--text); stroke-width: 1.5; fill: none; }
.chart__goal-label {
  fill: var(--text); font-size: 11px; font-weight: 600;
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px;
}
.chart__label { fill: var(--muted); font-size: 12px; }
.chart__label--today { fill: var(--accent-dark); font-weight: 700; }

/* Settings: cards, labelled fields (44px tall), reminder toggle row */
.settings { display: grid; gap: 16px; }
.card { padding: 16px; background: var(--surface); border-radius: var(--radius); }
.field { display: grid; gap: 6px; margin-top: 12px; }
.field label, .check { font-weight: 600; }
.field input, .field select {
  width: 100%; min-height: 44px; padding: 8px 12px; font-size: 1rem; color: var(--text);
  border: 1px solid #9aa7b5; border-radius: 12px; background: var(--surface);
}
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.check input { width: 24px; height: 24px; margin: 0; accent-color: var(--accent-dark); }
.field-hint { color: var(--muted); font-size: 0.9rem; margin: 8px 0 0; }
.field-hint.error { color: var(--danger); font-weight: 600; }
.error:empty { display: none; }
.suggest .btn { width: 100%; margin-top: 8px; }
.time-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.account p { margin: 0 0 12px; }
.account .btn { width: 100%; }

/* Notifications card (Settings): status line, then full-width 44px+ buttons */
.notify-status { margin: 0; font-weight: 600; }
.notify-actions { display: grid; gap: 8px; margin-top: 12px; }
.notify-actions .btn { width: 100%; }
