/* ============================================================
   词根词缀记忆工坊 · 墨纸朱砂学术风
   体系：纸(paper) 墨(ink) 朱砂(accent) 三 token，双主题自动切换
   字体：EB Garamond(拉丁词根) + 系统中文无衬线 + IBM Plex Mono(数据)
   圆角制度：全局 3px，唯一取值
   ============================================================ */

@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/eb-garamond-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}

@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/eb-garamond-latin-400-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}

@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/eb-garamond-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}

:root {
  --paper: #f8f6f1;
  --raised: #fffdf9;
  --ink: #211e1a;
  --ink-soft: #55504a;
  --muted: #6e685e;
  --line: rgba(33, 30, 26, 0.14);
  --line-strong: rgba(33, 30, 26, 0.36);
  --accent: #b23a26;
  --accent-ink: #8f2e1e;
  --accent-wash: rgba(178, 58, 38, 0.07);
  --on-accent: #f8f6f1;
  --ok: #3f6b50;
  --ok-wash: rgba(63, 107, 80, 0.09);
  --btn-primary-bg: #b23a26;
  --btn-primary-fg: #f8f6f1;
  --btn-primary-border: #b23a26;
  --btn-primary-hover: #8f2e1e;
  --btn-ok-bg: #3f6b50;
  --btn-ok-fg: #f8f6f1;
  --serif-latin: "EB Garamond", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "PingFang SC", "HarmonyOS Sans SC",
    "MiSans", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 3px;
  --grain-opacity: 0.05;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171411;
    --raised: #201c18;
    --ink: #ece5d8;
    --ink-soft: #c4bbab;
    --muted: #a09887;
    --line: rgba(236, 229, 216, 0.13);
    --line-strong: rgba(236, 229, 216, 0.38);
    --accent: #d0553c;
    --accent-ink: #e06a50;
    --accent-wash: rgba(208, 85, 60, 0.13);
    --on-accent: #171411;
    --ok: #7aa889;
    --ok-wash: rgba(122, 168, 137, 0.12);
    --btn-primary-bg: #ece5d8;
    --btn-primary-fg: #1a1512;
    --btn-primary-border: #ece5d8;
    --btn-primary-hover: #f8f3e9;
    --btn-ok-bg: #7aa889;
    --btn-ok-fg: #10160f;
    --grain-opacity: 0.08;
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* 顶部朱砂书签线 */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  z-index: 90;
}

/* 纸张颗粒 */
.grain {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

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

a {
  color: var(--accent);
}

:focus {
  outline: none;
}

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

/* ============ 报头 ============ */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.masthead {
  padding-top: 34px;
}

.masthead-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3.4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-weight: 700;
}

.sub {
  margin: 0 0 20px;
  max-width: 40em;
  color: var(--muted);
  font-size: 0.95rem;
}

/* 拉丁词根水印 */
.masthead-ghost {
  font-family: var(--serif-latin);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(4.5rem, 10vw, 7.5rem);
  line-height: 0.8;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--line-strong);
  user-select: none;
  white-space: nowrap;
}

@supports not (-webkit-text-stroke: 1px black) {
  .masthead-ghost {
    color: var(--line);
    -webkit-text-stroke: 0;
  }
}

/* 报头横线：统计 + 模式切换 */
.masthead-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
}

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

.stats > span:only-child {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  animation: pulse 1.2s ease-in-out infinite;
}

.chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 4px 10px;
  white-space: nowrap;
}

.chip-mastered {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

/* 墨块式选项卡 */
.tabs {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--raised);
}

.tab {
  border: none;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab:last-child {
  border-right: none;
}

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

.tab.active {
  background: var(--ink);
  color: var(--paper);
}

/* ============ 面板 ============ */

.app {
  padding: 20px 0 8px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
  animation: rise 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

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

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* ============ 通用控件 ============ */

input,
button {
  font: inherit;
}

input[type="search"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--raised);
  color: var(--ink);
  padding: 10px 14px;
  font-size: 0.95rem;
}

input[type="search"]::placeholder {
  color: var(--muted);
}

input[type="search"]:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.btn {
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--raised);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease,
    transform 0.1s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--ink);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
  color: var(--btn-primary-fg);
}

.btn-primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
}

.btn-ok {
  background: var(--btn-ok-bg);
  border-color: var(--btn-ok-bg);
  color: var(--btn-ok-fg);
}

.btn-ok:hover:not(:disabled) {
  border-color: var(--btn-ok-bg);
  opacity: 0.9;
}

/* ============ 学习地图 ============ */

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.map-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
  min-height: 56vh;
}

.root-list {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--raised);
  overflow: auto;
  max-height: 68vh;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.root-list::-webkit-scrollbar {
  width: 10px;
}

.root-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 5px;
}

.root-item {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.root-item:hover {
  background: var(--accent-wash);
}

.root-item.active {
  background: var(--accent-wash);
  box-shadow: inset 3px 0 0 var(--accent);
}

.root-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.root-key {
  font-family: var(--serif-latin);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.root-head > span:not(.root-key) {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.root-gloss {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.root-list > div:not(.root-item) {
  padding: 18px 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* 详情区：无框，直接呈现在纸上 */
.root-detail {
  padding: 4px 0;
}

.root-detail h2 {
  font-size: 1.15rem;
}

.root-detail p {
  color: var(--muted);
  font-size: 0.92rem;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: baseline;
}

.detail-root {
  font-family: var(--serif-latin);
  font-size: clamp(2.2rem, 5vw, 2.8rem);
  font-weight: 600;
  line-height: 1;
}

.root-detail > p {
  margin: 14px 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

.example-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--raised);
  padding: 10px 12px;
  transition: border-color 0.15s ease;
}

.example-card:hover {
  border-color: var(--line-strong);
}

.example-word {
  font-family: var(--serif-latin);
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.3;
}

.example-meaning {
  margin-top: 2px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.example-decomp {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

/* ============ 闪卡 ============ */

.flash-wrap {
  max-width: 680px;
  margin: 0 auto;
}

.flash-meta,
.quiz-score {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.flash-card {
  position: relative;
  min-height: 340px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--raised);
  box-shadow: 0 16px 40px rgba(33, 30, 26, 0.07);
  padding: 34px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  text-align: center;
}

/* 左上朱砂印 */
.flash-card::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 16px;
  width: 8px;
  height: 8px;
  background: var(--accent);
}

.flash-prompt {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.flash-root {
  font-family: var(--serif-latin);
  font-size: clamp(2.6rem, 8vw, 3.8rem);
  font-weight: 600;
  line-height: 1.1;
}

.flash-gloss,
.flash-words,
.flash-breakdown {
  font-size: 0.95rem;
  color: var(--ink-soft);
  max-width: 34em;
}

.is-revealed .flash-gloss,
.is-revealed .flash-words,
.is-revealed .flash-breakdown {
  animation: rise 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.is-revealed .flash-words {
  animation-delay: 0.07s;
}

.is-revealed .flash-breakdown {
  animation-delay: 0.14s;
}

.flash-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

/* ============ 选择题 ============ */

.quiz-wrap {
  max-width: 680px;
  margin: 0 auto;
}

.quiz-question {
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 16px;
}

.quiz-options {
  counter-reset: opt;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.quiz-option {
  display: flex;
  align-items: baseline;
  gap: 12px;
  text-align: left;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--raised);
  color: var(--ink);
  padding: 13px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quiz-option::before {
  counter-increment: opt;
  content: counter(opt, upper-alpha);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  min-width: 1.1em;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--ink);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option:not(.correct):not(.wrong):disabled {
  opacity: 0.55;
}

.quiz-option > span,
.quiz-option {
  font-family: var(--serif-latin);
  font-size: 1.05rem;
  font-weight: 600;
}

.quiz-option.correct {
  border-color: var(--ok);
  background: var(--ok-wash);
}

.quiz-option.correct::before {
  color: var(--ok);
  font-weight: 500;
}

.quiz-option.wrong {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.quiz-option.wrong::before {
  color: var(--accent);
  font-weight: 500;
}

.quiz-feedback {
  min-height: 44px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

/* ============ 页脚 ============ */

.credits {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 30px;
  border-top: 1px solid var(--line);
  margin-top: 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
}

.credits a {
  color: var(--ink-soft);
}

/* ============ 点读 ============ */

.say {
  cursor: pointer;
}

.say:hover {
  color: var(--accent);
}

.say.playing {
  color: var(--accent);
  animation: sayPulse 0.3s ease 3;
}

@keyframes sayPulse {
  50% {
    opacity: 0.45;
  }
}

.example-word-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.say-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.say-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.say-btn.playing {
  border-color: var(--accent);
  color: var(--accent);
  animation: sayPulse 0.3s ease 3;
}

.say-btn svg {
  display: block;
}

.example-word.say {
  display: inline-block;
  transition: color 0.15s ease;
}

.example-ipa {
  display: inline;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 400;
}

.flash-words .say,
.quiz-feedback .say {
  border-bottom: 1px dashed var(--line-strong);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.flash-words .say:hover,
.quiz-feedback .say:hover {
  border-bottom-color: var(--accent);
}

/* ============ 响应式 ============ */

@media (max-width: 900px) {
  .map-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .root-list {
    max-height: 38vh;
  }

  .masthead-ghost {
    font-size: 4rem;
  }
}

@media (max-width: 640px) {
  .masthead {
    padding-top: 26px;
  }

  .masthead-row {
    grid-template-columns: 1fr;
  }

  .masthead-ghost {
    display: none;
  }

  .masthead-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    display: flex;
    width: 100%;
  }

  .tab {
    flex: 1;
    padding: 10px 8px;
    font-size: 0.88rem;
  }

  .toolbar {
    flex-direction: column;
  }

  .flash-card {
    min-height: 280px;
    padding: 26px 20px;
  }

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

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

/* ============ 动效克制 ============ */

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

/* ============ 开屏欢迎界面 ============ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  cursor: pointer;
  perspective: 1400px;
  overflow: hidden;
  color: #f3ecdf;
  -webkit-tap-highlight-color: transparent;
}
.splash .door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50.5%;
  background: radial-gradient(120% 80% at var(--gx) 45%, #232c48 0%, #151b2e 55%, #0c1020 100%);
  transition: transform 1.5s cubic-bezier(0.65, 0, 0.35, 1), filter 1.5s;
  backface-visibility: hidden;
}
.splash.is-open .door::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(transparent, rgba(230, 180, 87, 0.45) 30%, rgba(230, 180, 87, 0.45) 70%, transparent);
}
.splash .door-l {
  left: 0;
  --gx: 100%;
  transform-origin: left center;
}
.splash .door-l::after {
  right: 0;
}
.splash .door-r {
  right: 0;
  --gx: 0%;
  transform-origin: right center;
}
.splash .door-r::after {
  left: 0;
}
.splash .splash-light {
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: 50%;
  width: 4px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 50% at 50% 50%, rgba(255, 236, 200, 0.95), rgba(255, 214, 150, 0.35) 45%, transparent 72%);
  opacity: 0;
  pointer-events: none;
}
.splash .splash-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.splash .splash-copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(11vh, 72px);
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
  pointer-events: none;
}
.splash .splash-tag {
  font: 600 clamp(20px, 3vw, 30px) / 1.2 "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  margin: 0;
  opacity: 0;
  transform: translateY(10px);
  filter: blur(6px);
  transition: opacity 1.2s cubic-bezier(0.22, 0.61, 0.21, 1), transform 1.2s cubic-bezier(0.22, 0.61, 0.21, 1), filter 1.2s cubic-bezier(0.22, 0.61, 0.21, 1), letter-spacing 1.6s cubic-bezier(0.22, 0.61, 0.21, 1);
  text-shadow: 0 0 30px rgba(255, 214, 150, 0.35);
}
.splash .splash-hint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: rgba(243, 236, 223, 0.6);
  opacity: 0;
  transition: opacity 0.8s 0.5s;
}
.splash .splash-key {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e6b457;
  box-shadow: 0 0 0 0 rgba(230, 180, 87, 0.6);
  animation: beacon 1.8s ease-out infinite;
}
@keyframes beacon {
  to {
    box-shadow: 0 0 0 14px rgba(230, 180, 87, 0);
  }
}
.splash .splash-skip {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: 20px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: rgba(243, 236, 223, 0.55);
  background: transparent;
  border: 1px solid rgba(243, 236, 223, 0.18);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, opacity 0.4s;
}
.splash .splash-skip:hover {
  color: #f3ecdf;
  border-color: rgba(243, 236, 223, 0.5);
}
.splash.is-ready .splash-tag,
.splash.is-open .splash-tag {
  opacity: 1;
  transform: none;
  filter: none;
}
.splash.is-ready .splash-hint {
  opacity: 1;
}
.splash.is-open {
  pointer-events: none;
}
.splash.is-open .splash-hint,
.splash.is-open .splash-skip {
  opacity: 0;
  transition: opacity 0.3s;
}
.splash.is-open .splash-tag {
  letter-spacing: 0.6em;
  opacity: 0;
  transition: opacity 1s 0.5s, letter-spacing 1.6s cubic-bezier(0.22, 0.61, 0.21, 1);
}
.splash.is-open .door-l {
  transform: rotateY(-96deg);
  filter: brightness(1.6);
}
.splash.is-open .door-r {
  transform: rotateY(96deg);
  filter: brightness(1.6);
}
.splash.is-open .splash-light {
  animation: doorlight 1.4s cubic-bezier(0.22, 0.61, 0.21, 1) forwards;
}
@keyframes doorlight {
  0% {
    opacity: 0;
    width: 4px;
  }
  25% {
    opacity: 1;
    width: 30vw;
  }
  100% {
    opacity: 0;
    width: 140vw;
  }
}
.splash .splash-static {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  font: 700 72px "Songti SC", "STSong", "SimSun", serif;
  transition: opacity 0.4s;
}
.splash .splash-static small {
  font: 600 14px "EB Garamond", Georgia, serif;
  letter-spacing: 0.4em;
  opacity: 0.7;
}
.splash.is-reduced .door {
  transition: opacity 0.3s;
}
.splash.is-reduced.is-open .door,
.splash.is-reduced.is-open .splash-static {
  transform: none;
  opacity: 0;
}

/* ============ 意境图 + 画风画廊 ============ */

.example-card {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 8px;
  align-items: center;
}
.example-card > .example-word-row,
.example-card > .example-meaning,
.example-card > .example-decomp {
  grid-column: 1;
}
.word-art {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 86px;
}
.word-art-img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: var(--r);
  border: 1px solid var(--line);
  cursor: zoom-in;
  display: block;
}
.word-art-lg {
  grid-column: auto;
  grid-row: auto;
  margin-top: 16px;
  justify-content: center;
}
.word-art-lg .word-art-img {
  width: min(280px, 82vw);
  height: auto;
}
.flash-card .word-art-lg {
  min-height: 0;
}
.gen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: var(--r);
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.gen-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}
.gen-btn:disabled {
  cursor: wait;
}
.gen-btn.is-busy {
  animation: gen-pulse 1.2s ease-in-out infinite;
}
@keyframes gen-pulse {
  50% {
    opacity: 0.55;
  }
}

.gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: color-mix(in srgb, var(--bg, #14100c) 72%, transparent);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
}
.gallery-modal {
  width: min(880px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.gallery-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gallery-title strong {
  font-size: 1.05rem;
}
.gallery-title span {
  font-size: 0.78rem;
  color: var(--muted);
}
.gallery-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.gallery-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}
.gallery-groups {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.gallery-chip {
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}
.gallery-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.gallery-grid {
  overflow-y: auto;
  padding: 4px 16px 16px;
}
.gallery-section-title {
  position: sticky;
  top: 0;
  padding: 12px 0 8px;
  background: var(--raised);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  z-index: 1;
}
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 10px;
}
.style-cell {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}
.style-cell:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}
.style-cell.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-wash);
}
.style-cell img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg, #eee);
}
.style-num {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #f3ecdf;
  font-family: var(--mono, monospace);
  font-size: 0.68rem;
}
.style-name {
  display: block;
  padding: 6px 8px 8px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ink);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.style-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
