@font-face {
  font-family: Fredoka;
  src: url("../fonts/Fredoka-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Fredoka;
  src: url("../fonts/Fredoka-Medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Fredoka;
  src: url("../fonts/Fredoka-SemiBold.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Fredoka;
  src: url("../fonts/Fredoka-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --cream: #FFFAF0;
  --card: #FFFCF6;
  --ink: #5E5C52;
  --title: #70644E;
  --sage: #7E927A;
  --sage-soft: #AEBD9E;
  --sage-line: #BCC8AE;
  --olive: #656D5D;
  --done: #7E927A;
  --done-bg: #E8F0E3;
  --peach: #E8C4A8;
  --honey: #E2C98A;
  --lavender: #C5B8D0;
  --aqua: #A8C5C4;
  --shadow: 0 8px 24px rgba(112, 100, 78, 0.12);
  --shadow-soft: 0 2px 8px rgba(112, 100, 78, 0.08);
  --radius: 28px;
  --tap: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: Fredoka, "Avenir Next", "Segoe UI", Trebuchet MS, system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 18px calc(20px + var(--safe-bottom));
  position: relative;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

img { display: block; max-width: 100%; }

/* ----- chrome ----- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-bottom: 8px;
}

.topbar h1, .topbar h2 {
  flex: 1;
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--title);
  letter-spacing: -0.02em;
  text-align: center;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--title);
  flex: 0 0 auto;
}

.icon-btn:active { background: rgba(126, 146, 122, 0.16); }

.icon-btn svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.grownups {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sage);
  padding: 8px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.grownups:active { background: rgba(126, 146, 122, 0.16); }

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 0 0 8px;
}

.brand img {
  width: 92px;
  height: 92px;
  object-fit: contain;
}

.brand .shop {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sage);
}

.brand .app-name {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--title);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hello {
  text-align: center;
  margin: 0 0 10px;
}

.hello .hi {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--title);
  letter-spacing: -0.03em;
}

.hello .prompt {
  margin: 4px 0 0;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--olive);
}

/* ----- home cards ----- */

.routine-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.routine-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--sage-line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-soft);
  min-height: 86px;
  transition: transform 0.12s ease, background 0.12s ease;
}

.routine-card:active { transform: scale(0.985); }

.routine-card .thumb {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--tint, #F0F4EC);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
}

.routine-card .thumb img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.routine-card .meta { flex: 1; min-width: 0; }

.routine-card .name {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--title);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.routine-card .status {
  display: block;
  margin-top: 2px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--olive);
}

.dots {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage-line);
}

.dots span.on { background: var(--sage); }

.routine-card.complete {
  background: var(--done-bg);
  border-color: var(--sage-soft);
}

/* ----- routine steps ----- */

.progress-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 14px;
}

.progress-row .count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--olive);
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--sage-line);
  border-radius: 24px;
  padding: 10px 12px;
  min-height: 108px;
  box-shadow: var(--shadow-soft);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.step:active { transform: scale(0.985); }

.step.is-now {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(126, 146, 122, 0.22), var(--shadow-soft);
}

.step .pic {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  overflow: hidden;
  flex: 0 0 auto;
  background: var(--cream);
}

.step .pic img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: transparent;
}

.step .label {
  flex: 1;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--title);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.tick {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 3px solid var(--sage-line);
  background: var(--cream);
  display: grid;
  place-items: center;
}

.tick svg { width: 22px; height: 22px; opacity: 0; }

.step.done {
  background: var(--done-bg);
  border-color: var(--sage-soft);
}

.step.done .tick {
  background: var(--sage);
  border-color: var(--sage);
}

.step.done .tick svg {
  opacity: 1;
  stroke: var(--cream);
  fill: none;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hint {
  text-align: center;
  margin: 14px 0 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--olive);
}

/* ----- celebrate ----- */

.celebrate {
  min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.celebrate h1 {
  margin: 8px 0 0;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--title);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.celebrate p {
  margin: 8px 0 28px;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--olive);
}

.celebrate .mascot {
  width: 240px;
  height: 240px;
  object-fit: contain;
  animation: bounce 1.1s ease-in-out infinite;
}

.celebrate-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn {
  flex: 1;
  min-height: 56px;
  border-radius: 18px;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 12px 16px;
}

.btn.primary {
  background: var(--sage);
  color: var(--cream);
}

.btn.primary:active { filter: brightness(0.95); }

.btn.ghost {
  background: transparent;
  color: var(--title);
  border: 2px solid var(--sage-line);
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ----- parent ----- */

.gate, .parent {
  padding-top: 8px;
}

.gate-card, .parent-card {
  background: var(--card);
  border: 2px solid var(--sage-line);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow-soft);
}

.gate-card h2, .parent h2, .parent h3 {
  margin: 0 0 8px;
  color: var(--title);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gate-card h2 { font-size: 1.6rem; text-align: center; }
.parent h2 { font-size: 1.15rem; margin-top: 22px; }
.parent h3 { font-size: 1.15rem; }

.gate-card p, .parent p, .note {
  margin: 0 0 16px;
  color: var(--olive);
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 500;
}

.gate-actions, .field { display: flex; flex-direction: column; gap: 10px; }

label.field-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--olive);
  margin-bottom: 6px;
}

input[type="text"] {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--sage-line);
  border-radius: 16px;
  padding: 10px 14px;
  background: var(--cream);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--title);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--sage);
}

.routine-admin {
  background: var(--card);
  border: 2px solid var(--sage-line);
  border-radius: 22px;
  padding: 14px;
  margin-bottom: 12px;
}

.routine-admin .head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.routine-admin .head h3 { flex: 1; margin: 0; }

.btn.small {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.9rem;
  border-radius: 12px;
  background: var(--cream);
  border: 2px solid var(--sage-line);
  color: var(--title);
  font-weight: 600;
}

.admin-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-top: 1px solid var(--sage-line);
}

.admin-step .n {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--title);
}

.admin-step.is-hidden .n { color: var(--sage-line); text-decoration: line-through; }

.admin-step .mini {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--title);
  background: var(--cream);
  border: 2px solid var(--sage-line);
}
.admin-step .mini:disabled {
  opacity: 0.35;
}

.admin-step .mini svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }

.admin-step .toggle {
  min-width: 64px;
  height: 40px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--cream);
  color: var(--olive);
  border: 2px solid var(--sage-line);
}

.admin-step .toggle.on {
  background: var(--done-bg);
  border-color: var(--sage-soft);
  color: var(--olive);
}

/* ----- motion ----- */

@media (prefers-reduced-motion: reduce) {
  .celebrate .mascot { animation: none; }
  .step, .routine-card, .btn { transition: none; }
}

@media (min-height: 800px) {
  .step { min-height: 114px; }
}
