[hidden] { display: none !important; }
:root {
  --bg: #f8fafc; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #0f766e; --brand-ink: #fff; --brand-soft: #ccfbf1; --danger: #b91c1c; --warn: #b45309;
  --r: 14px; --tabh: 62px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding-top: var(--sat); padding-bottom: calc(var(--tabh) + var(--sab)); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* prevents iOS zoom on focus */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: rgba(248,250,252,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #fef3c7; color: #92400e; }
.badge.ok { background: var(--brand-soft); color: var(--brand); }
.badge.due { background: #fee2e2; color: var(--danger); }
main { padding: 12px 14px 24px; max-width: 720px; margin: 0 auto; outline: none; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 4px 8px; display: flex; align-items: center; justify-content: space-between; }
h2 .link { text-transform: none; letter-spacing: 0; font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; }
.tile { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; min-height: 60px; }
.tile:active { background: #f1f5f9; }
.tile .main { flex: 1; min-width: 0; }
.tile .name { font-weight: 600; }
.tile .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .big { font-size: 22px; font-weight: 700; }
.tile.hero { padding: 16px; border-color: #99f6e4; background: linear-gradient(180deg, #f0fdfa, #fff); }
.plus { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); font-size: 24px; line-height: 44px; display: grid; place-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 4px; }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.in { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; }
.in.big { font-size: 28px; font-weight: 700; text-align: center; }
textarea.in { min-height: 70px; resize: vertical; }
.seg { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 10px 14px; min-height: 44px; min-width: 52px; cursor: pointer; }
.seg button + button { border-left: 1px solid #cbd5e1; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid #cbd5e1; background: #fff; border-radius: 99px; padding: 7px 12px; min-height: 36px; cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button { min-height: 52px; border-radius: 12px; border: 1px solid #cbd5e1; background: #fff; font-size: 20px; font-weight: 700; cursor: pointer; }
.scale button[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.hint { font-size: 13px; color: var(--brand); margin-top: 6px; min-height: 18px; }
.day { font-size: 13px; color: var(--muted); font-weight: 700; margin: 14px 4px 6px; }
.item { display: flex; gap: 10px; align-items: center; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; text-align: left; cursor: pointer; }
.item .t { color: var(--muted); font-size: 13px; width: 64px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .v { font-weight: 700; }
.item .n { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chartbox { position: relative; height: 240px; }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--sab); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; height: var(--tabh); color: var(--muted); text-decoration: none; font-size: 12px; gap: 2px; }
.tabbar a .ico { font-size: 20px; line-height: 1; }
.tabbar a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + var(--sab)); animation: up .18s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #cbd5e1; margin: 4px auto 8px; }
.sheet h3 { margin: 4px 0 6px; font-size: 19px; display: flex; justify-content: space-between; align-items: center; }
.sheet .actions { display: flex; gap: 8px; margin-top: 16px; position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; }
.sheet .actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + var(--sab) + 12px); z-index: 30; background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; max-width: 92vw; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast .link { color: #5eead4; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .main { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.notice { font-size: 13px; color: var(--muted); background: #f1f5f9; border-radius: 10px; padding: 10px 12px; }
.warnbox { font-size: 14px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
@media (min-width: 700px) { .chartbox { height: 300px; } }
.row > .tile { flex: 1; min-width: 0; width: auto; }
a.btn { text-decoration: none; color: inherit; }
/* r02: profiles, lock, cycle */
.profile-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 52vw; border: 2px solid var(--brand); background: #fff; border-radius: 99px; padding: 3px 10px 3px 3px; min-height: 40px; cursor: pointer; font-weight: 600; font-size: 14px; }
.profile-btn .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pfp { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-size: 22px; flex: none; color: #fff; }
.pfp.sm { width: 30px; height: 30px; font-size: 17px; }
.pfp.lg { width: 76px; height: 76px; font-size: 40px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; cursor: pointer; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.lock { text-align: center; padding-top: 24px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 16px 0 6px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.pin-dots span.on { background: var(--ink); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; justify-content: center; margin-top: 10px; }
.keypad button { height: 76px; border-radius: 50%; border: 1px solid #cbd5e1; background: #fff; font-size: 28px; cursor: pointer; }
.keypad button:active { background: #e2e8f0; }
.seg.wrap { display: flex; flex-wrap: wrap; }
.seg.wrap button { flex: 1; min-width: 64px; padding: 10px 6px; }
.tile.cycle { border-color: #fecdd3; background: linear-gradient(180deg, #fff1f2, #fff); cursor: default; align-items: flex-start; }
.tile.cycle .big { font-size: 22px; font-weight: 700; }
.cal-head, .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-head { margin: 10px 0 4px; font-size: 12px; color: var(--muted); font-weight: 700; }
.cal-day { position: relative; aspect-ratio: 1; border: 1px solid transparent; border-radius: 10px; background: #f8fafc; font-size: 15px; cursor: pointer; display: grid; place-items: center; padding: 0; }
.cal-day.future { color: #94a3b8; }
.cal-day.today { border: 2px solid var(--ink); font-weight: 800; }
.cal-day.p-period, .cal-day.p-medium { background: #f43f5e; color: #fff; }
.cal-day.p-light { background: #fda4af; color: #fff; }
.cal-day.p-heavy { background: #be123c; color: #fff; }
.cal-day.spot::after { content: ''; position: absolute; bottom: 5px; width: 6px; height: 6px; border-radius: 50%; background: #f43f5e; }
.cal-day.pred { border: 2px dashed #f43f5e; }
.cal-day.fert { background: #ccfbf1; }
.cal-day .ov { position: absolute; top: 1px; right: 4px; font-size: 9px; color: #0f766e; font-style: normal; }
.cal-day .lg { position: absolute; bottom: 4px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: #6366f1; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.cal-legend .lgd { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }
.lgd.p { background: #f43f5e; } .lgd.s { background: #fda4af; border-radius: 50%; } .lgd.pr { border: 2px dashed #f43f5e; } .lgd.f { background: #ccfbf1; border: 1px solid #5eead4; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: #f8fafc; border-radius: 10px; padding: 8px 10px; }
.stat .v { font-size: 20px; font-weight: 700; }
details.more { margin-top: 12px; } details.more summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; }
