/* Author: Qim */
/* Blog: https://ichochy.com */
/* Email: Qim.it@icloud.com */
/* FileName: iReader:style.css */
/* Update: 2026/8/13 */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
}

:root {
  color-scheme: light;
  --font-sans: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Space Grotesk", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --ink-1: #141414;
  --ink-2: #3d3d3d;
  --ink-3: #6b6f76;
  --paper-1: #f7f3ee;
  --paper-2: #efe9e2;
  --paper-3: #e6dfd6;

  --accent-1: #e04e39;
  --accent-2: #f28f3b;
  --accent-3: rgba(224, 78, 57, 0.18);
  --accent-strong: rgba(224, 78, 57, 0.35);
  --teal: #1f8a7a;
  --blue-accent: #3b82f6;

  --glass: rgba(255, 255, 255, 0.78);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --surface: rgba(255, 255, 255, 0.56);
  --border: rgba(20, 20, 20, 0.1);
  --border-strong: rgba(20, 20, 20, 0.18);

  --shadow-sm: 0 10px 24px rgba(18, 18, 18, 0.08);
  --shadow-md: 0 24px 50px rgba(18, 18, 18, 0.14);
  --shadow-xl: 0 40px 80px rgba(18, 18, 18, 0.2);

  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --control-h: 34px;

  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 20px;
  --space-5: 24px;
  --space-6: 32px;

  --scroll-thumb: rgba(122, 115, 104, 0.5);
  --scroll-thumb-hover: rgba(122, 115, 104, 0.75);
}

body.dark-theme {
  color-scheme: dark;
  --ink-1: #f7f4f0;
  --ink-2: #d2cbc4;
  --ink-3: #a9a39c;
  --paper-1: #0f1317;
  --paper-2: #141a20;
  --paper-3: #1a2128;

  --accent-1: #ff6b4a;
  --accent-2: #f7a348;
  --accent-3: rgba(255, 107, 74, 0.2);
  --accent-strong: rgba(255, 107, 74, 0.4);
  --teal: #3ad8c1;
  --blue-accent: #60a5fa;

  --glass: rgba(20, 26, 32, 0.88);
  --glass-strong: rgba(20, 26, 32, 0.96);
  --surface: rgba(20, 26, 32, 0.55);
  --border: rgba(247, 244, 240, 0.12);
  --border-strong: rgba(247, 244, 240, 0.2);

  --shadow-sm: 0 12px 28px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 28px 60px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 46px 90px rgba(0, 0, 0, 0.52);

  --scroll-thumb: rgba(166, 159, 150, 0.42);
  --scroll-thumb-hover: rgba(200, 193, 184, 0.7);
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink-1);
  line-height: 1.5;
  letter-spacing: -0.01em;
  background:
    radial-gradient(circle at 12% 8%, rgba(224, 78, 57, 0.14), transparent 40%),
    radial-gradient(circle at 88% 12%, rgba(31, 138, 122, 0.18), transparent 45%),
    linear-gradient(180deg, var(--paper-1) 0%, var(--paper-2) 100%);
  background-color: var(--paper-1);
  transition: background-color 0.35s ease, color 0.35s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

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

button:focus-visible,
select:focus-visible,
a:focus-visible,
.unit-item:focus-visible,
.lyric-line:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
}

#app {
  max-width: 1440px;
  margin: 0 auto;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 68px;
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--glass-strong);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  animation: riseIn 0.5s ease both;
  flex-shrink: 0;
}

.header-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.header-title-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 32px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.subtitle {
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.status-pill:hover {
  border-color: var(--accent-1);
  color: var(--ink-1);
  background: var(--accent-3);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--paper-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  position: relative;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--accent-3);
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle svg {
  position: absolute;
  color: var(--ink-1);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.sun-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.moon-icon {
  opacity: 0;
  transform: rotate(180deg) scale(0.5);
}

body.dark-theme .sun-icon {
  opacity: 0;
  transform: rotate(-180deg) scale(0.5);
}

body.dark-theme .moon-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.container {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.unit-list {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  animation: riseIn 0.5s ease both;
  animation-delay: 0.04s;
}

.desktop-only {
  display: flex;
}

.unit-list h2 {
  color: var(--ink-3);
  margin: 0;
  text-align: center;
  font-size: 20px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  flex-shrink: 0;
}

#unitListContainer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.unit-item {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
  min-width: 0;
  border: 1px solid transparent;
}

.unit-item:hover {
  background: rgba(224, 78, 57, 0.08);
}

.unit-item.active {
  background: var(--accent-3);
  border-color: var(--accent-strong);
}

.unit-item h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-item.active h3 {
  color: var(--accent-1);
}

.unit-practice-badge {
  display: inline-flex;
  margin-top: 5px;
  padding: 3px 8px;
  border: 1px solid var(--accent-strong);
  border-radius: 999px;
  color: var(--accent-1);
  background: var(--accent-3);
  font-size: 10px;
  font-family: var(--font-mono);
}

.player-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.player-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  animation: riseIn 0.5s ease both;
  animation-delay: 0.06s;
}

.book-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  width: 100%;
  height: 64px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.book-cover-wrap {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(224, 78, 57, 0.12), transparent 70%),
    var(--paper-3);
  flex-shrink: 0;
  overflow: hidden;
}

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

.book-cover:not([src]) {
  display: none;
}

.book-meta {
  flex: 1;
  min-width: 0;
}

.book-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-hint {
  margin-top: 1px;
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-select-wrap,
.unit-select-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
}

.book-select-wrap {
  flex: 0 1 240px;
  gap: 6px;
  margin-left: auto;
  padding: 2px 4px 2px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper-2);
}

.select-label {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: var(--ink-3);
}

.unit-select-wrap {
  flex: 1 1 auto;
}

.control-panel {
  margin: 6px 8px 0;
  padding: 6px 8px 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  flex-shrink: 0;
}

.navigation-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn,
.loop-toggle-btn,
.toggle-translation-btn,
.speed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-h);
  border: 1px solid var(--border);
  background: var(--paper-3);
  color: var(--ink-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.nav-btn,
.loop-toggle-btn,
.toggle-translation-btn {
  width: var(--control-h);
  min-width: var(--control-h);
  padding: 0;
  border-radius: var(--radius-sm);
}

.nav-btn:hover,
.loop-toggle-btn:hover,
.toggle-translation-btn:hover,
.speed-btn:hover {
  background: var(--accent-3);
  border-color: var(--accent-1);
  color: var(--accent-1);
  transform: translateY(-1px);
}

.nav-btn:active,
.loop-toggle-btn:active,
.toggle-translation-btn:active,
.speed-btn:active {
  transform: scale(0.96);
}

.nav-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  background: var(--paper-2);
  color: var(--ink-3);
}

.unit-select,
.book-select {
  height: var(--control-h);
  padding: 0 34px 0 10px;
  background-color: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-1);
  outline: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background-color 0.22s ease;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23636f76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.book-select {
  min-width: 0;
  max-width: none;
  width: 100%;
  height: 32px;
  font-size: 13px;
  border: none;
  background-color: transparent;
}

.unit-select {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-select:hover,
.unit-select:focus,
.book-select:hover,
.book-select:focus {
  border-color: var(--accent-1);
}

.unit-select:focus,
.book-select-wrap:focus-within {
  box-shadow: 0 0 0 3px var(--accent-3);
}

.book-select:focus {
  border-color: transparent;
  box-shadow: none;
}

.audio-player {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.audio-mode-hint {
  color: var(--ink-3);
  font-size: 11px;
  white-space: nowrap;
}

.audio-player[data-mode="tts"] .progress-container,
.audio-player[data-mode="tts"] .speed-btn {
  display: none;
}

.audio-player[data-mode="none"] {
  display: none;
}

#audioPlayer {
  display: none;
}

.play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-1);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 10px 20px var(--accent-strong);
}

.play-btn:disabled {
  background: #b8bec8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.75;
  transform: none;
}

body.dark-theme .play-btn:disabled {
  background: #4b5563;
}

.play-btn:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
}

.play-btn:disabled:hover,
.play-btn:disabled:active {
  background: #b8bec8;
  transform: none;
}

.play-btn:active {
  transform: scale(0.95);
}

.play-btn svg {
  color: #ffffff;
  position: absolute;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.play-icon {
  opacity: 1;
  transform: scale(1);
}

.pause-icon {
  opacity: 0;
  transform: scale(0.5);
}

.play-btn.playing .play-icon {
  opacity: 0;
  transform: scale(0.5);
}

.play-btn.playing .pause-icon {
  opacity: 1;
  transform: scale(1);
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.time-display {
  flex-shrink: 0;
  min-width: 2.4em;
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  white-space: nowrap;
}

#currentTime {
  text-align: right;
}

#duration {
  text-align: left;
}

.progress-bar {
  --progress: 0%;
  position: relative;
  flex: 1;
  min-width: 0;
  height: 6px;
  background: rgba(120, 110, 100, 0.24);
  border-radius: 999px;
  cursor: grab;
  transition: height 0.2s ease, box-shadow 0.2s ease;
}

.progress-bar:hover {
  height: 8px;
}

.progress-bar.dragging {
  height: 10px;
  cursor: grabbing;
  box-shadow: 0 0 0 6px rgba(120, 110, 100, 0.16);
}

.progress-fill {
  position: absolute;
  inset: 0;
  width: var(--progress);
  background: linear-gradient(90deg, var(--accent-1) 0%, var(--accent-2) 100%);
  border-radius: inherit;
  transition: width 0.1s ease;
  pointer-events: none;
}

.progress-handle {
  position: absolute;
  top: 50%;
  left: var(--progress);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent-2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.progress-bar:hover .progress-handle,
.progress-bar.dragging .progress-handle {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.speed-btn {
  width: 52px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-1);
  font-family: var(--font-mono);
}

.speed-btn.active {
  background: var(--accent-1);
  color: #ffffff;
  border-color: var(--accent-1);
  box-shadow: 0 8px 16px var(--accent-strong);
}

.loop-toggle-btn.list {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: #ffffff;
  box-shadow: 0 8px 16px var(--accent-strong);
}

.loop-toggle-btn.list:hover {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: #ffffff;
}

.loop-toggle-btn.book {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(139, 92, 246, 0.35);
}

.loop-toggle-btn.book:hover {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #ffffff;
}

.loop-toggle-btn.one {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(31, 138, 122, 0.35);
}

.loop-toggle-btn.one:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.loop-toggle-btn.click {
  background: var(--blue-accent);
  border-color: var(--blue-accent);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(59, 130, 246, 0.35);
}

.loop-toggle-btn.click:hover {
  background: var(--blue-accent);
  border-color: var(--blue-accent);
  color: #ffffff;
}

/* 控制 5 种模式对应的独立图标显示 */
.loop-toggle-btn svg {
  display: none;
}

.loop-toggle-btn:not(.click):not(.one):not(.list):not(.book) .loop-icon-off {
  display: inline-block;
}

.loop-toggle-btn.click .loop-icon-click {
  display: inline-block;
}

.loop-toggle-btn.one .loop-icon-one {
  display: inline-block;
}

.loop-toggle-btn.list .loop-icon-list {
  display: inline-block;
}

.loop-toggle-btn.book .loop-icon-book {
  display: inline-block;
}

.toggle-translation-btn {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.lyrics-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px 12px;
  overscroll-behavior: contain;
}

.lyrics-display {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.practice-reference-notice {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--accent-strong);
  border-radius: var(--radius-sm);
  background: var(--accent-3);
  color: var(--ink-1);
  font-size: 12px;
  line-height: 1.55;
}

body.english-translation .lyric-translation {
  display: none;
}

body.english-translation .lyric-text {
  font-size: 20px;
}

body.chinese-translation .lyric-text {
  display: block;
}

body.chinese-translation .lyric-translation {
  font-size: 15px;
  color: var(--ink-1);
  font-weight: 600;
  line-height: 1.5;
}

.lyric-translation-missing {
  color: var(--ink-3) !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  font-style: italic;
}

body.chinese-translation .lyric-line.active .lyric-translation {
  color: var(--accent-1);
}

body.blur-translation .lyric-translation,
body.blur-translation .lyric-text {
  filter: blur(4px);
  opacity: 0.6;
}

body.blur-translation .lyric-line:hover .lyric-translation,
body.blur-translation .lyric-line:hover .lyric-text {
  filter: none;
  opacity: 1;
}

.placeholder {
  text-align: center;
  color: var(--ink-3);
  font-size: 15px;
  padding: 64px 20px;
  font-weight: 500;
}

.lyric-line {
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  background: transparent;
  border: 1px solid transparent;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.lyric-line:hover {
  background: rgba(224, 78, 57, 0.08);
}

.lyric-line.active {
  background: var(--accent-3);
  border-color: var(--accent-strong);
}

.lyric-text {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.4;
  font-weight: 650;
  color: var(--ink-1);
  letter-spacing: -0.018em;
}

.lyric-line.active .lyric-text {
  color: var(--accent-1);
}

.lyric-translation {
  font-size: 13px;
  line-height: 1.4;
  margin-top: 3px;
  color: var(--ink-2);
  font-weight: 500;
}

.lyric-line.active .lyric-translation {
  color: var(--ink-1);
  opacity: 0.86;
}

.lyric-speak {
  float: right;
  min-height: 26px;
  margin: 2px 0 0 8px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--paper-2);
  color: var(--ink-3);
  cursor: pointer;
  font-size: 11px;
  opacity: 0;
  transition: opacity .2s ease, color .2s ease, border-color .2s ease;
}

.lyric-line:hover .lyric-speak,
.lyric-line:focus-within .lyric-speak {
  opacity: 1;
}

.lyric-speak:hover {
  color: var(--accent-1);
  border-color: var(--accent-1);
}

.like-and-support {
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
  padding: 18px 8px 8px;
  font-family: var(--font-mono);
}

.support-btn {
  margin-top: 8px;
  height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--paper-3);
  color: var(--ink-1);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.support-btn:hover {
  background: var(--accent-3);
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.support-btn:active {
  transform: scale(0.98);
}

.support-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 10, 12, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.support-modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.support-modal-card {
  position: relative;
  width: min(92vw, 360px);
  border-radius: 20px;
  background: var(--glass-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 24px 20px 20px;
  text-align: center;
}

.support-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.support-close-btn:hover {
  color: var(--ink-1);
  border-color: var(--accent-1);
}

.support-modal-card h3 {
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--ink-1);
  font-family: var(--font-display);
}

.support-text {
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.7;
}

.support-text h6 {
  color: var(--ink-3);
}

.support-lead {
  color: var(--ink-1);
  font-weight: 600;
}

.support-text p:last-child {
  margin-bottom: 0;
}

.support-qr {
  margin: 12px auto;
  display: block;
  width: min(62vw, 220px);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.like-and-support a,
.footer a {
  color: var(--ink-2);
  text-decoration: none;
}

.footer a:hover {
  color: var(--ink-1);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  flex-shrink: 0;
  padding: 2px 0 0;
}

html,
body,
#app,
.lyrics-container,
.unit-list {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

body::-webkit-scrollbar,
#app::-webkit-scrollbar,
.lyrics-container::-webkit-scrollbar,
.unit-list::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

body::-webkit-scrollbar-track,
#app::-webkit-scrollbar-track,
.lyrics-container::-webkit-scrollbar-track,
.unit-list::-webkit-scrollbar-track {
  background: transparent;
}

body::-webkit-scrollbar-thumb,
#app::-webkit-scrollbar-thumb,
.lyrics-container::-webkit-scrollbar-thumb,
.unit-list::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
}

body::-webkit-scrollbar-thumb:hover,
#app::-webkit-scrollbar-thumb:hover,
.lyrics-container::-webkit-scrollbar-thumb:hover,
.unit-list::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

@media (max-width: 1068px) {
  #app {
    padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
      calc(6px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }

  .container {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 10px;
  }

  .book-select-wrap {
    flex-basis: 240px;
  }
}

@media (max-width: 768px) {
  :root {
    --control-h: 32px;
  }

  #app {
    height: 100dvh;
    min-height: 100dvh;
    padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right))
      calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
    gap: 6px;
    overflow: hidden;
  }

  .container {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .desktop-only {
    display: none;
  }

  .header-logo {
    display: none;
  }

  .app-header {
    padding: 4px 10px;
    border-radius: 14px;
    min-height: 56px;
  }

  .app-header h1 {
    font-size: 18px;
  }

  .subtitle {
    font-size: 10px;
  }

  .theme-toggle {
    width: 32px;
    height: 32px;
  }

  .status-pill {
    height: 30px;
    padding: 0 10px;
  }

  .player-section,
  .unit-list {
    border-radius: 14px;
  }

  .book-info {
    padding: 6px 8px;
    gap: 8px;
    height: 48px;
  }

  .book-cover-wrap {
    width: 38px;
    height: 38px;
    border-radius: 8px;
  }

  .book-name {
    font-size: 13px;
  }

  .book-hint {
    font-size: 10px;
  }

  .book-select-wrap {
    flex: 0 1 auto;
    min-width: 0;
    margin-left: 0;
    padding: 1px 2px;
  }

  .select-label {
    display: none;
  }

  .book-select {
    flex: 1;
    min-width: 0;
    max-width: none;
    width: 100%;
    height: 30px;
    font-size: 12px;
    padding-right: 26px;
  }

  .control-panel {
    margin: 6px 6px 0;
    padding: 6px 6px 6px;
    border-radius: 12px;
  }

  .navigation-buttons {
    gap: 4px;
  }

  .audio-player {
    gap: 6px;
    margin-top: 6px;
  }

  .play-btn {
    width: 32px;
    height: 32px;
  }

  .play-btn svg {
    width: 18px;
    height: 18px;
  }

  .speed-btn {
    width: 48px;
    font-size: 12px;
  }

  .time-display {
    font-size: 11px;
    min-width: 2.2em;
  }

  .unit-select,
  .book-select {
    font-size: 13px;
    background-position: right 10px center;
  }

  .lyrics-container {
    padding: 6px 8px 10px;
    -webkit-overflow-scrolling: touch;
  }

  .lyric-line {
    padding: 4px 8px;
    border-radius: 10px;
  }

  .lyric-text {
    font-size: 16px;
  }

  .lyric-translation {
    font-size: 12px;
  }

  .placeholder {
    padding: 48px 16px;
    font-size: 14px;
  }

  .support-modal-card {
    width: min(94vw, 340px);
    padding: 20px 16px 16px;
    border-radius: 16px;
  }

  .footer {
    gap: 4px 10px;
    font-size: 11px;
  }
}




/* Local profile gate */
#authGate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(224, 78, 57, .16), transparent 38%),
    radial-gradient(circle at 90% 90%, rgba(31, 138, 122, .2), transparent 42%),
    var(--paper-1);
}
#authGate.is-hidden { display: none; }
#app.is-logged-out { display: none; }
.auth-card {
  width: min(100%, 430px);
  padding: clamp(24px, 6vw, 44px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--glass-strong);
  box-shadow: var(--shadow-xl);
  text-align: center;
}
.auth-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-1), var(--teal));
  color: #fff;
  font: 700 30px var(--font-display);
}
.auth-card h2 { margin: 8px 0; font: 700 30px var(--font-display); letter-spacing: -.05em; }
.auth-intro { margin: 0 0 24px; color: var(--ink-3); font-size: 13px; }
.auth-field { display: grid; gap: 7px; margin-top: 13px; text-align: left; }
.auth-field span { color: var(--ink-2); font-size: 12px; font-weight: 700; }
.auth-field input { width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--border); border-radius: 10px; outline: 0; background: var(--paper-2); color: var(--ink-1); }
.auth-field input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px var(--accent-3); }
.auth-submit { width: 100%; margin-top: 18px; }
.auth-switch { margin-top: 18px; border: 0; background: transparent; color: var(--accent-1); cursor: pointer; font-size: 12px; }
.auth-note { margin: 20px 0 0; color: var(--ink-3); font-size: 11px; line-height: 1.6; }
.auth-message { min-height: 18px; margin: 10px 0 -2px; color: var(--ink-3); font-size: 12px; }
.auth-message[data-type="error"] { color: var(--accent-1); }
.auth-message[data-type="busy"] { color: var(--teal); }
.user-chip { max-width: 120px; overflow: hidden; padding: 6px 10px; border-radius: 999px; background: var(--accent-3); color: var(--accent-1); font: 700 11px var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { height: 34px; padding: 0 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--paper-3); color: var(--ink-2); cursor: pointer; font-size: 11px; }
.logout-btn:hover { border-color: var(--accent-1); color: var(--accent-1); }


.workspace-nav {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--glass);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.workspace-tab {
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, transform .2s ease;
}

.workspace-tab:hover { color: var(--ink-1); transform: translateY(-1px); }
.workspace-tab.active { background: var(--ink-1); color: var(--paper-1); }

.view-panel { display: none; min-height: 0; }
.view-panel.active { display: flex; }
.container.view-panel.active { display: grid; }
.content-view,
.dashboard-view {
  flex: 1;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding: clamp(18px, 3vw, 34px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--glass);
  box-shadow: var(--shadow-sm);
}
.dashboard-view { animation: riseIn .4s ease both; }

.dashboard-hero,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.dashboard-hero {
  padding: clamp(20px, 4vw, 42px);
  border-radius: var(--radius-lg);
  color: #fff;
  background: linear-gradient(120deg, #17221f 0%, #23685d 55%, #e04e39 140%);
  box-shadow: var(--shadow-md);
}
.dashboard-hero h2, .panel-heading h2 { margin: 5px 0 6px; font-family: var(--font-display); font-size: clamp(25px, 4vw, 42px); line-height: 1.05; letter-spacing: -.05em; }
.dashboard-hero p, .panel-heading p { margin: 0; color: inherit; opacity: .72; }
.panel-heading p { color: var(--ink-3); }
.eyebrow { display: block; color: var(--accent-2); font: 700 10px var(--font-mono); letter-spacing: .16em; }
.dashboard-hero .eyebrow { color: #f8ba79; }

.primary-action, .ghost-action, .complete-action, .text-action {
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font: 700 13px var(--font-sans);
  transition: transform .2s ease, background-color .2s ease, border-color .2s ease;
}
.primary-action { display: inline-flex; align-items: center; justify-content: center; gap: 14px; min-height: 42px; padding: 0 18px; background: var(--accent-1); color: #fff; box-shadow: 0 8px 20px rgba(224, 78, 57, .2); }
.dashboard-hero .primary-action { align-self: flex-end; background: #fff; color: #18302c; }
.primary-action:hover, .ghost-action:hover, .complete-action:hover { transform: translateY(-2px); }
.ghost-action { min-height: 38px; padding: 0 15px; border-color: var(--border); background: var(--paper-2); color: var(--ink-2); }
.complete-action { width: 100%; min-height: 44px; background: var(--teal); color: #fff; }
.text-action { padding: 4px 8px; background: transparent; color: var(--accent-1); }

.dashboard-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-card { padding: 17px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.stat-card strong { display: block; font: 700 25px var(--font-display); letter-spacing: -.04em; }
.stat-card strong small { color: var(--ink-3); font-size: 14px; }
.stat-card span, .section-heading { color: var(--ink-3); font-size: 12px; }
.dashboard-progress { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.section-heading { display: flex; justify-content: space-between; margin-bottom: 15px; font-weight: 700; }
.book-progress-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; }
.book-progress-item > div:first-child { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: 13px; }
.book-progress-item span { color: var(--ink-3); font-size: 12px; }
.mini-progress, .review-progress { height: 6px; overflow: hidden; border-radius: 99px; background: var(--paper-3); }
.mini-progress i, .review-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--accent-1)); }
.dashboard-tools { display: flex; align-items: center; justify-content: space-between; color: var(--ink-3); font-size: 12px; }
.dashboard-tools div { display: flex; gap: 3px; }

.vocab-toolbar { display: flex; gap: 8px; align-items: center; }
.search-box { display: flex; flex: 1; align-items: center; gap: 8px; min-height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink-3); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink-1); }
.vocab-toolbar select { height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--paper-2); color: var(--ink-1); }
.vocab-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; overflow: auto; padding: 2px; }
.vocab-card { padding: 15px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.vocab-word { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vocab-word strong { font: 700 20px var(--font-display); }
.vocab-word span, .count-badge { padding: 4px 8px; border-radius: 99px; background: var(--accent-3); color: var(--accent-1); font: 700 10px var(--font-mono); }
.vocab-card p { min-height: 38px; margin: 10px 0; color: var(--ink-3); font-size: 12px; }
.vocab-actions { display: flex; justify-content: space-between; gap: 8px; }
.vocab-actions button { min-height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--paper-2); color: var(--ink-2); cursor: pointer; font-size: 12px; }
.vocab-actions .saved { border-color: var(--accent-1); color: var(--accent-1); background: var(--accent-3); }

.review-progress { margin: -4px 0 2px; }
.review-card { display: flex; flex: 1; min-height: 260px; flex-direction: column; align-items: center; justify-content: center; gap: 13px; padding: 30px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: radial-gradient(circle at 50% 0, var(--accent-3), transparent 52%), var(--surface); text-align: center; }
.review-label, .rating-actions > span { color: var(--ink-3); font: 700 10px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; }
.review-card > strong { font: 700 clamp(36px, 8vw, 72px) var(--font-display); letter-spacing: -.06em; }
.review-card p { max-width: 420px; margin: 0; color: var(--ink-3); }
.review-card-actions { display: flex; gap: 8px; margin-top: 15px; }
.rating-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.rating-actions > div { display: flex; gap: 6px; }
.rating-actions button { min-width: 76px; min-height: 42px; border: 1px solid var(--border); border-radius: 9px; background: var(--paper-2); color: var(--ink-2); cursor: pointer; font-weight: 700; }
.rating-actions button:hover { border-color: var(--accent-1); color: var(--accent-1); }
.rating-actions small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 10px; font-weight: 400; }
.review-complete { display: flex; min-height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.review-complete h2 { margin: 0; font: 700 32px var(--font-display); }
.review-complete p { max-width: 400px; color: var(--ink-3); }
.review-mark { display: grid; width: 68px; height: 68px; place-items: center; border-radius: 50%; background: var(--teal); color: #fff; font-size: 34px; }
.empty-state { display: grid; min-height: 180px; place-content: center; gap: 8px; color: var(--ink-3); text-align: center; }
.empty-state strong { color: var(--ink-1); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lesson-meta { margin: 4px 0 0; color: var(--ink-3); font-size: 11px; line-height: 1.5; }
.voice-backend-wrap, .voice-select-wrap { display: inline-flex; align-items: center; max-width: 180px; }
.voice-backend-wrap select, .voice-select-wrap select { max-width: 180px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--paper-2); color: var(--ink-2); font-size: 11px; }
.test-voice-btn { width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--paper-2); color: var(--ink-2); cursor: pointer; }
.test-voice-btn:hover, .voice-backend-wrap select:focus, .voice-select-wrap select:focus { border-color: var(--accent-1); outline: 0; }
.vocab-result-note { margin: 10px 0; color: var(--ink-3); font-size: 12px; }
.vocab-reference { display: block; color: var(--ink-3); font-size: 11px; line-height: 1.5; }
.lyrics-display > .empty-state { min-height: 240px; padding: 24px; }

@media (max-width: 768px) {
  .voice-backend-wrap, .voice-select-wrap { flex: 1 1 140px; max-width: none; }
  .voice-backend-wrap select, .voice-select-wrap select { width: 100%; max-width: none; }
  .test-voice-btn { flex: 0 0 32px; }

  .workspace-nav { overflow-x: auto; }
  .workspace-tab { flex: 0 0 auto; padding: 0 13px; font-size: 12px; }
  .content-view, .dashboard-view { padding: 14px; border-radius: 14px; }
  .dashboard-hero, .panel-heading, .dashboard-tools, .rating-actions { flex-direction: column; }
  .dashboard-hero .primary-action { align-self: stretch; }
  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
  .book-progress-grid { grid-template-columns: 1fr; }
  .vocab-toolbar { flex-wrap: wrap; }
  .search-box { flex-basis: 100%; }
  .vocab-toolbar select, .vocab-toolbar .ghost-action { flex: 1; }
  .rating-actions { align-items: stretch; }
  .rating-actions > div { display: grid; grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
