:root {
  color-scheme: light;
  --ink: #182132;
  --muted: #667085;
  --line: #d8dee8;
  --page: #f6f8fb;
  --panel: #ffffff;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --good: #1b9b5f;
  --bad: #d63d3d;
  --warn: #b7791f;
  --focus: #2563eb;
  --shadow: 0 14px 35px rgba(24, 33, 50, 0.11);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 8px;
  padding: 0.72rem 0.95rem;
  background: #e6edf5;
  color: var(--ink);
  cursor: pointer;
  min-height: 42px;
}

button.primary {
  background: var(--brand);
  color: white;
}

button.primary:hover {
  background: var(--brand-strong);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

button.danger {
  background: #fee2e2;
  color: #991b1b;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 3vw, 2.5rem);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 800;
  font-size: 1.2rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #0f766e;
  color: white;
  font-weight: 900;
}

.nav {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav button {
  padding-inline: 0.8rem;
}

.nav button.active {
  background: #ccfbf1;
  color: #134e4a;
}

.main {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2rem);
}

.grid {
  display: grid;
  gap: 1rem;
}

.two {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

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

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(1rem, 2vw, 1.4rem);
}

.card {
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 4vw, 2.4rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 1rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.right {
  margin-left: auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 1.1fr);
  align-items: stretch;
  gap: 1rem;
}

.hero-copy {
  display: grid;
  gap: 1rem;
  align-content: center;
  min-height: 320px;
}

.reader-preview {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.95)),
    url("/reading-sample.svg") center/cover;
  border: 1px solid var(--line);
}

.preview-strip {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preview-strip span,
.word {
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: white;
  border: 1px solid #dbeafe;
  line-height: 1.2;
}

.word {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  font-size: clamp(1.05rem, 2.7vw, 1.7rem);
  transition:
    color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

.current-prompt {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border: 2px solid #facc15;
  border-radius: 8px;
  background: #fff7cc;
}

.current-prompt span {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.current-prompt strong {
  font-size: clamp(1.9rem, 8vw, 3rem);
  line-height: 1;
}

.word.current {
  outline: 3px solid #facc15;
  background: #fff7cc;
  transform: translateY(-1px);
}

.word.correct {
  background: #dcfce7;
  color: var(--good);
  border-color: #86efac;
}

.word.wrong {
  animation: wrong 0.55s ease-in-out 2;
  background: #fee2e2;
  color: var(--bad);
  border-color: #fecaca;
}

.word.practice {
  background: #e0f2fe;
  color: #075985;
  border-color: #7dd3fc;
}

@keyframes wrong {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-5px);
  }
  70% {
    transform: translateX(5px);
  }
}

.book-grid,
.kid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

.book-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #edf2f7;
  border-bottom: 1px solid var(--line);
}

.card-body {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.82rem;
  font-weight: 700;
}

.pill.success {
  background: #dcfce7;
  color: #166534;
}

.pill.failed {
  background: #fee2e2;
  color: #991b1b;
}

.pill.unread {
  background: #fef3c7;
  color: #92400e;
}

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  background: #cbd5e1;
  flex: 0 0 auto;
}

.avatar.placeholder {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #334155;
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(0, 1.05fr);
  gap: 1rem;
  align-items: start;
}

.page-image {
  width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.karaoke {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.48rem;
  min-height: 220px;
  padding: 1rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.reader-controls {
  z-index: 5;
  margin-top: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
}

.meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe3ed;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--brand);
  width: 0;
  transition: width 0.2s ease;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 100;
  width: min(620px, calc(100% - 2rem));
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: #182132;
  color: white;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

.page-editor {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.page-editor img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.page-editor textarea {
  min-height: 170px;
}

.empty {
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfe;
}

@media (max-width: 880px) {
  .two,
  .three,
  .hero,
  .reader-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    justify-content: flex-start;
  }

  .page-editor {
    grid-template-columns: 1fr;
  }
}
