/* Author: Qim */
/* Blog: https://ichochy.com */
/* Email: Qim.it@icloud.com */
/* FileName: iReader:style.css */
/* Update: 2026/2/22 */

/* 说明：原项目引入 Google Fonts（国内被墙，会拖慢/阻塞首屏），
   已移除，改用系统字体栈（--font-sans / --font-display / --font-mono 已配置回退）。 */

* {
  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);
  --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: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --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);
  --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;
}

img {
  display: block;
  max-width: 100%;
}

#app {
  max-width: 1560px;
  margin: 0 auto;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: calc(5px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right))
    calc(5px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-xl);
  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.6s ease both;
}

.header-content {
  flex: 1;
  min-width: 0;
}

.header-book-select {
  display: flex;
  align-items: center;
  min-width: 0;
}

.header-book-select .book-select {
  min-width: 220px;
}

.app-header h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 58px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.02;
}

.subtitle {
  color: var(--ink-2);
  font-size: clamp(12px, 1.3vw, 18px);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.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: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  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(260px, 340px) 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: var(--space-3);
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  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-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  animation: riseIn 0.6s ease both;
  animation-delay: 0.05s;
}

.desktop-only {
  display: block;
}

.unit-list h2 {
  color: var(--ink-2);
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 10px 20px;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  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: 6px;
  width: 100%;
  padding: 10px 14px;
  min-height: 0;
  height: auto;
  padding-bottom: 18px;
}

.unit-item {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
  border: 1px solid transparent;
  min-width: 0;
  border: 1px solid var(--border);
}

.unit-item:hover {
  background: rgba(224, 78, 57, 0.08);
}

.unit-item.active {
  background: var(--accent-3);
  border-color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--accent-strong);
}

.unit-item h3 {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 4px;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-item.active h3 {
  color: var(--accent-1);
}

.player-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 0;
  height: 100%;
}

.player-column .player-section {
  flex: 1;
  gap: 5px;
}

.player-column .book-select-group {
  margin-bottom: 0;
}

.player-section {
  box-shadow: var(--shadow-md);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: riseIn 0.6s ease both;
  animation-delay: 0.08s;
}

.book-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  padding: 5px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 247, 235, 0.78));
  box-shadow: var(--shadow-sm);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

body.dark-theme .book-info {
  background: linear-gradient(135deg, rgba(28, 35, 42, 0.92), rgba(23, 30, 36, 0.88));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.book-cover {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  flex-shrink: 0;
}

.book-cover:hover {
  box-shadow: var(--shadow-md);
}

.unit-info {
  min-width: 0;
  display: flex;
  align-items: center;
  flex: 1;
}

.book-select-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-right: auto;
  margin-bottom: 0;
  border-radius: 18px;
  border: 1px solid var(--border);
}

.unit-title-group {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  gap: 8px;
  flex-wrap: wrap;
}

.book-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.unit-title-group label {
  display: flex;
  width: auto;
  margin: 0;
}

.book-select-title {
  min-width: 45px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: var(--ink-2);
}

.book-select {
  min-width: 200px;
  height: 34px;
  font-size: 13px;
}

.book-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
  line-height: 1.2;
}

.book-level {
  color: var(--ink-2);
  font-size: 13px;
  font-family: var(--font-mono);
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(120, 110, 100, 0.1);
  border: 1px solid rgba(120, 110, 100, 0.14);
  white-space: nowrap;
}

.control-panel {
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.4));
}

body.dark-theme .control-panel {
  background: linear-gradient(180deg, rgba(26, 33, 40, 0.92), rgba(18, 24, 30, 0.78));
}

.navigation-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 38px;
  padding: 0 12px;
  background: var(--paper-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-1);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.nav-btn:hover {
  background: var(--accent-3);
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.nav-btn:active {
  transform: scale(0.96);
}

.nav-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  background: var(--paper-2);
}

.nav-btn svg {
  color: var(--ink-2);
  transition: color 0.2s ease;
}

.nav-btn:hover svg {
  color: var(--accent-1);
}

.unit-select,
.book-select {
  height: 42px;
  padding: 0 38px 0 12px;
  background: 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 14px center;
}

.book-info > label {
  display: flex;
  align-items: center;
  margin-left: auto;
  width: min(100%, 220px);
}

.unit-select:hover,
.unit-select:focus,
.book-select:hover,
.book-select:focus {
  border-color: var(--accent-1);
}

.unit-select:focus,
.book-select:focus {
  box-shadow: 0 0 0 3px var(--accent-3);
}

.audio-player {
  margin-top: 2px;
}

#audioPlayer {
  display: none;
}

.custom-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.play-btn {
  width: 42px;
  height: 42px;
  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 12px 24px var(--accent-strong);
}

.play-btn:disabled {
  background: #b8bec8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.75;
  transform: none;
}

.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 {
  height: 8px;
  margin: 0px 5px;
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.progress-bar {
  --progress: 0%;
  position: relative;
  height: 6px;
  background: rgba(120, 110, 100, 0.24);
  border-radius: 999px;
  cursor: grab;
  transition: height 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.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: 54px;
  height: 36px;
  border-radius: 11px;
  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;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 620;
  color: var(--ink-1);
  font-family: var(--font-mono);
}

.speed-btn:hover {
  background: var(--accent-3);
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.speed-btn:active {
  transform: scale(0.97);
}

.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 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-3);
  color: var(--ink-2);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.loop-toggle-btn:hover {
  background: var(--accent-3);
  border-color: var(--accent-1);
  color: var(--accent-1);
  transform: translateY(-1px);
}

.loop-toggle-btn:active {
  transform: scale(0.97);
}

.loop-toggle-btn.active {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: #ffffff;
  box-shadow: 0 8px 16px var(--accent-strong);
}

.loop-toggle-btn.sentence {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(31, 138, 122, 0.35);
}

.loop-toggle-btn.sentence:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
  transform: translateY(-1px);
}

.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;
  transform: translateY(-1px);
}

/* 默认显示循环图标，隐藏单句图标 */
.loop-toggle-btn .repeat-one-icon {
  display: none;
}
.loop-toggle-btn .loop-icon {
  display: inline-block;
}

/* sentence 模式：显示单句图标，隐藏循环图标 */
.loop-toggle-btn.sentence .loop-icon {
  display: none;
}
.loop-toggle-btn.sentence .repeat-one-icon {
  display: inline-block;
}

/* click 模式：显示单句图标，隐藏循环图标 */
.loop-toggle-btn.click .loop-icon {
  display: none;
}
.loop-toggle-btn.click .repeat-one-icon {
  display: inline-block;
}

.lyrics-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.3));
  padding: 8px;
}

body.dark-theme .lyrics-container {
  background: linear-gradient(180deg, rgba(23, 30, 37, 0.86), rgba(17, 23, 29, 0.7));
}

.lyrics-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-translation-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.toggle-translation-btn:hover {
  background: var(--accent-3);
  border-color: var(--accent-1);
  color: var(--ink-1);
  transform: translateY(-1px);
}

.toggle-translation-btn:active {
  transform: scale(0.98);
}

body.english-translation .lyric-translation {
  display: none;
}

body.english-translation .lyric-text {
  font-size: 20px;
}

body.chinese-translation .lyric-text {
  display: none;
}

body.chinese-translation .lyric-translation {
  font-size: 18px;
  color: var(--ink-1);
  font-weight: 600;
  line-height: 1.5;
}

body.chinese-translation .lyric-line.active .lyric-translation {
  color: var(--accent-1);
  font-weight: 650;
}

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: 17px;
  padding: 74px 20px;
  font-weight: 500;
}

.lyric-line {
  padding: 5px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  background: transparent;
  border: 1px solid var(--border);
  word-wrap: break-word;
  overflow-wrap: break-word;
  position: relative;
  overflow: hidden;
}

.lyric-line:hover {
  background: rgba(224, 78, 57, 0.08);
  border-color: var(--border);
}



.lyric-line.active {
  background: var(--accent-3);
  border-color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--accent-strong);
}


@keyframes lyricPulse {
  0% {
    transform: translateY(6px);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.lyric-text {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.35;
  font-weight: 650;
  color: var(--ink-1);
  letter-spacing: -0.018em;
}

.lyric-line.active .lyric-text {
  color: var(--accent-1);
}

.lyric-translation {
  font-size: 12px;
  line-height: 1.35;
  margin-top: 4px;
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: -0.012em;
}

.lyric-line.active .lyric-translation {
  color: var(--ink-1);
  opacity: 0.86;
}

.like-and-support {
  font-size: 12px;
  color: var(--ink-2);
  text-align: center;
  padding: 10px 8px 6px;
  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: 20px 20px 18px;
  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);
}

.confirm-card {
  width: min(92vw, 380px);
  text-align: center;
}

.confirm-message {
  margin: 14px 0 18px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
  word-break: break-word;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.summary-card {
  width: min(94vw, 720px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  text-align: left;
}

.summary-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.summary-card-head h3 {
  font-size: 20px;
}

.summary-content {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--paper-2);
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink-1);
  word-break: break-word;
}

.summary-content h4 {
  font-size: 15px;
  color: var(--accent-1);
  margin: 16px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.summary-content h4:first-child {
  margin-top: 0;
}

.summary-content p {
  margin: 6px 0;
}

.summary-content ul,
.summary-content ol {
  margin: 6px 0 6px 4px;
  padding-left: 20px;
}

.summary-content li {
  margin: 5px 0;
}

.summary-content strong {
  color: var(--ink-1);
  font-weight: 700;
}

.summary-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--paper-3);
  padding: 1px 6px;
  border-radius: 5px;
}

.summary-loading,
.summary-error {
  padding: 28px 10px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
}

.summary-error {
  color: #dc2626;
  text-align: left;
  word-break: break-word;
}

.summary-card-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.support-text {
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.7;
}

.support-text p {
  margin: 0 0 8px;
}

.support-text p:first-child {
  color: var(--ink-1);
  font-weight: 600;
}

.support-text p:last-child {
  margin-bottom: 0;
}

.support-qr {
  margin-top: 12px;
  margin-bottom: 12px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: min(62vw, 220px);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.support-link {
  margin-top: 10px;
  font-size: 12px;
}

.support-link a {
  color: var(--ink-1);
  font-weight: 600;
  text-decoration: none;
}

.like-and-support a,
.footer a {
  color: var(--ink-2);
  text-decoration: none;
}

.footer {
  text-align: center;
  font-size: 12px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  flex-shrink: 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(5px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
      calc(5px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }

  .container {
    grid-template-columns: 230px 1fr;
    gap: 10px;
  }



  .app-header {
    padding: 10px 18px;
    border-radius: 20px;
  }
}

@media (max-width: 768px) {
  body {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  #app {
    height: 100dvh;
    min-height: 100dvh;
    padding: calc(2px + env(safe-area-inset-top)) calc(5px + env(safe-area-inset-right))
      calc(2px + env(safe-area-inset-bottom)) calc(5px + env(safe-area-inset-left));
    gap: 5px;
    overflow: hidden;
  }

  .container {
    grid-template-columns: 1fr;
    gap: 8px;
    flex: 1;
    min-height: 0;
  }

  .desktop-only {
    display: none;
  }

  .book-select-group {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }

  .book-select {
    flex: 1;
    min-width: 0;
  }

  .app-header {
    padding: 8px 16px;
    border-radius: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .header-actions {
    gap: 8px;
    margin-left: auto;
  }

  .header-book-select {
    order: 3;
    width: 100%;
  }

  .header-book-select .book-select {
    width: 100%;
  }

  .app-header h1 {
    font-size: 24px;
    margin-bottom: 2px;
  }

  .subtitle {
    font-size: 12px;
  }

  .theme-toggle {
    width: 38px;
    height: 38px;
  }

  .player-column .player-section {
    flex: 1;
    min-height: 0;
    gap: 3px;
  }

  .book-info {
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
  }

  .book-cover {
    width: 64px;
    height: 64px;
  }

  .unit-info {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .unit-title-group {
    align-items: flex-start;
    text-align: left;
  }

  .unit-title-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .unit-title-group label,
  .book-info > label {
    width: auto;
  }

  .unit-title-group label {
    padding: 0px 10px;
    max-width: 100%;
    width: auto;
  }

  .book-info > label {
    width: min(34vw, 128px);
    margin-left: auto;
  }

  .book-title-row {
    gap: 4px;
  }

  .book-name {
    font-size: 16px;
    letter-spacing: 0.02em;
  }

  .book-level {
    font-size: 11px;
    padding: 2px 8px;
  }

  .control-panel {
    padding: 8px;
  }

  .navigation-buttons {
    gap: 6px;
    margin-bottom: 6px;
  }

  .nav-btn {
    min-width: 40px;
    height: 36px;
    padding: 0 10px;
  }

  .unit-select,
  .book-select {
    max-width: 100%;
    height: 30px;
    font-size: 12px;
    background-position: right 10px center;
    background-size: 10px 7px;
  }

  .play-mode-btn {
    height: 36px;
    padding: 0 10px;
  }

  .toggle-translation-btn {
    height: 36px;
    font-size: 11px;
  }

  .custom-player {
    padding: 10px;
    gap: 10px;
  }

  .play-btn {
    width: 36px;
    height: 36px;
  }

  .speed-btn {
    width: 48px;
    height: 36px;
    font-size: 12px;
  }

  .time-display {
    font-size: 11px;
  }

  .lyrics-container {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    border-radius: 12px;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .support-modal-card {
    width: min(94vw, 340px);
    padding: 16px 14px 14px;
    border-radius: 14px;
  }

  .support-modal-card h3 {
    font-size: 18px;
  }

  .support-text {
    font-size: 12px;
  }

  .lyric-line {
    padding: 4px 8px;
    border-radius: 10px;
  }

  .lyric-text {
    font-size: 17px;
  }

  .lyric-translation {
    font-size: 12px;
  }
}

@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;
  }
}

/* ==========================================================================
   NCE 沉浸学习扩展样式
   ========================================================================== */

.hidden {
  display: none !important;
}

.app-title-btn {
  appearance: none;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  padding: 0;
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--ink-1);
  transition: color 0.2s ease, transform 0.2s ease;
}

.app-title-btn:hover {
  color: var(--accent-1);
  transform: translateY(-1px);
}

.app-title-btn:active {
  transform: scale(0.99);
}

.header-nav-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

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

.header-nav-btn:active,
.primary-btn:active,
.danger-btn:active,
.nav-btn:active {
  transform: scale(0.96);
}

.primary-btn {
  height: 42px;
  padding: 0 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-1);
  background: var(--accent-1);
  color: #ffffff;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 22px var(--accent-strong);
}

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

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-btn.small,
.nav-btn.small,
.danger-btn.small {
  height: 32px;
  padding: 0 14px;
  font-size: 12px;
  border-radius: 10px;
}

.danger-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.danger-btn:hover {
  background: rgba(220, 38, 38, 0.16);
}

/* ---------- 认证界面 ---------- */

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(circle at 15% 10%, rgba(224, 78, 57, 0.16), transparent 42%),
    radial-gradient(circle at 85% 15%, rgba(31, 138, 122, 0.2), transparent 46%),
    linear-gradient(180deg, var(--paper-1) 0%, var(--paper-2) 100%);
  overflow-y: auto;
}

.auth-card {
  width: min(94vw, 420px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-strong);
  background: var(--glass-strong);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  padding: 32px 28px 26px;
  animation: riseIn 0.5s ease both;
}

.auth-logo {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  color: var(--ink-1);
}

.auth-subtitle {
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
  margin: 8px 0 22px;
  letter-spacing: 0.03em;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--paper-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.auth-tab.active {
  background: var(--accent-1);
  color: #ffffff;
  box-shadow: 0 8px 18px var(--accent-strong);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form label,
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.auth-form input,
.settings-field input {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-2);
  color: var(--ink-1);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

.auth-form input:focus,
.settings-field input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px var(--accent-3);
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.auth-message {
  margin-top: 14px;
  min-height: 20px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.auth-message.error {
  color: #dc2626;
}

.auth-message.success {
  color: var(--teal);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-3);
  font-size: 12px;
  margin: 18px 0 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.demo-mode-btn {
  width: 100%;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.demo-mode-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(31, 138, 122, 0.07);
}

.demo-mode-btn.highlight {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(31, 138, 122, 0.07);
}

.auth-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.6;
}

/* ---------- 用户菜单 ---------- */

.user-menu {
  position: relative;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  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, border-color 0.2s ease, background-color 0.2s ease;
}

.user-menu-btn:hover {
  border-color: var(--accent-1);
  background: var(--accent-3);
}

.user-avatar {
  font-size: 16px;
}

.user-caret {
  font-size: 10px;
  color: var(--ink-3);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  z-index: 900;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  padding: 8px;
  animation: riseIn 0.2s ease both;
}

.user-dropdown-info {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-dropdown-info p {
  font-size: 12px;
  color: var(--ink-3);
  word-break: break-all;
}

.mode-badge {
  align-self: flex-start;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(31, 138, 122, 0.12);
  border: 1px solid rgba(31, 138, 122, 0.35);
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

.mode-badge.supabase {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--blue-accent);
}

.user-dropdown-item {
  width: 100%;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #dc2626;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  padding: 0 10px;
}

.user-dropdown-item:hover {
  background: rgba(220, 38, 38, 0.08);
}

/* ---------- 查词模式开关 ---------- */

.word-lookup-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.word-lookup-toggle:hover {
  background: var(--accent-3);
  border-color: var(--accent-1);
  color: var(--accent-1);
}

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

.word-token {
  cursor: pointer;
  border-radius: 5px;
  padding: 0 1px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.word-token:hover {
  background: var(--accent-3);
  color: var(--accent-1);
}

/* ---------- 课目标题栏 / 回译入口 ---------- */

.lesson-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.lesson-label {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-translate-actions {
  text-align: center;
  padding: 10px 8px 8px;
}

.bt-sentence {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--glass);
  margin-bottom: 8px;
}

.bt-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.bt-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-3);
  color: var(--accent-1);
  font-size: 12px;
  font-weight: 750;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.bt-chinese {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-1);
  font-weight: 550;
}

.bt-input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-2);
  color: var(--ink-1);
  font-size: 14px;
  font-family: var(--font-sans);
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bt-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 138, 122, 0.14);
}

/* ---------- 模块视图通用 ---------- */

.module-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px 8px;
  animation: riseIn 0.35s ease both;
}

.module-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  flex-shrink: 0;
}

.module-header h2 {
  font-family: var(--font-display);
  font-size: clamp(18px, 2.4vw, 26px);
  letter-spacing: -0.02em;
  color: var(--ink-1);
}

.module-subtitle {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

.module-tabs {
  display: flex;
  gap: 6px;
  background: var(--paper-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-left: auto;
}

.module-tab {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.module-tab.active {
  background: var(--accent-1);
  color: #ffffff;
}

.start-quiz-btn {
  margin-left: 10px;
  background: var(--accent-1);
  color: #ffffff;
  box-shadow: 0 8px 16px var(--accent-strong);
}

.start-quiz-btn:hover {
  background: var(--accent-2);
  color: #ffffff;
}

.start-quiz-btn:disabled {
  background: var(--paper-3);
  color: var(--ink-3);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.module-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 8px 0 12px;
}

/* ---------- 生词本 ---------- */

.vocab-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--glass);
  font-size: 13px;
  color: var(--ink-2);
}

.stat-pill b {
  color: var(--accent-1);
  font-size: 16px;
  font-family: var(--font-mono);
}

.vocab-cards {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-content: start;
  padding: 2px 2px 10px;
}

.vocab-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.vocab-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.vocab-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.vocab-word {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-1);
  letter-spacing: -0.02em;
  word-break: break-word;
}

.vocab-meaning {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.5;
  word-break: break-word;
}

.vocab-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

.vocab-hint {
  font-size: 12px;
  color: var(--teal);
  background: rgba(31, 138, 122, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
}

.vocab-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 6px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.learning {
  background: rgba(224, 78, 57, 0.1);
  color: var(--accent-1);
  border: 1px solid rgba(224, 78, 57, 0.3);
}

.status-badge.review {
  background: rgba(31, 138, 122, 0.1);
  color: var(--teal);
  border: 1px solid rgba(31, 138, 122, 0.3);
}

.status-badge.eliminated {
  background: rgba(120, 110, 100, 0.12);
  color: var(--ink-3);
  border: 1px solid var(--border);
}

.status-badge.spelling {
  background: rgba(59, 130, 246, 0.12);
  color: var(--blue-accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.vocab-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.vocab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--glass);
}

.vocab-row.eliminated {
  opacity: 0.72;
  filter: grayscale(0.35);
}

.vocab-row.eliminated .vocab-word {
  font-size: 15px;
  color: var(--ink-3);
}

.vocab-row-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.vocab-row.eliminated .vocab-meaning {
  font-size: 12px;
}

.vocab-date {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

/* ---------- 测验 ---------- */

.quiz-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.quiz-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
}

.quiz-progress {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-1);
  background: var(--accent-3);
  padding: 6px 14px;
  border-radius: 999px;
}

.quiz-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 10px;
}

.quiz-question-card {
  width: min(96%, 560px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 28px;
  text-align: center;
}

.quiz-type-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.quiz-word {
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 44px);
  margin: 14px 0 4px;
  color: var(--accent-1);
  letter-spacing: -0.02em;
}

.quiz-meaning {
  font-size: 20px;
  color: var(--ink-1);
  margin: 18px 0 20px;
  line-height: 1.5;
}

.quiz-prompt {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 18px;
}

.quiz-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.quiz-choice {
  min-height: 52px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-2);
  color: var(--ink-1);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.quiz-choice:hover:not(:disabled) {
  border-color: var(--accent-1);
  background: var(--accent-3);
  transform: translateY(-1px);
}

.quiz-choice.correct {
  background: rgba(31, 138, 122, 0.14);
  border-color: var(--teal);
  color: var(--teal);
}

.quiz-choice.wrong {
  background: rgba(220, 38, 38, 0.12);
  border-color: #dc2626;
  color: #dc2626;
}

.quiz-spelling {
  display: flex;
  gap: 10px;
  margin: 8px 0 14px;
}

.quiz-input {
  flex: 1;
  height: 46px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-2);
  color: var(--ink-1);
  font-size: 18px;
  font-family: var(--font-mono);
  outline: none;
  text-align: center;
  letter-spacing: 0.04em;
}

.quiz-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 138, 122, 0.14);
}

.quiz-feedback {
  min-height: 24px;
  margin-top: 14px;
  font-size: 15px;
  font-weight: 650;
}

.quiz-feedback.correct {
  color: var(--teal);
}

.quiz-feedback.wrong {
  color: #dc2626;
}

.quiz-next {
  margin-top: 14px;
}

.quiz-complete {
  text-align: center;
  padding: 40px 20px;
}

.quiz-complete h3 {
  font-family: var(--font-display);
  font-size: 28px;
  margin-bottom: 18px;
}

.quiz-complete-stats {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 30px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--glass);
  margin-bottom: 22px;
  font-size: 15px;
}

.quiz-complete-stats b {
  color: var(--accent-1);
}

/* ---------- 回译列表 / 详情 ---------- */

.translation-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
}

.translation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.translation-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.translation-item-main h3 {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink-1);
  margin-bottom: 4px;
}

.translation-item-main p {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

.translation-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-corrected {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--blue-accent);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 2px;
}

.translation-detail {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-bottom: 12px;
}

.detail-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--glass);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.detail-panel h3 {
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--paper-2);
  flex-shrink: 0;
}

.detail-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sentence-pair {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--glass-strong);
}

.sentence-pair-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.sentence-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.sentence-chinese {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-1);
}

.sentence-user {
  font-size: 13px;
  line-height: 1.5;
  color: var(--teal);
  background: rgba(31, 138, 122, 0.06);
  border-radius: 8px;
  padding: 8px 10px;
}

.sentence-standard summary {
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  margin-top: 6px;
}

.sentence-standard p {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 6px;
  line-height: 1.5;
}

.feedback-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--glass-strong);
  font-size: 13px;
  line-height: 1.6;
}

.feedback-card.correct,
.feedback-card.perfect {
  border-color: rgba(31, 138, 122, 0.35);
  background: rgba(31, 138, 122, 0.07);
  color: var(--teal);
  font-weight: 600;
}

.feedback-card h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--accent-1);
}

.feedback-field {
  margin-bottom: 7px;
  color: var(--ink-2);
  word-break: break-word;
}

.feedback-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 750;
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-right: 8px;
  min-width: 56px;
}

.feedback-summary {
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid var(--accent-strong);
  background: var(--accent-3);
  color: var(--ink-1);
  font-weight: 650;
  font-size: 14px;
  line-height: 1.6;
}

.feedback-perfect {
  color: var(--teal);
  font-weight: 700;
}

/* ---------- 设置 ---------- */

.settings-card {
  max-width: 680px;
  width: 100%;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-self: flex-start;
  margin: 0 auto;
}

.settings-card h3 {
  font-size: 15px;
  color: var(--ink-1);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-top: 8px;
}

.settings-field small {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
  line-height: 1.5;
}

.input-with-action {
  display: flex;
  gap: 8px;
}

.input-with-action input {
  flex: 1;
  min-width: 0;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-note {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
}

.settings-note code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--paper-3);
  padding: 1px 5px;
  border-radius: 5px;
}

.ai-test-result {
  font-size: 12px;
  line-height: 1.65;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-2);
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 22px;
}

.ai-test-result.success {
  color: var(--teal);
  border-color: rgba(31, 138, 122, 0.35);
  background: rgba(31, 138, 122, 0.07);
}

.ai-test-result.error {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.07);
}

/* ---------- 查词悬浮窗 ---------- */

.word-popup,
.word-phrases-popup {
  position: fixed;
  z-index: 1500;
  width: min(320px, calc(100vw - 24px));
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--glass-strong);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  animation: riseIn 0.2s ease both;
}

.word-popup-card,
.word-phrases-card {
  padding: 18px;
}

.word-popup-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.word-popup-head h3 {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--accent-1);
  letter-spacing: -0.02em;
}

.word-phonetic {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-3);
}

.word-meaning {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-1);
  word-break: break-word;
}

.word-pos {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 7px;
  background: var(--accent-3);
  color: var(--accent-1);
  font-size: 12px;
  font-weight: 700;
}

.word-phrases-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--teal);
}

.word-manual {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-2);
}

.word-manual input {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-2);
  color: var(--ink-1);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.word-manual input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px var(--accent-3);
}

.word-popup-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.word-popup-loading,
.word-popup-error {
  padding: 18px;
  font-size: 14px;
  color: var(--ink-2);
}

.word-popup-error {
  color: #dc2626;
}

.word-popup-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.word-phrases-card h4 {
  font-size: 14px;
  color: var(--ink-1);
  margin-bottom: 12px;
}

.aux-section {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.aux-section:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.aux-base-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.phrase-item {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.phrase-item:last-child {
  border-bottom: none;
}

.phrase-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal);
}

.phrase-meaning {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 3px;
}

.phrase-example {
  font-size: 12px;
  color: var(--ink-3);
  font-style: italic;
  margin-top: 4px;
  line-height: 1.5;
}

/* ---------- Toast ---------- */

.toast-container {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(92vw, 520px);
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--glass-strong);
  color: var(--ink-1);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: riseIn 0.25s ease both;
  text-align: center;
}

.toast.success {
  border-color: rgba(31, 138, 122, 0.4);
  color: var(--teal);
}

.toast.error {
  border-color: rgba(220, 38, 38, 0.4);
  color: #dc2626;
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ---------- 移动端适配 ---------- */

@media (max-width: 768px) {
  .app-title-btn {
    font-size: 20px;
  }

  .header-nav-btn {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .header-actions {
    gap: 6px;
  }

  .user-menu-btn {
    height: 32px;
    font-size: 12px;
    padding: 0 8px;
  }

  .user-name-text,
  .user-caret {
    display: none;
  }

  .module-view {
    padding: 0 2px 6px;
  }

  .module-header {
    padding: 12px 14px;
  }

  .translation-detail {
    grid-template-columns: 1fr;
  }

  .quiz-question-card {
    padding: 20px 16px;
  }

  .quiz-choices {
    grid-template-columns: 1fr;
  }

  .vocab-cards {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 18px 16px;
  }

  .word-lookup-toggle {
    font-size: 11px;
    padding: 0 9px;
  }

  .start-quiz-btn {
    margin-left: 6px;
    padding: 0 10px;
    font-size: 12px;
  }
}
