/* ─── Tokens ─── */
:root {
  --paper: #f6f1e7;
  --paper-light: #faf7f0;
  --ink: #2b2621;
  --ink-soft: rgba(43, 38, 33, 0.72);
  --ink-muted: rgba(43, 38, 33, 0.52);
  --forest: #5c6b5f;
  --forest-light: rgba(92, 107, 95, 0.12);
  --wood: #6e4b3a;
  --gold: #b08d57;
  --line: rgba(43, 38, 33, 0.15);
  --line-strong: rgba(43, 38, 33, 0.25);
  --ui-serif: "Noto Serif JP", "Hiragino Mincho ProN", serif;
  --poem-serif: "Noto Serif SC", "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Songti SC", "SimSun", "MS Mincho", serif;
  --latin-pinyin: "Noto Sans", "Segoe UI", system-ui, sans-serif;
}

html[lang="zh-CN"] { --ui-serif: "Noto Serif SC", "Songti SC", "SimSun", serif; --poem-serif: "Noto Serif SC", "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Songti SC", "SimSun", serif; }
html[lang="zh-TW"] { --ui-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif; --poem-serif: "Noto Serif TC", "Noto Serif SC", "Noto Serif JP", "Noto Serif KR", "Songti TC", "PMingLiU", serif; }
html[lang="ja"]    { --ui-serif: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; --poem-serif: "Noto Serif JP", "Noto Serif SC", "Noto Serif TC", "Noto Serif KR", "Hiragino Mincho ProN", "Yu Mincho", serif; }
html[lang="ko"]    { --ui-serif: "Noto Serif KR", "Batang", serif; --poem-serif: "Noto Serif KR", "Noto Serif SC", "Noto Serif TC", "Noto Serif JP", "Batang", serif; }
html[lang="vi"]    { --ui-serif: "Noto Serif", Georgia, serif; --poem-serif: "Noto Serif", "Noto Serif SC", "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Songti SC", "SimSun", serif; letter-spacing: normal !important; }
html[lang="en"]    { --ui-serif: "Noto Serif", Georgia, serif; --poem-serif: "Noto Serif SC", "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Songti SC", "SimSun", serif;
  --latin-serif: "Times New Roman", "Noto Serif", Georgia, serif;
  --radius: 3px;
  --transition: 0.15s ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 15% 10%, rgba(176, 141, 87, 0.08), transparent 50%),
    radial-gradient(ellipse at 85% 5%, rgba(92, 107, 95, 0.06), transparent 40%),
    var(--paper);
  font-family: var(--ui-serif);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── Forms ─── */
select, button, input { font: inherit; }

input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"] {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  color: var(--ink);
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="number"]:focus {
  border-color: var(--forest);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--line-strong);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--forest);
  border: 2px solid var(--paper-light);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--forest);
  border: 2px solid var(--paper-light);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  cursor: pointer;
}

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--paper-light);
  cursor: pointer;
  vertical-align: -3px;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}

input[type="checkbox"]:checked {
  background: var(--forest);
  border-color: var(--forest);
}

input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper-light);
  cursor: pointer;
  vertical-align: -3px;
  position: relative;
  transition: border-color var(--transition);
}

input[type="radio"]:checked {
  border-color: var(--forest);
}

input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--forest);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%232b2621' opacity='0.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 10px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--paper-light);
  color: var(--ink);
  padding: 0.35rem 1.6rem 0.35rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ─── Topbar ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(246, 241, 231, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 3.2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}

.seal {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  background: linear-gradient(135deg, #c49660, #8a5030);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.15em;
}

/* Desktop nav (inline in topbar) */
.nav-desktop {
  display: flex;
  gap: 0;
  flex: 1;
}

.nav-item {
  border: none;
  background: none;
  color: var(--ink-soft);
  padding: 0.9rem 0.85rem;
  cursor: pointer;
  font-size: 0.88rem;
  letter-spacing: 0.06em;
  position: relative;
  transition: color var(--transition);
}

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

.nav-item.active {
  color: var(--forest);
  font-weight: 500;
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0.5rem;
  right: 0.5rem;
  height: 2px;
  background: var(--forest);
  border-radius: 1px;
}

/* Bottom tab bar (mobile) */
.bottom-bar {
  display: none;
}

.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  border: none;
  background: none;
  color: var(--ink-muted);
  padding: 0.5rem 0 0.4rem;
  cursor: pointer;
  transition: color var(--transition);
}

.bottom-tab.active {
  color: var(--forest);
}

.bottom-tab-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.bottom-tab-label {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

/* ─── Main ─── */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  min-height: calc(100vh - 8rem);
}

/* ─── Footer ─── */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  border-top: 1px solid var(--line);
}

.site-footer p { margin: 0; }

.footer-lang {
  margin-top: 0.6rem;
}

.footer-lang select {
  border: 1px solid var(--line);
  background: var(--paper-light);
  color: var(--ink-muted);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

/* ─── Hero (Top) ─── */
.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  background: url('/static/img/hero.jpg') center/cover no-repeat var(--paper-light);
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(246, 241, 231, 0.7);
}

.hero-body {
  position: relative;
  text-align: center;
  padding: 3rem 2rem;
}

.hero-title {
  font-size: 2.6rem;
  font-weight: 400;
  letter-spacing: 0.6em;
  margin: 0 0 0.4rem;
  color: var(--wood);
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0 0 1.8rem;
  letter-spacing: 0.12em;
}

.hero-description {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 0 0 0.4rem;
  line-height: 1.8;
}

.hero-cycle {
  display: inline-block;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  color: var(--forest);
  border: 1px solid var(--forest);
  border-radius: var(--radius);
  padding: 0.45rem 1.4rem;
  margin: 1.8rem 0 0.2rem;
}

.hero-actions {
  margin-top: 1.5rem;
}

/* ─── Card ─── */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  padding: 1.2rem 1.3rem;
  margin-bottom: 0.75rem;
}

.card h3 {
  margin: 0 0 0.2rem;
  font-weight: 500;
  font-size: 1.05rem;
}

.card p { margin: 0.4rem 0; }

.card-link {
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.card-link:hover, .card-link:active {
  background: rgba(255, 255, 255, 0.85);
  border-color: var(--forest);
}

.card-summary {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0.25rem 0 0;
}

.title-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.poem-number {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  margin-right: 0.15rem;
}

.core-badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.08rem 0.35rem;
  border: 1px solid var(--gold);
  border-radius: 2px;
  color: var(--wood);
  background: rgba(176, 141, 87, 0.08);
  vertical-align: middle;
  margin-left: 0.3rem;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper-light);
  color: var(--ink);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  transition: background var(--transition), border-color var(--transition);
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
}

.icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
  vertical-align: -2px;
  margin-right: 0.15rem;
}

.btn:hover, .btn:active {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--ink-soft);
}

@media (hover: none) {
  .btn:hover { background: var(--paper-light); border-color: var(--line-strong); }
}

.btn.primary {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}

.btn.primary:hover {
  background: #4d5c50;
}

.actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.actions-compact {
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.actions-compact .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
}

/* ─── Detail Layout ─── */
.detail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.back-link {
  color: var(--ink-soft);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition);
}

.back-link:hover { color: var(--forest); }

.detail-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-vertical {
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  padding: 0.2rem;
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.72rem;
  min-width: 1.8rem;
  text-align: center;
  transition: all var(--transition);
}

.toggle-vertical:hover { border-color: var(--ink-soft); }

.toggle-vertical.active {
  background: var(--forest-light);
  border-color: var(--forest);
  color: var(--forest);
}

.toggle-vertical .icon {
  width: 12px;
  height: 12px;
  margin: 0;
  vertical-align: -1px;
}

.detail-size {
  display: flex;
  gap: 2px;
}

.detail-size .size-btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  min-width: 1.8rem;
  text-align: center;
}

.detail-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0.6rem 0;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.8rem 0;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  transition: all var(--transition);
}

.action-card:hover {
  border-color: var(--forest);
  color: var(--forest);
  background: var(--forest-light);
}

.action-card:active {
  transform: scale(0.97);
}

.action-card-icon {
  width: 28px;
  height: 28px;
}

/* ─── Pager ─── */
.pager {
  display: flex;
  justify-content: space-between;
  margin: 0.5rem 0;
}

.pager-btn {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.3rem 0;
  transition: color var(--transition);
}

.pager-btn:hover { color: var(--forest); }
.pager-btn:disabled { color: var(--ink-muted); cursor: default; }

/* ─── Audio Bar ─── */
.audio-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.7rem;
  margin: 0.5rem 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper-light);
}

.audio-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--forest);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}

.audio-play-btn:hover:not(:disabled) { background: #4d5c50; }
.audio-play-btn:active:not(:disabled) { transform: scale(0.93); }
.audio-play-btn:disabled { background: var(--ink-muted); cursor: default; }

.audio-play-btn.copied {
  color: var(--accent);
}

.audio-play-btn-outline {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.audio-play-btn-outline:hover:not(:disabled) {
  background: var(--paper-light);
  border-color: var(--ink-soft);
}

.audio-play-icon {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

/* Equalizer animation for playing state */
.audio-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.eq-bar {
  width: 3px;
  background: #fff;
  border-radius: 1px;
  animation: eq-bounce 0.8s ease-in-out infinite alternate;
}

.eq-bar:nth-child(1) { height: 40%; animation-delay: 0s; }
.eq-bar:nth-child(2) { height: 70%; animation-delay: 0.15s; }
.eq-bar:nth-child(3) { height: 50%; animation-delay: 0.3s; }
.eq-bar:nth-child(4) { height: 80%; animation-delay: 0.45s; }

@keyframes eq-bounce {
  0% { height: 20%; }
  100% { height: 100%; }
}

.audio-speed-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
}

.audio-speed-label {
  font-size: 0.6rem;
  color: var(--ink-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.audio-speed {
  flex: 1;
  max-width: 100px;
}

.audio-repeat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.audio-repeat-btn:hover { color: var(--ink-soft); }

.audio-repeat-btn.active {
  color: var(--forest);
  background: var(--forest-light);
}

.audio-repeat-icon {
  width: 18px;
  height: 18px;
}

/* ─── Tabs ─── */
.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.6rem 0 0.9rem;
}

.tab {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  color: var(--ink-soft);
  padding: 0.32rem 0.6rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all var(--transition);
}

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

.tab.active {
  border-color: var(--forest);
  background: var(--forest-light);
  color: var(--forest);
}

/* ─── Size Controls ─── */
.size-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  margin: 0.2rem 0 0.9rem;
}

.size-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.size-btn {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  color: var(--ink);
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all var(--transition);
}

.size-btn.active {
  border-color: var(--forest);
  background: var(--forest-light);
}

/* ─── Poem Display ─── */
.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.4rem;
  margin: 0.9rem 0;
}

.line {
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 2.2rem;
  line-height: 1.45;
  text-align: center;
}

.line:last-child { border-bottom: none; }

.line-tools { margin-top: 0.4rem; }

.reading {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ─── Audio Panel ─── */
.audio-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem;
  margin: 0.6rem 0 0.9rem;
  background: var(--paper-light);
}

/* ─── Translation ─── */
/* ---- Auth / Login ---- */
.auth-card { max-width: 420px; margin: 2rem auto; }
.auth-hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 1rem; }
.auth-tabs .tab { flex: 1; text-align: center; }
.auth-error { color: var(--danger, #c0392b); font-size: 0.85rem; min-height: 1.2em; margin-bottom: 0.5rem; }
.auth-field { margin-bottom: 0.75rem; }
.auth-field label { display: block; font-size: 0.85rem; margin-bottom: 0.25rem; color: var(--muted); }
.auth-field input { width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; font-size: 0.95rem; }
.auth-field input:focus { outline: none; border-color: var(--accent); }
.auth-submit { width: 100%; justify-content: center; margin-top: 0.5rem; }

/* Login prompt overlay */
.login-prompt-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}
.login-prompt-card {
  background: var(--paper, #fff);
  border-radius: var(--radius, 8px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 1.5rem 2rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.login-prompt-msg {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.2rem;
  color: var(--ink);
}
.login-prompt-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.login-prompt-login {
  background: var(--forest, #4a7c59) !important;
  color: #fff !important;
  border-color: var(--forest, #4a7c59) !important;
}
.login-prompt-skip {
  background: transparent !important;
  color: var(--ink-soft, #666) !important;
  border-color: var(--line, #ddd) !important;
  font-size: 0.85rem !important;
}

.auth-terms { margin-bottom: 0.75rem; }
.auth-terms-label { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.85rem; cursor: pointer; line-height: 1.5; }
.auth-terms-label input[type="checkbox"] { margin-top: 0.25rem; flex-shrink: 0; }
.auth-terms-label a { color: var(--accent); }

.auth-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0; color: var(--muted); font-size: 0.85rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }

.auth-social { display: flex; flex-direction: column; gap: 0.5rem; }
.auth-social-btn { display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; padding: 0.55rem 1rem; border-radius: var(--radius); font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: opacity 0.15s; }
.auth-social-btn:hover { opacity: 0.85; }
.auth-social-icon { width: 18px; height: 18px; flex-shrink: 0; }
.auth-google { background: #fff; border: 1px solid var(--line); color: #444; }
.auth-facebook { background: #1877F2; border: 1px solid #1877F2; color: #fff; }
.auth-facebook .auth-social-icon path { fill: #fff; }

.mypage-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.mypage-user-info { display: flex; align-items: center; gap: 0.5rem; }
.mypage-username { font-weight: 600; font-size: 0.9rem; }
.btn-sm { font-size: 0.8rem; padding: 0.25rem 0.6rem; }
.btn-danger { color: var(--danger, #c0392b); border-color: var(--danger, #c0392b); }
.btn-danger:hover { background: var(--danger, #c0392b); color: #fff; }

.password-form { margin-bottom: 1rem; padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,252,244,0.72); }
.auth-field-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.auth-field-row input { flex: 1; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; font-size: 0.9rem; }
.auth-field-row input:focus { outline: none; border-color: var(--accent); }

/* ---- Reference Links ---- */
.reference-links-section {
  margin: 0.8rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 244, 0.72);
}
.reference-links-section h4 { margin: 0 0 0.4rem; }
.reference-links-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.reference-links-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}
.reference-links-list a {
  color: var(--accent);
  text-decoration: none;
}
.reference-links-list a:hover {
  text-decoration: underline;
}
.ref-link-lang-badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--accent-pale, rgba(106,153,85,0.12));
  color: var(--ink-light, #666);
  white-space: nowrap;
}

.translation-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0.6rem 0 0.9rem;
  background: rgba(255, 252, 244, 0.72);
  font-family: var(--poem-serif);
}

.translation-panel h4 { margin: 0 0 0.35rem; }
.translation-panel p { margin: 0; line-height: 1.35; }
.translation-panel .translation-title { margin-bottom: 0.4rem; }

.translation-lines { display: grid; gap: 0.044rem; }
.translation-row { padding-top: 0; }

.translation-text {
  line-height: 1.485;
  color: var(--ink-soft);
}

/* ─── Practice ─── */
.practice-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0.8rem 1rem 6rem;
}

.practice-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.practice-reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-light);
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition);
}
.practice-reset-btn:hover { border-color: var(--forest); color: var(--forest); }

.practice-header {
  text-align: center;
  margin-bottom: 0.8rem;
}

.practice-poem-meta {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 0;
}

.practice-author { color: var(--ink-muted); }

/* Target selector pills */
.practice-target-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.practice-target-btn {
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--paper-light);
  color: var(--ink-soft);
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
  font-family: var(--ui-serif);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.03em;
}
.practice-target-btn:hover { border-color: var(--forest); color: var(--forest); }
.practice-target-btn.active { border-color: var(--forest); background: var(--forest); color: #fff; }
.practice-target-btn.active .target-sub { color: rgba(255, 255, 255, 0.85); }

/* Kanji variant sub-toggle */
.kanji-variant-row {
  display: flex;
  justify-content: center;
  gap: 0.2rem;
  margin-bottom: 0.6rem;
}

.kanji-variant-btn {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-light);
  color: var(--ink-muted);
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-family: var(--ui-serif);
  cursor: pointer;
  transition: all var(--transition);
}
.kanji-variant-btn:hover { border-color: var(--gold); color: var(--gold); }
.kanji-variant-btn.active { border-color: var(--gold); background: var(--gold); color: #fff; }

/* Progress bar */
.practice-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.practice-progress-bar {
  flex: 1;
  height: 5px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.practice-progress-fill {
  height: 100%;
  background: var(--forest);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.practice-progress-label {
  font-size: 0.72rem;
  color: var(--ink-muted);
  white-space: nowrap;
  min-width: 2.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Timer — ring display */
.practice-timer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.practice-timer-ring {
  display: block;
}

.practice-timer-arc {
  transition: stroke-dasharray 1s linear;
}

.practice-timer-label {
  position: absolute;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.practice-timer.urgent .practice-timer-label { color: #c0392b; }

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.practice-timer.urgent .practice-timer-label {
  animation: timer-pulse 1s ease infinite;
}
.practice-timer.urgent .practice-timer-ring {
  animation: timer-shake 0.4s ease;
}
@keyframes timer-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}
.timer-waiting { opacity: 0.5; }

/* Practice flash overlay */
.practice-flash {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.practice-flash--show { opacity: 1; }
.practice-flash--complete {
  background: rgba(74, 124, 89, 0.15);
  color: var(--forest);
}
.practice-flash--timeout {
  background: rgba(192, 57, 43, 0.15);
  color: #c0392b;
}

/* Practice board — single outer border */
.practice-board {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  padding: 0.8rem 0.9rem;
}

/* Practice line */
.practice-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
}
.practice-line + .practice-line { border-top: 1px solid rgba(43, 38, 33, 0.06); }

.practice-line-num {
  font-size: 0.7rem;
  color: var(--ink-muted);
  min-width: 1.2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.practice-line-chars {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
  font-family: var(--poem-serif);
}

/* Character tiles — shared base */
.pchar {
  min-width: 2rem;
  min-height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-family: var(--poem-serif);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.1rem 0.15rem;
  perspective: 600px;
}

/* Static chars (punctuation, spaces) */
.pchar-static {
  min-width: auto;
  min-height: auto;
  padding: 0;
  font-size: 1.2rem;
  color: var(--ink-muted);
  border: none;
  background: none;
}

/* Hidden tile — card-back crosshatch pattern */
.pchar-hidden {
  border: 1px solid rgba(120, 104, 79, 0.25);
  cursor: pointer;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      rgba(120, 104, 79, 0.08) 3px,
      rgba(120, 104, 79, 0.08) 4px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 3px,
      rgba(120, 104, 79, 0.08) 3px,
      rgba(120, 104, 79, 0.08) 4px
    ),
    rgba(245, 240, 230, 0.95);
  color: transparent;
  transition: transform 0.35s ease, background 0.2s ease;
}
.pchar-hidden:hover {
  border-color: rgba(120, 104, 79, 0.4);
  background:
    repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(120, 104, 79, 0.12) 3px, rgba(120, 104, 79, 0.12) 4px),
    repeating-linear-gradient(-45deg, transparent, transparent 3px, rgba(120, 104, 79, 0.12) 3px, rgba(120, 104, 79, 0.12) 4px),
    rgba(240, 235, 225, 0.95);
}

/* Typed — blue (memorized) */
.pchar-typed {
  color: #1a5276;
  border: 1px solid rgba(26, 82, 118, 0.2);
  background: rgba(214, 234, 248, 0.5);
  font-weight: 500;
}

/* Peeked — red (not memorized) */
.pchar-peeked {
  color: #922b21;
  border: 1px solid rgba(146, 43, 33, 0.2);
  background: rgba(245, 220, 215, 0.5);
  font-weight: 500;
}

/* Flip-in animation — applied via JS on reveal */
.pchar-flip-in {
  animation: pchar-flip-in 0.35s ease both;
}

@keyframes pchar-flip-in {
  0% {
    transform: scale(1.3);
    background: rgba(74, 124, 89, 0.15);
  }
  100% {
    transform: scale(1);
    background: transparent;
  }
}

/* Vietnamese syllable blocks */
.pchar-syl {
  min-width: auto;
  padding: 0.1rem 0.35rem;
  font-size: 1.1rem;
  font-family: "Noto Serif", "Noto Sans", Georgia, serif;
}
.pchar-syl.pchar-hidden {
  min-width: 2.5rem;
}

/* Input bar at bottom */
.practice-input-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0 0.75rem;
  margin-bottom: 0.5rem;
}
.practice-input-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  text-align: center;
}

.practice-input {
  width: 100%;
  max-width: 500px;
  border: 2px solid var(--forest);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0.8rem 1rem;
  font-size: 1.5rem;
  font-family: var(--poem-serif);
  outline: none;
  text-align: center;
  transition: border-color var(--transition);
}
.practice-input:focus {
  border-color: var(--forest);
}

/* Input feedback flash */
.practice-input.input-ok {
  border-color: #2471a3;
  background: rgba(36, 113, 163, 0.06);
  animation: input-flash-ok 0.4s ease;
}
.practice-input.input-ng {
  border-color: #c0392b;
  background: rgba(192, 57, 43, 0.06);
  animation: input-flash-ng 0.35s ease;
}
@keyframes input-flash-ok {
  0% { box-shadow: 0 0 0 0 rgba(36, 113, 163, 0.4); }
  100% { box-shadow: 0 0 0 6px rgba(36, 113, 163, 0); }
}
@keyframes input-flash-ng {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

/* Practice finish banner */
.practice-finish-banner {
  text-align: center;
  padding: 1rem;
  margin-top: 0.8rem;
  border: 1px solid var(--forest);
  border-radius: var(--radius);
  background: rgba(92, 107, 95, 0.08);
  color: var(--forest);
  font-size: 0.95rem;
  font-weight: 500;
}

.practice-finish-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

/* Practice result overlay */
.practice-result {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 33, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.practice-result-card {
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 320px;
  width: 90%;
}

.practice-result-card h3 {
  font-size: 1.1rem;
  color: var(--ink);
  margin: 0 0 0.8rem;
  letter-spacing: 0.1em;
}

.practice-result-score {
  font-size: 2.8rem;
  font-weight: 600;
  color: var(--forest);
  margin-bottom: 0.3rem;
}

.practice-result-detail {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}

.result-typed { color: #2471a3; font-weight: 600; }

.practice-result-lines {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin: 0 0 1.2rem;
}

.practice-result-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* ─── Poem Panel ─── */
.poem-panel {
  --poem-scale: 1;
  --v-main-track: calc(2.45rem * var(--poem-scale));
  --v-side-track: calc(0.66rem + 0.34rem * var(--poem-scale));
  --v-side-track-zhuyin: calc(0.9rem + 0.46rem * var(--poem-scale));
  --v-annot-gap: calc(0.01rem + 0.0175rem * var(--poem-scale));
  --v-zhuyin-gap: calc(0.02rem + 0.04rem * var(--poem-scale));
  font-family: var(--poem-serif);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  padding: 0.8rem;
  position: relative;
}

.poem-panel-toolbar {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 2;
}

.poem-panel-audio {
  position: absolute;
  bottom: 0.4rem;
  right: 0.4rem;
  z-index: 2;
  min-height: 0;
  text-align: center;
  overflow-y: hidden;
  font-family: var(--poem-serif);
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.audio-play-btn.copied {
  color: var(--accent);
}

.poem-actions-mobile {
  display: none;
}

.translation-title {
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
  color: var(--ink);
}

.title-reading {
  font-size: 0.75em;
  color: var(--ink-soft);
  margin-left: 0.2em;
}

.title-translation {
  display: block;
  font-size: 0.6em;
  font-weight: 400;
  color: var(--ink-soft);
  margin-top: 0.15em;
}

h2 ruby rt {
  font-size: 0.55em;
  font-weight: 400;
  color: var(--ink-soft);
}

.poem-panel-h {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: auto;
}

.poem-header-block {
  width: 100%;
  margin-bottom: 0.7rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px dashed var(--line);
}

.poem-body-block { width: 100%; }

.poem-spacer-h { height: calc(0.18rem + 0.12rem * var(--poem-scale)); }
.poem-header-gap-h { height: calc(0.44rem + 0.32rem * var(--poem-scale)); }

.line-ruby { margin: 0.55rem 0; text-align: center; }

.line-ruby-char {
  margin: 0.5rem 0;
  font-size: 2rem;
  line-height: 1.6;
  text-align: center;
}

.line-ruby-char ruby { ruby-position: over; margin-right: 0.12em; }

.line-ruby-char rt {
  font-size: 0.48em;
  color: var(--ink-soft);
}

.line-ruby .anno {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 0.08rem;
}

.line-ruby .base {
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  text-align: center;
}

.poem-h-line {
  display: block;
  width: fit-content;
  font-size: calc(2.2rem * var(--poem-scale));
  line-height: 1.45;
  text-align: center !important;
  margin: 0.25rem auto;
  white-space: nowrap;
}

.poem-h-line-header { margin-bottom: 0.08rem; }

.poem-couplet {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 0.25rem auto;
}

.poem-couplet .poem-h-line {
  margin: 0;
}

.poem-couplet .poem-ruby-line {
  margin: 0;
}


.poem-ruby-line {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: fit-content;
  text-align: center !important;
  margin: 0.25rem auto;
}

.poem-ruby-line-header { gap: 0.9rem; margin-bottom: 0.1rem; }

.header-char-group {
  display: inline-flex;
  align-items: flex-start;
}

.header-char-group .char-anno:last-child { margin-right: 0; }

.char-anno {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin-right: 0.14em;
  gap: 0.12rem;
}

.anno-top {
  font-size: calc(0.75rem + 0.2rem * var(--poem-scale, 1));
  color: var(--ink-soft);
  line-height: 1.1;
  margin-bottom: 0.1rem;
  text-align: center;
  width: 100%;
}

.anno-top-latin {
  font-family: var(--latin-pinyin);
  letter-spacing: 0;
  font-kerning: normal;
  line-height: 1.3;
  overflow: visible;
}
/* Vietnamese diacritics need extra space and proper font */
.anno-top-vi {
  font-family: "Noto Sans", "Segoe UI", system-ui, sans-serif;
  line-height: 1.4;
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

.anno-base {
  font-family: var(--poem-serif);
  font-size: calc(2rem * var(--poem-scale));
  line-height: 1;
}

.word-anno {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: max-content;
}

.anno-top-word { white-space: nowrap; padding: 0 0.15rem; }
.anno-base-word { letter-spacing: 0.08em; }

/* ─── Vertical Poem ─── */
.poem-vertical {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  justify-content: center;
  gap: 1.6rem;
  overflow-x: auto;
  overflow-y: clip;
  padding: 0.3rem;
  padding-bottom: 1.5rem;
}

.v-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: calc(2.35rem * var(--poem-scale));
}

.v-char {
  display: block;
  width: 1em;
  height: 1.15em;
  text-align: center;
  line-height: 1.15em;
}

.v-col-spacer { visibility: hidden; }

.v-col-header-spacer {
  display: block;
  width: calc(0.9rem + 0.1rem * var(--poem-scale));
  height: 1px;
}

.poem-vertical-anno {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: clip;
  min-height: 0;
  width: 100%;
  padding-bottom: 1.5rem;
}

.v-block {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.18rem;
}

.v-left,
.v-main,
.v-right {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  min-height: 380px;
}

.v-main {
  font-size: calc(2.35rem * var(--poem-scale));
  letter-spacing: 0.15em;
}

.v-left,
.v-right {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.v-char-wrap {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.08rem;
}

.v-char-main {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: calc(2rem * var(--poem-scale));
  line-height: 1;
}

.v-char-right {
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.v-char-left {
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.v-glyph {
  display: block;
  line-height: 1.05;
}

.v-cell-zhuyin .v-glyph {
  line-height: 0.8;
}

.v-glyph-punct {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.v-annot-grid {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  justify-content: center;
  gap: 0.34rem;
  overflow-x: auto;
  overflow-y: clip;
  min-height: 0;
  padding-right: 1rem;
  padding-bottom: 1.5rem;
}

.v-annot-grid-zhuyin {
  gap: 0;
  width: 100%;
  padding-bottom: 1.2rem;
}


.v-line-col {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.v-line-col-spacer { visibility: hidden; }
.v-line-col-header-spacer { flex: 0 0 calc(2.2rem * var(--poem-scale)); }
.v-line-col-header-gap { width: calc(2.2rem * var(--poem-scale)); }

.v-cell {
  display: grid;
  grid-template-columns: var(--v-side-track) var(--v-main-track) var(--v-side-track);
  align-items: center;
  justify-items: center;
  column-gap: var(--v-annot-gap);
}

.v-cell-kundoku { min-height: calc(var(--v-main-track) + 0.02rem); }
.v-cell-header-japanese { min-height: auto; }

.v-cell-zhuyin {
  grid-template-columns: var(--v-side-track) var(--v-main-track) var(--v-side-track-zhuyin);
}

.v-cell-main {
  font-size: calc(2.35rem * var(--poem-scale));
  line-height: 1;
  min-width: var(--v-main-track);
  text-align: center;
}

.v-cell-main-word {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.04rem;
}

.v-cell-spacer { visibility: hidden; }


.v-cell-left,
.v-cell-right {
  min-width: var(--v-side-track);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(0.58rem + 0.2rem * var(--poem-scale, 1));
  color: var(--ink-soft);
  line-height: 1.22;
}

.v-cell-kundoku .v-cell-left,
.v-cell-kundoku .v-cell-right { align-self: stretch; }

.v-cell-header-japanese .v-cell-left,
.v-cell-header-japanese .v-cell-right { align-self: center; }

.v-cell-right-header-japanese {
  min-width: calc(var(--v-side-track) + 0.14rem);
  font-size: 0.72rem;
}

.v-header-jp-ruby {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.v-header-jp-ruby .v-glyph { line-height: 0.96; }

.v-kundoku-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding-bottom: 0;
}

.v-kundoku-side .v-glyph { line-height: 0.82; }

.v-kundoku-side-right {
  transform: translate(-0.04rem, calc(0.64rem + 0.16rem * var(--poem-scale)));
}

.v-kundoku-side-left {
  transform: translate(0.15rem, calc(1.16rem + 0.16rem * var(--poem-scale)));
}

.v-cell-right-zhuyin {
  min-width: var(--v-side-track-zhuyin);
  align-items: flex-start;
}

.zhuyin-annot {
  display: grid;
  grid-template-columns: 1fr 0.5em;
  align-items: center;
  justify-items: center;
  column-gap: var(--v-zhuyin-gap);
}

.zhuyin-body,
.zhuyin-tone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.zhuyin-tone {
  align-self: center;
  transform: translateY(calc(0.2rem + 0.08rem * var(--poem-scale)));
}

.zhuyin-word-annot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
}

.zhuyin-word-syllable {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-items: center;
  column-gap: var(--v-zhuyin-gap);
}

.v-jp-section {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--line);
}

.v-jp-section h4 { margin: 0 0 0.5rem; font-size: 0.95rem; }

.v-jp-poem {
  width: 100%;
  height: auto;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  align-items: flex-start;
  gap: 0.3rem;
}

.v-jp-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18rem;
  white-space: nowrap;
}

.v-jp-line-header {
  font-weight: 400;
  font-size: calc(1.55rem * var(--poem-scale));
  line-height: 1.05;
  margin-bottom: 0.3rem;
}

.v-jp-line-spacer { width: calc(1.55rem * var(--poem-scale)); }

.jp-word-cell {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 0.08rem;
}

.jp-word-plain { grid-template-columns: auto; }

.jp-word-base {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(1.55rem * var(--poem-scale));
  line-height: 1.05;
}

.jp-word-ruby {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: center;
  font-size: 0.62rem;
  line-height: 1.05;
  color: var(--ink-soft);
}

/* ─── Quiz ─── */
/* ─── Quiz Game UI ─── */
.quiz-card { max-width: 520px; margin: 1rem auto; }
.quiz-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.quiz-title { font-size: 0.9rem; color: var(--ink-soft); }
.quiz-progress { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.quiz-progress-bar { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.quiz-progress-fill { height: 100%; background: var(--forest); border-radius: 3px; transition: width 0.3s ease; }
.quiz-progress-label { font-size: 0.8rem; color: var(--ink-soft); white-space: nowrap; }

.quiz-body { text-align: center; padding: 0.5rem 0 1rem; }
.quiz-prompt { margin-bottom: 1.2rem; }
.quiz-line-text { font-family: var(--poem-serif); font-size: 1.8rem; line-height: 1.6; letter-spacing: 0.05em; }
.quiz-blank { display: inline-flex; align-items: center; justify-content: center; width: 2.2em; height: 1.3em; border-bottom: 3px solid var(--forest); color: var(--forest); font-weight: 700; margin: 0 0.05em; }
.quiz-mc-prompt { font-size: 1.1rem; line-height: 1.6; }

.quiz-input-form { display: flex; gap: 0.5rem; justify-content: center; align-items: center; }
.quiz-fill-input { width: 4rem; font-size: 1.8rem; font-family: var(--poem-serif); text-align: center; padding: 0.4rem; border: 2px solid var(--forest); border-radius: var(--radius); outline: none; }
.quiz-fill-input:focus { box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15); }
.quiz-submit-btn { font-size: 1rem; padding: 0.5rem 1.2rem; }

.quiz-choices { display: flex; flex-direction: column; gap: 0.5rem; max-width: 360px; margin: 0 auto; }
.quiz-choice-btn {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  font: inherit; font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.quiz-choice-btn:hover { border-color: var(--forest); background: rgba(74, 124, 89, 0.06); }
.quiz-choice-btn:active { background: rgba(74, 124, 89, 0.12); }

.quiz-feedback {
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  padding: 0.8rem 1rem; border-radius: var(--radius); margin: 0.5rem auto; max-width: 360px;
  animation: quiz-feedback-in 0.3s ease;
}
.quiz-correct { background: rgba(39, 174, 96, 0.12); border: 1px solid rgba(39, 174, 96, 0.3); }
.quiz-wrong { background: rgba(192, 57, 43, 0.1); border: 1px solid rgba(192, 57, 43, 0.3); }
.quiz-feedback-icon { font-size: 2rem; line-height: 1; }
.quiz-correct .quiz-feedback-icon { color: #27ae60; }
.quiz-wrong .quiz-feedback-icon { color: #c0392b; }
.quiz-feedback-detail { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; }
.quiz-your-answer { font-size: 1.3rem; font-family: var(--poem-serif); }
.quiz-correct-answer { font-size: 0.85rem; color: var(--ink-soft); }

@keyframes quiz-feedback-in {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.quiz-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.quiz-nav-btn { font-size: 0.85rem; }
.quiz-nav-next { background: var(--forest) !important; color: #fff !important; border-color: var(--forest) !important; }

/* Quiz result */
.quiz-result { text-align: center; padding: 1.5rem 0; }
.quiz-result-emoji { font-size: 3rem; margin-bottom: 0.5rem; }
.quiz-result-score { font-size: 3rem; font-weight: 700; color: var(--forest); margin-bottom: 0.25rem; }
.quiz-result-detail { font-size: 1rem; color: var(--ink-soft); margin-bottom: 1.5rem; }
.quiz-result-actions { display: flex; gap: 0.75rem; justify-content: center; }

.quiz-review { margin: 1rem 0; text-align: left; }
.quiz-review-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.6rem; border-radius: var(--radius);
  margin-bottom: 0.3rem; font-size: 0.9rem;
}
.quiz-review-correct { background: rgba(39, 174, 96, 0.08); }
.quiz-review-wrong { background: rgba(192, 57, 43, 0.08); }
.quiz-review-icon { font-size: 1.1rem; font-weight: 700; flex-shrink: 0; width: 1.4rem; text-align: center; }
.quiz-review-correct .quiz-review-icon { color: #27ae60; }
.quiz-review-wrong .quiz-review-icon { color: #c0392b; }
.quiz-review-prompt { flex: 1; font-family: var(--poem-serif); color: var(--ink-soft); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-review-answers { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.quiz-review-yours { font-family: var(--poem-serif); font-size: 1.1rem; font-weight: 600; }
.quiz-review-correct .quiz-review-yours { color: #27ae60; }
.quiz-review-wrong .quiz-review-yours { color: #c0392b; text-decoration: line-through; }
.quiz-review-arrow { color: var(--ink-soft); font-size: 0.8rem; }
.quiz-review-correct-ans { font-family: var(--poem-serif); font-size: 1.1rem; font-weight: 600; color: #27ae60; }

/* Legacy */
.quiz-choice { display: block; margin: 0.4rem 0; }

/* ─── MyPage — Quest Board ─── */
.quest-overall {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.quest-overall-bar {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.quest-overall-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--forest));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.quest-overall-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.quest-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 0.3rem 0.3rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.2rem;
}

.quest-header-title { flex: 1; }

.quest-cat-header {
  font-size: 0.6rem;
  color: var(--ink-muted);
  text-align: center;
  width: 3.6rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quest-grid {
  display: grid;
  gap: 0;
}

.quest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.3rem;
  border-bottom: 1px solid rgba(43, 38, 33, 0.06);
  cursor: pointer;
  transition: background var(--transition);
}
.quest-row:hover { background: var(--forest-light); }
.quest-row:active { background: var(--forest-light); color: var(--forest); }
.quest-row:last-child { border-bottom: none; }

.quest-complete {
  background: rgba(92, 107, 95, 0.04);
}

.quest-title {
  flex: 1;
  font-size: 0.88rem;
  color: var(--ink);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 0.5rem;
}

.quest-title-done {
  color: var(--ink-muted);
}

.quest-author {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-left: 0.4em;
}

.quest-badges {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.quest-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.6rem;
  height: 1.6rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  transition: all var(--transition);
  cursor: pointer;
}

/* ★ 100% Perfect */
.quest-done {
  background: var(--forest);
  color: #fff;
  font-size: 0.85rem;
}

/* 90%+ */
.quest-90 {
  background: rgba(200, 50, 50, 0.18);
  color: #a02020;
  font-weight: 700;
  border: 1px solid rgba(200, 50, 50, 0.3);
}

/* 80%+ */
.quest-80 {
  background: rgba(210, 140, 30, 0.2);
  color: #9a6510;
  font-weight: 700;
  border: 1px solid rgba(210, 140, 30, 0.3);
}

/* 60%+ */
.quest-60 {
  background: rgba(176, 141, 87, 0.18);
  color: #8a6e30;
  font-weight: 700;
  border: 1px solid rgba(176, 141, 87, 0.25);
}

/* 40%+ */
.quest-40 {
  background: rgba(120, 120, 120, 0.15);
  color: #666;
  font-weight: 700;
  border: 1px solid rgba(120, 120, 120, 0.2);
}

/* 40%未満 */
.quest-wip {
  background: rgba(120, 120, 120, 0.12);
  color: #777;
  font-weight: 600;
  border: 1px solid rgba(120, 120, 120, 0.15);
}

/* Not started */
.quest-todo {
  background: var(--forest-light);
  color: var(--ink-muted);
  font-size: 0.9rem;
}

/* Settings page */
.settings-section {
  margin-bottom: 1.2rem;
}

.settings-section-title {
  font-size: 1rem;
  color: var(--ink);
  margin: 0 0 0.3rem;
}

.settings-desc {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin: 0 0 0.7rem;
}

.settings-toggles {
  display: grid;
  gap: 0.15rem;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.settings-toggle:hover { background: var(--forest-light); }

.settings-toggle input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--forest);
  flex-shrink: 0;
}

.settings-toggle-label {
  font-size: 0.92rem;
  color: var(--ink);
}

.settings-size-row {
  display: flex;
  gap: 0.4rem;
}

.settings-speed-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-speed-row .audio-speed {
  flex: 1;
}

/* 2-line labels for practice targets */
.target-sub {
  display: block;
  font-size: 0.65rem;
  color: var(--ink-muted);
  line-height: 1.2;
  font-weight: 400;
}

.practice-target-btn {
  line-height: 1.2;
  text-align: center;
  padding: 0.35rem 0.85rem 0.3rem;
}

.mypage-target-label .target-sub {
  font-size: 0.6rem;
}

/* ─── Progress (legacy) ─── */
.progress-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--line);
}

/* ─── Responsive ─── */
@media (max-width: 720px) {
  body { font-size: 14px; }

  .topbar-inner {
    padding: 0 0.8rem;
    height: 3rem;
    gap: 0;
  }

  .brand { padding: 0; }
  .brand-name { font-size: 1rem; }

  .nav-desktop { display: none; }

  .bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(246, 241, 231, 0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  main {
    padding: 0.8rem 0.6rem 4.5rem;
  }

  .site-footer {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0));
  }

  .hero { min-height: 280px; }
  .hero-title { font-size: 1.8rem; letter-spacing: 0.35em; }
  .hero-subtitle { font-size: 0.95rem; }
  .hero-body { padding: 1.5rem 1rem 2rem; }
  .hero-description { font-size: 0.85rem; }
  .hero-cycle { font-size: 0.78rem; padding: 0.35rem 0.8rem; }

  .card {
    padding: 0.9rem;
    margin-bottom: 0.6rem;
  }

  .card h3 { font-size: 0.98rem; }

  .title-row {
    flex-direction: column;
    gap: 0.2rem;
  }

  .tab-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.2rem;
  }

  .tab-row::-webkit-scrollbar { display: none; }

  .tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .size-row { gap: 0.3rem; }

  .btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
    justify-content: center;
  }

  .poem-panel {
    padding: 0.5rem;
    --poem-scale: 0.78;
    --v-main-track: calc(1.75rem * var(--poem-scale));
    --v-side-track: calc(0.4rem + 0.15rem * var(--poem-scale));
    --v-side-track-zhuyin: calc(0.55rem + 0.2rem * var(--poem-scale));
    --v-annot-gap: calc(0.02rem + 0.01rem * var(--poem-scale));
    --v-zhuyin-gap: calc(0.02rem + 0.03rem * var(--poem-scale));
  }

  .poem-h-line { font-size: calc(1.36rem * var(--poem-scale)); letter-spacing: -0.05em !important; }
  .v-col { font-size: calc(1.48rem * var(--poem-scale)); }
  .v-cell-main { font-size: calc(1.48rem * var(--poem-scale)); }
  .v-char { height: 1.1em; line-height: 1.1em; }
  .jp-word-base { font-size: calc(0.96rem * var(--poem-scale)); }
  .v-jp-line-header { font-size: calc(0.96rem * var(--poem-scale)); }

  .anno-base { font-size: calc(1.6rem * var(--poem-scale)); }
  .anno-top { font-size: calc(0.4rem + 0.16rem * var(--poem-scale, 1)); margin-bottom: 0; }
  .char-anno { gap: 0.01rem; margin-right: 0 !important; }
  .v-annot-grid-zhuyin { gap: 0.075rem; }
  .v-cell-kundoku { min-height: calc(1.75rem * var(--poem-scale) + 0.02rem); }
  .v-cell-kundoku .v-cell-left,
  .v-cell-kundoku .v-cell-right { font-size: calc(0.35rem + 0.2rem * var(--poem-scale, 1)); }
  .v-kundoku-side-right { transform: translate(-0.18rem, calc(0.64rem + 0.16rem * var(--poem-scale))); }
  .v-kundoku-side-left { transform: translate(0.30rem, calc(1.16rem + 0.16rem * var(--poem-scale))); }
  .jp-word-ruby { font-size: 0.46rem; }

  .poem-header-gap-h { height: calc(0.55rem + 0.25rem * var(--poem-scale)); }
  .v-line-col-header-gap { width: calc(4rem * var(--poem-scale)); }
  .v-line-col-header-spacer { flex: 0 0 calc(1.2rem * var(--poem-scale)); }
  .v-col-header-spacer { width: calc(1.2rem + 0.15rem * var(--poem-scale)); }

  .v-annot-grid {
    justify-content: flex-start;
  }

  .poem-panel-audio-desktop { display: none; }
  .poem-panel-toolbar { display: none; }

  .poem-actions-mobile {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0;
  }

  .audio-panel { padding: 0.5rem; }

  .translation-panel { padding: 0.6rem 0.7rem; }

  .progress-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
    padding: 0.6rem 0;
  }

  .practice-page {
    padding: 0.6rem 0.6rem 5.5rem;
  }

  .practice-target-btn {
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
  }

  .pchar {
    min-width: 1.7rem;
    min-height: 1.9rem;
    font-size: 1.2rem;
  }

  .practice-board {
    padding: 0.5rem 0.6rem;
  }

  .practice-input {
    font-size: 1.3rem;
    padding: 0.6rem 0.8rem;
  }
}
