/* FitLit's look: dark mode with teal and purple accents. */
:root {
  --bg: #0c0e13;
  --card: rgba(24, 27, 36, 0.78);
  --card-solid: #181b24;
  --card-hover: rgba(34, 38, 50, 0.9);
  --line: rgba(255, 255, 255, 0.07);
  --text: #eef0f4;
  --muted: #9aa1ad;
  --teal: #2dd4bf;
  --purple: #a78bfa;
  --health: #2dd4bf;
  --organisation: #60a5fa;
  --creativity: #c084fc;
  --gradient: linear-gradient(120deg, var(--teal), var(--purple));
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg); }
body { background: transparent; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Colourful background: two soft glows + a faint triangle pattern */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(70vmax 55vmax at 0% 0%, rgba(45, 212, 191, 0.34), transparent 65%),
    radial-gradient(70vmax 60vmax at 100% 100%, rgba(167, 139, 250, 0.40), transparent 65%),
    radial-gradient(45vmax 35vmax at 100% 15%, rgba(167, 139, 250, 0.20), transparent 65%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='48'%3E%3Cpath d='M28 6 L50 42 H6 Z' fill='none' stroke='%23ffffff' stroke-opacity='0.045' stroke-width='1.2'/%3E%3C/svg%3E");
}

/* Leaves room for the iPhone notch and home bar */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 18px calc(env(safe-area-inset-bottom) + 32px);
}

/* ---- Home screen ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.greeting { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.greeting span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.date { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }

.theme { margin-bottom: 24px; }
.theme-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 17px; font-weight: 700; }
.theme-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.app {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 12px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    var(--card);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius);
  color: inherit; text-decoration: none;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background 0.15s, transform 0.15s;
}
a.app:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
a.app:active { transform: scale(0.97); }
.app-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
.app-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.app-note { color: var(--muted); font-size: 11px; }
.app.soon { opacity: 0.5; }
.lock-badge { position: absolute; top: 10px; right: 10px; font-size: 11px; opacity: 0.7; }

.footer { margin-top: 12px; text-align: center; }
.footer a { color: var(--muted); font-size: 13px; }

/* ---- Login screen ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 320px; text-align: center; }
.login-box img { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 14px; }
.login-box h1 { margin: 0 0 6px; font-size: 24px; }
.login-box p { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.back { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 14px; }

/* ---- Form bits ---- */
.field {
  width: 100%; padding: 11px 14px; font-size: 16px; /* 16px stops iPhone from zooming in */
  background: var(--card-solid); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
  font-family: inherit;
}
.field:focus { border-color: var(--teal); }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 10px; padding: 11px 16px; font-size: 15px; font-weight: 600;
  border: 0; border-radius: 12px; cursor: pointer; color: #0c0e13;
  background: var(--gradient); font-family: inherit;
}
.button:active { transform: scale(0.98); }
.button.ghost { background: var(--card-solid); color: var(--text); border: 1px solid var(--line); }
.button.small { width: auto; padding: 8px 14px; font-size: 14px; margin-top: 0; }
.link { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 6px; font-family: inherit; }
.error { color: #f87171; margin-top: 10px; min-height: 1.2em; font-size: 14px; }
.hidden { display: none !important; }

/* ---- Inside an app (e.g. Cycle tracker) ---- */
.bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.bar a { color: var(--muted); text-decoration: none; font-size: 15px; }
.bar h1 { margin: 0; font-size: 18px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 18px; margin-bottom: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.card h2 { margin: 0 0 8px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* The big day counter ring */
.counter { text-align: center; }
.ring {
  --p: 0;
  width: 190px; height: 190px; margin: 4px auto 14px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--teal), var(--purple) calc(var(--p) * 1%), rgba(255,255,255,0.07) 0);
  box-shadow: 0 0 40px rgba(45, 212, 191, 0.12), 0 0 60px rgba(167, 139, 250, 0.12);
}
.ring-inner {
  width: 164px; height: 164px; border-radius: 50%;
  background: var(--card-solid);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-label { color: var(--muted); font-size: 13px; }
.ring-day { font-size: 54px; font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; }
.since { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.phase-pill {
  display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--phase, var(--teal)) 20%, transparent);
  color: var(--phase, var(--teal));
  border: 1px solid color-mix(in srgb, var(--phase, var(--teal)) 40%, transparent);
}
.phase-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.phase-head h2 { margin: 0; }
.fineprint { margin-top: 10px !important; font-size: 12px !important; opacity: 0.8; }

.other-date { display: flex; gap: 8px; margin-top: 10px; }
.other-date .field { flex: 1; }

/* History list */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.history li:first-child { border-top: 0; }
.history .meta { color: var(--muted); font-size: 12px; }
.delete { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 4px 9px; font-size: 12px; cursor: pointer; font-family: inherit; }
.delete.armed { border-color: #f87171; color: #f87171; }

/* ---- Daily log screen ---- */
.day-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.day-title { text-align: center; }
.day-title h1 { margin: 0; font-size: 22px; }
.day-title span { color: var(--muted); font-size: 13px; }
.round {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card-solid); border: 1px solid var(--line); color: var(--text);
  font-size: 22px; line-height: 1; text-decoration: none; cursor: pointer; font-family: inherit;
}
.round.disabled { opacity: 0.25; pointer-events: none; }
.log-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.saved { color: var(--teal); font-size: 13px; }
.search { margin-bottom: 18px; }
.group-title { font-size: 20px; margin: 20px 0 10px; }
.log-cat h3 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: baseline; gap: 8px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 5px; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--cat) 16%, var(--card-solid));
  border: 1.5px solid transparent; color: var(--text); font-size: 14px; font-family: inherit;
  transition: transform 0.1s;
}
.chip:active { transform: scale(0.96); }
.chip-icon {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 15px;
  background: color-mix(in srgb, var(--cat) 35%, #fff 10%);
}
.chip.on { border-color: var(--cat); background: color-mix(in srgb, var(--cat) 30%, var(--card-solid)); }
.chip.on .chip-label::after { content: " ✓"; color: var(--cat); font-weight: 700; }
.note { margin-top: 10px; resize: vertical; min-height: 44px; }
.water { display: flex; align-items: center; justify-content: space-between; }
.water-amount { font-size: 34px; font-weight: 800; }
.water-goal { color: var(--muted); font-size: 16px; }
.water-glasses { color: var(--muted); font-size: 12px; }
.water-buttons { display: flex; gap: 10px; }
.empty { color: var(--muted); text-align: center; }

/* ---- Week strip (cycle home) ---- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 4px 0 12px; }
.wday {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0;
  border-radius: 12px; cursor: pointer; background: none; border: 1px solid transparent;
  color: var(--text); font-family: inherit;
}
.wday small { color: var(--muted); font-size: 11px; }
.wday b {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 600;
}
.wday.period b { background: rgba(244, 114, 182, 0.25); color: #f9a8d4; }
.wday.today b { box-shadow: 0 0 0 1.5px var(--teal); }
.wday.selected { background: rgba(255, 255, 255, 0.06); border-color: var(--line); }
.wday i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.wday.logged i { background: var(--purple); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.card-head h2 { margin: 0; }
.card-head a { color: var(--muted); font-size: 14px; text-decoration: none; }
.summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.summary .chip { cursor: default; font-size: 13px; padding: 3px 10px 3px 3px; }
.summary .chip-icon { width: 22px; height: 22px; font-size: 12px; }
.summary-empty { color: var(--muted); font-size: 14px; margin: 2px 0 12px; }

/* ---- Month calendar ---- */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-nav h2 { margin: 0; font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal .dow { color: var(--muted); font-size: 12px; padding-bottom: 4px; }
.cal a, .cal span.day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 12px; color: var(--text); text-decoration: none; font-size: 15px;
}
.cal a:hover { background: rgba(255, 255, 255, 0.06); }
.cal .future { color: #4b5160; }
.cal .period { background: rgba(244, 114, 182, 0.22); color: #f9a8d4; font-weight: 600; }
.cal .today { box-shadow: inset 0 0 0 1.5px var(--teal); }
.cal i { width: 5px; height: 5px; border-radius: 50%; }
.cal .logged i { background: var(--purple); }
.legend { display: flex; gap: 14px; justify-content: center; margin-top: 12px; color: var(--muted); font-size: 12px; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend .l-period::before { background: rgba(244, 114, 182, 0.6); }
.legend .l-logged::before { background: var(--purple); }
.legend .l-today::before { box-shadow: inset 0 0 0 1.5px var(--teal); }

/* ---- IUD card ---- */
.iud-line { font-size: 15px; margin: 0 0 4px; }
.iud-form { display: grid; gap: 8px; margin-top: 10px; }
.iud-form label { color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
select.field { appearance: none; -webkit-appearance: none; }
.warn { color: #fbbf24 !important; }

/* App tile: cycle day number */
.app-day { position: absolute; right: 10px; bottom: 10px; font-size: 20px; font-weight: 800; color: var(--accent); }
.app-day small { display: block; font-size: 9px; font-weight: 600; color: var(--muted); text-align: right; letter-spacing: 0.04em; }

/* small fixes */
a.button { text-decoration: none; }
.error:empty { min-height: 0; margin: 0; }

/* Small "open me" button (e.g. Pregnancy test) */
.mini-toggle {
  display: block; margin: 6px auto 14px; padding: 6px 14px; border-radius: 999px;
  background: none; border: 1px dashed var(--line); color: var(--muted);
  font-size: 13px; cursor: pointer; font-family: inherit;
}
.row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ---- Water widget (shared by every screen) ---- */
.water-widget {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px;
}
.ww-ring {
  --p: 0;
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#38bdf8 calc(var(--p) * 1%), rgba(255, 255, 255, 0.08) 0);
  transition: background 0.3s;
}
.ww-ring span {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card-solid); font-size: 18px;
}
.ww-text { display: flex; flex-direction: column; min-width: 0; }
.ww-count { font-size: 16px; }
.ww-sub { color: var(--muted); font-size: 12px; }
.water-widget .ww-plus { background: linear-gradient(120deg, #38bdf8, var(--teal)); white-space: nowrap; }
.water-widget .round { width: 34px; height: 34px; font-size: 18px; }
.water-widget .round:disabled { opacity: 0.3; }
.water-widget.done .ww-ring { background: conic-gradient(var(--teal), var(--purple), var(--teal)); }
.water-widget.pop .ww-ring { animation: pop 0.35s ease; }
@keyframes pop { 50% { transform: scale(1.18); } }
.water-card { margin-bottom: 22px; }
.water-card h2 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }

/* ---- Daily check-in pop-up ---- */
.checkin {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 8, 12, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } }
.checkin-box {
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  background: linear-gradient(170deg, rgba(45, 212, 191, 0.10), transparent 40%), var(--card-solid);
  border: 1px solid var(--line); border-radius: 24px 24px 0 0;
  padding: 16px 18px calc(env(safe-area-inset-bottom) + 16px);
  animation: up 0.25s ease;
}
@keyframes up { from { transform: translateY(40px); } }
@media (min-width: 600px) { .checkin { align-items: center; } .checkin-box { border-radius: 24px; } }
.checkin-top { display: flex; align-items: center; justify-content: space-between; }
.dots { display: flex; gap: 6px; }
.dots i { width: 22px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); }
.dots i.on { background: var(--gradient); }
.checkin-title { margin: 14px 0 4px; font-size: 22px; }
.checkin-hint { margin: 0 0 14px; color: var(--muted); font-size: 14px; min-height: 1em; }
.checkin-body { overflow-y: auto; padding: 2px 0 8px; }
.checkin-body h3 { margin: 6px 0 8px; font-size: 14px; color: var(--muted); }
.checkin-body .chips { margin-bottom: 12px; }
.checkin-actions { display: flex; align-items: center; justify-content: space-between; padding-top: 10px; }
.checkin-actions .button { min-width: 110px; }

/* Home screen: check-in reminder */
.checkin-banner {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  border-color: rgba(167, 139, 250, 0.35);
  background: linear-gradient(120deg, rgba(45, 212, 191, 0.14), rgba(167, 139, 250, 0.18)), var(--card);
}
.checkin-banner > span:first-child { font-size: 24px; }
.checkin-banner div { flex: 1; display: flex; flex-direction: column; }
.checkin-banner small { color: var(--muted); font-size: 13px; }
.checkin-banner .chev { color: var(--muted); font-size: 24px; }
