:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --ink: #19180f;
  --muted: #6f6c63;
  --green: #2a7d5e;
  --green-mid: #4bad85;
  --green-soft: #e4f2ec;
  --red: #c04828;
  --red-soft: #faede9;
  --purple: #7040b0;
  --purple-soft: #f2ecf9;
  --amber: #956010;
  --amber-soft: #fdf3e0;
  --surface2: #edece8;
  --line: rgba(0, 0, 0, 0.1);
  --radius-card: 14px;
  --radius-input: 10px;
  --radius-btn: 14px;
  --radius-chip: 20px;
  --nav-height: 66px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.hidden { display: none !important; }

.brand, .topbar, .section-head, .email-row, .actions, .choice-row, .calendar-summary, .child-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand, .topbar, .section-head { justify-content: space-between; }

.top-link, .secondary-link {
  color: var(--green);
  font-weight: 800;
  text-decoration: none;
}

.mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 5vw, 48px); }
h2 { margin-bottom: 10px; font-size: clamp(22px, 3vw, 32px); }
p { line-height: 1.55; color: var(--muted); }

.hero, .card, .privacy, .login-card, .public-hero, .feature-card, .showcase-card, .login-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 1px 4px rgba(25, 24, 15, 0.08);
}

.hero {
  margin: 34px 0 16px;
  padding: clamp(22px, 5vw, 48px);
}

.login-card, .privacy, .card { padding: 18px; }
.login-card { margin-top: 24px; }

.public-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 28px;
  align-items: center;
  margin: 28px 0 16px;
  padding: clamp(24px, 5vw, 52px);
}

.public-hero h2 {
  max-width: 720px;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.02;
  letter-spacing: -1px;
}

.public-hero p { max-width: 620px; font-size: 17px; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.mock-phone {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-card);
  background: var(--bg);
  border: 1px solid var(--line);
}

.mock-header {
  color: var(--green);
  font-weight: 900;
  font-size: 22px;
}

.mock-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-input);
  background: white;
  border: 1px solid var(--line);
}

.mock-chip {
  justify-self: start;
  padding: 8px 10px;
  border-radius: var(--radius-chip);
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.feature-grid, .showcase-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.showcase-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.feature-card, .showcase-card, .login-section {
  padding: 18px;
}

.feature-card h3, .showcase-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 20px;
}

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

.mini-calendar span {
  min-height: 86px;
  padding: 8px;
  border-radius: var(--radius-input);
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.mini-calendar .me {
  background: var(--green-soft);
  color: var(--green);
}

.mini-calendar .partner {
  background: var(--red-soft);
  color: var(--red);
}

.login-section {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 18px;
  align-items: start;
  margin-top: 16px;
}

.login-section .login-card {
  margin-top: 0;
  box-shadow: none;
}

.auth-note {
  margin: 10px 0 0;
  font-size: 13px;
}

label, fieldset {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 6px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

legend { display: none; }

/* Segment control — matches Flutter's _Segment widget */
.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice-row label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 13px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-card);
  background: white;
  color: #6f6c63;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: center;
}

.choice-row label input[type="radio"] {
  display: none;
}

.choice-row label:has(input:checked) {
  background: rgba(42, 125, 94, 0.12);
  border-color: var(--green);
  color: var(--green);
}

/* Partner segment gets purple when checked */
.choice-row label:has(input[value="partner"]:checked) {
  background: rgba(112, 64, 176, 0.1);
  border-color: var(--purple);
  color: var(--purple);
}

input, textarea, button, select {
  width: 100%;
  border-radius: var(--radius-input);
  font: inherit;
}

input, textarea, select {
  border: 1.5px solid var(--line);
  padding: 12px 13px;
  background: white;
  color: var(--ink);
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--green-mid);
}

input[type="radio"], input[type="checkbox"] { width: auto; }

button, .link-button {
  border: 0;
  padding: 12px 16px;
  background: var(--green);
  color: white;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  border-radius: var(--radius-btn);
}

.link-list {
  display: grid;
  gap: 10px;
}

button.secondary {
  width: auto;
  background: white;
  color: var(--green);
  border: 1.5px solid var(--line);
}

button.danger { background: var(--red); }
button.outline-danger {
  background: white;
  color: var(--red);
  border: 1.5px solid rgba(192, 72, 40, 0.3);
}
.preview-button {
  margin-top: 10px;
  background: white;
  color: var(--green);
  border: 1.5px solid var(--line);
}
.email-row input { flex: 1; }
.email-row button { width: auto; min-width: 150px; }

.time-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.time-action button {
  width: auto;
  white-space: nowrap;
}

/* ── App shell ── */
.app-view {
  display: grid;
  gap: 16px;
}

/* ── Desktop tabs (top) ── */
.tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: white;
  color: var(--muted);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.tab.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.page { display: none; }
.page.active { display: grid; gap: 16px; }

.entry-form, .settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full-row { grid-column: 1 / -1; }

.partner-email-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.partner-email-row label { grid-column: unset; }
.partner-email-row button { width: auto; white-space: nowrap; align-self: end; }

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  background: white;
}

.switch-line span { display: grid; gap: 2px; }
.switch-line small, .subtle { color: var(--muted); font-weight: 500; }

.field-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#symptomList {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#symptomList .chip {
  justify-content: flex-start;
  width: 100%;
}

.chip, .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-chip);
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.chip.selected {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(42, 125, 94, 0.35);
}

.pill.green  { background: var(--green-soft);  color: var(--green);  border-color: rgba(42,125,94,0.25); }
.pill.red    { background: var(--red-soft);    color: var(--red);    border-color: rgba(192,72,40,0.25); }
.pill.purple { background: var(--purple-soft); color: var(--purple); border-color: rgba(112,64,176,0.25); }
.pill.grey   { background: var(--bg);          color: var(--muted);  border-color: var(--line); }

/* ── Calendar header ── */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-nav-btn {
  width: auto;
  padding: 8px 14px;
  font-size: 16px;
}

/* ── History ── */
.history-month-label {
  margin: 10px 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}

.pct-green  { color: var(--green); }
.pct-purple { color: var(--purple); }

.history-fk-pct {
  font-size: 11px;
  color: var(--muted);
}

/* ── Empty state ── */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.25;
}

.empty-state p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.empty-state small {
  font-size: 13px;
  color: var(--muted);
  opacity: 0.7;
}

/* ── Calc preview rows ── */
.calc-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 14px;
}

.calc-row strong { font-weight: 700; }

.calc-period {
  margin-top: 8px;
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
  opacity: 0.8;
}

.calc-preview {
  padding: 14px;
  border-radius: var(--radius-input);
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}

.calendar-summary {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.reminder-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.reminder-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(149, 96, 16, 0.25);
  border-radius: var(--radius-input);
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 800;
}

.reminder-item.urgent {
  border-color: rgba(192, 72, 40, 0.3);
  background: var(--red-soft);
  color: var(--red);
}

.reminder-item p {
  margin: 0;
  color: inherit;
  font-weight: 600;
}

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

.week-grid, .shift-grid, .shift-weeks {
  display: grid;
  gap: 8px;
}

.week-grid label, .shift-grid label {
  display: grid;
  grid-template-columns: 92px 1fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  background: white;
  color: var(--muted);
}

.shift-week {
  display: grid;
  grid-template-columns: 92px repeat(7, minmax(0, 1fr));
  align-items: center;
  gap: 6px;
  padding: 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  background: white;
}

.shift-week select {
  padding: 8px 6px;
  font-size: 12px;
}

.chip .chip-remove {
  margin-left: 4px;
  color: inherit;
  font-weight: 900;
}

.calendar-day {
  min-height: 82px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  background: white;
}

.calendar-day strong { display: block; margin-bottom: 8px; }
.calendar-day.me      { background: var(--green-soft); border-color: rgba(42, 125, 94, 0.3); }
.calendar-day.partner { background: var(--red-soft);   border-color: rgba(192, 72, 40, 0.3); }
.calendar-day.both    { background: linear-gradient(135deg, var(--green-soft), var(--red-soft)); }

.calendar-entry {
  display: grid;
  gap: 3px;
  margin-top: 5px;
  padding: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.calendar-entry button {
  width: auto;
  justify-self: start;
  padding: 4px 7px;
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(192, 72, 40, 0.25);
  font-size: 11px;
}

.fk-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bar-card {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
}

.bar-track {
  height: 16px;
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}

.bar {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: 8px;
}

.bar.green  { background: var(--green); }
.bar.red    { background: var(--red); }
.bar.purple { background: var(--purple); }
.bar.amber  { background: var(--amber); }

/* ── Stats page ── */
.stats-section-title {
  margin: 8px 0 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.eq-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.eq-label {
  display: grid;
  gap: 2px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}

.eq-label small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.eq-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.eq-val.green  { color: var(--green); }
.eq-val.purple { color: var(--purple); }
.eq-val.red    { color: var(--red); }

.eq-track {
  margin-top: 8px;
  height: 10px;
}

.stats-eq-msg {
  margin: 12px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: var(--radius-card);
}

.green-card { background: var(--green-soft); }
.red-card   { background: var(--red-soft); }
.grey-card  { background: var(--surface2); }

.stat-val {
  font-size: 22px;
  font-weight: 800;
}

.stat-val.green { color: var(--green); }
.stat-val.red   { color: var(--red); }
.stat-val.grey  { color: var(--muted); }

.stat-lbl {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  text-align: center;
}

.child-bar-row, .symptom-bar-row {
  margin-bottom: 12px;
}

.child-bar-head, .symptom-bar-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.child-bar-head strong, .symptom-bar-head strong {
  color: var(--green);
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: white;
}

.history-meta {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 8px;
  min-width: 92px;
}

.icon-button {
  width: auto;
  padding: 7px 9px;
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(192, 72, 40, 0.25);
  font-size: 12px;
}

.danger-zone {
  border-color: rgba(192, 72, 40, 0.25);
}

.privacy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 8px;
}

.privacy-actions button {
  width: auto;
}

.message {
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 14px;
}

.saved-dialog, .preview-dialog {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: 0 24px 80px rgba(25, 24, 15, 0.24);
}

.saved-dialog::backdrop, .preview-dialog::backdrop {
  background: rgba(25, 24, 15, 0.28);
}

.warning-dialog {
  border: 1px solid rgba(149, 96, 16, 0.28);
}

.warning-dialog h2 {
  color: var(--amber);
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.dialog-actions button {
  width: auto;
}

.preview-dialog {
  width: min(720px, calc(100% - 32px));
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.preview-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  background: var(--bg);
}

/* ── Mobile ── */
@media (max-width: 860px) {
  .shell {
    width: 100%;
    padding: 10px 6px calc(var(--nav-height) + 16px);
  }

  .brand, .topbar, .section-head, .email-row, .actions, .child-row {
    gap: 8px;
  }

  .brand, .topbar, .section-head {
    align-items: center;
    flex-direction: row;
  }

  .email-row, .actions, .child-row {
    align-items: stretch;
    flex-direction: column;
  }

  .app-view {
    gap: 10px;
  }

  .card, .privacy, .login-card, .feature-card, .showcase-card, .login-section {
    padding: 14px;
  }

  .public-hero {
    gap: 14px;
    margin: 14px 0 10px;
    padding: 18px;
  }

  .feature-grid, .showcase-grid {
    gap: 10px;
    margin-top: 10px;
  }

  input, textarea, select {
    padding: 10px 12px;
  }

  button, .link-button {
    padding: 12px 14px;
  }

  .public-hero, .feature-grid, .showcase-grid, .login-section {
    grid-template-columns: 1fr;
  }

  /* ── Bottom navigation bar ── */
  .tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    flex-direction: row;
    grid-template-columns: unset;
    gap: 0;
    background: white;
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgba(25, 24, 15, 0.08);
    padding: 0;
    border-radius: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .tabs::-webkit-scrollbar { display: none; }

  .tab {
    flex: 0 0 auto;
    min-width: 64px;
    flex-direction: column;
    gap: 3px;
    padding: 8px 6px 10px;
    font-size: 10px;
    border: none;
    border-radius: 0;
    background: white;
    color: #9a9890;
  }

  .tab svg { width: 22px; height: 22px; }

  .tab.active {
    background: white;
    color: var(--green);
    border: none;
  }

  .entry-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .settings-form {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .entry-form fieldset,
  #childPickerWrap,
  #entryChildFreeTextWrap,
  .entry-form .full-row {
    grid-column: 1 / -1;
  }

  fieldset, .switch-line {
    padding: 10px;
  }

  .choice-row {
    gap: 6px;
  }

  .choice-row label {
    padding: 11px 8px;
    font-size: 13px;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .calendar-day {
    min-height: 70px;
    padding: 6px;
  }

  .calendar-entry {
    gap: 2px;
    padding: 5px;
    font-size: 11px;
  }

  .week-grid label, .shift-grid label, .shift-week { grid-template-columns: 1fr; }
  #symptomList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  #symptomList .chip {
    min-height: 42px;
    padding: 7px 8px;
    font-size: 12px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .time-action { grid-template-columns: 1fr auto; }
  .preview-grid { grid-template-columns: 1fr; }
  .email-row button, button.secondary, .privacy-actions button, .dialog-actions button { width: 100%; }
  .dialog-actions { flex-direction: column; }
}

@media (max-width: 380px) {
  .entry-form, #symptomList {
    grid-template-columns: 1fr;
  }

  .time-action {
    grid-template-columns: 1fr;
  }
}
