:root {
  color-scheme: light;
  --paper: #f3f5f2;
  --surface: #ffffff;
  --ink: #202421;
  --ink-soft: #4f5751;
  --muted: #7a837c;
  --line: #dfe4df;
  --line-strong: #c8d0c9;
  --vermilion: #d84a3d;
  --vermilion-dark: #ad352c;
  --teal: #187c73;
  --teal-soft: #dcefeb;
  --sun: #e0a72d;
  --sun-soft: #fff2cf;
  --danger-soft: #fbe3df;
  --shadow: 0 18px 50px rgba(31, 39, 33, 0.12);
  --topbar-height: 72px;
  --sidebar-width: 232px;
  --panel-width: 310px;
  font-family: "Avenir Next", Avenir, "Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

button:not(:disabled),
a {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(24, 124, 115, 0.24);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-frame {
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr auto;
  align-items: center;
  min-height: var(--topbar-height);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 100%;
  padding: 0 20px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  flex: 0 0 auto;
  border-radius: 7px;
  box-shadow: 0 6px 14px rgba(216, 74, 61, 0.18);
}

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

.brand-copy strong {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-copy small {
  color: var(--muted);
  font-size: 10px;
}

.today-label {
  justify-self: start;
  padding-left: 28px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  padding-right: 22px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:not(:disabled):active {
  transform: translateY(1px);
}

.button:disabled {
  cursor: default;
  opacity: 0.45;
}

.button-primary {
  background: var(--vermilion);
  color: #fff;
  box-shadow: 0 8px 18px rgba(216, 74, 61, 0.18);
}

.button-primary:not(:disabled):hover {
  background: var(--vermilion-dark);
  box-shadow: 0 10px 24px rgba(216, 74, 61, 0.24);
}

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

.button-secondary:not(:disabled):hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.button-apk {
  display: none;
  border-color: rgba(24, 124, 115, 0.26);
  background: var(--teal-soft);
  color: #12675f;
  text-decoration: none;
}

.android-phone-web .button-apk {
  display: inline-flex;
}

.button-apk:hover {
  border-color: var(--teal);
  background: #cce8e2;
}

.button-apk small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.android-mark {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 6px 6px 8px 8px;
  background: var(--teal);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.mobile-nav-button {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(430px, 1fr) var(--panel-width);
  min-height: calc(100vh - var(--topbar-height));
  min-height: calc(100dvh - var(--topbar-height));
}

.lesson-sidebar,
.practice-panel {
  background: var(--surface);
}

.lesson-sidebar {
  position: sticky;
  top: var(--topbar-height);
  display: flex;
  flex-direction: column;
  align-self: start;
  height: calc(100vh - var(--topbar-height));
  height: calc(100dvh - var(--topbar-height));
  border-right: 1px solid var(--line);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.primary-nav {
  display: grid;
  gap: 4px;
  padding: 22px 14px 18px;
}

.handbook-import {
  padding: 0 14px 16px;
}

.button-handbook {
  width: 100%;
  height: 52px;
  justify-content: flex-start;
  gap: 10px;
  padding: 6px 10px;
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 18px rgba(24, 124, 115, 0.16);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.button-handbook:not(:disabled):hover {
  border-color: #12675f;
  background: #12675f;
  box-shadow: 0 10px 22px rgba(24, 124, 115, 0.22);
}

.button-handbook:disabled {
  cursor: progress;
  opacity: 1;
}

.button-handbook[data-state="loading"] {
  border-color: var(--ink-soft);
  background: var(--ink-soft);
  box-shadow: none;
}

.button-handbook[data-state="success"] {
  border-color: #276b50;
  background: #276b50;
}

.button-handbook[data-state="error"] {
  border-color: var(--vermilion);
  background: #fff;
  color: var(--vermilion-dark);
  box-shadow: none;
}

.n4-mark {
  position: relative;
  display: grid;
  width: 31px;
  aspect-ratio: 1;
  flex: 0 0 31px;
  place-items: center;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.button-handbook[data-state="error"] .n4-mark {
  background: var(--danger-soft);
  color: var(--vermilion-dark);
}

.button-handbook[data-state="loading"] .n4-mark {
  color: transparent;
}

.button-handbook[data-state="loading"] .n4-mark::after {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(79, 87, 81, 0.22);
  border-top-color: var(--ink-soft);
  border-radius: 50%;
  content: "";
  animation: handbook-spin 700ms linear infinite;
}

#n4-import-label {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
}

#n4-import-status {
  margin: 7px 3px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

#n4-import-status:empty {
  display: none;
}

.button-handbook[data-state="error"] + #n4-import-status {
  color: var(--vermilion-dark);
}

.nav-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item:hover {
  background: var(--paper);
}

.nav-item.is-active {
  background: #fbeae7;
  color: var(--vermilion-dark);
  font-weight: 700;
}

.nav-symbol {
  display: grid;
  width: 31px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--vermilion-dark);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 14px;
  font-weight: 800;
}

.weak-symbol {
  background: var(--sun-soft);
  color: #926514;
}

.nav-count {
  min-width: 24px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.sidebar-heading {
  display: flex;
  justify-content: space-between;
  padding: 18px 24px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.lesson-list {
  display: grid;
  padding: 0 14px 20px;
}

.lesson-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  min-width: 0;
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.lesson-item:hover .lesson-name,
.lesson-item.is-active .lesson-name {
  color: var(--vermilion-dark);
}

.lesson-name {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.lesson-percent {
  align-self: center;
  color: var(--teal);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 18px 24px 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.storage-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px var(--teal-soft);
}

.study-main {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  height: calc(100dvh - var(--topbar-height));
  min-width: 0;
  flex-direction: column;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(32, 36, 33, 0.045) 0.7px, transparent 0.7px);
  background-size: 13px 13px;
  overflow: hidden;
}

.study-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  min-height: 92px;
  padding: 22px clamp(24px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 242, 0.9);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--vermilion);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.study-toolbar h1,
.panel-heading h2,
.preview-heading h3,
.dialog-header h2,
.empty-view h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.queue-summary {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.study-stage {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
}

.session-progress {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: rgba(32, 36, 33, 0.08);
}

.session-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--teal);
  transition: width 300ms ease;
}

.word-view {
  display: grid;
  width: min(100%, 720px);
  min-height: 0;
  padding: 20px 48px 24px;
  grid-template-rows: auto minmax(180px, 1fr) auto auto auto;
}

.word-context {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 24px;
  color: var(--muted);
  font-size: 11px;
}

.context-divider {
  width: 18px;
  height: 1px;
  background: var(--line-strong);
}

.word-display {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 28px 0 20px;
  text-align: center;
}

.pronunciation-mark {
  position: absolute;
  z-index: 0;
  opacity: 0.055;
  transform: rotate(-7deg) scale(1.8);
  user-select: none;
}

.part-of-speech,
.japanese-word,
.reading,
.meaning,
.example {
  position: relative;
  z-index: 1;
  max-width: 100%;
}

.part-of-speech {
  min-height: 18px;
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
}

.japanese-word {
  overflow-wrap: anywhere;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", serif;
  font-size: 70px;
  font-weight: 600;
  line-height: 1.2;
}

.word-play-target {
  width: auto;
  margin-inline: auto;
  padding: 0 10px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.word-play-target:hover,
.word-play-target:focus-visible {
  background: var(--vermilion-soft);
  outline: 2px solid var(--vermilion);
  outline-offset: 3px;
}

.japanese-word.is-long {
  font-size: 50px;
}

.japanese-word.is-very-long {
  font-size: 37px;
}

.reading {
  margin-top: 10px;
  color: var(--vermilion);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 23px;
  line-height: 1.4;
}

.dictionary-form {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
  padding: 6px 12px;
  border: 1px solid rgba(25, 105, 100, 0.22);
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--ink-soft);
  font-size: 13px;
}

.dictionary-form[hidden] {
  display: none;
}

.dictionary-form span {
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.dictionary-form strong {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 16px;
}

.dictionary-form small {
  color: var(--muted);
  font-size: 11px;
}

.meaning {
  margin-top: 17px;
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 650;
}

.example {
  min-height: 23px;
  margin-top: 16px;
  color: var(--muted);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 13px;
  line-height: 1.7;
}

.playback-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 78px;
}

.autoplay-control {
  display: grid;
  justify-items: center;
  gap: 7px;
  margin: 2px 0 8px;
}

.autoplay-button {
  min-width: 250px;
  min-height: 46px;
  justify-content: center;
  border: 1px solid rgba(25, 105, 100, 0.32);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(25, 105, 100, 0.1);
}

.autoplay-button:not(:disabled):hover,
.autoplay-button.is-active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.autoplay-icon {
  font-size: 19px;
}

.autoplay-button.is-active .autoplay-icon {
  animation: autoplay-spin 1.2s linear infinite;
}

.autoplay-control small {
  color: var(--muted);
  font-size: 10px;
}

@keyframes autoplay-spin {
  to { transform: rotate(360deg); }
}

.round-button {
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.round-button:not(:disabled):hover {
  transform: translateY(-2px);
}

.round-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.small-round {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-soft);
  font-size: 27px;
}

#stop-button {
  font-size: 12px;
}

.play-button {
  width: 72px;
  height: 72px;
  background: var(--vermilion);
  color: #fff;
  box-shadow: 0 13px 30px rgba(216, 74, 61, 0.28);
  font-size: 24px;
}

.play-button:hover {
  background: var(--vermilion-dark);
  box-shadow: 0 16px 34px rgba(216, 74, 61, 0.34);
}

.play-button.is-speaking {
  animation: speaking-pulse 1.4s ease-in-out infinite;
}

.play-icon {
  margin-left: 4px;
}

.sound-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  color: var(--muted);
  font-size: 11px;
}

.sound-bars {
  display: flex;
  height: 14px;
  align-items: center;
  gap: 2px;
}

.sound-bars i {
  width: 2px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
}

.is-speaking .sound-bars i,
.sound-status.is-speaking .sound-bars i {
  background: var(--teal);
  animation: sound-bar 800ms ease-in-out infinite alternate;
}

.sound-status.is-speaking .sound-bars i:nth-child(2) { animation-delay: 120ms; }
.sound-status.is-speaking .sound-bars i:nth-child(3) { animation-delay: 240ms; }
.sound-status.is-speaking .sound-bars i:nth-child(4) { animation-delay: 360ms; }

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

.rating-button {
  display: grid;
  min-width: 0;
  min-height: 62px;
  align-content: center;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.rating-button:hover {
  transform: translateY(-1px);
}

.rating-button strong {
  font-size: 13px;
}

.rating-button span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rating-again:hover {
  border-color: var(--vermilion);
  background: var(--danger-soft);
}

.rating-hard:hover {
  border-color: var(--sun);
  background: var(--sun-soft);
}

.rating-good:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.empty-view {
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 60px 24px;
  text-align: center;
}

.empty-view img {
  margin-bottom: 24px;
  border-radius: 8px;
  opacity: 0.94;
}

.empty-view p:not(.eyebrow) {
  max-width: 400px;
  margin: 12px 0 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.practice-panel {
  position: sticky;
  top: var(--topbar-height);
  align-self: start;
  height: calc(100vh - var(--topbar-height));
  height: calc(100dvh - var(--topbar-height));
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.practice-panel section {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.panel-heading,
.preview-heading,
.dialog-header,
.textarea-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h2 {
  font-size: 15px;
}

.panel-heading > span,
.preview-heading > span {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.progress-figure {
  display: grid;
  grid-template-columns: 116px 1fr;
  align-items: center;
  gap: 18px;
  margin-top: 20px;
}

.progress-ring {
  display: grid;
  width: 116px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--vermilion) 0deg, var(--line) 0deg);
  transition: background 300ms ease;
}

.progress-ring::before {
  grid-area: 1 / 1;
  width: 88px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  content: "";
}

.progress-ring div {
  z-index: 1;
  display: grid;
  grid-area: 1 / 1;
  justify-items: center;
}

.progress-ring strong {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
}

.progress-ring span {
  color: var(--muted);
  font-size: 9px;
}

.overview-metrics {
  display: grid;
  gap: 10px;
  margin: 0;
}

.overview-metrics div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.overview-metrics dt {
  color: var(--muted);
  font-size: 11px;
}

.overview-metrics dd {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.field-label,
.setting-row > label,
.inline-setting > span {
  display: block;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.voice-settings .field-label {
  margin-top: 18px;
  margin-bottom: 7px;
}

select,
input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

select,
input[type="text"] {
  min-height: 40px;
  padding: 0 11px;
  font-size: 12px;
}

.field-note {
  min-height: 28px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.field-note.is-warning {
  color: var(--vermilion-dark);
}

.setting-row {
  margin-top: 18px;
}

.setting-row label {
  display: flex;
  justify-content: space-between;
}

.setting-row output {
  color: var(--teal);
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 14px 0 2px;
  accent-color: var(--teal);
}

.inline-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.segmented-control.style-control {
  grid-template-columns: repeat(2, 54px);
}

.segmented-control button {
  height: 31px;
  border-right: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.is-active {
  background: var(--ink);
  color: #fff;
}

.toggle-setting {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.toggle-setting input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--line-strong);
  transition: background 160ms ease;
}

.toggle-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(32, 36, 33, 0.22);
  content: "";
  transition: transform 160ms ease;
}

.toggle-setting input:checked + .toggle-track {
  background: var(--teal);
}

.toggle-setting input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.toggle-setting input:focus-visible + .toggle-track {
  outline: 3px solid rgba(24, 124, 115, 0.24);
  outline-offset: 2px;
}

.compact-heading h2 {
  font-size: 13px;
}

.queue-list {
  display: grid;
  gap: 0;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.queue-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.queue-item:last-child {
  border-bottom: 0;
}

.queue-index {
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.queue-word {
  overflow: hidden;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-reading {
  max-width: 80px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-empty {
  padding: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.data-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
}

.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.danger-text {
  color: var(--vermilion-dark);
}

.import-dialog {
  width: min(980px, calc(100vw - 40px));
  max-height: min(790px, calc(100vh - 40px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.import-dialog::backdrop {
  background: rgba(25, 31, 27, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-shell {
  display: grid;
  max-height: inherit;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.dialog-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.dialog-content {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow: auto;
}

.import-fields,
.import-preview {
  min-width: 0;
  padding: 24px;
}

.import-fields {
  border-right: 1px solid var(--line);
}

.import-fields > .field-label {
  margin-bottom: 7px;
}

.file-drop {
  position: relative;
  display: grid;
  min-height: 112px;
  margin: 16px 0;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  text-align: center;
}

.file-drop.is-dragging {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.file-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-drop strong {
  font-size: 12px;
}

.file-drop > span:not(.file-symbol) {
  max-width: calc(100% - 24px);
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-symbol {
  color: var(--vermilion);
  font-size: 25px;
  line-height: 1;
}

.textarea-heading {
  margin-bottom: 7px;
}

textarea {
  min-height: 180px;
  padding: 12px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.7;
}

.preview-heading h3 {
  font-size: 15px;
}

.preview-table-wrap {
  max-height: 340px;
  margin-top: 18px;
  border: 1px solid var(--line);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  font-size: 10px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--paper);
  color: var(--muted);
  font-weight: 800;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.preview-placeholder td {
  height: 110px;
  color: var(--muted);
  text-align: center;
}

.import-errors {
  display: grid;
  gap: 5px;
  margin: 14px 0 0;
  padding: 0;
  color: var(--vermilion-dark);
  font-size: 10px;
  list-style: none;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}

.dialog-footer > span {
  color: var(--muted);
  font-size: 10px;
}

.dialog-footer > div {
  display: flex;
  gap: 8px;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 16px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@keyframes speaking-pulse {
  0%, 100% { box-shadow: 0 13px 30px rgba(216, 74, 61, 0.28), 0 0 0 0 rgba(216, 74, 61, 0.16); }
  50% { box-shadow: 0 13px 30px rgba(216, 74, 61, 0.24), 0 0 0 13px rgba(216, 74, 61, 0); }
}

@keyframes sound-bar {
  from { height: 4px; }
  to { height: 13px; }
}

@keyframes handbook-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1180px) {
  :root {
    --sidebar-width: 210px;
    --panel-width: 280px;
  }

  .practice-panel section {
    padding-right: 18px;
    padding-left: 18px;
  }

  .progress-figure {
    grid-template-columns: 100px 1fr;
  }

  .progress-ring {
    width: 100px;
  }

  .progress-ring::before {
    width: 76px;
  }

  .japanese-word {
    font-size: 62px;
  }

  .japanese-word.is-long {
    font-size: 45px;
  }

  .japanese-word.is-very-long {
    font-size: 34px;
  }
}

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

  .mobile-nav-button {
    display: inline-grid;
    margin-left: 14px;
  }

  .brand {
    padding-left: 12px;
  }

  .today-label {
    display: none;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .lesson-sidebar {
    position: fixed;
    z-index: 30;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    width: min(300px, 86vw);
    height: auto;
    max-height: calc(100vh - var(--topbar-height));
    max-height: calc(100dvh - var(--topbar-height));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 220ms ease;
    visibility: hidden;
    will-change: transform;
  }

  .lesson-sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  body.sidebar-open {
    position: fixed;
    width: 100%;
    overflow: hidden;
    touch-action: none;
  }

  body.sidebar-open .lesson-sidebar {
    touch-action: pan-y;
  }

  body.sidebar-open::after {
    position: fixed;
    z-index: 25;
    inset: var(--topbar-height) 0 0;
    background: rgba(25, 31, 27, 0.36);
    content: "";
  }

  .word-view {
    padding-right: 30px;
    padding-left: 30px;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 64px;
  }

  .topbar {
    min-height: var(--topbar-height);
  }

  .brand img {
    width: 36px;
    height: 36px;
  }

  .brand-copy strong {
    font-size: 16px;
  }

  .brand-copy small,
  .compact-label span:last-child {
    display: none;
  }

  .topbar-actions {
    gap: 5px;
    padding-right: 10px;
  }

  .topbar-actions .button {
    min-width: 40px;
    padding: 0 10px;
  }

  .button-apk small {
    display: none;
  }

  .workspace {
    display: block;
  }

  .study-main {
    height: auto;
    overflow: visible;
  }

  .study-toolbar {
    min-height: 82px;
    padding: 17px 18px 15px;
  }

  .study-toolbar h1 {
    font-size: 18px;
  }

  .toolbar-actions {
    gap: 8px;
  }

  .queue-summary {
    display: none;
  }

  #continuous-button {
    width: min(100%, 290px);
    min-width: 0;
    padding: 0 16px;
  }

  .study-stage {
    min-height: calc(100vh - 146px);
    min-height: calc(100dvh - 146px);
  }

  .word-view {
    min-height: calc(100vh - 146px);
    min-height: calc(100dvh - 146px);
    padding: 22px 18px 24px;
    grid-template-rows: auto minmax(270px, 1fr) auto auto auto;
  }

  .japanese-word {
    font-size: 52px;
  }

  .japanese-word.is-long {
    font-size: 32px;
  }

  .japanese-word.is-very-long {
    font-size: 27px;
  }

  .word-display {
    padding-top: 20px;
  }

  .example {
    max-width: 92%;
    font-size: 12px;
  }

  .playback-controls {
    gap: 10px;
  }

  .small-round {
    width: 42px;
    height: 42px;
  }

  .play-button {
    width: 64px;
    height: 64px;
  }

  .rating-controls {
    gap: 6px;
  }

  .rating-button {
    min-height: 58px;
    padding: 7px 5px;
  }

  .rating-button span {
    white-space: normal;
  }

  .practice-panel {
    position: static;
    height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
    overflow: visible;
  }

  .practice-panel section {
    padding: 22px 18px;
  }

  .daily-overview,
  .voice-settings {
    max-width: 520px;
    margin: 0 auto;
  }

  .up-next {
    display: none;
  }

  .dialog-content {
    display: block;
  }

  .import-fields {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .dialog-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-footer > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .brand-copy small {
    display: none;
  }

  .topbar-actions .button-secondary {
    display: none;
  }

  .button-apk {
    padding: 0 9px;
  }

  .button-apk .apk-label {
    font-size: 11px;
  }

  .word-view {
    padding-right: 13px;
    padding-left: 13px;
  }

  .word-context {
    max-width: 100%;
    overflow: hidden;
  }

  #word-lesson {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .rating-button strong {
    font-size: 12px;
  }

  .rating-button span {
    font-size: 9px;
  }

  .import-dialog {
    width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .import-fields,
  .import-preview,
  .dialog-header,
  .dialog-footer {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
