:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --paper: #ffffff;
  --accent: #1d4ed8;
}

html.dark {
  color-scheme: dark;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: #1e293b;
  --paper: #0b0d10;
  --accent: #60a5fa;
}

html {
  overflow-x: clip;
  width: 100%;
}

body {
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Noto Sans TC", "Noto Sans JP", "Noto Sans KR", "Noto Sans Thai", sans-serif;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

#view {
  max-width: 100%;
  overflow-x: clip;
}

.overflow-wrap-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: #dbeafe;
  color: #1e3a8a;
}

html.dark ::selection {
  background: #1e3a8a;
  color: #eff6ff;
}

.font-display {
  font-family: "Plus Jakarta Sans", "Noto Sans TC", "Noto Sans JP", "Noto Sans KR", sans-serif;
}

.jp-text {
  font-family: "Noto Sans JP", sans-serif;
}

.zh-text {
  font-family: "Noto Sans SC", "Noto Sans TC", sans-serif;
}

.kr-text {
  font-family: "Noto Sans KR", sans-serif;
}

.thai-text {
  font-family: "Noto Sans Thai", sans-serif;
  line-height: 1.85 !important;
}

.blur-mask {
  filter: blur(7px);
  opacity: 0.45;
  user-select: none;
  transition: filter 0.2s ease, opacity 0.2s ease;
  cursor: pointer;
}

.blur-mask.is-revealed {
  filter: none;
  opacity: 1;
  user-select: auto;
}

@keyframes pulseWave {
  0%,
  100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.speaking {
  animation: pulseWave 0.6s infinite ease-in-out;
}

@keyframes wrongShake {
  0%,
  100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.is-wrong {
  animation: wrongShake 0.28s ease;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.topbar {
  padding-top: env(safe-area-inset-top);
}

.tabbar {
  padding-bottom: env(safe-area-inset-bottom);
  width: 100%;
  max-width: 100%;
  left: 0;
  right: 0;
}

.tabbar .grid {
  width: 100%;
  max-width: 100vw;
}

.tabbar button {
  min-width: 0;
  padding-left: 0.125rem;
  padding-right: 0.125rem;
}

.tabbar button span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet {
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

.lesson-token {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  line-height: inherit;
  white-space: pre-wrap;
}

.script-line {
  border-left: 2px solid var(--line);
  padding: 0.35rem 0 0.35rem 0.75rem;
}

.script-line.is-hot,
.passage-sentence.is-hot {
  border-left-color: var(--accent);
  background: rgba(29, 78, 216, 0.06);
}

.lesson-player {
  bottom: calc(4rem + env(safe-area-inset-bottom));
}

input,
select,
textarea {
  font-size: 16px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
