:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-strong: #f0f4f8;
  --ink: #18202a;
  --muted: #647184;
  --line: #d8e0ea;
  --green: #1f8a5b;
  --green-soft: #dff3ea;
  --blue: #2563eb;
  --blue-soft: #e3edff;
  --amber: #b86b00;
  --amber-soft: #fff0cf;
  --red: #c83e49;
  --red-soft: #ffe3e7;
  --shadow: 0 18px 50px rgba(32, 45, 64, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #f9fbfd 0%, var(--bg) 48%, #edf2f7 100%);
  color: var(--ink);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f151c;
  --panel: #17202a;
  --panel-strong: #111922;
  --ink: #eef4f8;
  --muted: #9aa8b7;
  --line: #2c3947;
  --green: #36b37e;
  --green-soft: #153729;
  --blue: #7aa2ff;
  --blue-soft: #172a4f;
  --amber: #f0b957;
  --amber-soft: #3a2b12;
  --red: #ff6b7a;
  --red-soft: #3f1820;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  background:
    linear-gradient(180deg, #101820 0%, var(--bg) 54%, #0b1118 100%);
}

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

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  align-items: start;
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  min-width: 0;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
}

body[data-theme="dark"] .sidebar {
  background: rgba(23, 32, 42, 0.9);
}

body[data-theme="dark"] .revision-pill,
body[data-theme="dark"] .source-line span,
body[data-theme="dark"] .completion-note,
body[data-theme="dark"] .lesson-meta-row span[data-done="true"] {
  color: #9ff0c4;
}

.brand-block {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1;
}

h2 {
  font-size: 30px;
  line-height: 1.15;
}

.revision-pill {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid #badcca;
  border-radius: 8px;
  background: var(--green-soft);
  color: #12613f;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.profile-panel,
.search-field,
.control-strip label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profile-panel small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-transform: none;
}

.profile-panel select,
.search-field input,
.control-strip select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

body[data-theme="dark"] .search-field input,
body[data-theme="dark"] .profile-panel select,
body[data-theme="dark"] .control-strip select,
body[data-theme="dark"] .toggle-row,
body[data-theme="dark"] .icon-button,
body[data-theme="dark"] .typing-stage,
body[data-theme="dark"] .stat-tile,
body[data-theme="dark"] .keyboard-panel,
body[data-theme="dark"] .mistake-panel,
body[data-theme="dark"] .mini-button {
  background: var(--panel);
}

.search-field input {
  padding: 0 12px;
}

.profile-panel select,
.control-strip select {
  padding: 0 38px 0 12px;
}

.search-field input:focus,
.control-strip select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.overall-progress {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.progress-copy strong {
  color: var(--ink);
}

.progress-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mini-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.mini-button:hover {
  border-color: #efbac1;
  background: var(--red-soft);
  color: #951f2a;
}

.track,
.mini-track {
  display: block;
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: #d9e1ec;
}

.track span,
.mini-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.chapter-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 3px;
}

.chapter-button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.chapter-button:hover {
  background: #f3f7fb;
}

body[data-theme="dark"] .chapter-button:hover {
  background: #1c2834;
}

.chapter-button[data-active="true"] {
  border-color: #adc5ff;
  background: var(--blue-soft);
}

.chapter-number {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #18202a;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.chapter-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.chapter-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-copy span {
  color: var(--muted);
  font-size: 12px;
}

.mini-track {
  grid-column: 1 / -1;
  height: 4px;
}

.trainer {
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  align-content: start;
  gap: 18px;
  width: min(1180px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 26px;
}

.trainer-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.lesson-heading {
  min-width: 0;
}

.lesson-heading h2 {
  overflow-wrap: anywhere;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 1px 0 rgba(18, 24, 32, 0.04);
  cursor: pointer;
}

.icon-button:hover {
  border-color: #adc5ff;
  background: var(--blue-soft);
}

.icon-button[data-active="true"] {
  border-color: #8fb0ff;
  background: var(--blue-soft);
  color: var(--blue);
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(130px, 0.3fr) minmax(240px, 1fr) repeat(3, auto);
  align-items: end;
  align-content: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.toggle-row {
  display: flex !important;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink) !important;
  text-transform: none !important;
  white-space: nowrap;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.typing-stage {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.source-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.source-line span {
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--green-soft);
  color: #12613f;
  font-weight: 800;
}

.source-line a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.lesson-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lesson-meta-row span {
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.lesson-meta-row span[data-done="true"] {
  border-color: #badcca;
  background: var(--green-soft);
  color: #12613f;
}

.target-text {
  min-height: 150px;
  padding: 16px;
  border: 1px solid #e0e7f0;
  border-radius: 8px;
  background: #fbfcfe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 22px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

body[data-theme="dark"] .target-text,
body[data-theme="dark"] textarea {
  background: #101820;
}

.char {
  border-radius: 3px;
}

.char.correct {
  color: #0f6b45;
  background: rgba(31, 138, 91, 0.13);
}

.char.wrong {
  color: #951f2a;
  background: var(--red-soft);
}

.char.current {
  color: #0d4bb3;
  background: #dbe8ff;
  box-shadow: inset 0 -2px 0 var(--blue);
}

.char.blocked {
  color: #951f2a;
  background: var(--red-soft);
  box-shadow: inset 0 -2px 0 var(--red);
  animation: blocked-key 0.42s ease;
}

.char.extra {
  text-decoration: underline;
}

@keyframes blocked-key {
  0%,
  100% {
    transform: translateX(0);
  }

  30% {
    transform: translateX(-1px);
  }

  65% {
    transform: translateX(1px);
  }
}

textarea {
  width: 100%;
  height: 118px;
  min-height: 104px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.55;
  outline: 0;
}

textarea:disabled {
  background: #f5f8fb;
  color: var(--muted);
}

body[data-theme="dark"] textarea:disabled {
  background: #121a23;
}

.completion-note {
  padding: 10px 12px;
  border: 1px solid #badcca;
  border-radius: 8px;
  background: var(--green-soft);
  color: #12613f;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 12px;
}

.stat-tile {
  display: grid;
  gap: 5px;
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat-tile span,
.stat-tile small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-tile strong {
  font-size: 30px;
  line-height: 1;
}

.lower-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 12px;
}

.keyboard-panel,
.mistake-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-title strong {
  color: var(--ink);
  font-size: 14px;
}

.keyboard {
  display: grid;
  gap: 7px;
}

.key-row {
  display: flex;
  gap: 6px;
}

.key-row[data-row="2"] {
  padding-left: 18px;
}

.key-row[data-row="3"] {
  padding-left: 42px;
}

.key {
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: #293242;
  font-weight: 900;
  text-transform: uppercase;
}

body[data-theme="dark"] .key {
  background: #101820;
  color: var(--ink);
}

.key[data-next="true"] {
  border-color: #f1b84d;
  background: var(--amber-soft);
  color: #7b4500;
  box-shadow: 0 0 0 3px rgba(184, 107, 0, 0.12);
}

.key[data-hot="true"] {
  background: color-mix(in srgb, var(--red-soft) calc(var(--heat) * 12%), #f8fafc);
  border-color: #efbac1;
}

.mistake-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.mistake-chip,
.empty-state {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.mistake-chip {
  background: var(--red-soft);
  color: #951f2a;
}

.empty-state {
  background: #eef3f7;
  color: var(--muted);
}

body[data-theme="dark"] .empty-state {
  background: #111922;
}

body.focus-mode .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.focus-mode .sidebar,
body.focus-mode .lower-panel {
  display: none;
}

body.focus-mode .trainer {
  width: min(980px, 100%);
}

body.focus-mode .typing-stage {
  padding: 22px;
}

body.focus-mode .target-text {
  min-height: 170px;
  font-size: 24px;
  line-height: 1.75;
}

body.focus-mode textarea {
  height: 132px;
}

@media (max-width: 1180px) {
  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toggle-row {
    justify-content: flex-start;
  }
}

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

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chapter-list {
    max-height: 300px;
  }

  .trainer {
    padding: 18px;
  }

  .control-strip,
  .lower-panel {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .brand-block {
    display: grid;
    justify-items: start;
  }

  .revision-pill {
    white-space: normal;
  }

  .trainer-top {
    display: grid;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .icon-button {
    width: 100%;
  }

  h2 {
    font-size: 24px;
  }

  .target-text {
    min-height: 140px;
    font-size: 19px;
    line-height: 1.65;
  }

  textarea {
    font-size: 18px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .key {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: 32px;
    font-size: 13px;
  }

  .key-row {
    gap: 4px;
  }

  .key-row[data-row="2"],
  .key-row[data-row="3"] {
    padding-left: 0;
  }
}

/* ============================
   PDD-Reader Specific Styles
   ============================ */

/* --- Tab Switcher --- */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 4px;
}

.tab-button {
  border: none;
  background: transparent;
  padding: 9px 8px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.01em;
  text-decoration: none;
  text-align: center;
}

.tab-button:hover {
  color: var(--ink);
}

.tab-button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);
}

body[data-theme="dark"] .tab-button.active {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* --- Reader Main Layout --- */
.reader {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 100vh;
  min-width: 0;
  width: 100%;
  padding: 26px 26px 0;
  gap: 18px;
  box-sizing: border-box;
}

.reader .trainer-top {
  padding: 0;
}

.reader .control-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}

/* --- Reader Body (Two-Column) --- */
.reader-body {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 26px;
}

/* --- Rules Scroll Pane --- */
.rules-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 6px;
  scroll-behavior: smooth;
}

/* Subtle scrollbar */
.rules-view::-webkit-scrollbar { width: 5px; }
.rules-view::-webkit-scrollbar-track { background: transparent; }
.rules-view::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}
.rules-view::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* --- Rule Cards --- */
.rule-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  flex-shrink: 0;
}

.rule-card:hover {
  border-color: color-mix(in srgb, var(--blue) 40%, var(--line));
  background: var(--panel-strong);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.05);
}

.rule-card.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1);
  transform: translateY(0);
}

.rule-card-play {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.rule-card:hover .rule-card-play {
  border-color: color-mix(in srgb, var(--blue) 50%, var(--line));
}

.rule-card.active .rule-card-play {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.rule-card-text {
  flex: 1 1 auto;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
}

.rule-card-number {
  font-weight: 800;
  color: var(--muted);
  margin-right: 6px;
  font-size: 13px;
}

/* --- Details Panel (Right Column) --- */
.details-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.details-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow);
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

.details-card::-webkit-scrollbar { width: 4px; }
.details-card::-webkit-scrollbar-track { background: transparent; }
.details-card::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

/* --- Chapter Illustration --- */
.illustration-container {
  border-radius: 12px;
  overflow: hidden;
  height: 180px;
  flex-shrink: 0;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  position: relative;
}

#chapterIllustration {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#chapterIllustration:hover {
  transform: scale(1.03);
}

/* --- Audio Visualizer --- */
.visualizer-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.visualizer-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.visualizer {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 48px;
  padding: 6px 14px;
  background: var(--panel-strong);
  border-radius: 10px;
  border: 1px solid var(--line);
  box-sizing: border-box;
}

.visualizer .bar {
  flex: 1;
  height: 4px;
  background: var(--blue);
  border-radius: 3px;
  transition: height 0.08s ease;
}

#audioVisualizer.playing .bar:nth-child(1) { animation: vis-bounce 0.7s ease-in-out infinite alternate 0.05s; }
#audioVisualizer.playing .bar:nth-child(2) { animation: vis-bounce 0.6s ease-in-out infinite alternate 0.18s; }
#audioVisualizer.playing .bar:nth-child(3) { animation: vis-bounce 0.8s ease-in-out infinite alternate 0.08s; }
#audioVisualizer.playing .bar:nth-child(4) { animation: vis-bounce 0.65s ease-in-out infinite alternate 0.22s; }
#audioVisualizer.playing .bar:nth-child(5) { animation: vis-bounce 0.75s ease-in-out infinite alternate 0.12s; }
#audioVisualizer.playing .bar:nth-child(6) { animation: vis-bounce 0.55s ease-in-out infinite alternate 0.28s; }
#audioVisualizer.playing .bar:nth-child(7) { animation: vis-bounce 0.85s ease-in-out infinite alternate 0.02s; }

@keyframes vis-bounce {
  0% { height: 4px; }
  100% { height: 34px; }
}

/* --- Chapter Summary --- */
.chapter-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.chapter-summary h3 {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0;
  letter-spacing: 0.5px;
}

.chapter-summary ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chapter-summary li {
  color: var(--ink);
}

/* --- Reader Responsive --- */

@media (max-width: 1200px) {
  .reader-body {
    grid-template-columns: 1fr 300px;
    gap: 16px;
  }

  .illustration-container {
    height: 140px;
  }
}

@media (max-width: 980px) {
  .reader {
    padding: 18px 18px 0;
    gap: 14px;
  }

  .reader-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    overflow: visible;
    padding-bottom: 18px;
  }

  .rules-view {
    max-height: 50vh;
    overflow-y: auto;
  }

  .details-panel {
    overflow: visible;
  }

  .details-card {
    max-height: none;
    overflow-y: visible;
  }

  .illustration-container {
    height: 160px;
  }
}

@media (max-width: 620px) {
  .reader {
    padding: 14px 12px 0;
    gap: 10px;
  }

  .reader .trainer-top {
    display: grid;
    gap: 10px;
  }

  .reader .toolbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

  .reader .icon-button {
    width: 100%;
  }

  .reader .control-strip {
    padding: 10px;
  }

  .reader-body {
    gap: 12px;
    padding-bottom: 14px;
  }

  .rule-card {
    padding: 12px;
    gap: 10px;
  }

  .rule-card-text {
    font-size: 14px;
    line-height: 1.5;
  }

  .rule-card-play {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .illustration-container {
    height: 120px;
  }

  .details-card {
    padding: 14px;
    gap: 14px;
  }
}
