:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #3a2f28;
  --soft: #8a7b70;
  --accent: #ff9f43;
  --accent-ink: #ffffff;
  --mine: #dff3e4;
  --line: #f0e3d0;
  --good: #3bb273;
  --night: #2d3561;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Zen Maru Gothic", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 28px;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  -webkit-user-select: none; user-select: none;
}
body.night { --bg: #1f2547; --card: #2d3561; --ink: #f4f1ff; --soft: #b8b3d9; --line: #3d4677; --mine: #3f5a6b; }

button { font: inherit; color: inherit; border: none; cursor: pointer; }

/* ---------- header ---------- */
#top {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 0; border-bottom: 2px solid var(--line);
}
#clock { width: 130px; height: 130px; flex: none; color: var(--ink); }
#clock .face { fill: var(--card); stroke: var(--accent); stroke-width: 6; }
#clock .num { font-size: 20px; fill: var(--ink); text-anchor: middle; dominant-baseline: central; font-weight: bold; }
#clock .tick { stroke: var(--soft); stroke-width: 2; }
#clock .hour { stroke: var(--ink); stroke-width: 9; stroke-linecap: round; }
#clock .min { stroke: var(--accent); stroke-width: 6; stroke-linecap: round; }
#info { flex: 1; min-width: 0; }
#digital { font-size: 44px; font-weight: bold; }
#countdown-text { font-size: 24px; color: var(--soft); margin-top: 4px; }
.bar { height: 16px; background: var(--line); border-radius: 8px; overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 8px; transition: width .6s; }
#side { display: flex; flex-direction: column; gap: 8px; }
#side button { background: var(--card); border-radius: 16px; padding: 8px 14px; font-size: 24px; }

/* ---------- chat ---------- */
#chat { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 12px; align-items: flex-end; animation: pop .25s ease-out; }
.msg .face { font-size: 52px; line-height: 1; flex: none; }
.bubble {
  background: var(--card); border-radius: 24px 24px 24px 6px;
  padding: 16px 22px; max-width: 80%; line-height: 1.9;
  box-shadow: 0 2px 0 var(--line);
}
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: var(--mine); border-radius: 24px 24px 6px 24px; }
rt { font-size: 0.45em; color: var(--soft); }
.typing .bubble { color: var(--soft); letter-spacing: 4px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- answers ---------- */
#answers { padding: 12px 0 20px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.choice {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 24px; padding: 18px 28px; min-width: 180px;
  font-size: 30px; font-weight: bold; box-shadow: 0 5px 0 #d97c22;
  display: flex; flex-direction: column; align-items: center;
}
.choice:active { transform: translateY(4px); box-shadow: 0 1px 0 #d97c22; }
.choice small { font-size: 20px; font-weight: normal; opacity: .9; margin-top: 4px; }
.choice.ghost { background: var(--card); color: var(--ink); box-shadow: 0 5px 0 var(--line); }

/* doing-a-task card */
.doing { width: 100%; max-width: 640px; background: var(--card); border-radius: 28px; padding: 20px 24px; text-align: center; }
.doing .big { font-size: 64px; }
.doing .label { font-size: 34px; font-weight: bold; margin: 4px 0 8px; }
.doing .sub { font-size: 22px; color: var(--soft); }
.doing .bar { height: 22px; margin: 12px 0 18px; }
.doing .bar > div { background: var(--good); }

/* evening checklist */
.checklist { width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 12px; }
.check {
  display: flex; align-items: center; gap: 16px; text-align: left;
  background: var(--card); border-radius: 22px; padding: 16px 22px; font-size: 32px;
  box-shadow: 0 4px 0 var(--line);
}
.check .em { font-size: 44px; }
.check .t { flex: 1; }
.check .t small { display: block; font-size: 20px; color: var(--soft); }
.check .box { width: 48px; height: 48px; border-radius: 14px; border: 4px solid var(--soft); display: grid; place-items: center; }
.check.done { opacity: .55; }
.check.done .box { background: var(--good); border-color: var(--good); color: #fff; }
.check.done .box::after { content: "✓"; font-weight: bold; }

/* parent */
#parent { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; font-family: system-ui, sans-serif; font-size: 18px; }
#parent[hidden] { display: none; }
#parent .panel { background: #fff; color: #222; border-radius: 16px; padding: 20px 24px; width: min(560px, 92vw); max-height: 85vh; overflow: auto; }
#parent table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
#parent td { border-bottom: 1px solid #eee; padding: 6px 4px; }
#parent .name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
#parent .name-row input { flex: 1; min-width: 0; font-size: 18px; padding: 8px 10px; border: 1px solid #ccc; border-radius: 8px; -webkit-user-select: text; user-select: text; }
#parent .name-row button { padding: 8px 14px; border-radius: 8px; background: #e6f4ea; }
#parent h3 { margin: 16px 0 4px; font-size: 18px; }
#parent .note { font-size: 14px; color: #666; margin: 4px 0; }
#parent .task-head td { padding-top: 14px; border-bottom: none; }
#parent .stepper { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
#parent .stepper button { width: 40px; height: 40px; border-radius: 10px; background: #f0f0f0; font-size: 22px; }
#parent .stepper b { min-width: 28px; text-align: center; font-size: 20px; }
#parent .row { display: flex; gap: 12px; justify-content: flex-end; }
#parent .row button { padding: 10px 16px; border-radius: 10px; background: #eee; }
#parent #parent-reset { background: #ffe0e0; }

@media (max-width: 600px) {
  body { font-size: 22px; }
  #clock { width: 90px; height: 90px; }
  #digital { font-size: 32px; }
  .choice { min-width: 140px; font-size: 24px; padding: 14px 20px; }
}
