:root {
  --sky-top: #8fc1ea;
  --sky-bot: #def0f8;
  --ink: #1f2e4a;
  --ink-soft: rgba(31, 46, 74, .66);
  --panel: rgba(255, 255, 255, .38);
  --panel-line: rgba(255, 255, 255, .55);
  --mochi-body: #ffeee3;
  --mochi-hi: #ffffff;
  --cheek: #ff97ae;
  --eye: #2a2440;
  --leaf: #79c98a;
  --listen: #5fe0c0;
  --sun: #fff3c4;
  --font: "Fredoka", ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  color-scheme: light;
}
body[data-phase="dawn"] {
  --sky-top: #f2a99a; --sky-bot: #fde4c8; --ink: #3b2a40; --ink-soft: rgba(59, 42, 64, .66);
  --sun: #ffe0a8;
}
body[data-phase="dusk"] {
  --sky-top: #5d5aa8; --sky-bot: #f0a49c; --ink: #fff7ef; --ink-soft: rgba(255, 247, 239, .74);
  --panel: rgba(40, 34, 90, .28); --panel-line: rgba(255, 255, 255, .22); --sun: #ffc59a;
  color-scheme: dark;
}
body[data-phase="night"] {
  --sky-top: #0f1335; --sky-bot: #2a2e63; --ink: #e7e8ff; --ink-soft: rgba(231, 232, 255, .62);
  --panel: rgba(10, 12, 40, .4); --panel-line: rgba(255, 255, 255, .1);
  --mochi-body: #e9dcef; --mochi-hi: #fbf6ff; --sun: #f3f0ff;
  color-scheme: dark;
}
/* deep night: dim everything so the tablet works as a night light */
body.sleeping .layout { opacity: .55; }
body.sleeping .panel { opacity: .5; }
body.lights-off .clock-block, body.lights-off .bubble, body.lights-off .care,
body.lights-off .dock, body.lights-off .panel { opacity: .22; transition: opacity 2s; }
body.lights-off .sky { filter: brightness(.45); }
body.lights-off .mochi { opacity: .9; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--sky-bot);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 2s;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--listen); outline-offset: 3px; border-radius: 12px; }

/* ---------- sky ---------- */
.sky {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bot));
  transition: background 3s;
}
.sun {
  position: absolute; width: 34vmin; height: 34vmin; border-radius: 50%;
  right: 8%; top: 6%;
  background: radial-gradient(circle, var(--sun) 0 30%, transparent 70%);
  opacity: .8; transition: opacity 3s, background 3s;
}
body[data-phase="night"] .sun { width: 14vmin; height: 14vmin; background: radial-gradient(circle, var(--sun) 0 38%, transparent 72%); opacity: .7; }
.stars {
  position: absolute; inset: 0; opacity: 0; transition: opacity 4s;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 42%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 58% 30%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 72% 54%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 86% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 18% 70%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 35% 84%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 78%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 64% 8%, #fff 50%, transparent 51%);
}
body[data-phase="night"] .stars { opacity: .8; }
body[data-phase="dusk"] .stars { opacity: .25; }

/* ---------- layout ---------- */
.layout {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  gap: clamp(12px, 2vw, 32px);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  transition: opacity 3s;
}
.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  justify-items: center;
  min-height: 0;
  padding: clamp(8px, 2vh, 24px) clamp(8px, 2vw, 32px);
}

/* clock: the one big piece of type */
.clock-block { justify-self: start; }
.clock {
  font-size: clamp(64px, 11vw, 148px);
  font-weight: 500;
  line-height: .9;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.date { font-size: clamp(18px, 2vw, 26px); font-weight: 400; margin-top: .35em; }
.greet { font-size: clamp(15px, 1.5vw, 19px); color: var(--ink-soft); margin-top: .2em; }

/* the character */
.mochi {
  all: unset;
  height: 100%;
  max-height: min(50vh, 540px);
  min-height: 0;
  max-width: 100%;
  aspect-ratio: 340 / 360;
  align-self: center;
  cursor: pointer;
  touch-action: manipulation;
}
.mochi:focus-visible { outline: 3px solid var(--listen); outline-offset: -10px; border-radius: 50%; }
.mochi-svg { width: 100%; height: 100%; overflow: visible; display: block; }
.m-body { stroke: rgba(80, 40, 60, .12); stroke-width: 2; filter: drop-shadow(0 6px 10px rgba(40, 30, 70, .12)); }
.m-shadow { fill: #1a1840; }
.m-cheek { fill: var(--cheek); }
.m-eye { fill: var(--eye); }
.m-shine { fill: #fff; }
.m-heart { fill: #ff5f86; }
.m-line, .m-brow { fill: none; stroke: var(--eye); stroke-width: 5; stroke-linecap: round; }
.m-brow { stroke-width: 4; }
.m-mouth { fill: #6b2840; stroke: #6b2840; stroke-width: 3.5; stroke-linejoin: round; }
.m-tongue { fill: #ff8aa2; }
.m-stem { fill: none; stroke: #5aa86c; stroke-width: 5; stroke-linecap: round; }
.m-leaf { fill: var(--leaf); stroke: #5aa86c; stroke-width: 2; }
.m-dot { fill: var(--ink); }
.m-z { font: 600 28px var(--font); fill: var(--ink); }
.m-band { fill: none; stroke: #3d4a6b; stroke-width: 9; stroke-linecap: round; transition: opacity .4s; }
.m-cup { fill: #3d4a6b; }
.m-cup-in { fill: #7ed7c1; }
.m-note { font: 600 30px var(--font); fill: var(--ink); }
.m-heart-fx { fill: #ff7d9c; }
.m-sparkle { fill: #ffe08a; }
.m-thought { fill: var(--panel); stroke: var(--panel-line); stroke-width: 2; }
.snack { pointer-events: none; }

/* speech */
.bubble {
  max-width: min(560px, 100%);
  max-height: 30vh; overflow-y: auto;
  text-align: center;
  min-height: 3.2em;
}
.heard { margin: 0 0 .3em; font-size: 15px; color: var(--ink-soft); }
.heard:empty { display: none; }
.said {
  margin: 0;
  font-size: clamp(19px, 2.1vw, 26px);
  line-height: 1.35;
  font-weight: 400;
  text-wrap: balance;
}

.typebox { display: flex; gap: 8px; margin-top: 10px; width: min(480px, 100%); }
.typebox[hidden] { display: none; }
.typebox input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 18px;
  border-radius: 999px; border: 1.5px solid var(--panel-line);
  background: var(--panel); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  -webkit-user-select: text; user-select: text; font-size: 17px;
}
.typebox input::placeholder { color: var(--ink-soft); }
.typebox button { border: 0; border-radius: 999px; padding: 0 20px; background: var(--ink); color: var(--sky-bot); font-weight: 500; }

/* ---------- side panel ---------- */
.panel {
  background: var(--panel);
  border: 1.5px solid var(--panel-line);
  -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
  border-radius: 32px;
  padding: clamp(18px, 2.2vw, 30px);
  display: flex; flex-direction: column; gap: clamp(18px, 2.6vh, 30px);
  overflow-y: auto;
  min-height: 0;
  transition: background 3s, opacity 3s;
}
.panel h2 { font-size: 15px; font-weight: 500; color: var(--ink-soft); margin: 0 0 10px; }

.wx-now { display: flex; align-items: center; gap: 14px; }
.wx-icon { width: 72px; height: 72px; flex: none; }
.wx-icon svg, .hours svg { width: 100%; height: 100%; }
.wx-temp { font-size: 54px; font-weight: 500; line-height: 1; letter-spacing: -.02em; }
.wx-label { font-size: 18px; margin-top: 4px; }
.wx-detail { margin: 10px 0 0; font-size: 15px; color: var(--ink-soft); line-height: 1.45; }

.hours {
  list-style: none; margin: 14px -4px 0; padding: 0 4px 4px;
  display: grid; grid-auto-flow: column; grid-auto-columns: 54px; gap: 4px;
  overflow-x: auto; scrollbar-width: none;
}
.hours::-webkit-scrollbar { display: none; }
.hours li { display: grid; justify-items: center; gap: 2px; font-size: 14px; }
.hours .h-time { color: var(--ink-soft); }
.hours .h-ico { width: 30px; height: 30px; }
.hours .h-temp { font-weight: 500; font-size: 16px; }
.hours .h-rain { font-size: 12px; color: #2f7dc4; min-height: 1.2em; }
body[data-phase="night"] .hours .h-rain, body[data-phase="dusk"] .hours .h-rain { color: #9fd0ff; }

.agenda ul, .world ul { list-style: none; margin: 0; padding: 0; }
.agenda li {
  display: grid; grid-template-columns: 62px 1fr; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--panel-line); font-size: 17px;
}
.agenda li:first-child { border-top: 0; }
.agenda .a-time { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.agenda .a-loc { display: block; font-size: 14px; color: var(--ink-soft); }
.agenda li.past { opacity: .45; }
.agenda li.now .a-time { color: var(--ink); font-weight: 600; }
.agenda li.now { position: relative; }
.agenda li.now::before {
  content: ""; position: absolute; left: -14px; top: 15px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--listen);
}
.agenda .empty { grid-column: 1 / -1; display: block; color: var(--ink-soft); font-size: 16px; padding: 4px 0; }
.tomorrow { margin: 10px 0 0; font-size: 14px; color: var(--ink-soft); }
.tomorrow:empty { display: none; }

.world li {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline;
  padding: 7px 0; border-top: 1px solid var(--panel-line);
}
.world li:first-child { border-top: 0; }
.world .w-city { font-size: 17px; }
.world .w-diff { display: block; font-size: 13px; color: var(--ink-soft); }
.world .w-time { font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.world .w-time small { font-size: 13px; font-weight: 400; color: var(--ink-soft); margin-left: 4px; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--sky-bot); padding: 12px 20px; border-radius: 16px;
  font-size: 16px; max-width: calc(100% - 32px); text-align: center;
}

/* ---------- portrait tablets & phones ---------- */
@media (max-aspect-ratio: 1/1), (max-width: 760px) {
  body { overflow-y: auto; }
  .layout { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100dvh; }
  .stage { min-height: 88dvh; padding-inline: 0; }
  .mochi { height: min(78vw, 44vh, 460px); }
  .panel { overflow: visible; }
}
@media (max-width: 420px) {
  .clock { font-size: 64px; }
  .talk { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .sky, .sun, .stars, .layout, .panel { transition: none; }
}

/* ================= rain / snow on the window ================= */
.rain { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ================= care strip ================= */
.care {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center;
  margin-top: 10px; font-size: 14px; color: var(--ink-soft);
}
.meter, .lvl { display: inline-flex; align-items: center; gap: 6px; }
.meter svg { width: 16px; height: 16px; fill: var(--ink-soft); }
.bar {
  position: relative; display: block; width: 56px; height: 7px; border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 14%, transparent); overflow: hidden;
}
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: #7ed7c1; transition: width 1s ease; }
.meter:nth-child(1) .bar i { background: #f6b26b; }
.meter:nth-child(2) .bar i { background: #8fb8ff; }
.meter:nth-child(3) .bar i { background: #ff97ae; }
.bar[data-low="1"] i { animation: lowpulse 1.6s ease-in-out infinite; }
@keyframes lowpulse { 50% { opacity: .35; } }
.lvl { font-weight: 500; color: var(--ink); }
.bar.xp { width: 44px; }
.bar.xp i { background: linear-gradient(90deg, #ffd25e, #ff97ae); }

/* ================= dock ================= */
.dock { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.talk, .tool {
  border: 1.5px solid var(--panel-line);
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-radius: 999px;
}
.talk { min-height: 54px; display: inline-flex; align-items: center; gap: 10px; padding: 0 24px 0 18px; font-size: 18px; font-weight: 500; }
.talk svg, .tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.talk[data-state="listening"] { background: var(--listen); color: #0d2f2a; border-color: transparent; }
.talk[data-state="busy"] { opacity: .6; }
.tools { display: flex; gap: 6px; }
.tool {
  width: 54px; height: 54px; padding: 0; display: grid; place-items: center; align-content: center; gap: 1px;
  border-radius: 18px; font-size: 11px; font-weight: 500;
}
.tool span { line-height: 1; }
body.music-on #btnMusic, body.focusing #btnFocus, body.lights-off #btnLights { background: var(--ink); color: var(--sky-bot); }

/* ================= focus ================= */
body.focusing .clock { color: color-mix(in srgb, var(--ink) 92%, #7ed7c1); }
.focus-info {
  all: unset; display: inline-block; margin-top: 8px; padding: 6px 12px; border-radius: 99px;
  background: var(--panel); border: 1.5px solid var(--panel-line); font-size: 14px; cursor: pointer;
}
.focus-info[hidden] { display: none; }

/* ================= now playing ================= */
.np { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 12px; }
.np[hidden] { display: none; }
.np-art {
  width: 58px; height: 58px; border-radius: 16px; display: flex; align-items: flex-end; justify-content: center; gap: 4px;
  padding: 10px 9px; background: linear-gradient(160deg, #6e6bb8, #f0a49c); transition: transform .12s;
}
.np-art.beat { animation: artbeat .25s ease-out; }
@keyframes artbeat { 30% { transform: scale(1.06); } }
.np-art i { flex: 1; height: 100%; background: rgba(255, 255, 255, .85); border-radius: 3px; transform-origin: bottom; transform: scaleY(.2); transition: transform .08s; }
.np-title { font-size: 18px; font-weight: 500; text-transform: lowercase; }
.np-sub { font-size: 13px; color: var(--ink-soft); }
.np-ctl { display: flex; gap: 4px; }
.np-ctl button { all: unset; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; }
.np-ctl button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.np-ctl button[hidden] { display: none; }
.np-ctl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ================= light card ================= */
.light[hidden] { display: none; }
.light-row { display: grid; gap: 6px; }
.lw { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 10px; padding: 9px 12px; border-radius: 14px; }
.lw.gold { background: linear-gradient(90deg, rgba(255, 196, 110, .35), rgba(255, 150, 120, .18)); }
.lw.blue { background: linear-gradient(90deg, rgba(100, 140, 230, .32), rgba(70, 90, 180, .16)); }
.lw.active { outline: 2px solid var(--ink-soft); }
.lw-name { font-size: 16px; font-weight: 500; }
.lw-time { font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; }
.lw-note { grid-column: 1 / -1; font-size: 13px; color: var(--ink-soft); }
.light-sky { margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); line-height: 1.4; }
.light-sky:empty { display: none; }
.light-sky[data-score="4"]::before, .light-sky[data-score="3"]::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ffb35c; margin-right: 7px; vertical-align: 1px; }

/* ================= sheets ================= */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; background: rgba(15, 18, 45, .35); padding: 16px; }
.sheet[hidden] { display: none; }
.sheet-card {
  width: min(520px, 100%); background: var(--sky-bot); color: var(--ink); border-radius: 28px; padding: 22px;
  box-shadow: 0 20px 60px rgba(10, 10, 40, .35); text-align: center; animation: rise .25s ease-out;
}
body[data-phase="night"] .sheet-card, body[data-phase="dusk"] .sheet-card { background: #262a5a; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.sheet-card h3 { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.sheet-sub { margin: 0 0 14px; color: var(--ink-soft); font-size: 15px; }
.snacks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.snack-btn { all: unset; cursor: pointer; display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border-radius: 18px; font-size: 14px; }
.snack-btn:hover, .snack-btn:focus-visible { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.snack-btn svg { width: 56px; height: 56px; }
.chips { display: flex; gap: 8px; justify-content: center; margin: 6px 0 14px; }
.chips button { border: 0; border-radius: 99px; padding: 12px 18px; font-size: 17px; font-weight: 500; background: var(--ink); color: var(--sky-bot); }
.sheet-close { border: 0; background: none; color: var(--ink-soft); font-size: 15px; padding: 8px 14px; }

/* ================= game ================= */
.game { position: fixed; inset: 0; z-index: 30; background: linear-gradient(#141a48, #3a3f86); color: #fff; touch-action: none; }
.game[hidden] { display: none; }
.game canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.game-hud {
  position: absolute; top: max(16px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; justify-content: space-between;
  padding: 0 24px; font-size: 40px; font-weight: 600; pointer-events: none; z-index: 1;
}
.game-hud span:last-child { font-size: 22px; opacity: .7; align-self: center; }
.game-mochi { position: absolute; left: 50%; bottom: 0; width: 160px; transform: translateX(-50%); pointer-events: none; aspect-ratio: 340/360;
  --mochi-body: #ffeee3; --mochi-hi: #fff; --ink: #fff; }
.game-end { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(10, 12, 40, .45); }
.game-end[hidden] { display: none; }
.game-end p { font-size: 28px; margin: 0 0 8px; }
.game-end button { border: 0; border-radius: 99px; padding: 14px 26px; font-size: 18px; font-weight: 500; background: #fff; color: #1f2e4a; min-width: 180px; }
.game-end button.ghost { background: transparent; color: #fff; border: 1.5px solid rgba(255, 255, 255, .5); }

/* ================= screensaver ================= */
.saver { position: fixed; inset: 0; z-index: 40; background: #0c0e22; opacity: 0; transition: opacity .6s; overflow: hidden; cursor: none; }
.saver[hidden] { display: none; }
.saver.visible { opacity: 1; }
.saver-img { position: absolute; inset: -2%; background: center / cover no-repeat; opacity: 0; transition: opacity 2.2s ease; }
.saver-img.show { opacity: 1; }
.saver-img.kb { animation: kenburns 14s linear forwards; }
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.14); } }
.saver-shade { position: absolute; inset: 0; background: linear-gradient(transparent 60%, rgba(0, 0, 0, .55)); pointer-events: none; }
.saver-caption {
  position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; gap: 4px 16px; max-width: 70%; color: rgba(255, 255, 255, .88); font-size: 15px; letter-spacing: .01em;
}
.saver-clock {
  position: absolute; right: max(28px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  color: #fff; font-size: clamp(44px, 7vw, 84px); font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 20px rgba(0, 0, 0, .35);
}
.saver-mochi {
  position: absolute; right: 8%; bottom: -120px; width: 150px; aspect-ratio: 340/360; transition: bottom 1.2s cubic-bezier(.3, 1.4, .5, 1);
  --mochi-body: #ffeee3; --mochi-hi: #fff; --ink: #fff;
}
.saver-mochi.peek { bottom: -40px; }
.saver.empty { background: radial-gradient(ellipse at 50% 120%, #3a2f6e, #0c0e22 70%); }
.saver.empty .saver-mochi { bottom: auto; top: 50%; right: auto; left: 50%; width: 220px; transform: translate(-50%, -50%); animation: drift 40s ease-in-out infinite alternate; }
.saver.empty .saver-clock { right: 50%; transform: translateX(50%); bottom: 12%; }
@keyframes drift { 0% { transform: translate(-90%, -70%); } 50% { transform: translate(-20%, -40%); } 100% { transform: translate(-60%, -20%); } }

@media (max-width: 760px) {
  .tools { flex-wrap: wrap; justify-content: center; }
  .tool { width: 50px; height: 50px; }
  .care { gap: 10px; }
  .bar { width: 44px; }
  .snacks { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .saver-img.kb, .saver.empty .saver-mochi, .np-art.beat { animation: none; }
}

.clock-unit { font-size: .22em; font-weight: 400; letter-spacing: 0; margin-left: .3em; color: var(--ink-soft); }

/* ================= v3: wellbeing ================= */
.stage { position: relative; }
.gear {
  all: unset; position: absolute; top: clamp(8px, 2vh, 24px); right: clamp(8px, 2vw, 32px); z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; opacity: .55;
}
.gear:hover, .gear:focus-visible { opacity: 1; background: var(--panel); }
.gear svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.nudge-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; animation: rise .3s ease-out; }
.nudge-actions[hidden] { display: none; }
.nudge-actions button {
  border: 1.5px solid var(--panel-line); background: var(--panel); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-radius: 99px; padding: 10px 18px; font-size: 16px; font-weight: 500; min-height: 44px;
}
.nudge-actions button:first-child { background: var(--ink); color: var(--sky-bot); border-color: transparent; }

/* guided breathing / stretch: big calm type where the clock was */
.guide {
  position: absolute; inset: 0 0 auto 0; z-index: 3; padding: clamp(8px, 2vh, 24px) clamp(8px, 2vw, 32px);
  display: grid; justify-items: start; gap: 6px; animation: rise .4s ease-out;
}
.guide[hidden] { display: none; }
.guide-text { font-size: clamp(40px, 6vw, 76px); font-weight: 500; line-height: 1; letter-spacing: -.02em; }
.guide-sub { font-size: clamp(28px, 3vw, 40px); color: var(--ink-soft); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.guide-stop { border: 1.5px solid var(--panel-line); background: var(--panel); border-radius: 99px; padding: 8px 18px; font-size: 15px; }
body.guiding .clock-block { visibility: hidden; }
body.guiding .panel, body.guiding .care, body.guiding .dock, body.guiding .bubble, body.guiding .nudge-actions { opacity: .25; transition: opacity 1s; pointer-events: none; }

/* settings */
.settings { text-align: left; }
.settings h3 { text-align: center; margin-bottom: 12px; }
.set-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--panel-line); }
.set-row b { display: block; font-weight: 500; font-size: 17px; }
.set-row small { display: block; color: var(--ink-soft); font-size: 13px; line-height: 1.35; margin-top: 2px; }
.set-ctl { display: grid; justify-items: end; gap: 2px; }
.set-ctl input[type=range] { width: 150px; accent-color: #7ed7c1; }
.set-ctl output { font-size: 14px; font-variant-numeric: tabular-nums; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 20%, transparent); position: relative; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch:checked { background: #5fcfb3; }
.switch:checked::after { transform: translateX(20px); }
.set-try { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 14px 0 4px; border-top: 1px solid var(--panel-line); }
.set-try button { border: 1.5px solid var(--panel-line); background: transparent; border-radius: 99px; padding: 8px 14px; font-size: 14px; }
.sheet-card.settings { max-height: calc(100dvh - 32px); overflow-y: auto; }
.guide-text { max-width: calc(100% - 56px); }

/* ================= v4: meals + settings blocks ================= */
.tool { position: relative; }
.tool .badge { display: none; position: absolute; top: 5px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: #ff8a5c; box-shadow: 0 0 0 2px var(--sky-bot); }
#btnFeed.meal-time .badge { display: block; animation: lowpulse 1.4s ease-in-out infinite; }
#btnFeed.meal-time { border-color: #ffb36b; box-shadow: 0 0 0 3px rgba(255, 179, 107, .25); }

.set-block { padding: 12px 0; border-top: 1px solid var(--panel-line); }
.set-block > b { display: block; font-weight: 500; font-size: 17px; }
.set-block > small { display: block; color: var(--ink-soft); font-size: 13px; margin: 2px 0 8px; }
.tz-list { list-style: none; margin: 0; padding: 0; }
.tz-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; }
.tz-list li b { display: block; font-weight: 500; }
.tz-list li small { color: var(--ink-soft); font-size: 13px; }
.tz-empty { color: var(--ink-soft); }
.tz-btns { display: flex; gap: 4px; }
.tz-btns button { all: unset; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; font-size: 18px; }
.tz-btns button:hover, .tz-btns button:focus-visible { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.tz-add { display: grid; grid-template-columns: 1fr 140px auto; gap: 8px; margin-top: 8px; }
.tz-add input, .meals input {
  min-width: 0; min-height: 42px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--panel-line);
  background: color-mix(in srgb, var(--ink) 6%, transparent); -webkit-user-select: text; user-select: text; font-size: 15px;
}
.tz-add button { border: 0; border-radius: 12px; padding: 0 16px; background: var(--ink); color: var(--sky-bot); font-weight: 500; }
.set-err { color: #ff8a8a; font-size: 14px; margin: 8px 0 0; }
.set-err[hidden] { display: none; }
.meals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.meals label { display: grid; gap: 4px; font-size: 14px; color: var(--ink-soft); }
@media (max-width: 520px) { .tz-add { grid-template-columns: 1fr; } .meals { grid-template-columns: 1fr; } }

/* ================= v5: coins, games, doodle, room ================= */
.coins { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; color: var(--ink); }
.coins svg, .room-coins svg { width: 17px; height: 17px; fill: #ffd166; stroke: #c99a2e; stroke-width: 1.4; }
.glow-warm { filter: drop-shadow(0 0 14px rgba(255, 200, 120, .75)); }
body[data-phase="day"] .glow-warm { filter: none; }
.twinkle { animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .35; } }

/* game chooser */
.games { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 6px; }
.games button { all: unset; cursor: pointer; display: grid; justify-items: center; gap: 4px; padding: 16px 8px; border-radius: 20px;
  background: color-mix(in srgb, var(--ink) 6%, transparent); text-align: center; }
.games button:hover, .games button:focus-visible { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.games svg { width: 48px; height: 48px; }
.games b { font-weight: 500; font-size: 17px; }
.games span { font-size: 13px; color: var(--ink-soft); }

/* rhythm */
.rhythm { position: fixed; inset: 0; z-index: 30; background: radial-gradient(ellipse at 50% 110%, #5d4a9e, #141a48 65%); color: #fff; touch-action: none; }
.rhythm[hidden] { display: none; }
.rhythm canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.rhythm .game-hud span:last-child { font-size: 20px; opacity: .85; }
.rhythm-result { display: grid; gap: 4px; text-align: center; }
.rhythm-result b { font-size: 34px; font-weight: 600; }
.rhythm-result span { font-size: 17px; opacity: .85; }
.rhythm .game-mochi { width: 130px; }

/* doodle */
.doodle { position: fixed; inset: 0; z-index: 30; display: grid; grid-template-rows: auto 1fr auto auto; gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: linear-gradient(var(--sky-top), var(--sky-bot)); }
.doodle[hidden] { display: none; }
.doodle-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.doodle-top b { font-weight: 500; font-size: clamp(18px, 2.2vw, 24px); margin-right: 10px; }
.linkish { all: unset; cursor: pointer; font-size: 14px; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.doodle-x { all: unset; cursor: pointer; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; background: var(--panel); }
#doodleCanvas { width: 100%; height: 100%; min-height: 0; border-radius: 22px; background: #fffdf8; box-shadow: 0 8px 30px rgba(20, 20, 60, .18); touch-action: none; cursor: crosshair; }
.doodle-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.swatches, .sizes { display: flex; gap: 6px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .12); }
.swatch.on { outline: 3px solid var(--ink); outline-offset: 2px; }
.sizes button { width: 38px; height: 38px; border-radius: 12px; border: 1.5px solid var(--panel-line); background: var(--panel); display: grid; place-items: center; }
.sizes i { display: block; border-radius: 50%; background: var(--ink); }
.sizes button.on { background: var(--ink); } .sizes button.on i { background: var(--sky-bot); }
.doodle-tools > button { border: 1.5px solid var(--panel-line); background: var(--panel); border-radius: 99px; padding: 8px 14px; font-size: 15px; }
.doodle-tools > button.on { background: var(--ink); color: var(--sky-bot); }
.doodle-bottom { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center; }
.doodle-mochi { width: 90px; aspect-ratio: 340/360; }
.doodle-reply { margin: 0; font-size: 18px; line-height: 1.35; }
.doodle-actions { display: flex; gap: 8px; }
.doodle-actions button { border: 1.5px solid var(--panel-line); background: var(--panel); border-radius: 99px; padding: 12px 18px; font-size: 16px; font-weight: 500; }
.doodle-actions .primary { background: var(--ink); color: var(--sky-bot); border-color: transparent; }
.doodle-actions button:disabled { opacity: .5; }

/* room */
.room { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(15, 18, 45, .4); padding: 16px; }
.room[hidden] { display: none; }
.room-card { width: min(860px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--sky-bot); color: var(--ink);
  border-radius: 28px; padding: 18px 22px 22px; box-shadow: 0 20px 60px rgba(10, 10, 40, .35); animation: rise .25s ease-out; }
body[data-phase="night"] .room-card, body[data-phase="dusk"] .room-card { background: #262a5a; }
.room-head { display: flex; align-items: center; gap: 12px; }
.room-head h3 { margin: 0; font-size: 24px; font-weight: 500; flex: 1; }
.room-coins { display: inline-flex; align-items: center; gap: 5px; font-size: 18px; }
.room-coins b { font-weight: 600; }
.room-tabs { display: flex; gap: 6px; margin: 14px 0 12px; }
.room-tabs button { border: 0; border-radius: 99px; padding: 9px 16px; font-size: 15px; font-weight: 500; background: color-mix(in srgb, var(--ink) 7%, transparent); }
.room-tabs button.on { background: var(--ink); color: var(--sky-bot); }
.room-card section[hidden] { display: none; }
.wall-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.wall-head p { margin: 0; color: var(--ink-soft); }
.upload { cursor: pointer; border-radius: 99px; padding: 11px 18px; background: var(--ink); color: var(--sky-bot); font-weight: 500; }
.upload.busy { opacity: .5; pointer-events: none; }
.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.frame { all: unset; cursor: pointer; display: grid; gap: 6px; padding: 8px 8px 10px; background: #fffdf8; border-radius: 6px;
  box-shadow: 0 6px 18px rgba(20, 20, 60, .18); color: #3b3346; transform: rotate(var(--tilt, 0deg)); transition: transform .15s; }
.frame:nth-child(3n) { --tilt: -1.5deg; } .frame:nth-child(3n+1) { --tilt: 1deg; }
.frame:hover, .frame:focus-visible { transform: rotate(0) scale(1.03); }
.frame img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px; background: #eee; }
.frame.doodle img { object-fit: contain; background: #fffdf8; }
.frame span { font-size: 14px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wall-empty { color: var(--ink-soft); grid-column: 1 / -1; }

.jar-wrap { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: center; }
.jar-art { display: grid; justify-items: center; text-align: center; }
.jar-art svg { width: 170px; }
.jar-art b { font-size: 28px; font-weight: 600; line-height: 1; } .jar-art span { color: var(--ink-soft); font-size: 14px; }
.jar-star { animation: twinkle 3s ease-in-out infinite; }
#jarForm { display: grid; gap: 8px; }
#jarForm textarea { resize: none; border-radius: 16px; padding: 12px 14px; border: 1.5px solid var(--panel-line);
  background: color-mix(in srgb, var(--ink) 6%, transparent); font: inherit; font-size: 17px; -webkit-user-select: text; user-select: text; color: inherit; }
#jarForm button { justify-self: start; border: 0; border-radius: 99px; padding: 11px 18px; background: var(--ink); color: var(--sky-bot); font-weight: 500; }
.ghost-btn { border: 1.5px solid var(--panel-line); background: transparent; border-radius: 99px; padding: 9px 16px; font-size: 15px; margin-top: 8px; }
.jar-memory { margin: 10px 0 0; padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, #ffd166 22%, transparent); line-height: 1.4; }
.jar-memory[hidden] { display: none; }
.jar-list { list-style: none; padding: 0; margin: 16px 0 0; }
.jar-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--panel-line); }
.jar-list small { color: var(--ink-soft); white-space: nowrap; }

.shop-note { margin: 0 0 6px; color: var(--ink-soft); font-size: 14px; }
#shopGrid h4 { margin: 16px 0 8px; font-size: 15px; font-weight: 500; color: var(--ink-soft); }
.shop-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.shop-card { display: grid; justify-items: center; gap: 6px; padding: 12px; border-radius: 18px; background: color-mix(in srgb, var(--ink) 6%, transparent); text-align: center; }
.shop-card.on { outline: 2px solid #7ed7c1; }
.shop-pv { width: 100%; height: 86px; display: grid; place-items: center; }
.shop-pv svg { width: 100%; height: 100%; }
.shop-card span { font-size: 15px; }
.shop-card button { border: 0; border-radius: 99px; padding: 8px 14px; font-size: 14px; font-weight: 500; background: var(--ink); color: var(--sky-bot); }
.shop-card.on button { background: #7ed7c1; color: #0d2f2a; }
.shop-card button:disabled { opacity: .4; }

.lightbox { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; background: rgba(8, 8, 20, .82); padding: 16px; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; display: grid; gap: 12px; max-width: min(900px, 100%); max-height: 100%; }
.lightbox img { max-width: 100%; max-height: 70dvh; object-fit: contain; border-radius: 8px; background: #fffdf8; justify-self: center; }
.lightbox figcaption { color: #fff; display: grid; gap: 4px; }
.lightbox figcaption b { font-size: 22px; font-weight: 500; }
.lightbox figcaption small { opacity: .7; }
.lightbox figcaption p { margin: 4px 0 0; font-size: 17px; line-height: 1.4; }
.lb-btns { display: flex; gap: 8px; margin-top: 6px; }
.lb-btns .ghost-btn { color: #fff; border-color: rgba(255, 255, 255, .4); margin: 0; }

@media (max-width: 760px) {
  .games { grid-template-columns: 1fr; }
  .jar-wrap { grid-template-columns: 1fr; }
  .doodle-bottom { grid-template-columns: 60px 1fr; }
  .doodle-mochi { width: 60px; }
  .doodle-actions { grid-column: 1 / -1; justify-content: center; }
}
@media (max-width: 760px) {
  .tools { gap: 4px; flex-wrap: nowrap; }
  .tool { width: 46px; height: 50px; border-radius: 15px; font-size: 10px; }
  .tool svg { width: 20px; height: 20px; }
}

/* ================= v6: water tracker + sun ================= */
.water-head { display: flex; justify-content: space-between; align-items: baseline; }
.water-head h2 { margin: 0; }
.water-count { font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.water-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.glasses { flex: 1; display: flex; flex-wrap: wrap; gap: 3px; }
.glass { width: 20px; height: 26px; }
.glass .g-out { fill: rgba(255, 255, 255, .14); stroke: var(--ink-soft); stroke-width: 1.4; }
.glass .g-in { fill: transparent; transition: fill .4s; }
.glass.full .g-in { fill: #6cc4f5; }
.glass.extra .g-out { stroke-dasharray: 2 2; }
.water-btns { display: flex; gap: 6px; }
.water-btns button { border: 1.5px solid var(--panel-line); background: transparent; border-radius: 99px; min-width: 44px; height: 44px; padding: 0 14px; font-size: 16px; font-weight: 500; }
.water-btns .primary { background: #6cc4f5; color: #0b2a3d; border-color: transparent; }
.water-note { margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.wk { display: grid; justify-items: center; gap: 3px; }
.wk-bar { position: relative; width: 100%; max-width: 22px; height: 30px; border-radius: 5px; background: color-mix(in srgb, var(--ink) 8%, transparent); overflow: hidden; }
.wk-bar i { position: absolute; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, #6cc4f5 60%, transparent); border-radius: 5px; }
.wk.met .wk-bar i { background: #6cc4f5; }
.wk small { font-size: 11px; color: var(--ink-soft); }
.wk.today small { color: var(--ink); font-weight: 600; }

.sun-arc svg { width: 100%; display: block; }
.sun-arc .horizon { stroke: var(--ink-soft); stroke-width: 1; opacity: .5; }
.sun-arc .arc-rest { fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-dasharray: 3 5; opacity: .6; }
.sun-arc .arc-done { fill: none; stroke: url(#arcGrad); stroke-width: 3.5; stroke-linecap: round; }
.sun-arc .sun-glow { fill: #ffd166; opacity: .3; }
.sun-arc .sun-dot { fill: #ffd166; stroke: #f0a93b; stroke-width: 1.5; }
.sun-arc .moon-dot { fill: #f1ecc8; }
.sun-arc .sun-t { font: 500 14px var(--font); fill: var(--ink); }
.sun-arc .sun-l { font: 400 11px var(--font); fill: var(--ink-soft); }
.sun-len { margin: 4px 0 12px; font-size: 14px; color: var(--ink-soft); line-height: 1.4; }

/* settings: water + affirmations */
.water-set { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.water-set label { display: grid; gap: 4px; font-size: 14px; color: var(--ink-soft); }
.stepper { display: inline-grid; grid-template-columns: 42px 1fr 42px; align-items: center; height: 42px; border-radius: 12px;
  border: 1.5px solid var(--panel-line); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.stepper button { all: unset; cursor: pointer; text-align: center; font-size: 20px; height: 100%; color: var(--ink); }
.stepper output { text-align: center; font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }
.water-set select { min-height: 42px; border-radius: 12px; padding: 0 10px; border: 1.5px solid var(--panel-line);
  background: color-mix(in srgb, var(--ink) 6%, transparent); font-size: 15px; color: var(--ink); }
.seg { display: inline-flex; padding: 3px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 8%, transparent); margin-bottom: 8px; }
.seg button { border: 0; background: transparent; border-radius: 99px; padding: 8px 14px; font-size: 14px; font-weight: 500; }
.seg button.on { background: var(--ink); color: var(--sky-bot); }
.affirm-times { grid-template-columns: 1fr 1fr !important; }
.affirm-times[hidden] { display: none; }
@media (max-width: 520px) {
  .glass { width: 16px; height: 21px; }
  .glasses { gap: 2px; }
  .water-btns button { padding: 0 12px; }
}

/* v11: sound blocked by the browser */
.sound-chip { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; border: 0; border-radius: 99px;
  padding: 11px 18px; font-size: 16px; font-weight: 500; background: #ffd166; color: #3b2a10; animation: rise .3s ease-out, chipglow 1.8s ease-in-out .3s infinite; }
@keyframes chipglow { 50% { box-shadow: 0 0 0 8px rgba(255, 209, 102, .35); } }
.sound-chip[hidden] { display: none; }
.sound-chip svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* token gate (home-screen apps don't share Safari's storage) */
#tokenGate { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: rgba(222, 240, 248, .96); }
#tokenGate form { width: min(380px, 100%); background: #fff; border-radius: 22px; padding: 24px;
  box-shadow: 0 10px 40px rgba(60, 90, 120, .18); text-align: center; font-family: inherit; color: #34495e; }
#tokenGate h2 { margin: 0 0 8px; font-size: 1.3rem; }
#tokenGate p { margin: 0 0 16px; font-size: .95rem; line-height: 1.4; }
#tokenGate input { width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 12px; border: 2px solid #cfe3f1;
  font-size: 16px; margin-bottom: 12px; background: #f6fbfe; color: #34495e; }
#tokenGate button { width: 100%; padding: 12px; border: 0; border-radius: 12px; background: #8fc1ea; color: #fff;
  font-size: 1rem; font-weight: 700; }
