:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --ink: rgba(0, 0, 0, 0.88);
  --muted: #6c7280;
  --soft: #979eaf;
  --line: #e4e7ec;
  --line-strong: #cfd5e3;
  --nav: #2f3950;
  --orange: #ff7e33;
  --blue: #3b82f6;
  --green: #10b981;
  --yellow: #f6b73c;
  --red: #ef4444;
  --shadow: 0 18px 52px rgba(177, 177, 185, 0.18), 0 7px 16px rgba(177, 177, 185, 0.16);
  --soft-shadow: 0 4px 12px rgba(47, 57, 80, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Poppins, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid rgba(228, 231, 236, 0.8);
}

.workspace {
  display: flex;
  min-width: 0;
  max-height: 100vh;
  flex-direction: column;
  overflow: hidden;
  padding: 0 16px 16px 16px;
}

.workspace main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 8px 8px 8px 0;
}

.topbar strong {
  display: block;
  font-size: 22px;
  line-height: 1.25;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 2px 6px 24px;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 14px 26px rgba(47, 57, 80, 0.12);
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong {
  display: block;
  font-family: "Fugaz One", Poppins, sans-serif;
  font-size: 23px;
  font-weight: 400;
  line-height: 1.1;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.study-back-link {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  width: 100%;
  margin: -10px 0 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--nav);
  background: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--soft-shadow);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

body[data-view="map"][data-study-panel="home"] .study-back-link {
  display: inline-flex;
}

.study-back-link:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 126, 51, 0.34);
  background: #fff;
}

.creation-journey-link {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid rgba(255, 126, 51, 0.34);
  border-radius: 999px;
  padding: 0 24px;
  color: #fff;
  background: linear-gradient(135deg, #ff8a3d, #d1752b);
  box-shadow: 0 16px 36px rgba(255, 126, 51, 0.28);
  font-size: 15px;
  font-weight: 900;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.creation-journey-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(255, 126, 51, 0.34);
}

.side-menu {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.side-menu p {
  margin: 14px 8px 2px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 600;
  line-height: 24px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.side-item span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.side-item.active,
.side-item:hover {
  background: var(--surface);
  box-shadow: var(--soft-shadow);
}

.side-item.active span {
  color: var(--orange);
}

.side-card {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  border-radius: 16px;
  background: var(--nav);
  color: white;
  padding: 18px;
  box-shadow: var(--soft-shadow);
}

.side-card span,
.side-card small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  line-height: 1.5;
}

.side-card strong {
  font-size: 32px;
  line-height: 1;
}

.sidebar-language {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.sidebar-language > span {
  margin-left: 8px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.top-stats {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.language-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  border-radius: 999px;
  background: var(--surface);
  padding: 4px;
  box-shadow: var(--soft-shadow);
}

.language-toggle button {
  min-width: 88px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.language-toggle button.active {
  background: var(--nav);
  color: white;
}

.top-stats span:not(.avatar),
.level-pill,
.panel-label {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--soft-shadow);
}

#coinBadge {
  gap: 7px;
  background: linear-gradient(135deg, #fff8df, #ffffff);
  color: #7a4b00;
}

#coinBadge .coin-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #fff7ba 0 16%, transparent 17%),
    linear-gradient(135deg, #ffe27a, #f7a928 52%, #c97704);
  color: transparent;
  box-shadow: inset 0 -2px 0 rgba(117, 74, 0, 0.24), 0 3px 8px rgba(247, 169, 40, 0.32);
}

#coinBadge b {
  font-weight: 800;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--nav);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#mapView.library-focus .map-hero {
  display: none;
}

#mapView.library-focus .level-tabs {
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.home-hero {
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
}

.home-heading {
  padding: 12px 4px 0;
}

.home-heading h1 {
  margin: 0;
  color: #14161b;
  font-size: clamp(38px, 4.8vw, 64px);
  font-weight: 800;
  line-height: 1;
}

.hero-dashboard {
  display: grid;
  grid-template-columns: minmax(520px, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.map-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(190px, 0.64fr);
  gap: 8px;
  align-items: stretch;
  min-height: 284px;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at 76% 14%, rgba(255, 194, 95, 0.34), transparent 12rem),
    radial-gradient(circle at 92% 84%, rgba(96, 165, 250, 0.24), transparent 15rem),
    linear-gradient(135deg, #342d3e 0%, #493a35 52%, #7a5630 100%);
  color: white;
  padding: 28px 32px;
  box-shadow: 0 22px 48px rgba(80, 67, 59, 0.22), 0 8px 18px rgba(80, 67, 59, 0.12);
}

.map-hero::before {
  content: "";
  position: absolute;
  inset: auto 22% -72px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.map-hero::after {
  content: "";
  position: absolute;
  right: 34px;
  top: 22px;
  width: 128px;
  height: 48px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 16% 50%, #93e4dc 0 8px, transparent 9px),
    radial-gradient(circle at 84% 50%, #93e4dc 0 8px, transparent 9px),
    linear-gradient(90deg, transparent 0 18px, #ffbd55 19px 109px, transparent 110px);
  opacity: 0.92;
  transform: rotate(-5deg);
}

.hero-main {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
}

h1 {
  max-width: 720px;
  margin-bottom: 12px;
  color: #181b22;
  font-size: clamp(38px, 6vw, 72px);
  font-weight: 800;
  line-height: 0.98;
}

.map-hero .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.map-hero h2 {
  max-width: 560px;
  margin: 6px 0 14px;
  color: white;
  font-size: clamp(32px, 4.1vw, 48px);
  font-weight: 800;
  line-height: 1.02;
}

.hero-copy {
  max-width: 520px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.hero-actions .primary {
  min-width: 190px;
  border-radius: 999px;
  background: #c77534;
  box-shadow: 0 12px 26px rgba(141, 72, 24, 0.28);
}

.hero-actions span {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 800;
  backdrop-filter: blur(10px);
}

.hero-character {
  position: relative;
  z-index: 1;
  align-self: end;
  justify-self: end;
  width: min(250px, 100%);
  aspect-ratio: 1;
  border: 8px solid rgba(255, 255, 255, 0.86);
  border-radius: 30px;
  background: #fff8ec;
  object-fit: cover;
  object-position: center;
  box-shadow: 0 28px 46px rgba(22, 18, 16, 0.34);
  transform: rotate(-2deg);
}

.progress-panel {
  display: grid;
  align-content: center;
  gap: 18px;
  border-radius: 24px;
  background: var(--surface);
  padding: 28px;
  box-shadow: var(--shadow);
}

.progress-line {
  display: grid;
  gap: 10px;
}

.progress-line > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.progress-line span {
  color: #111827;
  font-size: 16px;
  font-weight: 700;
}

.progress-line strong {
  color: #111827;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.progress-line i {
  display: block;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dff4e9;
}

.progress-line b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #4ec383;
  transition: width 0.35s ease;
}

.progress-line.blue i {
  background: #dceefd;
}

.progress-line.blue b {
  background: #56b7f5;
}

.progress-line.violet i {
  background: #e9e1f5;
}

.progress-line.violet b {
  background: #8d6ac8;
}

.progress-line.pink i {
  background: #fdeaf3;
}

.progress-line.pink b {
  background: #f5a8cf;
}

.reading-plan-card {
  overflow: hidden;
  border: 1px solid rgba(228, 231, 236, 0.78);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding-top: 24px;
}

.achievement-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
  align-items: stretch;
  border-radius: 20px;
  background:
    radial-gradient(circle at 85% 18%, rgba(255, 126, 51, 0.16), transparent 18rem),
    linear-gradient(135deg, #ffffff, #f6f9ff);
  padding: 32px;
  box-shadow: var(--shadow);
}

.achievement-hero h1 {
  margin-bottom: 12px;
}

.achievement-hero p {
  max-width: 640px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.7;
}

.rank-card {
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  padding: 20px;
}

.rank-card span,
.rank-card small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.rank-card strong {
  color: #111827;
  font-size: 52px;
  line-height: 1;
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.achievement-grid article,
.medal-board article {
  border-radius: 18px;
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--soft-shadow);
}

.achievement-grid strong {
  display: block;
  color: #111827;
  font-size: 36px;
  line-height: 1;
}

.achievement-grid span {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-weight: 800;
}

.medal-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  padding-bottom: 20px;
}

.medal-board article {
  display: grid;
  gap: 8px;
  min-height: 168px;
  align-content: center;
  text-align: center;
}

.medal-board span {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin: 0 auto;
  border-radius: 50%;
  background: #eef2f7;
  color: #c2c8d2;
  font-size: 30px;
}

.medal-board article.earned span {
  background: linear-gradient(135deg, #ffe29a, #ff9f43);
  color: white;
  box-shadow: 0 10px 22px rgba(255, 126, 51, 0.26);
}

.medal-board strong {
  color: #111827;
}

.medal-board small {
  color: var(--muted);
  font-weight: 700;
}

.level-tabs {
  display: inline-flex;
  height: 46px;
  margin: 0 34px 20px;
  max-width: 100%;
  overflow: auto;
  border-radius: 999px;
  background: #f2f4f8;
  padding: 4px;
}

.tab-button {
  width: auto;
  min-width: 160px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  color: #6b7280;
  opacity: 1;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 800;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.tab-button.active {
  background: #202124;
  color: white;
  box-shadow: 0 8px 20px rgba(32, 33, 36, 0.14);
}

.book-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 14px;
  padding: 0 34px 34px;
}

.classic-empty {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 170px;
  border: 1px solid #e3e8f0;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(241, 245, 255, 0.88)),
    var(--surface);
  padding: 28px;
}

.classic-empty span {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.classic-empty h2 {
  margin: 0 0 8px;
  color: #1f2937;
  font-size: 26px;
}

.classic-empty p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.7;
}

.classic-empty strong {
  border-radius: 999px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 14px 18px;
  color: var(--nav);
  font-size: 14px;
  white-space: nowrap;
}

.book-row {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 232px;
  border: 1px solid #edf0f4;
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  padding: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.book-row.featured {
  grid-column: 1 / -1;
  grid-template-columns: 260px minmax(0, 1fr) 140px;
  align-items: center;
  min-height: 248px;
  padding: 0 18px 0 0;
}

.book-row:hover {
  border-color: rgba(59, 130, 246, 0.42);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
  transform: translateY(-2px);
}

.book-row.locked {
  opacity: 0.94;
}

.book-cover {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 126, 51, 0.1), rgba(59, 130, 246, 0.12)),
    var(--surface-soft);
  font-size: 56px;
}

.book-row.compact-card .book-cover {
  aspect-ratio: 1;
  border-radius: 12px;
  font-size: 38px;
}

.book-row.featured .book-cover {
  width: 260px;
  height: 260px;
  aspect-ratio: 1;
  border-radius: 18px 0 0 18px;
}

.book-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(0.7px);
  font-size: 36px;
  text-shadow: 0 8px 18px rgba(47, 57, 80, 0.24);
}

.book-title-line {
  display: flex;
  gap: 9px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.book-title-line h2 {
  margin: 0;
  color: #1f2937;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
}

.compact-card .book-title-line {
  gap: 6px;
  margin-bottom: 2px;
}

.compact-card .book-title-line h2 {
  font-size: 16px;
}

.compact-card .book-title-line span {
  font-size: 11px;
}

.book-title-line span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.book-theme {
  display: -webkit-box;
  margin: 0 0 12px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.compact-card .book-theme {
  margin-bottom: 0;
  font-size: 12px;
  line-height: 1.45;
  -webkit-line-clamp: 1;
}

.book-summary {
  margin: 4px 0 0;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

.stage-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 46px));
  gap: 7px;
  max-width: 620px;
}

.compact-card .stage-strip {
  display: none;
}

.stage-dot {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: #1f2937;
  font-size: 13px;
  font-weight: 800;
}

.stage-dot.current {
  border-color: var(--orange);
  background: #fff0e8;
  box-shadow: 0 0 0 4px rgba(255, 126, 51, 0.16);
  animation: pulse 1.7s infinite;
}

.stage-dot.done {
  border-color: rgba(16, 185, 129, 0.42);
  background: #ecfdf5;
  color: #047857;
}

.stage-dot.locked {
  background: #fafbfe;
  color: #b8bfcc;
}

.book-action {
  width: 100%;
  justify-self: stretch;
  margin-top: auto;
}

.compact-card .book-action {
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 10px;
}

.book-row.featured .book-action {
  width: 120px;
  justify-self: center;
  margin-top: 0;
}

.primary,
.secondary,
.icon-button {
  border-radius: 10px;
  font-weight: 700;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary,
.secondary {
  min-height: 48px;
  border: 0;
  padding: 12px 18px;
}

.primary {
  background: var(--orange);
  color: white;
  box-shadow: 0 8px 18px rgba(255, 126, 51, 0.24);
}

.primary:hover {
  background: #f26e24;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: #1f2937;
}

.secondary:hover {
  border-color: var(--line-strong);
  background: #f9fafb;
}

.small {
  min-height: 42px;
  padding: 10px 14px;
}

.icon-button {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: #1f2937;
  font-size: 20px;
  box-shadow: var(--soft-shadow);
}

.primary:active,
.secondary:active,
.icon-button:active,
.stage-dot:active {
  transform: translateY(1px);
}

.stage-header {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto 48px;
  gap: 16px;
  align-items: center;
  min-height: 80px;
  padding-right: 8px;
}

.stage-header p {
  margin: 0 0 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-header h2 {
  margin: 0;
  color: #111827;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
}

.mode-switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  border-radius: 999px;
  background: var(--surface);
  padding: 4px;
  box-shadow: var(--soft-shadow);
}

.mode-switch span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  height: 40px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.mode-switch .active {
  background: var(--nav);
  color: white;
}

.reader-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(520px, 1.28fr);
  gap: 16px;
  min-height: calc(100vh - 112px);
  padding-bottom: 16px;
}

.reader-side {
  display: grid;
  grid-template-rows: auto 76px;
  gap: 14px;
  align-content: start;
}

.illustration-card,
.practice-card,
.stage-nav-card {
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.illustration-card {
  min-height: 0;
  aspect-ratio: 1;
}

.practice-card {
  min-height: 0;
}

.illustration-card {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.scene-sky {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(59, 130, 246, 0.06), rgba(16, 185, 129, 0.08)),
    radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.18) 34%, transparent 35%);
}

.scene-emoji {
  position: relative;
  display: grid;
  width: min(390px, 84%);
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(228, 231, 236, 0.74);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 126, 51, 0.1), rgba(59, 130, 246, 0.16)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.42) 12px, rgba(255, 255, 255, 0.08) 12px, rgba(255, 255, 255, 0.08) 24px);
  font-size: clamp(76px, 14vw, 132px);
  box-shadow: inset 0 -18px 42px rgba(47, 57, 80, 0.06);
}

.scene-emoji img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  object-position: center;
}

.illustration-card p {
  position: relative;
  max-width: 520px;
  margin: 0;
  color: #374151;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.8;
}

.stage-nav-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 12px;
}

.stage-nav-card .secondary {
  min-height: 50px;
  padding: 10px 12px;
}

.stage-nav-card .secondary:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.stage-nav-card span {
  min-width: 74px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.practice-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.sentence {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: center;
  align-items: center;
  min-height: 178px;
  margin: 22px 0 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcff;
}

.classic-translation {
  flex: 1 0 100%;
  margin: 2px 6px 0;
  color: #5d6a82;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.word {
  display: inline-grid;
  min-height: 56px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: #111827;
  padding: 8px 13px;
  font-size: clamp(24px, 3.2vw, 38px);
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(47, 57, 80, 0.04);
}

.word.active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
  transform: translateY(-2px);
  animation: word-read-pulse 0.72s ease-in-out infinite alternate;
}

.word.good {
  border-color: rgba(16, 185, 129, 0.5);
  background: #ecfdf5;
}

.word.ok {
  border-color: rgba(246, 183, 60, 0.58);
  background: #fff7df;
}

.word.bad {
  border-color: rgba(239, 68, 68, 0.5);
  background: #fff1f2;
}

.phonetic {
  min-height: 28px;
  color: var(--blue);
  font-size: 15px;
  font-weight: 700;
}

.hint-box {
  width: 100%;
  margin: 16px 0 18px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #eff6ff;
  color: #1e3a8a;
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

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

.controls .hidden + .secondary,
.controls .hidden + .primary {
  grid-column: auto;
}

.recording-panel {
  margin-top: 18px;
  border: 1px dashed rgba(59, 130, 246, 0.5);
  border-radius: 16px;
  background: #f3f7ff;
  padding: 16px;
}

.wave {
  display: flex;
  align-items: end;
  gap: 6px;
  height: 48px;
  margin-top: 10px;
}

.wave span {
  width: 10px;
  height: 20px;
  border-radius: 999px;
  background: var(--blue);
  animation: wave 0.8s ease-in-out infinite alternate;
}

.wave span:nth-child(2) { animation-delay: 0.08s; }
.wave span:nth-child(3) { animation-delay: 0.16s; }
.wave span:nth-child(4) { animation-delay: 0.24s; }
.wave span:nth-child(5) { animation-delay: 0.32s; }
.wave span:nth-child(6) { animation-delay: 0.4s; }

.fallback-box {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
}

.transcript-box {
  min-height: 52px;
  margin-top: 16px;
  border-radius: 14px;
  background: #f8fafc;
  color: #374151;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
  padding: 14px 16px;
}

.mic-note {
  border: 1px solid #fde68a;
  border-radius: 12px;
  background: #fff8df;
  color: #8a5a00;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.mic-note a {
  color: #1d4ed8;
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
}

.inline-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  margin-top: 14px;
  border: 1px solid rgba(16, 185, 129, 0.32);
  border-radius: 16px;
  background: linear-gradient(135deg, #f0fdf4, #ffffff);
  padding: 14px;
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.08);
}

.inline-result.retry {
  border-color: rgba(246, 183, 60, 0.4);
  background: linear-gradient(135deg, #fff7df, #ffffff);
}

.inline-result > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

#inlineStars {
  color: var(--yellow);
  font-size: 24px;
  font-weight: 900;
}

#inlineScore {
  color: #111827;
  font-size: 32px;
  line-height: 1;
}

.inline-result p {
  grid-column: 1 / -1;
  margin: 0;
  color: #374151;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
}

.inline-result small {
  color: #047857;
  font-size: 13px;
  font-weight: 900;
}

.inline-result.retry small {
  color: #9a6700;
}

.inline-result .primary {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: stretch;
  min-width: 128px;
}

.hidden {
  display: none !important;
}

.result-dialog {
  width: min(620px, calc(100% - 28px));
  border: 0;
  padding: 0;
  border-radius: 20px;
  background: transparent;
}

.daily-dialog {
  width: min(640px, calc(100% - 28px));
  border: 0;
  padding: 0;
  border-radius: 24px;
  background: transparent;
}

.daily-dialog::backdrop {
  background: rgba(47, 57, 80, 0.5);
  backdrop-filter: blur(8px);
}

.daily-report {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at 86% 10%, rgba(255, 126, 51, 0.18), transparent 16rem),
    radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.16), transparent 17rem),
    linear-gradient(135deg, #ffffff, #f8fbff);
  padding: 30px;
  box-shadow: var(--shadow);
}

.daily-report::after {
  content: "";
  position: absolute;
  right: -54px;
  bottom: -80px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.13);
  pointer-events: none;
}

.daily-report > * {
  position: relative;
  z-index: 1;
}

.report-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  padding: 7px 14px 7px 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--soft-shadow);
}

.report-badge img {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  object-fit: cover;
}

.daily-report h3 {
  position: relative;
  margin: 22px 0 8px;
  color: #111827;
  font-size: clamp(30px, 6vw, 48px);
  line-height: 1.06;
}

.daily-report p {
  position: relative;
  max-width: 520px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.7;
}

.report-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.report-stats article {
  border: 1px solid rgba(228, 231, 236, 0.86);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  padding: 16px;
  box-shadow: var(--soft-shadow);
}

.report-stats strong {
  display: block;
  color: #111827;
  font-size: 32px;
  line-height: 1;
}

.report-stats span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.report-medal {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 18px;
  background: var(--nav);
  color: white;
  padding: 16px 18px;
  margin-bottom: 22px;
}

.report-medal span {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffe29a, #ff9f43);
  color: white;
  font-size: 30px;
  box-shadow: 0 10px 22px rgba(255, 126, 51, 0.32);
}

.report-medal strong {
  font-size: 20px;
}

.result-dialog::backdrop {
  background: rgba(47, 57, 80, 0.46);
  backdrop-filter: blur(6px);
}

.result-card {
  position: relative;
  border-radius: 20px;
  background: var(--surface);
  padding: 30px;
  box-shadow: var(--shadow);
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.stars {
  margin: 8px 0;
  color: var(--yellow);
  font-size: 46px;
  letter-spacing: 0;
}

.result-card h3 {
  margin-bottom: 8px;
  color: #111827;
  font-size: 24px;
}

.result-card p {
  color: #4b5563;
  line-height: 1.65;
}

.score-meter {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
  font-weight: 800;
}

.score-meter div {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f5;
}

.score-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--orange));
  transition: width 0.35s ease;
}

.word-feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.feedback-token {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 8px 10px;
  color: #111827;
  font-weight: 800;
}

.feedback-token.good { border-color: var(--green); background: #ecfdf5; }
.feedback-token.ok { border-color: var(--yellow); background: #fff7df; }
.feedback-token.bad { border-color: var(--red); background: #fff1f2; }

.coins-line {
  font-weight: 800;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: hidden;
  pointer-events: none;
}

.coin-fly {
  position: fixed;
  z-index: 10000;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 28%, #fff8b8 0 18%, transparent 19%),
    linear-gradient(135deg, #ffe27a, #f7a928 54%, #c97704);
  box-shadow: inset 0 -2px 0 rgba(117, 74, 0, 0.22), 0 8px 16px rgba(247, 169, 40, 0.28);
  animation: coin-fly 0.95s cubic-bezier(0.18, 0.72, 0.2, 1) var(--delay) forwards;
  pointer-events: none;
}

.celebration i {
  position: absolute;
  top: -42px;
  left: var(--x);
  width: 14px;
  height: 22px;
  border-radius: 4px;
  background: var(--orange);
  color: var(--yellow);
  font-style: normal;
  font-size: 22px;
  animation: confetti-fall 1.35s ease-out var(--delay) forwards;
  transform: rotate(var(--rot));
}

.celebration i:nth-child(3n) {
  background: var(--blue);
}

.celebration i:nth-child(4n) {
  background: var(--green);
}

.celebration i:nth-child(5n) {
  background: var(--yellow);
}

.celebration.mega {
  background: radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0));
}

.celebration.mega strong {
  position: absolute;
  top: 42%;
  left: 50%;
  color: #111827;
  font-size: clamp(42px, 8vw, 94px);
  font-weight: 900;
  text-shadow: 0 14px 34px rgba(246, 183, 60, 0.42);
  transform: translate(-50%, -50%);
  animation: pop-perfect 1.2s ease-out forwards;
}

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

@keyframes word-read-pulse {
  from {
    box-shadow: 0 2px 6px rgba(47, 57, 80, 0.04), 0 0 0 0 rgba(59, 130, 246, 0.2);
  }
  to {
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.16), 0 0 0 5px rgba(59, 130, 246, 0.1);
  }
}

@keyframes wave {
  from { height: 12px; opacity: 0.52; }
  to { height: 44px; opacity: 1; }
}

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translateY(0) rotate(var(--rot)) scale(0.8);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(112vh) rotate(720deg) scale(1);
  }
}

@keyframes coin-fly {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.65) rotate(0deg);
  }
  15% {
    opacity: 1;
  }
  65% {
    opacity: 1;
    transform: translate(calc(var(--dx) * 0.72), calc(var(--dy) * 0.72 - 42px)) scale(1.05) rotate(260deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.3) rotate(560deg);
  }
}

@keyframes pop-perfect {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(245, 246, 249, 0.94);
    backdrop-filter: blur(14px);
  }

  .brand {
    width: auto;
    padding-bottom: 10px;
  }

  .side-menu {
    flex: none;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .side-menu p,
  .side-card {
    display: none;
  }

  .sidebar-language {
    width: 100%;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .sidebar-language > span {
    display: none;
  }

  .sidebar-language .language-toggle {
    width: min(280px, 100%);
  }

  .side-item {
    width: auto;
    white-space: nowrap;
  }

  .workspace {
    max-height: none;
    min-height: 0;
    overflow: visible;
    padding: 0 12px 16px;
  }

  .workspace main {
    overflow: visible;
  }

  .hero-dashboard,
  .reader-grid,
  .achievement-hero,
  .achievement-grid,
  .medal-board,
  .book-list {
    grid-template-columns: 1fr;
  }

  .map-hero {
    grid-template-columns: minmax(0, 1fr) 210px;
    min-height: 250px;
    padding: 26px;
  }

  .progress-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-tabs,
  .book-list {
    margin-left: 0;
    margin-right: 0;
  }

  .level-tabs {
    margin-left: 24px;
    margin-right: 24px;
  }

  .book-list {
    padding-left: 24px;
    padding-right: 24px;
  }

  .stage-header {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
  }

  .mode-switch {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .mode-switch span {
    flex: 1;
  }

  .book-row,
  .book-row.featured {
    grid-template-columns: 116px minmax(0, 1fr);
    min-height: auto;
    padding: 14px;
  }

  .book-cover,
  .book-row.featured .book-cover {
    width: 116px;
    height: 116px;
    aspect-ratio: 1;
    border-radius: 14px;
  }

  .book-action {
    grid-column: 1 / -1;
    width: calc(100% - 28px);
    justify-self: center;
    margin-bottom: 14px;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-stats {
    justify-content: flex-start;
  }

  .map-hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 22px;
  }

  .map-hero::after {
    right: 18px;
    top: 16px;
    width: 94px;
    height: 36px;
  }

  .map-hero h2 {
    max-width: 320px;
    font-size: 35px;
  }

  .hero-character {
    display: none;
  }

  .hero-copy {
    font-size: 14px;
    line-height: 1.5;
  }

  .hero-actions {
    margin-top: 18px;
  }

  .hero-actions .primary,
  .hero-actions span {
    width: 100%;
    justify-content: center;
  }

  .progress-panel {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 22px;
  }

  .progress-line > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .level-tabs {
    display: grid;
    grid-template-columns: 1fr;
    width: auto;
    height: auto;
    margin: 0 18px 16px;
    border-radius: 16px;
    padding: 4px;
  }

  .tab-button {
    width: auto;
  }

  .book-list {
    padding-left: 18px;
    padding-right: 18px;
  }

  .classic-empty {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .classic-empty strong {
    white-space: normal;
  }

  .book-row,
  .book-row.featured {
    grid-template-columns: 1fr;
  }

  .book-cover,
  .book-row.featured .book-cover {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
  }

  .book-row.compact-card .book-cover {
    aspect-ratio: 1;
  }

  .controls,
  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .controls > button,
  .dialog-actions > button {
    width: 100%;
  }

  .creation-journey-link {
    right: 16px;
    bottom: 16px;
    width: calc(100% - 32px);
  }
}
