/* Microhabits — one-screen-at-a-time habit app for students with ADHD.
   Layout: a phone-width column (max 540px) with a fixed bottom tab bar; on wide
   screens Today spreads its three time blocks side by side. */

:root {
  --bg: #F2F5F3;
  --surface: #FFFFFF;
  --surface-2: #ECEFED;
  --fg: #1E2622;
  --muted: #5F6B66;
  --faint: #8A9490;
  --line: #EEF1EF;
  --dot-off: #DDE3DF;
  --accent: #2F7D4F;
  --accent-fg: #FFFFFF;
  --accent-soft: #E4F2E9;
  --accent-soft-fg: #163D27;
  --urgent: #E0772F;
  --urgent-fg: #C9601B;
  --morning: #FFE08A;
  --morning-fg: #3A2D00;
  --morning-muted: #6B5614;
  --morning-dot: #FFD24D;
  --afternoon: #BFE1FF;
  --afternoon-fg: #0F2E4D;
  --afternoon-muted: #3E6A92;
  --afternoon-dot: #8FC8F5;
  --evening: #2C2A5E;
  --evening-fg: #FFFFFF;
  --evening-muted: #C9C6F2;
  --evening-dot: #4B4799;
  --weekly-dot: #2F7D4F;
  --row-on-block: rgba(255, 255, 255, 0.72);
  --row-on-dark-block: rgba(255, 255, 255, 0.12);
  --pink: #FFD9E0;      --pink-fg: #4A1F2B;   --pink-muted: #7E3A4D;   --pink-eyebrow: #9A3B55;
  --yellow: #FFF2B3;    --yellow-fg: #3A2D00; --yellow-muted: #6B5614; --yellow-eyebrow: #6B5614;
  --blue: #CFEAFF;      --blue-fg: #0F2E4D;   --blue-muted: #3E6A92;   --blue-eyebrow: #3E6A92;
  --green: #D9F2E3;     --green-fg: #163D27;  --green-muted: #2F6B49;  --green-eyebrow: #2F6B49;
  --trophy-bg: #FFF6DB;
  --trophy-fg: #3A2D00;
  --trophy-muted: #6B5614;
  --timer-bg: #2C2A5E;
  --timer-fg: #FFFFFF;
  --timer-muted: #C9C6F2;
  --timer-disk: #FFB86B;
  --shadow: 0 6px 14px rgba(30, 38, 34, 0.14);
  --shadow-soft: 0 3px 8px rgba(30, 38, 34, 0.10);
  --focus: 0 0 0 3px rgba(47, 125, 79, 0.45);
  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131A16;
    --surface: #1D2622;
    --surface-2: #27322C;
    --fg: #F2F5F3;
    --muted: #A9B5AF;
    --faint: #7E8983;
    --line: #2C3832;
    --dot-off: #344139;
    --accent: #5DBB82;
    --accent-fg: #0E2217;
    --accent-soft: #1E3A2A;
    --accent-soft-fg: #CDEBD8;
    --urgent: #F08A45;
    --urgent-fg: #FFB07A;
    --morning: #5A4A12;
    --morning-fg: #FFEDB3;
    --morning-muted: #DEC878;
    --morning-dot: #FFD24D;
    --afternoon: #17344F;
    --afternoon-fg: #DCEEFF;
    --afternoon-muted: #9FC6EA;
    --afternoon-dot: #8FC8F5;
    --evening: #2C2A5E;
    --evening-fg: #FFFFFF;
    --evening-muted: #C9C6F2;
    --evening-dot: #7B77D6;
    --weekly-dot: #5DBB82;
    --row-on-block: rgba(255, 255, 255, 0.10);
    --row-on-dark-block: rgba(255, 255, 255, 0.12);
    --pink: #5A2A36;   --pink-fg: #FFD9E0;   --pink-muted: #F1B4C1;   --pink-eyebrow: #FFB0C0;
    --yellow: #4A3D0E; --yellow-fg: #FFF2B3; --yellow-muted: #E2CF84; --yellow-eyebrow: #E2CF84;
    --blue: #17344F;   --blue-fg: #DCEEFF;   --blue-muted: #9FC6EA;   --blue-eyebrow: #9FC6EA;
    --green: #173D28;  --green-fg: #D9F2E3;  --green-muted: #9FD4B4;  --green-eyebrow: #9FD4B4;
    --trophy-bg: #4A3D0E;
    --trophy-fg: #FFF2B3;
    --trophy-muted: #E2CF84;
    --shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
    --shadow-soft: 0 3px 8px rgba(0, 0, 0, 0.35);
    --focus: 0 0 0 3px rgba(93, 187, 130, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131A16;
  --surface: #1D2622;
  --surface-2: #27322C;
  --fg: #F2F5F3;
  --muted: #A9B5AF;
  --faint: #7E8983;
  --line: #2C3832;
  --dot-off: #344139;
  --accent: #5DBB82;
  --accent-fg: #0E2217;
  --accent-soft: #1E3A2A;
  --accent-soft-fg: #CDEBD8;
  --urgent: #F08A45;
  --urgent-fg: #FFB07A;
  --morning: #5A4A12;
  --morning-fg: #FFEDB3;
  --morning-muted: #DEC878;
  --morning-dot: #FFD24D;
  --afternoon: #17344F;
  --afternoon-fg: #DCEEFF;
  --afternoon-muted: #9FC6EA;
  --afternoon-dot: #8FC8F5;
  --evening: #2C2A5E;
  --evening-fg: #FFFFFF;
  --evening-muted: #C9C6F2;
  --evening-dot: #7B77D6;
  --weekly-dot: #5DBB82;
  --row-on-block: rgba(255, 255, 255, 0.10);
  --row-on-dark-block: rgba(255, 255, 255, 0.12);
  --pink: #5A2A36;   --pink-fg: #FFD9E0;   --pink-muted: #F1B4C1;   --pink-eyebrow: #FFB0C0;
  --yellow: #4A3D0E; --yellow-fg: #FFF2B3; --yellow-muted: #E2CF84; --yellow-eyebrow: #E2CF84;
  --blue: #17344F;   --blue-fg: #DCEEFF;   --blue-muted: #9FC6EA;   --blue-eyebrow: #9FC6EA;
  --green: #173D28;  --green-fg: #D9F2E3;  --green-muted: #9FD4B4;  --green-eyebrow: #9FD4B4;
  --trophy-bg: #4A3D0E;
  --trophy-fg: #FFF2B3;
  --trophy-muted: #E2CF84;
  --shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 3px 8px rgba(0, 0, 0, 0.35);
  --focus: 0 0 0 3px rgba(93, 187, 130, 0.5);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; text-wrap: balance; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { display: block; }

/* ---------- app frame ---------- */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 540px;
  margin: 0 auto;
  position: relative;
}
.view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-block: 18px 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tabbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 64px;
  padding: 6px 8px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.tab[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.tab svg { width: 22px; height: 22px; }
.tab .badge {
  position: absolute;
  transform: translate(14px, -4px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--urgent);
  color: #FFFFFF;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.tab { position: relative; }

/* ---------- common pieces ---------- */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}
.page-head .titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.kicker { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.page-head h1 { font-size: 28px; line-height: 1.1; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
  gap: 8px;
}
.section-head .right { font-size: 12px; font-weight: 700; color: var(--faint); }
.dot-label { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; }
.dot.morning { background: var(--morning-dot); }
.dot.afternoon { background: var(--afternoon-dot); }
.dot.evening { background: var(--evening-dot); }
.dot.weekly { background: var(--weekly-dot); }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: none;
  background: var(--surface);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.icon-btn svg { width: 22px; height: 22px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn.ghost { background: var(--surface); color: var(--fg); border: 2px solid var(--dot-off); }
.btn.quiet { background: var(--surface-2); color: var(--fg); }
.btn.urgent { background: var(--urgent-fg); color: #FFFFFF; }
.btn.danger { background: transparent; color: var(--urgent-fg); border: 2px solid var(--urgent-fg); }
.btn.big { min-height: 56px; border-radius: 28px; font-family: var(--font-display); font-size: 20px; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1 1 0; }
.btn:disabled { opacity: 0.5; cursor: default; }

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 14px;
  min-height: 52px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--fg);
  text-align: left;
  text-decoration: none;
}
.row + .row { border-top: 1px solid var(--line); }
.row .text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex-grow: 1; }
.row .name { font-size: 15px; font-weight: 700; }
.row .meta { font-size: 12px; color: var(--muted); }
.row .chev { color: var(--faint); flex-shrink: 0; width: 18px; height: 18px; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-soft-fg);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.pill.urgent { background: var(--urgent); color: #FFFFFF; }
.empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.hint { font-size: 13px; color: var(--muted); text-align: center; padding: 0 16px; line-height: 1.4; }
.spacer { flex-grow: 1; }
.week-dots { display: flex; gap: 4px; flex-shrink: 0; }
.wd { width: 9px; height: 9px; border-radius: 5px; background: var(--dot-off); }
.wd.on { background: var(--accent); }
.wd.na { background: transparent; border: 1px solid var(--dot-off); }
.wd.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent); }

/* ---------- Today ---------- */
.next-up { display: flex; flex-direction: column; gap: 10px; }
.next-up .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.next-up .cls { font-size: 17px; font-weight: 700; }
.next-up .where { font-size: 13px; color: var(--muted); }
.next-up .leave { display: flex; flex-direction: column; align-items: flex-end; }
.next-up .leave .big { font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1; color: var(--urgent-fg); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--urgent); transition: width 0.6s ease; }

.sticky-surface {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 12px 16px;
  background: var(--pink);
  color: var(--pink-fg);
  border-radius: 6px;
  box-shadow: var(--shadow);
  transform: rotate(-1deg);
  margin: 4px 2px;
}
.sticky-surface .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sticky-surface .eyebrow { display: flex; align-items: center; gap: 6px; color: var(--pink-eyebrow); font-size: 11px; }
.sticky-surface .eyebrow svg { width: 13px; height: 13px; }
.sticky-surface .title { font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1.15; }
.sticky-surface .meta { font-size: 13px; color: var(--pink-muted); }
.sticky-surface .bar { background: rgba(255, 255, 255, 0.5); flex-grow: 1; height: 7px; }
.sticky-surface .bottom { display: flex; align-items: center; gap: 10px; }
.sticky-surface .left { font-size: 12px; font-weight: 700; color: var(--pink-eyebrow); white-space: nowrap; }
.sticky-surface .check { background: rgba(255, 255, 255, 0.55); color: var(--pink-fg); }

.block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 24px;
  padding: 18px;
}
.block.morning { background: var(--morning); color: var(--morning-fg); --bm: var(--morning-muted); --rb: var(--row-on-block); }
.block.afternoon { background: var(--afternoon); color: var(--afternoon-fg); --bm: var(--afternoon-muted); --rb: var(--row-on-block); }
.block.evening { background: var(--evening); color: var(--evening-fg); --bm: var(--evening-muted); --rb: var(--row-on-dark-block); }
.block.weekly { background: var(--surface); color: var(--fg); --bm: var(--muted); --rb: var(--surface-2); }
.block .head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.block .head h2 { font-size: 20px; letter-spacing: 0.01em; }
.block .count { font-size: 13px; font-weight: 700; color: var(--bm); }
.block .habits { display: flex; flex-direction: column; gap: 10px; }
.habit {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: 16px;
  background: var(--rb);
}
.habit .text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-grow: 1; }
.habit .name { font-size: 17px; font-weight: 700; line-height: 1.25; }
.habit.done .name { color: var(--bm); text-decoration: line-through; }
.habit .anchor { font-size: 13px; color: var(--bm); }
.check {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2.5px solid var(--bm);
  background: transparent;
  color: var(--accent-fg);
  transition: transform 0.15s ease, background 0.15s ease;
}
.check svg { width: 22px; height: 22px; }
.check.on { background: var(--accent); border-color: var(--accent); }
.check:active { transform: scale(0.9); }
.habit.pop .check { animation: pop 0.35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.2); } 100% { transform: scale(1); } }
.block .empty { color: var(--bm); padding: 8px; }
.block .empty .btn { background: var(--rb); color: inherit; }

.plant-row { display: flex; align-items: center; gap: 14px; padding: 0 6px; }
.plant-row svg { width: 78px; height: 78px; flex-shrink: 0; }
.plant-row .big { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.plant-row .small { font-size: 13px; color: var(--muted); }

.collapsed { display: flex; flex-direction: column; gap: 8px; }
.collapsed .row { background: var(--surface); border-radius: 14px; min-height: 48px; }
.collapsed .row .name { font-size: 15px; }
.collapsed .row .meta { font-size: 13px; }
.collapsed .row .dot-label { gap: 10px; flex-grow: 1; }

.today-blocks { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Stickies ---------- */
.sticky-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 0 2px;
}
.sticky {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 14px 12px;
  min-height: 150px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  text-decoration: none;
  border: none;
  text-align: left;
  width: 100%;
  position: relative;
}
.sticky .title { font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1.15; }
.sticky .meta { font-size: 13px; line-height: 1.35; }
.sticky .pill { align-self: flex-start; }
.sticky.pink { background: var(--pink); color: var(--pink-fg); --sm: var(--pink-muted); --se: var(--pink-eyebrow); }
.sticky.yellow { background: var(--yellow); color: var(--yellow-fg); --sm: var(--yellow-muted); --se: var(--yellow-eyebrow); }
.sticky.blue { background: var(--blue); color: var(--blue-fg); --sm: var(--blue-muted); --se: var(--blue-eyebrow); }
.sticky.green { background: var(--green); color: var(--green-fg); --sm: var(--green-muted); --se: var(--green-eyebrow); }
.sticky .meta { color: var(--sm); }
.sticky .pill:not(.urgent) { background: rgba(255, 255, 255, 0.55); color: var(--se); }
.sticky.r1 { transform: rotate(-1.5deg); }
.sticky.r2 { transform: rotate(1deg); }
.sticky.r3 { transform: rotate(0.8deg); }
.sticky.r4 { transform: rotate(-0.7deg); }
.sticky-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  border: none;
  width: 100%;
  text-align: left;
}
.sticky-row .text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sticky-row .name { font-size: 15px; font-weight: 700; }
.sticky-row .meta { font-size: 13px; color: var(--sm); }
.sticky-row .when { font-size: 12px; font-weight: 700; color: var(--sm); white-space: nowrap; }
.sticky-row.pink { background: var(--pink); color: var(--pink-fg); --sm: var(--pink-muted); }
.sticky-row.yellow { background: var(--yellow); color: var(--yellow-fg); --sm: var(--yellow-muted); }
.sticky-row.blue { background: var(--blue); color: var(--blue-fg); --sm: var(--blue-muted); }
.sticky-row.green { background: var(--green); color: var(--green-fg); --sm: var(--green-muted); }
.sticky-list { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Habits ---------- */
.habit-row .name-line { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.row[disabled] { opacity: 0.5; cursor: default; }
.trophies { display: flex; gap: 10px; padding: 12px; background: var(--surface); border-radius: 16px; flex-wrap: wrap; }
.trophy {
  flex: 1 1 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border-radius: 12px;
  background: var(--trophy-bg);
  color: var(--trophy-fg);
  border: none;
  text-align: center;
}
.trophy svg { width: 26px; height: 26px; color: var(--urgent-fg); }
.trophy .name { font-size: 11px; font-weight: 700; line-height: 1.2; }
.trophy .when { font-size: 10px; color: var(--trophy-muted); }

/* ---------- Progress ---------- */
.checkin-item { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; }
.checkin-item.grad { background: var(--trophy-bg); color: var(--trophy-fg); }
.checkin-item.wobbly { background: var(--surface-2); }
.checkin-item.done { background: var(--accent-soft); color: var(--accent-soft-fg); }
.checkin-item .lead { display: flex; align-items: center; gap: 10px; }
.checkin-item .lead svg { width: 24px; height: 24px; flex-shrink: 0; color: var(--urgent-fg); }
.checkin-item.done .lead svg { color: var(--accent); }
.checkin-item .t { font-size: 15px; font-weight: 700; }
.checkin-item .s { font-size: 12px; opacity: 0.8; }
.checkin-item.grad .btn.ghost { background: transparent; border-color: rgba(128, 96, 0, 0.3); color: inherit; }
.month-row { display: flex; flex-direction: column; gap: 5px; padding: 8px 14px; }
.month-row + .month-row { border-top: 1px solid var(--line); }
.month-row .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.month-row .name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month-row .count { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.month-dots { display: flex; gap: 2px; justify-content: space-between; }
.md { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--dot-off); }
.md.week { width: 22px; flex-basis: 22px; border-radius: 6px; }
.md.on { background: var(--accent); }
.md.today { background: var(--surface); border: 2px solid var(--accent); }
.md.future { background: var(--surface); border: 1px solid var(--line); }
.md.na { background: transparent; }

/* ---------- Sheet (forms) ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  max-width: 540px;
  max-height: 92%;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding-block: 14px calc(20px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: rise 0.2s ease;
}
@keyframes rise { from { transform: translateY(30px); } to { transform: translateY(0); } }
.sheet > *, .sheet form > *, .view > * { flex-shrink: 0; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--dot-off); margin: 0 auto; }
.sheet h2 { font-size: 24px; }
.sheet .head { display: flex; align-items: center; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; min-width: 0; }
.input, .select { min-width: 0; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.field label .opt { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--faint); }
.input, .select, .textarea {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: var(--surface);
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
}
.textarea { padding: 12px 14px; min-height: 120px; font-family: ui-monospace, monospace; font-size: 12px; font-weight: 400; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: none; }
.input.big { font-family: var(--font-display); font-size: 20px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  flex: 1 1 0;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  border: 2px solid transparent;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-fg); }
.chip.morning.on { background: var(--morning); color: var(--morning-fg); border-color: var(--morning); }
.chip.afternoon.on { background: var(--afternoon); color: var(--afternoon-fg); border-color: var(--afternoon); }
.chip.evening.on { background: var(--evening); color: var(--evening-fg); border-color: var(--evening); }
.sticky-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px 16px;
  background: var(--pink);
  color: var(--pink-fg);
  border-radius: 6px;
  box-shadow: var(--shadow);
  transform: rotate(-0.8deg);
  margin: 4px 2px;
}
.sticky-form label { color: var(--pink-eyebrow); }
.sticky-form .input { background: rgba(255, 255, 255, 0.75); color: #4A1F2B; border-color: rgba(154, 59, 85, 0.25); }
.startby { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; background: var(--surface); }
.startby .ic { width: 48px; height: 48px; border-radius: 24px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--accent); }
.startby .ic svg { width: 24px; height: 24px; }
.startby .big { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.1; color: var(--accent); }
.startby .small { font-size: 12px; color: var(--muted); }
.startby .lbl { font-size: 13px; color: var(--muted); }
.inline-confirm { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.inline-confirm .q { font-size: 14px; font-weight: 700; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: 14px; }
.toggle-row .text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.toggle-row .name { font-size: 15px; font-weight: 700; }
.toggle-row .meta { font-size: 12px; color: var(--muted); }
.switch { width: 50px; height: 30px; border-radius: 15px; border: none; background: var(--dot-off); position: relative; flex-shrink: 0; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: var(--surface); transition: transform 0.15s ease; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.day-picker { display: flex; gap: 6px; }
.day-picker .chip { flex: 1 1 0; min-height: 40px; padding: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.class-row .meta { font-variant-numeric: tabular-nums; }
.install-box { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-soft-fg); font-size: 13px; line-height: 1.45; }
.install-box b { font-weight: 700; }

/* ---------- Timer overlay ---------- */
.timer {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--timer-bg);
  color: var(--timer-fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-block: calc(18px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow-y: auto;
}
.timer .inner { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 24px; flex-grow: 1; }
.timer .top { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.timer .top .icon-btn { background: rgba(255, 255, 255, 0.12); color: var(--timer-fg); }
.timer .top .eyebrow { color: var(--timer-muted); letter-spacing: 0.1em; }
.timer .task { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 0 12px; }
.timer .task .t { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.15; }
.timer .task .s { font-size: 14px; color: var(--timer-muted); }
.timer .disk { position: relative; width: min(300px, 76vw); aspect-ratio: 1; }
.timer .disk svg { width: 100%; height: 100%; }
.timer .clock {
  position: absolute; left: 0; right: 0; bottom: -2px;
  display: flex; justify-content: center;
}
.timer .clock span { padding: 6px 14px; border-radius: 14px; background: rgba(0, 0, 0, 0.3); font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.timer .done-msg { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--timer-disk); text-align: center; }
.timer .btn-row { width: 100%; }
.timer .btn.outline { background: transparent; color: var(--timer-fg); border: 2px solid rgba(255, 255, 255, 0.35); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 16px;
  border-radius: 18px;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  width: max-content;
  max-width: calc(100% - 32px);
}
.toast > span { flex: 1 1 auto; min-width: 0; }
.toast .btn { min-height: 34px; padding: 0 12px; font-size: 13px; background: var(--accent); color: var(--accent-fg); flex-shrink: 0; }

/* ---------- Desktop ---------- */
@media (min-width: 960px) {
  #app { max-width: 1120px; }
  .view { padding-left: 32px; padding-right: 32px; padding-top: 28px; }
  .tabbar { max-width: 540px; margin: 0 auto; width: 100%; border-radius: 22px 22px 0 0; }
  .today-blocks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  .today-blocks .collapsed { display: contents; }
  .today-blocks .collapsed > .row { grid-column: 1 / -1; }
  .today-top { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .sticky-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .habits-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
  .page-head h1 { font-size: 34px; }
}

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