:root {
  --bg: #f3f0fa;
  --accent: #8b7cf6;
  --accent-soft: #c4bafc;
  --secondary: #a8d8ea;
  --text: #2e2a47;
  --text-muted: #6b6588;
  --card: #ffffff;
  --parent-bg: #f7f7f7;
  --danger: #d97777;
  --success: #5bb89a;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(46, 42, 71, 0.08);
  --font: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

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

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: transparent;
  line-height: 1.5;
  position: relative;
}

body.parent-page {
  background: transparent;
}

/* Full-viewport responsive background slideshow */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.app-bg__layer {
  position: absolute;
  inset: 0;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.6s ease-in-out;
  transform: scale(1.02);
}

.app-bg__layer.is-active {
  opacity: 1;
}

.app-bg__veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      180deg,
      rgba(243, 240, 250, 0.72) 0%,
      rgba(243, 240, 250, 0.55) 45%,
      rgba(243, 240, 250, 0.78) 100%
    );
}

body.parent-page .app-bg__veil {
  background:
    linear-gradient(
      180deg,
      rgba(247, 247, 247, 0.78) 0%,
      rgba(247, 247, 247, 0.62) 50%,
      rgba(247, 247, 247, 0.82) 100%
    );
}

.page {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 20px 16px 40px;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.back-link,
.parent-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.back-link:hover,
.parent-link:hover {
  color: var(--text);
  background: #fff;
}

.greeting {
  margin-bottom: 20px;
}

.greeting .date {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.greeting h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 24px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--secondary);
  font-size: 0.9rem;
  font-weight: 600;
}

.badge-streak {
  background: rgba(139, 124, 246, 0.18);
  color: var(--text);
}

.badge-dday {
  background: #fff;
  box-shadow: var(--shadow);
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 0;
  margin: 0 0 28px;
}

.card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 96px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(46, 42, 71, 0.12);
}

.card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.card-breathing {
  border-left: 4px solid var(--accent);
}

.card-stories {
  border-left: 4px solid #7eb8d4;
}

.card-routine {
  border-left: 4px solid var(--success);
}

.page-footer {
  text-align: center;
  padding-top: 8px;
}

.section-title {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.section-desc {
  margin: 0 0 20px;
  color: var(--text-muted);
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 44px;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid rgba(46, 42, 71, 0.12);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

/* Breathing */
.breath-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
}

.breath-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d8d1ff, var(--accent));
  box-shadow: 0 0 0 12px rgba(139, 124, 246, 0.15);
  transform: scale(1);
}

.breath-circle.animating {
  animation: breathe 19s ease-in-out infinite;
}

@keyframes breathe {
  0% {
    transform: scale(1);
  }
  21% {
    /* 4/19 ≈ inhale end */
    transform: scale(1.4);
  }
  58% {
    /* (4+7)/19 ≈ hold end */
    transform: scale(1.4);
  }
  100% {
    transform: scale(1);
  }
}

.breath-status {
  margin: 24px 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
}

.breath-timer {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 16px;
  border-radius: 999px;
  background: rgba(139, 124, 246, 0.15);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s linear;
}

/* Stories */
.story-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 2px solid transparent;
  text-align: left;
  font-family: inherit;
  color: inherit;
  width: 100%;
}

.story-card.active {
  border-color: var(--accent);
}

.story-thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--secondary), var(--accent-soft));
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-thumb img {
  width: 32px;
  height: 32px;
}

.story-meta h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.story-meta p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.player-panel {
  margin-top: 16px;
}

.player-panel audio {
  width: 100%;
  margin-top: 10px;
}

.player-title {
  margin: 0;
  font-weight: 700;
}

.hint {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Routine */
.check-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(46, 42, 71, 0.08);
}

.check-item input[type='checkbox'] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.check-item label {
  flex: 1;
  font-weight: 600;
}

.check-item .status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.check-item.done {
  border-color: rgba(91, 184, 154, 0.5);
  background: rgba(91, 184, 154, 0.08);
}

.time-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.time-row input[type='time'] {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(46, 42, 71, 0.15);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
}

.streak-big {
  text-align: center;
  padding: 12px 0 4px;
}

.streak-big .num {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(168, 216, 234, 0.35);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Parent report */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.stat-value {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(46, 42, 71, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: min(100%, 360px);
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.modal p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal input[type='password'],
.modal input[type='text'] {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid rgba(46, 42, 71, 0.2);
  border-radius: 10px;
  font-size: 1.25rem;
  letter-spacing: 0.3em;
  text-align: center;
  font-family: inherit;
}

.modal-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 0 0 8px;
}

.report-content.locked {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

@media (min-width: 768px) {
  .page {
    width: min(100%, 720px);
    padding: 32px 24px 48px;
  }

  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .breath-circle {
    width: 200px;
    height: 200px;
  }
}
