:root {
  --sky-50: #F3F9FE;
  --sky-100: #DCEEFB;
  --sky-200: #BFE1F7;
  --sky-300: #8FC7EE;
  --blue: #256EA8;
  --blue-dark: #1B5686;
  --ink: #10304A;
  --muted: #54728A;
  --line: #CFE3F3;
  --butter: #FFD66B;
  --butter-100: #FFF1C7;
  --danger: #B3372F;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--sky-50);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* ---------- Splash ---------- */
#splash {
  position: fixed; inset: 0; z-index: 100;
  background: var(--sky-200);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  transition: opacity .4s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
#splash .word { font-size: 2.3rem; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
#splash .steam path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: steam .9s ease-out forwards; }
#splash .steam path:nth-child(1) { animation-delay: .15s; }
#splash .steam path:nth-child(2) { animation-delay: .3s; }
#splash .steam path:nth-child(3) { animation-delay: .45s; }
@keyframes steam { to { stroke-dashoffset: 0; } }

/* ---------- Header ---------- */
.top {
  background: var(--sky-200);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 0 16px;
  border-radius: 0 0 28px 28px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand-name { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.pill {
  margin-left: auto; border: 0; background: #fff; color: var(--blue-dark);
  font-weight: 700; font-size: .9rem; padding: 8px 14px; border-radius: 999px;
}

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 13px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 46px; border: 0; border-radius: 14px; background: #fff;
  padding: 0 14px 0 44px; font-size: 1rem;
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); }

.tabs { display: flex; gap: 8px; margin-top: 12px; }
.tabs button {
  border: 0; background: transparent; color: var(--ink);
  padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: .95rem;
}
.tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- List ---------- */
.main { padding-top: 18px; padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.list > li:not(.empty) {
  display: flex; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
}
.row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 0 10px 10px; }
.row-text { min-width: 0; }
.row-title { display: block; font-weight: 700; font-size: 1.05rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; gap: 12px; color: var(--muted); font-size: .875rem; margin-top: 2px; }

.tile {
  flex: none; width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.7rem; line-height: 1;
}
.t0 { background: var(--sky-100); }
.t1 { background: var(--sky-200); }
.t2 { background: var(--butter-100); }

.star {
  flex: none; width: 48px; height: 48px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--muted); border-radius: 50%;
}
.star svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.star.on { color: var(--ink); }
.star.on svg { fill: var(--butter); stroke: var(--ink); }

.empty { padding: 36px 12px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }

.note {
  background: var(--butter-100); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px;
  display: flex; gap: 12px; align-items: center;
}
.note p { margin: 0; font-size: .95rem; flex: 1; }
.btn-text { border: 0; background: transparent; color: var(--blue-dark); font-weight: 800; padding: 8px; }

.fab {
  position: fixed; z-index: 20;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: max(20px, calc(50% - 300px));
  display: inline-flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 22px 0 18px; border-radius: 28px;
  background: var(--blue); color: #fff; font-weight: 800; font-size: 1.02rem;
  box-shadow: 0 6px 18px rgba(16, 48, 74, .22);
}
.fab:active { background: var(--blue-dark); }

/* ---------- Full-screen view (detail + editor) ---------- */
.view {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto; overscroll-behavior: contain;
  background: var(--sky-50);
  transform: translateX(100%); visibility: hidden;
  transition: transform .28s ease, visibility 0s .28s;
}
.view.open { transform: none; visibility: visible; transition: transform .28s ease, visibility 0s; }
.view:focus { outline: none; }

.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--sky-200);
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px 8px;
}
.bar-title { margin: 0; font-size: 1.05rem; font-weight: 800; }
.bar-actions { display: flex; align-items: center; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 12px;
  border: 0; background: transparent; color: var(--ink); font-weight: 700; border-radius: 12px;
}
.btn-ghost svg { width: 22px; height: 22px; }

.page { min-height: 100%; display: flex; flex-direction: column; }
.detail { flex: 1; width: 100%; padding-top: 22px; padding-bottom: 28px; }
.cover { width: 88px; height: 88px; border-radius: 24px; display: grid; place-items: center; font-size: 3rem; line-height: 1; }
.detail h1 { font-size: 1.9rem; line-height: 1.15; letter-spacing: -0.02em; margin: 16px 0 6px; font-weight: 800; }
.detail .meta { display: flex; gap: 16px; margin: 0 0 8px; color: var(--muted); }

.checks { list-style: none; margin: 0; padding: 0; }
.checks li { border-bottom: 1px solid var(--line); }
.checks label { display: flex; align-items: center; gap: 12px; padding: 12px 2px; cursor: pointer; }
.checks input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--blue); }
.checks input:checked + span { color: var(--muted); text-decoration: line-through; }


.seg {
  display: flex; gap: 4px; padding: 4px; margin: 22px 0 8px;
  background: var(--sky-100); border-radius: 16px;
}
.seg button {
  flex: 1; min-height: 44px; border: 0; border-radius: 12px; background: transparent;
  font-weight: 700; color: var(--muted);
}
.seg button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 48, 74, .12); }
.badge {
  display: inline-block; min-width: 1.6em; padding: 1px 7px; margin-left: 4px; border-radius: 999px;
  background: var(--sky-200); color: var(--ink); font-size: .8rem; font-weight: 800; text-align: center;
}
.hint { color: var(--muted); margin: 16px 2px; }
.tools { display: flex; justify-content: flex-end; min-height: 8px; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.steps li::before {
  content: counter(step); flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--sky-200); display: grid; place-items: center; font-weight: 800; font-size: .9rem;
}
.step-text { flex: 1; padding-top: 3px; }

.dock {
  position: sticky; bottom: 0; z-index: 3;
  background: var(--sky-50); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.dock-in { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.dock-in .btn-primary { flex: 2; }
.dock-in .btn-secondary { flex: 1; }
.btn-secondary {
  min-height: 52px; border-radius: 16px; font-weight: 800; font-size: 1.02rem;
  background: transparent; color: var(--ink); border: 1.5px solid var(--sky-300);
}
.btn-secondary:disabled { opacity: .45; cursor: default; }

/* ---------- Cook mode ---------- */
.cook { min-height: 100%; display: flex; flex-direction: column; }
.bar-spacer { width: 88px; flex: none; }
.cook-title { flex: 1; min-width: 0; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cook-body { flex: 1; width: 100%; display: flex; flex-direction: column; padding-top: 18px; padding-bottom: 20px; }
.progress { display: flex; gap: 5px; }
.progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--sky-200); }
.progress i.done { background: var(--ink); }
.progress i.now { background: var(--blue); }
.cook-count { margin: 10px 0 0; color: var(--muted); font-weight: 700; }
.cook-step {
  flex: 1; margin: 0; padding: 24px 0; display: flex; align-items: center;
  font-size: clamp(1.5rem, 6vw, 2.1rem); line-height: 1.35; font-weight: 700; letter-spacing: -0.01em;
}
.cook-step:focus { outline: none; }
.peek { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 0 14px; }
.peek summary { min-height: 48px; display: flex; align-items: center; font-weight: 800; cursor: pointer; }
.peek .checks { max-height: 34vh; overflow-y: auto; padding-bottom: 6px; }
.peek .checks li:last-child { border-bottom: 0; }

.cook-done { align-items: center; justify-content: center; text-align: center; gap: 4px; }
.cook-done h1 { margin: 18px 0 4px; font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.cook-done h1:focus { outline: none; }
.cook-done p { margin: 0 0 20px; color: var(--muted); font-size: 1.05rem; }
.stack { display: grid; gap: 10px; width: 100%; max-width: 360px; }

/* ---------- Timers ---------- */
.timers { margin: 0 0 14px; }
.timers:focus { outline: none; }
.timer-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.timer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px;
}
.timer-main { display: flex; flex-direction: column; }
.timer-time { font-size: 1.8rem; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.timer-label { color: var(--muted); font-size: .85rem; }
.timer.paused .timer-time { color: var(--muted); }
.timer.done { background: var(--butter-100); border-color: var(--butter); }
.timer-actions, .timer-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px; font-weight: 700; font-size: .9rem;
  background: transparent; border: 1.5px solid var(--sky-300); color: var(--ink);
}
.chip-go { background: var(--butter); border-color: var(--butter); }
.timer-form { display: flex; align-items: flex-end; gap: 8px; margin-top: 10px; }
.mini { display: grid; gap: 4px; flex: 1; min-width: 0; font-weight: 700; font-size: .85rem; }
.mini input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 9px 12px; font-size: 1rem; -webkit-appearance: none; appearance: none;
}
.timer-form .chip { min-height: 44px; }

#alarm {
  position: fixed; z-index: 300; left: 12px; right: 12px; max-width: 616px; margin: 0 auto;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff; border-radius: 18px; padding: 12px 12px 12px 16px;
  box-shadow: 0 8px 24px rgba(16, 48, 74, .3);
}
.alarm-text { font-weight: 700; flex: 1; min-width: 0; }
.btn-alarm {
  flex: none; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--butter); color: var(--ink); font-weight: 800;
}

/* ---------- Editor ---------- */
.editor { padding-top: 20px; padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 18px; }
.field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 700; font-size: .95rem; padding: 0; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; background: #fff;
  padding: 12px 14px; font-size: 1rem; -webkit-appearance: none; appearance: none;
}
.field textarea { resize: vertical; line-height: 1.5; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.covers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cover-opt {
  width: 48px; height: 48px; border-radius: 14px; border: 2px solid transparent;
  background: var(--sky-100); font-size: 1.5rem; line-height: 1;
}
.cover-opt[aria-pressed="true"] { border-color: var(--ink); background: var(--butter-100); }
.error { margin: 0; color: var(--danger); font-weight: 600; }

.btn-primary, .btn-danger {
  min-height: 52px; border-radius: 16px; border: 0; font-weight: 800; font-size: 1.02rem;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:active { background: var(--blue-dark); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; z-index: 200; left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-weight: 700;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  #splash .steam path { animation: none; stroke-dashoffset: 0; }
  .view, .view.open, #splash, #toast { transition-duration: .01ms !important; transition-delay: 0s !important; }
}
