/* =========================================================
   墨韵 · 古诗词拼音打字
   视觉：宣纸、墨色、朱砂、青玉
   ========================================================= */

:root {
  --bg: #efe6d6;
  --bg-deep: #e7dcc8;
  --paper: #fbf7ed;
  --paper-soft: #f6efe2;
  --paper-raised: #fffdf7;
  --ink: #2a251f;
  --ink-soft: #5e5548;
  --pinyin: #7b6d5a;
  --muted: #948775;
  --faint: #c7baa6;
  --line: rgba(71, 56, 37, 0.13);
  --line-strong: rgba(71, 56, 37, 0.22);
  --accent: #b5442e;
  --accent-deep: #90311f;
  --accent-soft: rgba(181, 68, 46, 0.1);
  --accent-faint: rgba(181, 68, 46, 0.05);
  --jade: #6e8a71;
  --jade-soft: rgba(110, 138, 113, 0.12);
  --gold: #ab8348;
  --shadow: 0 24px 65px rgba(72, 52, 28, 0.12);
  --shadow-soft: 0 12px 34px rgba(72, 52, 28, 0.08);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --kai: "KaiTi", "STKaiti", "Kaiti SC", "KaiTi_GB2312", var(--serif);
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  --radius-lg: 20px;
  --radius-md: 13px;
  --radius-sm: 8px;
}

html[data-theme="dark"] {
  --bg: #17150f;
  --bg-deep: #0f0e0a;
  --paper: #211e17;
  --paper-soft: #28241c;
  --paper-raised: #2d281f;
  --ink: #f0e5d2;
  --ink-soft: #c8b9a1;
  --pinyin: #b8a88f;
  --muted: #92846f;
  --faint: #554d3f;
  --line: rgba(239, 226, 202, 0.1);
  --line-strong: rgba(239, 226, 202, 0.18);
  --accent: #da6a4e;
  --accent-deep: #eb8265;
  --accent-soft: rgba(218, 106, 78, 0.14);
  --accent-faint: rgba(218, 106, 78, 0.07);
  --jade: #8caa8e;
  --jade-soft: rgba(140, 170, 142, 0.12);
  --gold: #c5a066;
  --shadow: 0 24px 65px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 8% -8%, rgba(181, 68, 46, 0.09), transparent 34%),
    radial-gradient(ellipse at 96% 4%, rgba(171, 131, 72, 0.09), transparent 30%),
    radial-gradient(ellipse at 50% 110%, rgba(87, 101, 80, 0.07), transparent 46%),
    linear-gradient(135deg, var(--bg), var(--bg-deep));
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.3s ease;
}

button {
  color: inherit;
  font: inherit;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

::selection {
  color: var(--paper-raised);
  background: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

kbd {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ink-soft);
  background: var(--paper-raised);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
}

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

.grain {
  position: fixed;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image: radial-gradient(rgba(62, 47, 29, 0.24) 0.55px, transparent 0.65px);
  background-size: 4px 4px;
  mix-blend-mode: multiply;
}

html[data-theme="dark"] .grain {
  opacity: 0.12;
  mix-blend-mode: screen;
}

.ambient {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(2px);
}

.ambient-one {
  top: -20vh;
  left: -14vw;
  width: 56vw;
  height: 56vw;
  background: radial-gradient(circle, rgba(181, 68, 46, 0.08), transparent 66%);
}

.ambient-two {
  right: -18vw;
  bottom: -28vh;
  width: 62vw;
  height: 62vw;
  background: radial-gradient(circle, rgba(110, 138, 113, 0.08), transparent 68%);
}

.app-shell {
  position: relative;
  z-index: 2;
  width: min(1460px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px clamp(18px, 3vw, 42px) 26px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 54px;
  margin-bottom: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-seal {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border-radius: 7px;
  color: #fbf3e3;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), transparent 45%),
    var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(255, 249, 237, 0.25),
    inset 0 0 0 4px rgba(255, 249, 237, 0.08),
    0 7px 16px rgba(129, 44, 28, 0.2);
  font-family: var(--kai);
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
  transform: rotate(-2deg);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-family: var(--kai);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1.1;
}

.brand-sub {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.26em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
}

.topbar-quote {
  margin-right: 14px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.17em;
}

.icon-button,
.random-button {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 48%, transparent);
  box-shadow: 0 3px 10px rgba(72, 52, 28, 0.03);
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon-button:hover,
.random-button:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: var(--paper);
}

.icon-button:active,
.random-button:active {
  transform: translateY(1px);
}

.icon-sound-off,
.icon-sun {
  display: none;
}

#soundButton[aria-pressed="false"] .icon-sound-on {
  display: none;
}

#soundButton[aria-pressed="false"] .icon-sound-off {
  display: block;
}

html[data-theme="dark"] .icon-moon {
  display: none;
}

html[data-theme="dark"] .icon-sun {
  display: block;
}

.random-button {
  display: inline-flex;
  height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 15px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* ---------- 主体布局 ---------- */

.workspace {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

/* ---------- 左侧诗卷 ---------- */

.sidebar {
  position: sticky;
  top: 22px;
  display: flex;
  max-height: calc(100vh - 140px);
  flex-direction: column;
  padding: 22px 13px 15px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--paper-raised) 58%, transparent), transparent 58%),
    color-mix(in srgb, var(--paper) 84%, transparent);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.library-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 9px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.24em;
}

.library-heading h1 {
  margin: 0;
  font-family: var(--kai);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.15;
}

.library-count {
  margin-bottom: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  margin: 16px 6px 9px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg) 45%, transparent);
}

.filter {
  padding: 6px 0;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  line-height: 1.3;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.filter:hover {
  color: var(--ink);
}

.filter.active {
  color: var(--ink);
  background: var(--paper-raised);
  box-shadow: 0 2px 7px rgba(72, 52, 28, 0.07);
}

.poet-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 6px 12px;
}

.poet-filter-label {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.select-shell {
  position: relative;
  min-width: 0;
  flex: 1;
}

.select-shell::after {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 5px;
  height: 5px;
  border-right: 1.2px solid var(--muted);
  border-bottom: 1.2px solid var(--muted);
  content: "";
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
}

.poet-select {
  width: 100%;
  height: 30px;
  padding: 0 26px 0 10px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--paper-raised) 88%, transparent);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.poet-select:hover {
  border-color: var(--line-strong);
  background: var(--paper-raised);
}

.poet-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.poem-list {
  min-height: 180px;
  flex: 1;
  overflow-y: auto;
  padding: 1px 4px 5px;
  scrollbar-color: var(--faint) transparent;
  scrollbar-width: thin;
}

.poem-list::-webkit-scrollbar {
  width: 5px;
}

.poem-list::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background: var(--faint);
}

.poem-item {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
  padding: 10px 10px 10px 12px;
  border: 0;
  border-radius: 9px;
  text-align: left;
  background: transparent;
  transition: background 0.17s ease, color 0.17s ease;
}

.poem-item::before {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 2px;
  height: 18px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: translateY(-50%) scaleY(0.5);
  transition: opacity 0.17s ease, transform 0.17s ease;
}

.poem-item:hover {
  background: var(--accent-faint);
}

.poem-item.active {
  background: var(--accent-soft);
}

.poem-item.active::before {
  opacity: 1;
  transform: translateY(-50%) scaleY(1);
}

.poem-item-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.poem-item-title {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poem-item.active .poem-item-title {
  color: var(--accent-deep);
}

.poem-item-author {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poem-item-side {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.item-length {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
}

.item-check {
  display: grid;
  width: 13px;
  height: 13px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper-raised);
  background: var(--jade);
  font-size: 8px;
  line-height: 1;
}

.item-diff {
  display: flex;
  gap: 2px;
}

.item-diff i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--faint);
}

.item-diff i.on {
  background: var(--gold);
}

.poem-empty {
  padding: 28px 12px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 12px;
  text-align: center;
}

.library-footer {
  margin-top: 9px;
  padding: 13px 10px 1px;
  border-top: 1px solid var(--line);
}

.record-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.record-line + .record-line {
  margin-top: 4px;
}

.record-line strong {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.record-line em {
  color: var(--faint);
  font-size: 9px;
  font-style: normal;
}

.record-note {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.04em;
}

/* ---------- 右侧练习卡 ---------- */

.practice-column {
  min-width: 0;
}

.practice-card {
  position: relative;
  overflow: hidden;
  min-height: 690px;
  padding: clamp(21px, 2.9vw, 38px) clamp(20px, 3.5vw, 46px) clamp(20px, 2.6vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background-color: var(--paper);
  background-image:
    radial-gradient(130% 90% at 50% -10%, rgba(255, 255, 255, 0.45), transparent 56%),
    repeating-linear-gradient(90deg, rgba(79, 61, 37, 0.018) 0 1px, transparent 1px 29px),
    repeating-linear-gradient(0deg, rgba(79, 61, 37, 0.012) 0 1px, transparent 1px 29px);
  box-shadow: var(--shadow);
  transition: background-color 0.35s ease, border-color 0.35s ease;
}

html[data-theme="dark"] .practice-card {
  background-image:
    radial-gradient(130% 90% at 50% -10%, rgba(255, 255, 255, 0.035), transparent 56%),
    repeating-linear-gradient(90deg, rgba(255, 244, 220, 0.012) 0 1px, transparent 1px 29px),
    repeating-linear-gradient(0deg, rgba(255, 244, 220, 0.009) 0 1px, transparent 1px 29px);
}

.paper-ornament {
  position: absolute;
  top: 28px;
  bottom: 28px;
  width: 1px;
  pointer-events: none;
  background: linear-gradient(transparent, var(--line) 13%, var(--line) 87%, transparent);
  opacity: 0.6;
}

.ornament-left {
  left: 15px;
}

.ornament-right {
  right: 15px;
}

.card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.poem-tags {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.1em;
  line-height: 1;
}

.tag-category {
  color: var(--accent-deep);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 15%, transparent);
}

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

.toolbar-text {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.13em;
  white-space: nowrap;
}

.toolbar-dot {
  color: var(--faint);
  font-size: 10px;
}

.difficulty {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.difficulty-dots {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.difficulty-dots i {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--faint);
}

.difficulty-dots i.on {
  background: var(--gold);
}

.text-button {
  display: inline-flex;
  height: 30px;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.text-button .icon {
  width: 13px;
  height: 13px;
}

.text-button:hover {
  color: var(--accent);
  border-color: var(--line);
  background: var(--accent-faint);
}

.poem-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-top: 15px;
}

.poem-heading h2 {
  margin: 0;
  font-family: var(--kai);
  font-size: clamp(34px, 3.7vw, 48px);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.18;
}

.poem-heading h2.title-long {
  font-size: clamp(30px, 3vw, 41px);
  letter-spacing: 0.04em;
}

.poem-author {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.13em;
}

.author-dot {
  margin: 0 6px;
  color: var(--faint);
}

.dynasty-seal {
  display: grid;
  width: 51px;
  height: 51px;
  flex: 0 0 auto;
  margin-top: 3px;
  place-items: center;
  border: 1.5px solid color-mix(in srgb, var(--accent) 72%, transparent);
  border-radius: 6px;
  color: var(--accent);
  background: var(--accent-faint);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--paper) 65%, transparent);
  font-family: var(--kai);
  font-size: 22px;
  line-height: 1;
  opacity: 0.82;
  transform: rotate(2.5deg);
}

.progress-block {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 22px 0 15px;
}

.progress-track {
  position: relative;
  height: 4px;
  flex: 1;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--faint) 45%, transparent);
}

.progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--gold)));
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: width 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-label {
  min-width: 66px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
  white-space: nowrap;
}

/* ---------- 诗词与拼音 ---------- */

.stage-wrap {
  position: relative;
}

.stage-frame {
  position: relative;
}

.stage-fade {
  position: absolute;
  right: 5px;
  left: 1px;
  z-index: 3;
  height: 26px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.stage-fade-top {
  top: 1px;
  border-radius: 13px 13px 0 0;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--paper) 92%, transparent),
    transparent
  );
}

.stage-fade-bottom {
  bottom: 1px;
  border-radius: 0 0 13px 13px;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--paper) 92%, transparent),
    transparent
  );
}

.stage-frame.has-overflow.show-top .stage-fade-top,
.stage-frame.has-overflow.show-bottom .stage-fade-bottom {
  opacity: 1;
}

.stage-watermark {
  position: absolute;
  top: 48%;
  right: 1.5%;
  color: var(--accent);
  font-family: var(--kai);
  font-size: clamp(95px, 10vw, 146px);
  line-height: 1;
  opacity: 0.035;
  pointer-events: none;
  transform: translateY(-50%) rotate(5deg);
  user-select: none;
}

.poem-stage {
  position: relative;
  z-index: 1;
  max-height: 390px;
  min-height: 222px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 19px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--paper-raised) 56%, transparent), transparent 80%),
    color-mix(in srgb, var(--paper-soft) 48%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
  scrollbar-color: var(--faint) transparent;
  scrollbar-width: thin;
  scroll-padding: 22px 0;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.poem-stage::-webkit-scrollbar {
  width: 4px;
}

.poem-stage::-webkit-scrollbar-track {
  background: transparent;
}

.poem-stage::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--faint);
}

html[data-theme="dark"] .poem-stage {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.poem-stage:focus {
  outline: none;
}

.poem-stage:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-faint);
}

.pinyin-poem {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
}

.poem-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 1px 1px;
}

.syllable {
  position: relative;
  display: flex;
  min-width: 52px;
  flex-direction: column;
  align-items: center;
  padding: 3px 3px 2px;
  border-radius: 8px;
  transition: background 0.16s ease, box-shadow 0.16s ease, opacity 0.2s ease;
}

.syllable-pinyin {
  display: flex;
  height: 23px;
  align-items: center;
  justify-content: center;
  color: var(--pinyin);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.015em;
  line-height: 1;
  white-space: nowrap;
}

.py-letter {
  position: relative;
  border-radius: 2px;
  transition: color 0.1s ease, background 0.1s ease;
}

.py-letter.typed {
  color: var(--accent);
  font-weight: 700;
}

.py-letter.upcoming {
  color: var(--pinyin);
}

.py-letter.caret-before {
  background: var(--accent-faint);
}

.py-letter.caret-before::before {
  position: absolute;
  top: 50%;
  left: -1.5px;
  width: 1.5px;
  height: 0.98em;
  border-radius: 1px;
  background: var(--accent);
  content: "";
  transform: translateY(-50%);
  animation: caret-blink 1.05s steps(1, end) infinite;
}

.syllable-hanzi {
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(27px, 2.65vw, 35px);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.34;
  transition: color 0.16s ease, transform 0.16s ease;
}

.syllable.active {
  background: var(--accent-faint);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 45%, transparent);
}

.syllable.active .syllable-hanzi {
  color: var(--accent-deep);
  transform: translateY(-1px);
}

.syllable.done .syllable-hanzi {
  color: var(--ink-soft);
}

.syllable.done .py-letter {
  color: var(--jade);
}

.syllable.done .syllable-pinyin::after {
  width: 2px;
  height: 2px;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--jade);
  content: "";
  opacity: 0.72;
}

.syllable.error {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  animation: shake 0.3s ease;
}

.syllable.error .syllable-hanzi {
  color: var(--accent);
}

.punctuation {
  position: relative;
  align-self: flex-end;
  min-width: 15px;
  padding: 0 1px 6px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1.34;
  opacity: 0.62;
  transition: color 0.2s ease, opacity 0.2s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.punctuation.active {
  color: var(--accent-deep);
  background: var(--accent-faint);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 45%, transparent);
  opacity: 1;
}

.punctuation.done {
  color: var(--jade);
  opacity: 0.55;
}

.punctuation.error {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  opacity: 1;
  animation: shake 0.3s ease;
}

.stage-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.11em;
  transition: color 0.25s ease;
}

.caption-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: soft-pulse 2.2s ease-in-out infinite;
}

.stage-caption.running {
  color: var(--muted);
}

.stage-caption.running .caption-dot {
  background: var(--jade);
}

/* ---------- 实时输入 ---------- */

.live-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 61px;
  margin-top: 15px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper-soft) 62%, transparent);
}

.live-current {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.live-label {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.13em;
}

.live-char {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-family: var(--kai);
  font-size: 25px;
  line-height: 1;
}

.live-pinyin {
  display: flex;
  min-width: 108px;
  align-items: center;
  color: var(--pinyin);
  font-family: var(--mono);
  font-size: clamp(19px, 2.05vw, 24px);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.live-pinyin .py-letter.typed {
  color: var(--accent);
}

.live-pinyin .py-letter.upcoming {
  color: var(--pinyin);
}

.live-pinyin .py-letter.caret-before {
  background: transparent;
}

.live-pinyin .py-letter.caret-before::before {
  left: -2px;
  width: 2px;
  height: 1.02em;
}

.live-pinyin .live-done {
  color: var(--jade);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.live-pinyin .live-punct-text {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.live-pinyin .live-punct-text:first-child {
  margin-right: 5px;
}

.live-pinyin .live-punct-text:last-child {
  margin-left: 5px;
}

.live-pinyin .live-key {
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  border-bottom-width: 2px;
  color: var(--accent);
  background: var(--paper);
  font-size: 15px;
  box-shadow: 0 2px 5px color-mix(in srgb, var(--accent) 8%, transparent);
}

.live-pinyin .live-idle {
  color: var(--faint);
  letter-spacing: 0.24em;
}

.live-side {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
}

.last-key {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.last-key-label {
  white-space: nowrap;
}

.last-key-value {
  min-width: 24px;
  height: 23px;
  border-color: var(--line);
  color: var(--ink-soft);
  background: var(--paper);
  font-size: 11px;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.last-key-value.good {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-faint);
}

.last-key-value.bad {
  color: var(--paper-raised);
  border-color: var(--accent);
  background: var(--accent);
}

.input-tip {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.input-tip kbd {
  min-width: 15px;
  height: 15px;
  font-size: 8px;
}

/* ---------- 数据 ---------- */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--line);
}

.stat {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  padding: 9px 15px 10px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
}

.stat-label {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.stat-value {
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-value small {
  color: var(--faint);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0;
}

/* ---------- 虚拟键盘 ---------- */

.keyboard-block {
  margin-top: 14px;
}

.keyboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.09em;
}

.keyboard-caption {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 9px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--paper-soft) 65%, transparent), transparent),
    color-mix(in srgb, var(--bg) 32%, transparent);
}

.keyboard-row {
  display: flex;
  gap: 5px;
}

.keyboard-row-punctuation {
  margin-top: 1px;
  padding-top: 5px;
  border-top: 1px dashed var(--line);
}

.keyboard-row-label {
  display: inline-flex;
  align-items: center;
  padding-right: 3px;
  color: var(--faint);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.key {
  position: relative;
  display: grid;
  width: clamp(27px, 3vw, 37px);
  height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: var(--paper);
  box-shadow: 0 1px 0 var(--line);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  transition:
    transform 0.06s ease,
    color 0.1s ease,
    background 0.1s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

.key[data-key="v"]::after {
  position: absolute;
  top: 1px;
  right: 3px;
  color: var(--faint);
  content: "ü";
  font-family: var(--sans);
  font-size: 7px;
  line-height: 1;
}

.punct-key {
  display: inline-flex;
  width: 38px;
  height: 23px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--mono);
}

.punct-key .key-main {
  color: var(--ink-soft);
  font-size: 10px;
}

.punct-key .key-sub {
  color: var(--faint);
  font-family: var(--sans);
  font-size: 8px;
}

.punct-key.next .key-main {
  color: var(--accent-deep);
}

.punct-key.next .key-sub {
  color: var(--accent);
}

.key.next {
  color: var(--accent-deep);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--accent-soft);
  box-shadow:
    0 0 0 2px var(--accent-faint),
    0 1px 0 color-mix(in srgb, var(--accent) 30%, transparent);
}

.key.next::before {
  position: absolute;
  bottom: -4px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.key.pressed {
  color: var(--paper-raised);
  border-color: var(--ink);
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--accent-faint);
  transform: translateY(2px);
}

.key.pressed.bad {
  color: #fff8ed;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ---------- 完成弹层 ---------- */

.completion {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}

.completion-veil {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  backdrop-filter: blur(4px);
  animation: veil-in 0.3s ease both;
}

.completion-card {
  position: relative;
  width: min(440px, 100%);
  padding: 27px 32px 25px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(100% 80% at 50% 0, color-mix(in srgb, var(--paper-raised) 70%, transparent), transparent 60%),
    var(--paper);
  box-shadow: 0 28px 80px rgba(25, 18, 9, 0.32);
  text-align: center;
  animation: card-in 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.completion-seal {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  place-items: center;
  border: 1.5px solid var(--accent);
  border-radius: 7px;
  color: var(--accent);
  background: var(--accent-faint);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
  font-family: var(--kai);
  font-size: 29px;
  line-height: 1;
  transform: rotate(-3deg);
}

.completion-card .eyebrow {
  margin-bottom: 3px;
}

.completion-card h3 {
  margin: 0;
  font-family: var(--kai);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.25;
}

.completion-poem {
  margin: 5px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.completion-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 19px 0 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.completion-stats > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-left: 1px solid var(--line);
}

.completion-stats > div:first-child {
  border-left: 0;
}

.completion-stats span {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.completion-stats strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 500;
}

.completion-stats strong small {
  color: var(--faint);
  font-family: var(--sans);
  font-size: 8px;
  font-weight: 400;
}

.completion-best {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.completion-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
}

.primary-button,
.secondary-button {
  height: 37px;
  padding: 0 20px;
  border-radius: 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-button {
  border: 1px solid var(--accent);
  color: #fff8ec;
  background: var(--accent);
  box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 25%, transparent);
}

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

.secondary-button {
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  background: var(--paper);
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.confetti-layer {
  position: absolute;
  z-index: 24;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -14px;
  width: 4px;
  height: 9px;
  border-radius: 1px;
  opacity: 0;
  animation: confetti-fall 2.2s cubic-bezier(0.2, 0.5, 0.4, 1) forwards;
}

.mobile-input {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0.01;
  font-size: 16px;
  pointer-events: none;
}

/* ---------- 页脚和提示 ---------- */

.page-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 8px 0;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.footer-dot {
  opacity: 0.6;
}

.toast {
  position: fixed;
  z-index: 100;
  bottom: 30px;
  left: 50%;
  max-width: calc(100vw - 40px);
  padding: 9px 17px;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 999px;
  color: var(--paper-raised);
  background: var(--ink);
  box-shadow: 0 10px 28px rgba(30, 22, 11, 0.25);
  font-size: 11px;
  letter-spacing: 0.03em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript-message {
  position: fixed;
  z-index: 999;
  right: 20px;
  bottom: 20px;
  left: 20px;
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper);
  text-align: center;
}

/* ---------- 移动端赏读 ---------- */

.mobile-reading,
.mobile-library {
  display: none;
}

@media (max-width: 720px) {
  .workspace {
    display: none;
  }

  .topbar #soundButton,
  .topbar .random-button {
    display: none;
  }

  .mobile-reading {
    display: block;
    padding-bottom: 28px;
    animation: reading-in 0.45s ease both;
  }

  .reading-hero {
    padding: 7px 4px 2px;
  }

  .reading-kicker {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .reading-kicker .eyebrow {
    margin: 0;
  }

  .reading-index {
    color: var(--faint);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.06em;
  }

  .reading-title {
    margin: 10px 0 5px;
    font-family: var(--kai);
    font-size: clamp(36px, 11vw, 44px);
    font-weight: 700;
    letter-spacing: 0.07em;
    line-height: 1.12;
  }

  .reading-title.is-long {
    font-size: clamp(27px, 7.8vw, 31px);
    letter-spacing: 0.04em;
  }

  .reading-byline {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.12em;
  }

  .reading-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 11px;
  }

  .reading-form,
  .reading-theme {
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.05em;
  }

  .reading-theme {
    padding-left: 8px;
    border-left: 1px solid var(--line-strong);
    color: var(--gold);
  }

  .reading-actions {
    display: flex;
    gap: 8px;
    margin-top: 17px;
  }

  .reading-pill {
    height: 35px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    background: color-mix(in srgb, var(--paper) 60%, transparent);
    font-size: 11px;
    letter-spacing: 0.05em;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.16s ease;
  }

  .reading-pill:active {
    transform: translateY(1px);
  }

  .reading-pill[aria-pressed="true"] {
    color: var(--accent-deep);
    border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
    background: var(--accent-soft);
  }

  .reading-pill.speaking {
    color: var(--accent-deep);
    border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
    background: var(--accent-soft);
  }

  .reading-pill-primary {
    margin-left: auto;
    color: #fff8ec;
    border-color: var(--accent);
    background: var(--accent);
  }

  .reading-paper {
    position: relative;
    overflow: hidden;
    margin-top: 15px;
    padding: 27px 17px 21px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background:
      radial-gradient(120% 90% at 50% 0, color-mix(in srgb, var(--paper-raised) 62%, transparent), transparent 58%),
      color-mix(in srgb, var(--paper) 92%, transparent);
    box-shadow: var(--shadow-soft);
  }

  .reading-watermark {
    position: absolute;
    top: 18px;
    right: 8px;
    color: var(--accent);
    font-family: var(--kai);
    font-size: 88px;
    line-height: 1;
    opacity: 0.035;
    pointer-events: none;
    transform: rotate(4deg);
  }

  .mobile-poem {
    position: relative;
    z-index: 1;
    color: var(--ink);
    font-family: var(--serif);
  }

  .m-line {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: 0 1px;
    margin-bottom: 5px;
    font-size: clamp(24px, 7vw, 28px);
    line-height: 1.48;
  }

  .m-token {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: bottom;
  }

  .m-py {
    display: none;
    height: 0;
    overflow: hidden;
    color: var(--pinyin);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
  }

  .mobile-poem.show-pinyin .m-py {
    display: flex;
    height: 17px;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
  }

  .m-hz {
    display: block;
    font-family: var(--serif);
    line-height: 1.45;
  }

  .m-punct {
    align-self: flex-end;
    padding: 0 1px 2px;
    color: var(--muted);
    font-family: var(--serif);
    font-size: 0.82em;
    line-height: 1.45;
    opacity: 0.62;
  }

  .mobile-poem.is-prose .m-line {
    display: block;
    margin-bottom: 8px;
    font-size: 17px;
    line-height: 2;
    text-align: justify;
    text-indent: 2em;
  }

  .m-paragraph {
    margin: 0 0 13px;
    color: var(--ink);
    font-family: var(--serif);
    font-size: 17px;
    line-height: 2;
    text-align: justify;
    text-indent: 2em;
  }

  .m-paragraph:last-child {
    margin-bottom: 0;
  }

  .mobile-poem.is-prose .m-token {
    display: inline-flex;
    vertical-align: bottom;
  }

  .mobile-poem.is-prose .m-py {
    font-size: 9px;
  }

  .mobile-poem.is-prose.show-pinyin .m-py {
    height: 14px;
  }

  .mobile-poem.is-prose .m-punct {
    display: inline;
    padding: 0;
    font-size: inherit;
    line-height: inherit;
  }

  .mobile-poem.is-collapsed .m-line:nth-child(n + 13) {
    display: none;
  }

  .reading-expand {
    display: block;
    margin: 13px auto 0;
    padding: 6px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--accent);
    background: var(--accent-faint);
    font-size: 10px;
    letter-spacing: 0.06em;
  }

  .reading-quote {
    position: relative;
    margin-top: 23px;
    padding: 17px 20px 0;
    border-top: 1px dashed var(--line-strong);
    text-align: center;
  }

  .reading-quote p {
    margin: 0;
    color: var(--ink-soft);
    font-family: var(--kai);
    font-size: 17px;
    letter-spacing: 0.03em;
    line-height: 1.75;
  }

  .quote-mark {
    position: absolute;
    top: 4px;
    left: 0;
    color: var(--accent);
    font-family: Georgia, serif;
    font-size: 42px;
    line-height: 1;
    opacity: 0.16;
    pointer-events: none;
  }

  .quote-label {
    display: block;
    margin-top: 9px;
    color: var(--accent);
    font-size: 8px;
    letter-spacing: 0.22em;
  }

  .appreciation-card {
    margin-top: 14px;
    padding: 22px 19px 17px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background:
      linear-gradient(145deg, color-mix(in srgb, var(--paper-raised) 48%, transparent), transparent 60%),
      color-mix(in srgb, var(--paper) 88%, transparent);
    box-shadow: var(--shadow-soft);
  }

  .appreciation-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 13px;
  }

  .analysis-seal {
    display: grid;
    width: 39px;
    height: 39px;
    flex: 0 0 auto;
    place-items: center;
    border: 1.5px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    background: var(--accent-faint);
    font-family: var(--kai);
    font-size: 21px;
    line-height: 1;
    transform: rotate(-2deg);
  }

  .appreciation-head .eyebrow {
    margin-bottom: 1px;
    font-size: 8px;
  }

  .appreciation-head h2 {
    margin: 0;
    font-family: var(--kai);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.12em;
    line-height: 1.1;
  }

  .appreciation-text {
    margin: 0;
    color: var(--ink-soft);
    font-family: var(--serif);
    font-size: 15.5px;
    line-height: 2;
    text-align: justify;
  }

  .reading-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 19px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }

  .reading-nav-button {
    padding: 7px 0;
    border: 0;
    color: var(--ink-soft);
    background: transparent;
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  .reading-nav-button:hover {
    color: var(--accent);
  }

  .reading-progress {
    color: var(--faint);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.05em;
  }

  .reading-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px 11px;
    padding: 17px 6px 0;
    color: var(--faint);
    font-size: 8px;
    letter-spacing: 0.05em;
    text-align: center;
  }

  .mobile-library {
    position: fixed;
    z-index: 60;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
  }

  .mobile-library-veil {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--ink) 42%, transparent);
    backdrop-filter: blur(3px);
    animation: veil-in 0.24s ease both;
  }

  .mobile-library-sheet {
    position: relative;
    display: flex;
    width: 100%;
    max-height: 86vh;
    flex-direction: column;
    padding: 17px 16px calc(16px + env(safe-area-inset-bottom));
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    background:
      radial-gradient(100% 60% at 50% 0, color-mix(in srgb, var(--paper-raised) 55%, transparent), transparent 60%),
      var(--paper);
    box-shadow: 0 -20px 60px rgba(35, 25, 12, 0.22);
    animation: sheet-up 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }

  .mobile-library-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-library-head h2 {
    margin: 0;
    font-family: var(--kai);
    font-size: 25px;
    font-weight: 700;
    letter-spacing: 0.08em;
  }

  .mobile-library-head .eyebrow {
    margin-bottom: 2px;
  }

  .mobile-library-close {
    width: 33px;
    height: 33px;
    flex: 0 0 auto;
  }

  .mobile-library-filters {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    margin: 13px 0 7px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: color-mix(in srgb, var(--bg) 40%, transparent);
  }

  .mobile-library-filters .filter {
    padding: 7px 0;
    border-radius: 6px;
  }

  .mobile-poem-list {
    min-height: 130px;
    overflow-y: auto;
    padding: 2px 2px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--faint) transparent;
  }

  .mobile-poem-list::-webkit-scrollbar {
    width: 4px;
  }

  .mobile-poem-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--faint);
  }

  .mobile-poem-item {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 8px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 7px;
    background: transparent;
    text-align: left;
  }

  .mobile-poem-item.active {
    background: var(--accent-soft);
  }

  .mpoem-main {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
  }

  .mpoem-title {
    overflow: hidden;
    color: var(--ink);
    font-family: var(--serif);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-poem-item.active .mpoem-title {
    color: var(--accent-deep);
  }

  .mpoem-author {
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.05em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mpoem-side {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    color: var(--faint);
    font-family: var(--mono);
    font-size: 9px;
  }

  .mpoem-side .is-current {
    color: var(--accent);
  }

  body.mobile-drawer-open {
    overflow: hidden;
  }

  @keyframes reading-in {
    from {
      opacity: 0;
      transform: translateY(7px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes sheet-up {
    from {
      opacity: 0.6;
      transform: translateY(32px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* ---------- 动画 ---------- */

@keyframes caret-blink {
  0%,
  48% {
    opacity: 1;
  }
  49%,
  100% {
    opacity: 0;
  }
}

@keyframes soft-pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-3px);
  }
  40% {
    transform: translateX(3px);
  }
  60% {
    transform: translateX(-2px);
  }
  80% {
    transform: translateX(2px);
  }
}

@keyframes veil-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  10% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 620px, 0) rotate(var(--spin));
  }
}

/* ---------- 响应式 ---------- */

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 262px minmax(0, 1fr);
    gap: 18px;
  }

  .topbar-quote {
    display: none;
  }

  .sidebar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .practice-card {
    padding-right: 26px;
    padding-left: 26px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding-top: 17px;
  }

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

  .practice-column {
    order: 1;
  }

  .sidebar {
    position: static;
    order: 2;
    max-height: none;
    margin-top: 2px;
  }

  .poem-list {
    display: grid;
    max-height: 290px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
  }

  .library-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 22px;
  }

  .record-note {
    width: 100%;
    margin-top: 3px;
  }

  .practice-card {
    min-height: 660px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px 12px 20px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .brand-seal {
    width: 39px;
    height: 39px;
    font-size: 23px;
  }

  .brand-title {
    font-size: 21px;
  }

  .brand-sub {
    font-size: 8px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .random-button {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .random-button span {
    display: none;
  }

  .topbar-right {
    gap: 6px;
  }

  .practice-card {
    min-height: 0;
    padding: 18px 14px 18px;
    border-radius: 16px;
  }

  .paper-ornament {
    display: none;
  }

  .card-toolbar {
    gap: 8px;
  }

  .poem-tags {
    gap: 6px;
  }

  .toolbar-text {
    font-size: 9px;
  }

  .text-button span {
    display: none;
  }

  .text-button {
    width: 30px;
    justify-content: center;
    padding: 0;
  }

  .poem-header {
    margin-top: 12px;
  }

  .poem-heading h2 {
    font-size: 33px;
  }

  .poem-heading h2.title-long {
    font-size: clamp(22px, 6.5vw, 26px);
  }

  .poem-author {
    margin-top: 4px;
    font-size: 10px;
  }

  .dynasty-seal {
    width: 43px;
    height: 43px;
    font-size: 19px;
  }

  .progress-block {
    margin: 16px 0 12px;
  }

  .poem-stage {
    max-height: 335px;
    padding: 14px 4px 11px;
    border-radius: 11px;
  }

  .stage-fade {
    height: 20px;
  }

  .stage-fade-top {
    border-radius: 10px 10px 0 0;
  }

  .stage-fade-bottom {
    border-radius: 0 0 10px 10px;
  }

  .stage-watermark {
    display: none;
  }

  .pinyin-poem {
    gap: 11px;
  }

  .syllable {
    min-width: clamp(30px, 8.4vw, 47px);
    padding: 2px 1px;
  }

  .syllable-pinyin {
    height: 20px;
    font-size: clamp(10px, 2.9vw, 12.5px);
  }

  .syllable-hanzi {
    font-size: clamp(25px, 7.4vw, 33px);
  }

  .punctuation {
    min-width: 11px;
    padding-bottom: 4px;
    font-size: clamp(21px, 6.4vw, 28px);
  }

  .stage-caption {
    margin-top: 8px;
    font-size: 9px;
  }

  .live-panel {
    min-height: 56px;
    margin-top: 12px;
    padding: 8px 11px;
  }

  .live-current {
    gap: 9px;
  }

  .live-char {
    width: 34px;
    height: 34px;
    font-size: 22px;
  }

  .live-pinyin {
    min-width: 75px;
    font-size: 19px;
  }

  .live-side {
    gap: 0;
  }

  .last-key {
    display: none;
  }

  .input-tip {
    font-size: 8px;
    white-space: normal;
    text-align: right;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
    margin-top: 11px;
  }

  .stat {
    padding: 8px 12px;
  }

  .stat-value {
    font-size: 17px;
  }

  .keyboard-block {
    display: none;
  }

  .page-footer {
    gap: 5px;
    padding-top: 11px;
    font-size: 8px;
  }

  .completion-card {
    padding: 23px 18px 21px;
  }

  .completion-card h3 {
    font-size: 27px;
  }

  .poem-list {
    max-height: 330px;
  }
}

@media (max-width: 420px) {
  .brand-copy {
    gap: 1px;
  }

  .brand-title {
    font-size: 19px;
  }

  .brand-sub {
    letter-spacing: 0.13em;
  }

  .topbar-right {
    gap: 4px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
  }

  .random-button {
    width: 32px;
    height: 34px;
  }

  .live-label {
    display: none;
  }

  .input-tip {
    display: none;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .stage-caption {
    letter-spacing: 0.05em;
  }

  .poem-item-title {
    font-size: 13px;
  }

  .poem-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

  .confetti-layer {
    display: none;
  }
}
