:root {
  --bg: #f6f4ef;
  --panel: #fffefa;
  --panel-soft: #fff8ed;
  --ink: #253238;
  --muted: #687679;
  --line: #ddd9d0;
  --teal: #2f6f73;
  --teal-soft: #e8f3f0;
  --coral: #c8755d;
  --coral-soft: #fbeae3;
  --plum: #73556b;
  --sun: #f5ce78;
  --shadow: 0 8px 24px rgba(37, 50, 56, 0.07);
  --shadow-floating: 0 12px 30px rgba(37, 50, 56, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", "Yu Gothic UI", "Hiragino Sans", Meiryo, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
}

.site-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border: 1px solid rgba(37, 50, 58, 0.16);
  border-radius: 8px;
  background: var(--panel);
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 800;
}

.brand-note {
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

.heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.episode-subtitle {
  margin: 0;
  color: var(--teal);
  font-weight: 800;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid rgba(200, 117, 93, 0.35);
  border-radius: 6px;
  background: var(--coral-soft);
  color: #8d452e;
  font-size: 0.84rem;
  font-weight: 800;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 4px 0 0;
  font-size: 1.65rem;
  line-height: 1.24;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(380px, 1.05fr);
  gap: 20px;
  max-width: 1320px;
  height: calc(100vh - 116px);
  min-height: 620px;
  margin: 0 auto;
  padding: 0 24px 24px;
}

.video-panel,
.dialogue-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.video-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 14px;
  align-content: start;
  overflow: auto;
  padding: 16px;
}

.video-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid #202b32;
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  background: #182128;
}

.video-frame iframe,
.video-frame > div {
  width: 100%;
  height: 100%;
}

.episode-card {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
}

.episode-thumbnail {
  width: 118px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
}

.episode-card-copy {
  min-width: 0;
}

.eyebrow {
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.episode-card h2 {
  margin: 2px 0 4px;
  font-size: 1rem;
}

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

.learning-points {
  padding: 12px 14px;
  border: 1px solid rgba(47, 111, 115, 0.24);
  border-radius: 8px;
  background: #f8fcf8;
}

.learning-points h2 {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.95rem;
}

.learning-points ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.learning-points li {
  color: #3d4d50;
  font-weight: 700;
}

.playbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button,
.icon-button,
.audio-button,
.shadow-button,
.turn-action-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button {
  min-height: 42px;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  font-weight: 800;
}

.button-primary {
  background: var(--teal);
  color: #fff;
}

.button-secondary {
  border-color: rgba(115, 85, 107, 0.32);
  background: #fff;
  color: var(--plum);
}

.button-secondary.is-mix-playing,
.button-secondary.is-looping,
.button-secondary.is-filtering {
  border-color: rgba(200, 117, 93, 0.55);
  background: var(--coral-soft);
  color: #8d452e;
}

.button-symbol {
  display: inline-flex;
  width: 16px;
  justify-content: center;
}

.button-symbol svg {
  width: 16px;
  height: 16px;
}

.icon-button,
.audio-button,
.shadow-button,
.turn-action-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.audio-button svg,
.shadow-button svg,
.turn-action-button svg {
  width: 18px;
  height: 18px;
}

.speed-control {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.speed-control select {
  border: 0;
  background: transparent;
  color: var(--teal);
  font-weight: 900;
  outline: none;
}

.button:hover,
.icon-button:hover,
.audio-button:hover,
.shadow-button:hover,
.turn-action-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
}

.button:disabled,
.icon-button:disabled,
.audio-button:disabled,
.shadow-button:disabled,
.turn-action-button:disabled,
.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.audio-button.is-playing,
.loop-turn-button.is-looping {
  border-color: rgba(47, 111, 115, 0.5);
  background: var(--teal-soft);
  color: var(--teal);
}

.favorite-button {
  color: #8d7a34;
  font-size: 1.3rem;
  line-height: 1;
}

.favorite-button.is-favorite {
  border-color: rgba(245, 206, 120, 0.8);
  background: #fff3c9;
  color: #9b6b00;
}

.record-button.is-recording {
  border-color: rgba(190, 72, 66, 0.65);
  background: #ffe4df;
  color: #b8322a;
  box-shadow: 0 0 0 3px rgba(190, 72, 66, 0.14);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-strip span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.notice-message {
  padding: 10px 12px;
  border: 1px solid rgba(200, 117, 93, 0.38);
  border-radius: 7px;
  background: var(--coral-soft);
  color: #7b3d2b;
  font-weight: 700;
}

.mini-player {
  display: none;
}

.dialogue-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

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

.check-control,
.select-control {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.check-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.select-control select {
  min-width: 112px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  outline: none;
}

.subscribe-prompt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 12px 16px 0;
  padding: 12px;
  border: 1px solid rgba(47, 111, 115, 0.26);
  border-radius: 8px;
  background: #f8fcf8;
}

.subscribe-prompt strong {
  color: var(--teal);
}

.subscribe-prompt p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.subscribe-actions .button {
  min-height: 40px;
  white-space: nowrap;
}

.turn-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 16px 22px;
  scroll-behavior: smooth;
}

.turn {
  display: flex;
  margin-bottom: 14px;
}

.turn-left {
  justify-content: flex-start;
}

.turn-right {
  justify-content: flex-end;
}

.bubble {
  width: min(88%, 680px);
  padding: 13px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.turn-right .bubble {
  background: var(--teal-soft);
}

.bubble:hover,
.bubble:focus-visible {
  border-color: rgba(47, 111, 115, 0.45);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.12);
}

.turn.active .bubble {
  border-color: rgba(200, 117, 93, 0.78);
  background: #fff0df;
  box-shadow: 0 0 0 3px rgba(200, 117, 93, 0.16);
}

.turn-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.speaker-line {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.speaker-label {
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 900;
}

.turn-time {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.turn-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.jp-text {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.95;
}

ruby {
  padding: 0 1px;
}

rt {
  color: var(--muted);
  font-size: 0.58em;
  font-weight: 700;
  line-height: 1;
}

.hide-furigana rt {
  visibility: hidden;
}

.hide-furigana .jp-text {
  cursor: default;
  line-height: 2.18;
}

.hide-furigana ruby {
  min-height: 1.75em;
  margin: 0 0.02em;
  padding: 0.02em 0.18em;
  border-bottom: 1px dotted rgba(47, 111, 115, 0.44);
  border-radius: 7px;
  background: rgba(245, 206, 120, 0.2);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(47, 111, 115, 0.14);
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.hide-furigana ruby:hover {
  background: rgba(245, 206, 120, 0.34);
  border-bottom-color: rgba(47, 111, 115, 0.72);
}

.hide-furigana ruby:focus-visible {
  outline: 2px solid rgba(47, 111, 115, 0.58);
  outline-offset: 2px;
}

.hide-furigana ruby.revealed rt {
  visibility: visible;
  color: var(--coral);
}

.hide-furigana ruby.revealed {
  background: rgba(226, 240, 236, 0.9);
  border-bottom-color: rgba(200, 117, 93, 0.8);
  box-shadow: 0 0 0 2px rgba(47, 111, 115, 0.1);
}

@media (min-width: 769px) {
  .jp-text {
    line-height: 2.08;
  }

  .hide-furigana .jp-text {
    line-height: 2.38;
  }

  ruby {
    ruby-align: center;
    ruby-position: over;
  }

  rt {
    position: relative;
    top: -0.45em;
    font-size: 0.68em;
    line-height: 1.1;
  }
}

.translation {
  display: none;
  margin: 9px 0 0;
  padding-top: 8px;
  border-top: 1px dashed rgba(110, 122, 125, 0.26);
  color: #49575b;
  font-size: 0.94rem;
}

.translation.is-visible {
  display: block;
}

.recording-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(110, 122, 125, 0.26);
}

.mini-button {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal);
  font-size: 0.88rem;
  font-weight: 800;
}

.mini-button.is-comparing {
  border-color: rgba(200, 117, 93, 0.55);
  background: var(--coral-soft);
  color: #8d452e;
}

.empty-message {
  margin: 20px auto;
  padding: 12px;
  border: 1px dashed rgba(110, 122, 125, 0.4);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.next-lesson-footer {
  max-width: 1320px;
  margin: -10px auto 24px;
  padding: 0 24px;
  text-align: right;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 768px) {
  body {
    overflow: auto;
  }

  .site-header {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px 8px;
  }

  .brand {
    min-width: 0;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .brand-note {
    font-size: 0.74rem;
  }

  .episode-subtitle {
    font-size: 0.82rem;
  }

  h1 {
    font-size: 1.2rem;
  }

  .app-layout {
    display: flex;
    height: auto;
    min-height: 0;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
    padding: 0 10px 10px;
  }

  .video-panel {
    flex: 0 0 auto;
    gap: 8px;
    overflow: visible;
    padding: 10px;
    box-shadow: none;
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .video-frame {
    display: none;
  }

  .dialogue-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
    box-shadow: none;
  }

  .learning-controls {
    justify-content: flex-start;
  }

  .subscribe-prompt {
    display: none;
  }

  .subscribe-actions {
    align-items: stretch;
    justify-content: space-between;
  }

  .bubble {
    width: 100%;
    padding: 10px 12px;
  }

  .jp-text {
    font-size: 1.125rem;
  }

  .turn {
    margin-bottom: 9px;
  }

  .turn-list {
    flex: none;
    overflow: visible;
    padding: 10px;
  }

  .status-strip {
    display: none;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 1.34rem;
  }

  .episode-card {
    grid-template-columns: 1fr;
  }

  .episode-thumbnail {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .playbar,
  .learning-controls {
    align-items: stretch;
    gap: 8px;
  }

  .button {
    flex: 1 1 calc(50% - 8px);
    min-height: 38px;
    padding: 0 10px;
  }

  .icon-button {
    width: 42px;
    height: 38px;
  }

  .check-control,
  .select-control,
  .speed-control {
    flex: 1 1 calc(50% - 8px);
    width: auto;
    min-height: 38px;
    justify-content: space-between;
  }

  .select-control select,
  .speed-control select {
    width: 48%;
    min-width: 0;
  }

  .turn-list {
    padding: 8px;
  }

  .bubble {
    width: 100%;
    border-color: rgba(222, 215, 202, 0.8);
  }

  .turn-meta {
    align-items: flex-start;
  }

  .turn-action-button {
    width: 42px;
    height: 42px;
  }

  .jp-text {
    font-size: 1.125rem;
    line-height: 1.9;
  }

  .hide-furigana .jp-text {
    line-height: 2.32;
  }

  .hide-furigana ruby {
    min-height: 1.95em;
    padding: 0.08em 0.24em;
    border-radius: 9px;
  }

  rt {
    font-size: 0.6em;
  }

  .next-lesson-footer {
    padding: 0 16px 18px;
    text-align: left;
  }

  .next-lesson-footer .button {
    width: 100%;
  }
}

/* Reference-inspired learning-player layout */
body {
  background: #f7f5ef;
}

.site-header {
  max-width: 1220px;
  padding-top: 16px;
}

.app-layout {
  max-width: 1220px;
  grid-template-columns: minmax(340px, 0.9fr) minmax(420px, 1.1fr);
  gap: 28px;
}

.video-panel {
  grid-template-rows: auto auto;
  gap: 14px;
  overflow: visible;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.video-frame,
.control-card,
.dialogue-panel {
  border: 1px solid rgba(37, 50, 58, 0.12);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(37, 50, 58, 0.08);
}

.video-frame {
  border-color: rgba(37, 50, 58, 0.18);
}

.control-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.scene-control {
  display: block;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.scene-control select {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.scene-control select {
  min-height: 42px;
  padding: 0 38px 0 12px;
  text-overflow: ellipsis;
  cursor: pointer;
}

.playbar {
  gap: 8px;
}

.player-learning-controls {
  justify-content: flex-start;
}

.dialogue-panel {
  border-radius: 16px;
}

.turn-list {
  background:
    linear-gradient(135deg, rgba(47, 111, 115, 0.025) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(225deg, rgba(47, 111, 115, 0.02) 25%, transparent 25%) 0 0 / 22px 22px,
    var(--panel);
}

.bubble {
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(37, 50, 58, 0.05);
}

.turn.active .bubble {
  border-color: rgba(200, 117, 93, 0.82);
  background: var(--coral-soft);
  box-shadow: inset 4px 0 0 var(--coral), 0 0 0 3px rgba(200, 117, 93, 0.14), 0 8px 20px rgba(37, 50, 58, 0.08);
}

@media (max-width: 768px) {
  .site-header {
    display: none;
  }

  .brand {
    gap: 8px;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
  }

  .brand-name {
    font-size: 0.92rem;
  }

  .brand-note,
  .episode-subtitle {
    display: none;
  }

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

  .level-badge {
    min-height: 22px;
    padding: 2px 7px;
    font-size: 0.74rem;
  }

  h1 {
    margin-top: 2px;
    font-size: 1rem;
    line-height: 1.25;
  }

  .app-layout {
    display: block;
    height: auto;
    padding: 8px 10px 88px;
  }

  .video-panel {
    position: static;
    display: contents;
    margin-bottom: 0;
    padding: 0;
    background: transparent;
  }

  .video-frame {
    display: block;
    position: sticky;
    top: 8px;
    z-index: 15;
    margin-bottom: 9px;
    overflow: hidden;
    border-radius: 14px;
    background: #000;
    box-shadow: 0 10px 24px rgba(37, 50, 58, 0.12);
  }

  .control-card {
    gap: 9px;
    margin: 0 0 10px;
    padding: 12px;
    border-radius: 16px;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
  }

  .scene-control {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }

  .scene-control {
    display: block;
  }

  .scene-control select {
    min-height: 44px;
    padding: 0 36px 0 12px;
    text-overflow: ellipsis;
  }

  .playbar {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 0.9fr) minmax(0, 1.12fr);
    gap: 8px;
  }

  .button {
    min-height: 44px;
    min-width: 0;
    padding: 0 9px;
    font-size: 0.95rem;
  }

  .icon-button {
    width: 40px;
    height: 38px;
  }

  #loopButton,
  #favoritesOnlyButton,
  #previousTurnButton,
  #nextTurnButton,
  .speed-control {
    display: none;
  }

  #mixPlayButton {
    border-color: rgba(18, 143, 93, 0.36);
    background: #159768;
    color: #fff;
  }

  #mixPlayButton.is-mix-playing {
    background: #9b634f;
    color: #fff;
  }

  .player-learning-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(222, 215, 202, 0.75);
  }

  .check-control,
  .select-control {
    min-height: 34px;
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
  }

  .select-control {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(120px, 1fr);
    justify-content: start;
    gap: 8px;
  }

  .select-control span::after {
    content: ":";
  }

  .select-control select {
    min-height: 30px;
    padding: 0 28px 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background-color: #fff;
    font-weight: 600;
  }

  .check-control {
    justify-content: flex-start;
    gap: 8px;
  }

  .check-control input {
    width: 22px;
    height: 22px;
  }

  .status-strip {
    display: none;
  }

  .dialogue-panel {
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .turn-list {
    padding: 0;
    background: transparent;
  }

  .turn,
  .turn-left,
  .turn-right {
    justify-content: stretch;
  }

  .turn {
    margin-bottom: 8px;
  }

  .bubble {
    width: 100%;
    padding: 10px;
    border-radius: 12px;
    background: #fffdf8;
    box-shadow: none;
  }

  .turn-right .bubble {
    background: #f4fbf8;
  }

  .turn.active .bubble {
    border-color: rgba(200, 117, 93, 0.82);
    background: var(--coral-soft);
    box-shadow: inset 4px 0 0 var(--coral), 0 0 0 3px rgba(200, 117, 93, 0.12);
  }

  .turn-meta {
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 4px;
  }

  .turn-actions {
    gap: 5px;
  }

  .turn-action-button {
    width: 38px;
    height: 38px;
  }

  .speaker-label {
    font-size: 0.78rem;
  }

  .jp-text {
    font-size: 1.08rem;
    line-height: 1.85;
  }

  .recording-panel {
    gap: 6px;
    margin-top: 8px;
  }

  .mini-button {
    min-height: 34px;
    font-size: 0.82rem;
  }

  .mini-player {
    position: fixed;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    min-height: 58px;
    padding: 8px;
    border: 1px solid rgba(37, 50, 58, 0.16);
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 12px 30px rgba(37, 50, 58, 0.18);
    backdrop-filter: blur(10px);
  }

  .mini-player-meta {
    display: none;
    min-width: 0;
    gap: 1px;
    padding: 0 2px;
  }

  .mini-player-controls {
    display: grid;
    grid-template-columns: minmax(46px, 0.8fr) minmax(86px, 1.4fr) minmax(46px, 0.8fr);
    align-items: center;
    justify-self: center;
    width: min(78vw, 320px);
    overflow: hidden;
    border: 1px solid rgba(47, 111, 115, 0.26);
    border-radius: 13px;
    background: #fff;
  }

  .mini-player-line,
  .mini-player-time {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mini-player-line {
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 800;
  }

  .mini-player-time {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
  }

  .mini-player-button,
  .mini-player-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 40px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font-weight: 900;
    cursor: pointer;
  }

  .mini-player-button + .mini-player-play,
  .mini-player-play + .mini-player-button {
    border-left: 1px solid rgba(47, 111, 115, 0.18);
  }

  .mini-player-play {
    gap: 5px;
    padding: 0 10px;
    background: var(--teal);
    color: #fff;
  }

  .mini-player-play.is-lesson-playing {
    border-color: rgba(155, 99, 79, 0.38);
    background: #9b634f;
  }
}

@media (max-width: 420px) {
  .player-learning-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .playbar {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.82fr) minmax(0, 1fr);
    gap: 6px;
  }

  .button {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 0.86rem;
  }

  .mini-player {
    padding: 7px;
  }

  .mini-player-controls {
    grid-template-columns: minmax(42px, 0.8fr) minmax(78px, 1.4fr) minmax(42px, 0.8fr);
    width: min(78vw, 300px);
  }

  .mini-player-play {
    gap: 3px;
    padding: 0 8px;
    font-size: 0.86rem;
  }
}

/* Final visual-system polish */
.brand-name,
.episode-subtitle,
.level-badge {
  font-weight: 700;
}

.video-frame,
.control-card,
.dialogue-panel {
  border-color: rgba(37, 50, 56, 0.13);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.video-frame {
  border-color: rgba(37, 50, 56, 0.2);
}

.scene-control,
.button,
.icon-button,
.turn-action-button,
.mini-button,
.speed-control,
.check-control,
.select-control {
  border-radius: 8px;
}

.scene-control {
  border-color: var(--line);
}

.scene-control select,
.button,
.speed-control,
.speed-control select {
  font-weight: 700;
}

.button-secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.button-secondary.is-mix-playing,
.button-secondary.is-looping,
.button-secondary.is-filtering {
  border-color: rgba(200, 117, 93, 0.56);
  background: var(--coral-soft);
  color: #864b39;
}

.button:hover,
.icon-button:hover,
.audio-button:hover,
.shadow-button:hover,
.turn-action-button:hover,
.mini-button:hover {
  transform: none;
}

.button:not(:disabled):hover,
.icon-button:not(:disabled):hover,
.turn-action-button:not(:disabled):hover,
.mini-button:not(:disabled):hover {
  border-color: rgba(47, 111, 115, 0.42);
  background-color: var(--teal-soft);
}

.button-primary:not(:disabled):hover {
  border-color: transparent;
  background: #285f63;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
.bubble:focus-visible {
  outline: 3px solid rgba(47, 111, 115, 0.22);
  outline-offset: 2px;
}

.playbar {
  display: grid;
  gap: 9px;
}

.playback-actions,
.utility-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.utility-actions {
  padding-top: 9px;
  border-top: 1px solid rgba(221, 217, 208, 0.82);
}

.player-learning-controls {
  padding-top: 10px;
  border-top: 1px solid rgba(221, 217, 208, 0.82);
}

.turn-list {
  background: var(--panel);
  scrollbar-color: rgba(104, 118, 121, 0.48) transparent;
  scrollbar-width: thin;
}

.turn-list::-webkit-scrollbar {
  width: 7px;
}

.turn-list::-webkit-scrollbar-track {
  background: transparent;
}

.turn-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(104, 118, 121, 0.42);
  background-clip: padding-box;
}

.bubble {
  border-color: var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  box-shadow: none;
}

.turn-right .bubble {
  background: var(--teal-soft);
}

.bubble:hover {
  border-color: rgba(47, 111, 115, 0.36);
  box-shadow: 0 0 0 2px rgba(47, 111, 115, 0.08);
}

.turn.active .bubble {
  border-color: rgba(200, 117, 93, 0.72);
  background: var(--coral-soft);
  box-shadow: inset 3px 0 0 var(--coral), 0 0 0 2px rgba(200, 117, 93, 0.12);
}

.speaker-label {
  font-weight: 700;
}

.turn-time {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.turn-action-button {
  border-color: rgba(37, 50, 56, 0.15);
  background: rgba(255, 255, 255, 0.82);
}

.turn-action-button svg {
  width: 18px;
  height: 18px;
}

.favorite-button {
  color: #8b742e;
  font-size: inherit;
}

.favorite-button.is-favorite svg {
  fill: currentColor;
}

.mini-player {
  border-radius: 12px;
  box-shadow: var(--shadow-floating);
}

@media (min-width: 769px) and (max-width: 900px) {
  .site-header {
    padding-right: 16px;
    padding-left: 16px;
  }

  .app-layout {
    grid-template-columns: minmax(290px, 0.9fr) minmax(360px, 1.1fr);
    gap: 16px;
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 768px) {
  .video-frame,
  .control-card {
    border-radius: 12px;
  }

  .video-frame {
    box-shadow: 0 8px 22px rgba(37, 50, 56, 0.11);
  }

  .control-card {
    box-shadow: 0 6px 18px rgba(37, 50, 56, 0.06);
  }

  .playbar {
    display: block;
  }

  .playback-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .playback-actions .button {
    width: 100%;
  }

  .utility-actions,
  #loopButton {
    display: none;
  }

  #mixPlayButton {
    border-color: rgba(47, 111, 115, 0.42);
    background: #fff;
    color: var(--teal);
  }

  #mixPlayButton.is-mix-playing {
    border-color: rgba(200, 117, 93, 0.56);
    background: var(--coral-soft);
    color: #864b39;
  }

  .player-learning-controls {
    grid-template-columns: minmax(130px, 0.85fr) minmax(170px, 1.15fr);
    gap: 8px;
  }

  .select-control {
    grid-column: auto;
    grid-template-columns: auto minmax(72px, 1fr);
    gap: 6px;
  }

  .check-control,
  .select-control {
    font-size: 0.86rem;
  }

  .check-control input {
    width: 20px;
    height: 20px;
  }

  .select-control select {
    min-width: 0;
    width: 100%;
  }

  .bubble {
    border-radius: 10px;
  }

  .mini-player {
    box-shadow: 0 10px 26px rgba(37, 50, 56, 0.15);
  }
}

@media (max-width: 360px) {
  .player-learning-controls {
    grid-template-columns: 1fr;
  }

  .select-control {
    grid-column: 1;
  }
}

.print-cover,
.print-end-card {
  display: none;
}

@page {
  size: A4;
  margin: 16mm 17mm 18mm;
}

@media print {
  :root {
    --bg: #fffdf7;
    --panel: #fffdf7;
    --panel-soft: #fbfaf6;
    --ink: #30383b;
    --muted: #6d7a7b;
    --line: #d8dfdc;
    --teal: #547973;
    --teal-soft: #edf4f1;
    --coral: #b97867;
    --coral-soft: #f8ece7;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html,
  body {
    min-height: auto;
    background: var(--panel);
  }

  body:not(.print-handout) > * {
    display: none !important;
  }

  .print-handout .site-header,
  .print-handout .video-panel,
  .print-handout .subscribe-prompt,
  .print-handout .next-lesson-footer,
  .print-handout .mini-player,
  .print-handout audio,
  .print-handout .turn-actions,
  .print-handout .recording-panel {
    display: none !important;
  }

  .print-handout .print-cover {
    position: relative;
    display: flex;
    min-height: 250mm;
    flex-direction: column;
    justify-content: center;
    padding: 14mm 7mm 30mm;
    background: linear-gradient(145deg, #fffdf7 0%, #eef5f1 100%);
    break-after: page;
  }

  .print-brand {
    margin-bottom: 18mm;
    color: var(--teal);
    font-size: 11pt;
    font-weight: 800;
    letter-spacing: 0.22em;
  }

  .print-rule {
    width: 20mm;
    height: 1.2mm;
    margin-bottom: 10mm;
    border-radius: 1mm;
    background: #7ca197;
  }

  .print-cover h1 {
    max-width: 165mm;
    margin: 0;
    color: var(--ink);
    font-size: 27pt;
    line-height: 1.42;
    text-wrap: balance;
  }

  .print-subtitle {
    margin: 6mm 0 0;
    color: var(--muted);
    font-size: 12pt;
  }

  .print-meta {
    display: flex;
    gap: 5mm;
    align-items: center;
    margin-top: 12mm;
    color: var(--teal);
    font-size: 9pt;
    font-weight: 700;
  }

  .print-video-card,
  .print-end-card {
    display: flex !important;
    gap: 5mm;
    align-items: center;
    justify-content: space-between;
    color: var(--teal);
  }

  .print-video-card {
    position: absolute;
    right: 7mm;
    bottom: 12mm;
    max-width: 90mm;
  }

  .print-video-card a,
  .print-end-card a {
    display: block;
    max-width: 62mm;
    margin-top: 1.5mm;
    color: var(--teal);
    font-size: 7.5pt;
    overflow-wrap: anywhere;
  }

  .print-video-card img,
  .print-end-card img {
    width: 28mm;
    height: 28mm;
    padding: 1.5mm;
    border: 0.25mm solid var(--line);
    border-radius: 2mm;
    background: #fff;
  }

  .print-handout .app-layout {
    display: block;
    width: auto;
    max-width: none;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  .print-handout .dialogue-panel {
    display: block;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .print-handout .turn-list {
    display: block;
    overflow: visible;
    padding: 0;
  }

  .print-handout .turn {
    display: block !important;
    margin: 0;
    padding: 4mm 0;
    border-bottom: 0.25mm solid var(--line);
    break-inside: avoid;
  }

  .print-handout .bubble,
  .print-handout .turn-right .bubble,
  .print-handout .turn.active .bubble {
    width: 100%;
    max-width: none;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .print-handout .turn-meta {
    margin-bottom: 2mm;
  }

  .print-handout .speaker-label {
    display: inline-flex;
    min-width: 8mm;
    min-height: 8mm;
    align-items: center;
    justify-content: center;
    padding: 1mm 2.5mm;
    border-radius: 99mm;
    background: #7ca197;
    color: #fff;
    font-size: 8pt;
  }

  .print-handout .turn-time {
    font-size: 8pt;
  }

  .print-handout .jp-text {
    color: var(--ink);
    font-size: 13pt;
    line-height: 2.05;
  }

  .print-handout rt,
  .print-handout.hide-furigana rt {
    visibility: visible !important;
    color: var(--teal);
  }

  .print-handout.hide-furigana ruby {
    min-height: 0;
    margin: 0;
    padding: 0 0.04em;
    border: 0;
    background: transparent;
  }

  .print-handout .translation.is-visible {
    display: block;
    margin: 2.5mm 0 0;
    padding: 3mm 4mm;
    border-left: 1mm solid #7ca197;
    border-radius: 1.5mm;
    background: var(--teal-soft);
    color: #4a5758;
    font-size: 10pt;
    line-height: 1.65;
  }

  .print-handout .translation.is-visible::before {
    content: attr(data-language-label) " Translation  ";
    color: var(--teal);
    font-weight: 800;
  }

  .print-handout .print-end-card {
    min-height: 35mm;
    margin-top: 8mm;
    padding-top: 5mm;
    border-top: 0.25mm solid var(--line);
    break-inside: avoid;
  }
}
