/* PaintersAreIn. Cool paper, ink navy, madder red for periods, teal for the fertile window. System fonts only. */
:root {
  --bg: #EEF1F5;
  --surface: #FFFFFF;
  --ink: #1B2333;
  --muted: #566074;
  --line: #D3D9E3;
  --madder: #B3243B;
  --on-madder: #FFFFFF;
  --madder-tint: #F6DDE1;
  --teal: #0F7480;
  --teal-tint: #D3ECEF;
  --focus: #0F7480;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161F;
    --surface: #1B2130;
    --ink: #E9EDF4;
    --muted: #A3ADBF;
    --line: #2E3648;
    --madder: #E8627A;
    --on-madder: #12161F;
    --madder-tint: #4A2530;
    --teal: #4EC3CE;
    --teal-tint: #173F45;
    --focus: #4EC3CE;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
  min-height: 100vh;
  min-height: 100dvh;
}
#app { max-width: 34rem; margin: 0 auto; padding: calc(1rem + env(safe-area-inset-top)) 1.1rem calc(6rem + env(safe-area-inset-bottom)); }
.boot { color: var(--muted); padding: 30vh 0 0; text-align: center; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 8vw, 2.5rem); line-height: 1.1; margin: 0.5rem 0 0.75rem; }
h2 { font-size: 1.3rem; line-height: 1.25; margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1:focus { outline: none; }
.muted, .sub, .hint, .fine { color: var(--muted); }
.fine { font-size: 0.85rem; }

/* Forms and buttons */
.auth { padding-top: 8vh; }
.brand { font: 600 1.1rem var(--serif); margin: 0 0 1.5rem; }
.field { margin: 0 0 1rem; }
label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.3rem; }
input[type="email"], input[type="password"], input[type="text"], textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  min-height: 48px;
}
textarea { resize: vertical; }
.hint { font-size: 0.85rem; margin: 0.3rem 0 0; }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin: 0.4rem 0 0; min-height: 32px; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--ink); }
.error { color: var(--madder); font-weight: 600; margin: 0 0 0.75rem; }
.error:empty { display: none; }
.notice { background: var(--teal-tint); border-radius: 10px; padding: 0.7rem 0.9rem; margin: 0 0 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0.7rem 1.3rem;
  font: 600 1rem var(--sans);
  color: var(--bg); background: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 10px; cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.danger { background: transparent; color: var(--madder); border-color: var(--madder); }
.btn.block { display: flex; width: 100%; }
.link { background: none; border: 0; padding: 0.5rem 0; min-height: 44px; font: inherit; font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.stack { display: flex; flex-direction: column; gap: 0.25rem; align-items: flex-start; margin-top: 0.75rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.25rem 0 1rem; }

/* Home */
.home { display: grid; gap: 1.5rem; }
.summary h1 { margin-top: 0.25rem; }
.sub { margin: 0 0 0.35rem; }
.bar-wrap { margin: 1.25rem 0 0.25rem; }
.bar { position: relative; height: 14px; }
.bar .track { position: absolute; inset: 0; border-radius: 7px; background: var(--line); overflow: hidden; }
.bar .seg { position: absolute; top: 0; bottom: 0; }
.bar .seg.period { background: var(--madder); }
.bar .seg.fertile { background: var(--teal); }
.bar .marker { position: absolute; top: -5px; width: 4px; height: 24px; margin-left: -2px; border-radius: 2px; background: var(--ink); box-shadow: 0 0 0 2px var(--bg); }
.bar-labels { display: flex; justify-content: space-between; margin-top: 0.45rem; font-size: 0.85rem; color: var(--muted); }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.cal-head h2 { margin: 0; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--line); }
.dow, .grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dow span { text-align: center; font-size: 0.8rem; color: var(--muted); padding: 0.3rem 0; }
.blank { aspect-ratio: 1; }
.day {
  position: relative; aspect-ratio: 1; margin: 2px;
  display: grid; place-items: center;
  border: 2px solid transparent; border-radius: 50%;
  background: transparent; color: var(--ink);
  font: inherit; font-variant-numeric: tabular-nums; cursor: pointer;
}
.day.fertile { background: var(--teal-tint); border-radius: 12px; }
.day.predicted { border: 2px dashed var(--madder); border-radius: 50%; }
.day.period { background: var(--madder); color: var(--on-madder); border-color: var(--madder); border-radius: 50%; font-weight: 600; }
.day.today .n { font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.day.future { color: var(--muted); cursor: default; }
.day.ovulation::before { content: ""; position: absolute; top: 5px; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--teal); }
.day.has-log::after, .day.spotting::after { content: ""; position: absolute; bottom: 5px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--muted); }
.day.spotting::after { background: var(--madder); }
.day.period.has-log::after { background: var(--on-madder); }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin: 0.9rem 0 0.5rem; padding: 0; list-style: none; font-size: 0.85rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 0.4rem; }
.sw { width: 16px; height: 16px; display: inline-block; flex: none; }
.sw.period { background: var(--madder); border-radius: 50%; }
.sw.predicted { border: 2px dashed var(--madder); border-radius: 50%; }
.sw.fertile { background: var(--teal-tint); border-radius: 5px; }
.sw.ovulation { width: 7px; height: 7px; margin: 0 4.5px; background: var(--teal); border-radius: 50%; }

@media (min-width: 56rem) {
  #app { max-width: 64rem; }
  .home { grid-template-columns: minmax(18rem, 22rem) 1fr; gap: 3rem; align-items: start; padding-top: 1rem; }
  .auth, .page { max-width: 30rem; margin-inline: auto; }
}

/* Account and admin */
.page section { padding: 1.25rem 0; border-top: 1px solid var(--line); }
.page section:first-of-type { border-top: 0; }
details { margin-top: 0.5rem; }
summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.user-row { padding: 0.9rem 0; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-row .email { font-weight: 600; overflow-wrap: anywhere; }
.user-row .meta { color: var(--muted); font-size: 0.85rem; margin: 0.1rem 0 0.5rem; }
.user-row .btn { min-height: 40px; padding: 0.4rem 0.9rem; font-size: 0.9rem; }

/* Bottom navigation */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs-inner { display: flex; max-width: 34rem; margin: 0 auto; }
.tab { flex: 1; min-height: 58px; border: 0; background: none; color: var(--muted); font: 600 0.95rem var(--sans); cursor: pointer; }
.tab[aria-current="page"] { color: var(--ink); box-shadow: inset 0 3px 0 var(--madder); }

/* Day editor */
.scrim { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(10, 14, 22, 0.55); }
.sheet {
  width: 100%; max-width: 34rem; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  animation: rise 0.18s ease-out;
}
@media (min-width: 40rem) { .scrim { align-items: center; } .sheet { border-radius: 20px; } }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin-bottom: 1rem; }
.group { margin: 0 0 1.1rem; padding: 0; border: 0; min-width: 0; }
.group legend { font-weight: 600; font-size: 0.92rem; padding: 0; margin-bottom: 0.5rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip { min-height: 44px; padding: 0.4rem 0.95rem; font: inherit; color: var(--ink); background: transparent; border: 1.5px solid var(--line); border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.flows { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; }
.flows .chip { border-radius: 10px; padding: 0.4rem 0.1rem; font-size: 0.88rem; }
.flows .chip.flow[aria-pressed="true"] { background: var(--madder); color: var(--on-madder); border-color: var(--madder); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 2rem); padding: 0.6rem 1.1rem; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.toast.show { opacity: 1; }

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

.net { margin: 0 0 1rem; }
.net p { margin: 0 0 0.4rem; }
