/* Kegel Timer — warm light, sage + terracotta, breathing orb */
:root {
  --bg: #f4efe7; --card: #fffdf9; --line: #e4dccf; --ink: #1f1b16; --muted: #7a7166;
  --accent: #4f7a5c; --on-accent: #ffffff;
  --squeeze: #c9654a; --relax: #4f7a5c; --rest: #6b7f99;
  --orb: radial-gradient(circle at 50% 40%, #fbf7f0, #ebe3d6 75%);
  --orb-squeeze: radial-gradient(circle at 50% 40%, #f0b9a6, #c9654a 80%);
  --orb-relax: radial-gradient(circle at 50% 40%, #b9d4bf, #4f7a5c 80%);
  --radius: 24px; --btn-radius: 16px; --mark-radius: 50%;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --track-display: -0.01em;
  --shadow: 0 10px 30px -18px rgba(60, 40, 20, 0.25);
}
h1, h2, .tile-title, .p-text b, .brand { font-weight: 600; }
.count, .hold-time, .goal-text, .stat b { font-weight: 500; letter-spacing: -0.02em; }
.phase { letter-spacing: 0.18em; font-weight: 600; }
.eyebrow { color: var(--accent); }
body[data-phase="squeeze"] { background: #f3e9e2; }
body[data-phase="relax"] { background: #edf1ea; }
.orb-wrap .ring-bg { stroke: #e9e2d6; }
.btn.primary { box-shadow: 0 10px 24px -12px rgba(79,122,92,0.6); }

/* Shared layout. Variants override tokens and shapes in their own file. */
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; min-height: 100dvh; transition: background 0.6s; }
.app { max-width: 480px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 40px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.1; letter-spacing: var(--track-display, -0.02em); }
h1, .screen-title { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1rem; margin-bottom: 10px; }
p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: 0.85rem; }
.eyebrow { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.screen[hidden] { display: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 12px; box-shadow: var(--shadow, none); }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; min-height: 40px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.mark { width: 26px; height: 26px; border-radius: var(--mark-radius, 50%); background: var(--accent); display: inline-block; position: relative; }
.mark::after { content: ""; position: absolute; inset: 7px; border-radius: inherit; background: var(--card); }

/* buttons */
.btn { font: inherit; font-weight: 600; border-radius: var(--btn-radius); padding: 12px 18px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; min-height: 44px; transition: transform 0.15s, background 0.2s, border-color 0.2s, box-shadow 0.2s; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { width: 100%; padding: 16px; font-size: 1.05rem; margin-top: 14px; }
.btn.ghost { background: transparent; }
.btn.link { background: transparent; border-color: transparent; color: var(--muted); padding: 8px 10px; min-height: 36px; }
.btn.link:hover { color: var(--ink); }
.btn.small { font-size: 0.9rem; }

/* goal */
.goal { display: flex; gap: 16px; align-items: center; }
.goal-ring-wrap { position: relative; width: 96px; height: 96px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 339.3; stroke-dashoffset: 339.3; transition: stroke-dashoffset 0.6s ease, stroke 0.3s; }
.goal-text { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.goal-label { font-weight: 600; }
.streak { color: var(--muted); font-size: 0.95rem; }
.week-dots { display: flex; gap: 6px; margin-top: 10px; }
.dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; font-weight: 600; color: var(--muted); border: 1px solid var(--line); }
.dot.done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.dot.today:not(.done) { border-color: var(--accent); border-style: dashed; }

/* reco + tiles */
.reco h2 { margin: 2px 0 2px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.row .card { margin: 0; }
.tile { display: flex; flex-direction: column; gap: 4px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.tile-title { font-weight: 700; font-family: var(--font-display); font-size: 1rem; }
.tile.custom summary { list-style: none; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.tile.custom summary::-webkit-details-marker { display: none; }
.tile.custom[open] { grid-column: 1 / -1; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.grid label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 4px; }
.grid input { background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: var(--btn-radius); padding: 10px; font: inherit; font-size: 1rem; width: 100%; }
.grid input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid button, .grid .error { grid-column: 1 / -1; }
.error { color: var(--squeeze); font-size: 0.9rem; min-height: 1.2em; }

/* programs */
.programs { display: grid; gap: 8px; }
.program { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: var(--btn-radius); padding: 12px 14px; cursor: pointer; font: inherit; transition: border-color 0.2s, transform 0.15s; }
.program:hover { border-color: var(--accent); }
.program:active { transform: scale(0.99); }
.p-text { display: flex; flex-direction: column; }
.p-text b { font-family: var(--font-display); }
.p-note { font-size: 0.85rem; color: var(--muted); }
.p-dur { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }

/* cues */
.cues { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle:has(input:checked) { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.toggle:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* history */
.history ul { list-style: none; padding: 0; margin: 0 0 8px; }
.history li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.history li.empty { color: var(--muted); border: 0; }
footer { margin-top: 20px; line-height: 1.45; }
.legal-links { display: block; margin-top: 8px; }
.legal-links a, .legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line); }
.legal-links a:hover, .legal a:hover { text-decoration-color: currentColor; }
.onboard .legal-links { text-align: center; margin-top: 18px; }

/* legal pages */
.legal a.brand { text-decoration: none; color: var(--ink); }
.legal h1 { margin: 12px 0 18px; }
.legal h2 { font-size: 1.15rem; margin: 22px 0 6px; }
.legal p { margin: 0 0 8px; overflow-wrap: anywhere; }
.legal footer { margin-top: 32px; }

/* onboarding */
.onboard { min-height: calc(100dvh - 60px); display: flex; flex-direction: column; justify-content: center; }
.onboard article { text-align: center; }
.onboard .screen-title { margin: 6px 0 12px; }
.onboard p { max-width: 34ch; margin-inline: auto; }
.illus { width: min(260px, 80%); margin: 24px auto 0; display: block; }
.onboard-dots { display: flex; justify-content: center; gap: 6px; margin: 28px 0 16px; }
.onboard-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.onboard-dots i.on { background: var(--accent); width: 24px; border-radius: 4px; }
.onboard-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

/* figure */
.bone { fill: var(--muted); }
.floor { fill: none; stroke: var(--relax); stroke-width: 6; stroke-linecap: round; transition: opacity 0.5s ease; }
.floor-squeezed { opacity: 0; stroke: var(--squeeze); }
.organ { fill: var(--line); transition: transform 0.5s ease; }
body[data-phase="squeeze"] .session .floor-relaxed { opacity: 0; }
body[data-phase="squeeze"] .session .floor-squeezed { opacity: 1; }
body[data-phase="squeeze"] .session .organ { transform: translateY(-16px); }

/* session */
.session { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; text-align: center; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
.phase-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.9rem; }
.figure { width: min(220px, 70%); margin: 12px auto 0; display: block; }
.orb-wrap { position: relative; width: min(280px, 78vw); aspect-ratio: 1; margin: 12px auto 8px; }
.orb-wrap .ring { position: absolute; inset: 0; }
.orb-wrap .ring-fg { stroke-width: 7; stroke-dashoffset: 0; transition: stroke 0.3s; }
.orb-wrap .ring-bg { stroke-width: 7; }
.orb { position: absolute; inset: 12%; border-radius: 50%; background: var(--orb); transition: transform 0.6s cubic-bezier(.3,.7,.3,1), background 0.4s, box-shadow 0.4s; transform: scale(0.9); }
body[data-phase="squeeze"] .orb { transform: scale(1.02); background: var(--orb-squeeze); }
body[data-phase="relax"] .orb { transform: scale(0.86); background: var(--orb-relax); }
body[data-phase="rest"] .orb { transform: scale(0.8); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.count { font-family: var(--font-display); font-size: clamp(4rem, 22vw, 6rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.phase { margin-top: 6px; font-size: 0.95rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; }
body[data-phase="squeeze"] .ring-fg, body[data-phase="squeeze"] .phase { stroke: var(--squeeze); color: var(--squeeze); }
body[data-phase="relax"] .ring-fg, body[data-phase="relax"] .phase { stroke: var(--relax); color: var(--relax); }
body[data-phase="rest"] .ring-fg, body[data-phase="rest"] .phase { stroke: var(--rest); color: var(--rest); }
body[data-paused] .count { opacity: 0.5; }
.next { min-height: 1.5em; margin-bottom: 16px; }
.controls { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 8px; margin-top: auto; }

/* done */
.finish { min-height: calc(100dvh - 60px); display: flex; flex-direction: column; justify-content: center; text-align: center; }
.finish .screen-title { margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 28px 0 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 8px; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.6rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { font-size: 0.78rem; color: var(--muted); }

/* hold test */
.hold { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; text-align: center; }
.hold .screen-title { margin-bottom: 10px; }
.hold .muted { max-width: 36ch; margin-inline: auto; }
.hold-time { font-family: var(--font-display); font-size: clamp(4rem, 24vw, 6.5rem); font-weight: 800; letter-spacing: -0.04em; margin: auto 0 8px; font-variant-numeric: tabular-nums; }
.hold-time .unit { font-size: 0.35em; color: var(--muted); margin-left: 6px; }
.hold-btn { width: min(220px, 60vw); aspect-ratio: 1; border-radius: 50%; margin: 0 auto 16px; border: 0; background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 700; font-size: 1.1rem; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 0 0 0 var(--accent); }
.hold-btn.holding { transform: scale(0.94); box-shadow: 0 0 0 18px color-mix(in srgb, var(--accent) 25%, transparent); }

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

/* text on a coloured orb */
body[data-phase="squeeze"] .ring-text, body[data-phase="relax"] .ring-text { color: var(--on-orb, #fff); }
body[data-phase="squeeze"] .orb-wrap .phase, body[data-phase="relax"] .orb-wrap .phase { color: inherit; opacity: 0.85; }

/* learn section */
.learn { margin-top: 28px; }
.learn h2 { font-size: 1.35rem; margin-bottom: 12px; }
.learn h3 { font-size: 1.05rem; }
.learn p + p { margin-top: 8px; }
.learn ol { padding-left: 20px; margin: 0 0 10px; }
.learn li { margin-bottom: 6px; }
h1.brand { font-size: 1.05rem; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
