:root {
  --bg: #eef7f1;
  --card: #ffffff;
  --ink: #16212d;
  --muted: #657273;
  --green: #21836c;
  --green-dark: #0c4d40;
  --mint: #dceee8;
  --line: #cfe1dc;
  --orange: #f28a35;
  --shadow: 0 16px 36px rgba(21, 56, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at top, #e5f5ed 0, var(--bg) 44%, #f7fbf8 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: var(--green);
  font-size: 36px;
  font-weight: 900;
}

.topbar p,
.topbar h1,
.lesson-title-row h2,
.lesson-title-row p,
.now-box p,
.now-box h2,
.audio-card p,
.audio-card h2,
.list-head p,
.list-head h2,
.page-head p,
.page-head h2 {
  margin: 0;
}

.topbar p {
  color: var(--green);
  font-size: 15px;
  font-weight: 900;
}

.topbar h1 {
  margin-top: 2px;
  font-size: clamp(30px, 8vw, 44px);
  line-height: 1.05;
}

.lesson-card,
.mode-card,
.audio-card,
.list-card,
.page-card {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.lesson-title-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.lesson-number {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: var(--orange);
  font-size: 24px;
  font-weight: 950;
}

.lesson-title-row h2 {
  font-size: 25px;
  line-height: 1.2;
}

.lesson-title-row p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.lesson-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-top: 16px;
  padding-bottom: 2px;
}

.lesson-strip button {
  flex: 0 0 auto;
  min-width: 66px;
  min-height: 56px;
  border-radius: 14px;
  color: var(--green-dark);
  background: var(--mint);
  font-size: 18px;
  font-weight: 950;
}

.lesson-strip button.is-active {
  color: #fff;
  background: var(--green);
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-tabs button,
.jump-btn,
.primary-controls button,
.list-head button,
.page-head button,
.item-card button {
  min-height: 54px;
  border-radius: 14px;
  color: var(--green-dark);
  background: var(--mint);
  font-size: 18px;
  font-weight: 950;
}

.mode-tabs button.is-active,
.primary-controls button:first-child,
.item-card button.is-active {
  color: #fff;
  background: var(--green);
}

.now-box {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid #ffd7ad;
  border-radius: 16px;
  background: #fff8ee;
}

.now-box p,
.audio-card p,
.list-head p,
.page-head p {
  color: var(--orange);
  font-size: 15px;
  font-weight: 950;
}

.now-box h2 {
  margin-top: 4px;
  font-size: 30px;
}

.now-box p:last-child {
  margin-top: 6px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 850;
}

.tts-card {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.tts-card label {
  display: grid;
  gap: 6px;
  color: var(--green-dark);
  font-size: 15px;
  font-weight: 950;
}

.tts-card select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  font-size: 17px;
  font-weight: 850;
}

.primary-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.primary-controls button {
  min-height: 62px;
  padding: 0 8px;
  font-size: clamp(15px, 4vw, 20px);
}

.audio-card {
  display: grid;
  gap: 12px;
}

.audio-card h2 {
  font-size: 26px;
}

audio {
  width: 100%;
}

.list-head,
.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 12px;
  align-items: center;
}

.list-head h2,
.page-head h2 {
  margin-top: 3px;
  font-size: 28px;
}

.list-head button,
.page-head button {
  min-height: 48px;
  font-size: 16px;
}

.item-list {
  display: grid;
  gap: 5px;
  margin-top: 14px;
}

.item-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 74px;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf7;
}

.item-no {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--green);
  font-size: 18px;
  font-weight: 950;
}

.item-card strong,
.item-card small {
  display: block;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.item-card strong {
  font-family: "Noto Sans JP", "Noto Sans KR", system-ui, sans-serif;
  font-size: 22px;
  line-height: 1.25;
}

.item-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.35;
}

.item-card button {
  min-height: 48px;
  font-size: 16px;
}

.page-card.is-hidden {
  display: none;
}

.page-card img {
  display: block;
  width: 100%;
  min-height: 360px;
  margin-top: 12px;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
}

.page-card img.is-error {
  border: 2px dashed #e3b49a;
  background: #fff7ef;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 10;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  min-width: 220px;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(13, 55, 46, 0.94);
  font-weight: 900;
  text-align: center;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (min-width: 640px) {
  .tts-card {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
