/* 图片墙 —— 一屏铺几十张图，快速过词建立图↔词的直觉。
   颜色和排版沿用 style.css 的变量，这里只写墙和放映特有的部分。 */

.wall-page { background: var(--bg); }

/* ------------------------------------------------------------ 深色下的墙
 *
 * 插图基本都是白底的：抽样 60 张，平均亮度 190、中位数 197、43% 高于 200，
 * 而深色页面底色亮度只有 15。4564 张平铺 = 一墙灯箱，深色本该省眼睛，
 * 结果比浅色还刺眼。
 *
 * 不砍深色模式（那是用户自己按的开关），改成两头收：墙的底色抬一档，
 * 图压一档，鼠标停上去恢复原亮度——真正在看的那张永远是全保真的。
 * 放映和聚焦浮层不压：那两处一次只有一张图，不存在累加的光。
 */
.wall-page[data-dim] .wall { background: var(--wall-ground); }
.wall-page[data-dim] .tile figure {
  box-shadow: 0 0 0 1px var(--line), 0 2px 10px -6px rgba(0, 0, 0, .7);
}
.wall-page[data-dim] .tile img {
  filter: brightness(.78) saturate(.92);
  transition: filter .16s;
}
.wall-page[data-dim] .tile:hover img,
.wall-page[data-dim] .tile:focus-visible img { filter: none; }
/* 标记框要压过上面那条 box-shadow，否则红绿框在深色下看不见 */
.wall-page[data-dim] .tile.weak figure { box-shadow: 0 0 0 2px var(--rose); }
.wall-page[data-dim] .tile.known figure { box-shadow: 0 0 0 2px var(--teal); }

/* ------------------------------------------------------------ 顶栏补充 */

.switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--line-soft);
  flex: none;
}
.switch .sw {
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  text-decoration: none;
  transition: all .15s;
}
.switch a.sw:hover { color: var(--ink); }
.switch .sw.on {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.wall-count { font: 500 12px var(--mono); color: var(--ink-3); white-space: nowrap; }

.icon.play {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  padding: 0 14px;
}
.icon.play:hover { filter: brightness(1.08); color: #fff; }

/* ------------------------------------------------------------ 网格 */

/* width:100% 不能省。body 是列向 flex，`margin: 0 auto` 会取消交叉轴拉伸，
   网格退化成按内容取宽——auto-fill 于是铺出几十列，整页横向溢出。 */
.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile, 150px), 1fr));
  gap: 12px;
  padding: 16px max(12px, env(safe-area-inset-left)) 30px max(12px, env(safe-area-inset-right));
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.tile {
  display: block;
  border: 0;
  padding: 0;
  background: none;
  text-align: center;
  cursor: pointer;
  /* 网格项的自动最小尺寸是 min-content。格子里的中文释义是 nowrap 的，
     长释义会把整条轨道顶宽，窄屏上整个网格就溢出屏幕。必须归零。 */
  min-width: 0;
  overflow: hidden;
  /* 4283 个格子全渲染会卡死。交给浏览器：屏幕外的不排版、不绘制。 */
  content-visibility: auto;
  /* 没渲染的格子按这个高度占位。写死会让滚动条说谎，所以由 wall.js 量出真实
     高度回填 --tile-h，密度一变就重量。190px 只是首屏前的兜底。 */
  contain-intrinsic-size: auto var(--tile-h, 190px);
}

.tile figure {
  margin: 0 0 6px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--line-soft);
  box-shadow: 0 2px 10px -6px rgba(16, 20, 26, .5);
  transition: transform .16s, box-shadow .16s;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile:hover figure {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 24px -10px rgba(16, 20, 26, .5);
}
.tile:focus-visible figure { outline: 2px solid var(--teal); outline-offset: 3px; }

.tile b {
  display: block;
  font: 600 13.5px/1.35 var(--serif);
  color: var(--ink);
  word-break: break-word;
}
.tile span {
  display: block;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 盖住单词——只看图自测，鼠标移上去才露出来 */
.wall-page.hide-words .tile b,
.wall-page.hide-words .tile span { visibility: hidden; }
.wall-page.hide-words .tile:hover b,
.wall-page.hide-words .tile:hover span,
.wall-page.hide-words .tile:focus-visible b,
.wall-page.hide-words .tile:focus-visible span { visibility: visible; }

/* 标过的卡在墙上一眼能认出来 */
.tile.weak figure { box-shadow: 0 0 0 2px var(--rose); }
.tile.known figure { box-shadow: 0 0 0 2px var(--teal); }

/* 正在念的那一格：给个看得见的落点，否则声音不知道从哪来 */
.tile.sounding figure {
  box-shadow: 0 0 0 3px var(--teal), 0 10px 24px -10px rgba(16, 20, 26, .5);
  transform: translateY(-3px) scale(1.02);
}
.icon#btn-hover.on { border-color: var(--teal); color: var(--teal); }

.wall-empty { text-align: center; padding: 90px 20px; color: var(--ink-3); }
.wall-empty p { margin-bottom: 18px; }

/* ------------------------------------------------------------ 聚焦浮层 */

.focus {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  animation: fade .18s;
}
.focus-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-elev);
  font-size: 14px;
}
.focus-box {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 26px;
  align-items: center;
  max-width: 760px;
  width: 100%;
  padding: 26px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.focus-box img { width: 100%; border-radius: 14px; display: block; }
.focus-head { display: flex; align-items: center; gap: 12px; }
.focus-info h2 { margin: 0; font: 700 32px/1.15 var(--serif); }
.focus-ipa { margin: 8px 0 0; font: 400 14px var(--mono); color: var(--ink-3); }
.focus-ipa:empty { display: none; }
.focus-cn { margin: 14px 0 0; font-size: 20px; font-weight: 650; }
.focus-ex { margin: 12px 0 0; font: 400 15px/1.6 var(--serif); color: var(--ink-2); }
.focus-ex:empty { display: none; }
.focus-ex mark {
  background: color-mix(in srgb, var(--teal) 18%, transparent);
  color: inherit;
  font-weight: 700;
  border-radius: 3px;
  padding: 0 2px;
}
.focus-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.focus-actions .ghost-btn { text-decoration: none; }

/* 上一张 / 下一张。贴在浮层左右边缘，鼠标不用回到卡片上 */
.focus-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-elev);
  color: var(--ink-2);
  font: 400 22px/1 var(--sans);
  box-shadow: var(--shadow-sm);
  transition: border-color .12s, color .12s, opacity .12s;
}
.focus-nav:hover:not(:disabled) { border-color: var(--teal); color: var(--ink); }
.focus-nav:disabled { opacity: .28; cursor: default; }
.focus-nav.prev { left: max(14px, calc(50vw - 480px)); }
.focus-nav.next { right: max(14px, calc(50vw - 480px)); }

.focus-at { margin-left: auto; font: 500 12px var(--mono); color: var(--ink-3); }

/* 搭配：一眼能看出中心词怎么用 */
.focus-col {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.focus-col:empty { display: none; }
.focus-col li {
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--line-soft);
  font-size: 13px;
  color: var(--ink-2);
}
.focus-col mark {
  background: none;
  color: var(--teal);
  font-weight: 700;
}

@media (max-width: 900px) {
  .focus-nav { width: 38px; height: 38px; font-size: 19px; }
  .focus-nav.prev { left: 10px; }
  .focus-nav.next { right: 10px; }
}

@media (max-width: 680px) {
  .focus-box { grid-template-columns: 1fr; gap: 16px; padding: 18px; max-height: 88vh; overflow-y: auto; }
  .focus-box img { max-width: 220px; margin: 0 auto; }
  .focus-info h2 { font-size: 26px; }
}

/* ------------------------------------------------------------ 放映 */

.flash {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.flash-bar {
  flex: none;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.flash-progress { height: 3px; background: var(--line); }
.flash-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--teal);
  transition: width .18s linear;
}
.flash-ctl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.flash-round {
  font: 600 12px var(--sans, inherit);
  color: var(--ink-2);
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.flash-pos { font: 500 12px var(--mono); color: var(--ink-3); margin-right: 6px; }
.flash-speed { font: 600 12px var(--mono); color: var(--ink-2); min-width: 62px; text-align: center; }
.fbtn {
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
}
.fbtn:hover { border-color: var(--teal); color: var(--ink); }
.fbtn.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.fbtn.wide { min-width: 62px; }
/* 开着但这个速度下必然被掐断——别让人以为坏了 */
.fbtn.on.muted-by-speed { opacity: .45; }

/* 齿轮收起来的设置区 */
.flash-set {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  justify-items: center;
}
.fs-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.fs-label { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.fs-note { font-size: 11px; color: var(--ink-3); margin-left: 4px; }
/* 设置收起来了，但里面有开着的开关——齿轮上点一下让你知道 */
#flash-gear { position: relative; }
#flash-gear.has-on::after {
  content: '';
  position: absolute;
  top: 4px; right: 4px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--teal);
}
#flash-gear.on.has-on::after { background: #fff; }

.flash-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 20px;
  min-height: 0;
}
.flash-stage img {
  max-height: min(56vh, 520px);
  max-width: min(92vw, 520px);
  border-radius: 18px;
  box-shadow: 0 20px 50px -24px rgba(0, 0, 0, .6);
  display: block;
  transition: opacity .12s;
}
.flash-text { text-align: center; transition: opacity .12s; }
/* 回忆窗里藏起来的那一半：正向藏词，反向藏图。用 opacity 不用 display，
   位置留着，答案出现时画面不跳。 */
.flash-text.veiled,
.flash-stage img.veiled { opacity: 0; }

/* 反向轮问的是词，词就得在最上面。不换序的话，隐形的图仍然占着上半屏，
   单词被挤到屏幕最底下，题目反而最不显眼。 */
.flash-stage.reverse .flash-text { order: -1; }
.flash-text h2 {
  margin: 0;
  font: 700 clamp(30px, 6vw, 50px)/1.1 var(--serif);
  letter-spacing: -.015em;
}
.flash-ipa { margin: 6px 0 0; font: 400 15px var(--mono); color: var(--ink-3); }
.flash-ipa:empty { display: none; }
.flash-cn { margin: 10px 0 0; font-size: clamp(18px, 3.6vw, 24px); font-weight: 650; color: var(--teal); }
/* 中文是单独一层：留着位置但不给看，按 C 才露。眼睛一旦读到中文就不再想词了 */
.flash-cn.cn-hide { visibility: hidden; }
.flash-cn:empty { visibility: hidden; }

/* 没插图的卡：图位收起来，改用挖空的例句当线索 */
.flash-stage.no-image img { display: none; }
.flash-cue {
  margin: 0;
  max-width: 46ch;
  text-align: center;
  font-size: clamp(18px, 2.8vw, 24px);
  line-height: 1.7;
  color: var(--ink);
}
.flash-cue:empty { display: none; }
.flash-cue .blank { text-decoration: none; color: var(--teal); letter-spacing: .06em; }

/* 墙上没图的格子：首字母占位，别放碎图标 */
.tile.flat figure {
  display: grid;
  place-items: center;
  background: var(--line-soft);
}
.noimg {
  font: 700 clamp(24px, 4vw, 40px)/1 var(--serif);
  font-style: normal;
  color: var(--ink-3);
}

.flash-hint {
  margin: 0;
  min-height: 20px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-3);
  letter-spacing: .04em;
}
.flash-ex {
  margin: 0;
  max-width: 46ch;
  text-align: center;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-2);
}
.flash-ex:empty { display: none; }
.flash-ex mark { background: none; color: var(--rose); font-weight: 700; }

/* 按了空格：这张没认出来，整个舞台换个调子，让「栽了」有实感 */
.flash-stage.missed img { box-shadow: 0 0 0 3px var(--rose), 0 20px 50px -24px rgba(0, 0, 0, .6); }
.flash-stage.missed .flash-hint { color: var(--rose); }

/* 这幅画和别的词撞车，中文是仅剩的线索 */
.flash-note {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--rose);
  letter-spacing: .04em;
}
.flash-note:empty { display: none; }

/* ------------------------------------------------------------ Day 区间选择
 *
 * 以前这里是 320 个胶囊，塞在 168px 的框里、内容高 18000px——选 Day 250 要滚
 * 一百多屏，还看不出它属于哪个牌组。Day 本来就是连续轴，改成区间 + 牌组图例。
 */

#opt-day { display: grid; gap: 10px; }
.day-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
}
.dnum {
  width: 62px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: 600 13px var(--mono);
  text-align: center;
}
.dnum:focus { outline: none; border-color: var(--teal); }
.dnum::placeholder { color: var(--ink-3); font-weight: 400; }

.day-legend { display: grid; gap: 5px; }
.dayrun {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
  text-align: left;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.dayrun:hover { border-color: var(--teal); }
.dayrun b { font-size: 13px; font-weight: 600; color: var(--ink); }
.dayrun span { font: 500 12px var(--mono); color: var(--ink-3); white-space: nowrap; }
.dayrun.on { background: var(--teal); border-color: var(--teal); }
.dayrun.on b, .dayrun.on span { color: #fff; }

/* 「今天该复习 N 张」——打开就知道该干什么，所以它要比别的 chip 显眼 */
.chip.due {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-ink);
  font-weight: 650;
}
.chip.due:hover { background: var(--teal); color: #fff; }

/* ------------------------------------------------------------ 四选一图 */

.quiz {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  min-height: 0;
}
.quiz h2 {
  margin: 0;
  font: 700 clamp(28px, 5vw, 46px)/1.1 var(--serif);
  letter-spacing: -.015em;
}
.quiz-opts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  width: min(92vw, 840px);
}
.qopt {
  position: relative;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elev);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  transition: border-color .12s, transform .12s;
}
.qopt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qopt:hover { border-color: var(--teal); transform: translateY(-2px); }
.qnum {
  position: absolute;
  left: 7px; top: 7px;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 7px;
  background: rgba(16, 20, 26, .72);
  color: #fff;
  font: 600 12px var(--mono);
}
.qopt.right { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal); }
.qopt.wrong { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose); opacity: .75; }

@media (max-width: 720px) {
  .quiz-opts { grid-template-columns: repeat(2, 1fr); width: min(94vw, 460px); }
}

/* ------------------------------------------------------------ 拼写 / 听写 */

.wspell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  min-height: 0;
}
.wspell-sent {
  margin: 0;
  max-width: 46ch;
  text-align: center;
  font-size: clamp(16px, 2.4vw, 20px);
  line-height: 1.7;
  color: var(--ink);
}
.wspell-sent .blank {
  text-decoration: none;
  color: var(--teal);
  letter-spacing: .06em;
}
.wspell-cn { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-3); }
.wspell-cn:empty { display: none; }

/* 搭配填空的三条题干。竖排、居中，空位对齐，一眼能看出是同一个中心词 */
.wspell-cols {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  justify-items: center;
}
.wspell-cols:empty { display: none; }
.wspell-cols li {
  font-size: clamp(17px, 2.6vw, 22px);
  line-height: 1.5;
  color: var(--ink);
}
.wspell-cols .blank { text-decoration: none; color: var(--teal); letter-spacing: .06em; }
/* 类名不能叫 .spell —— 学习页在 style.css 里已经占了这个名字，
   那边的 `.spell input { flex: 1 }` 会把这里的输入框拉成半屏高。 */
#wspell-input {
  flex: none;
  width: min(92vw, 420px);
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-elev);
  color: var(--ink);
  font: 500 18px var(--mono);
  text-align: center;
}
#wspell-input:focus { outline: none; border-color: var(--teal); }
#wspell-input:disabled { opacity: .55; }

.wspell-feed { display: grid; gap: 6px; justify-items: center; }
.wspell-feed:empty { display: none; }
.sf-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sf-tag { font-size: 11px; font-weight: 600; color: var(--ink-3); letter-spacing: .06em; }
.sf-line b { font: 700 22px var(--mono); letter-spacing: .02em; }
.sf-line b.ok { color: var(--ink); }
.sf-line b.bad { color: var(--rose); text-decoration: line-through; }
/* 从这个字母起对不上 */
.sf-line b .cut { font-style: normal; color: var(--rose); text-decoration: underline; }
.sf-ipa { font: 400 14px var(--mono); color: var(--ink-3); }
.sf-at { font-size: 12px; color: var(--ink-3); }
.sf-line b.chunks { font-size: 20px; color: var(--teal); }
.sf-line b.chunks i { font-style: normal; color: var(--ink-3); padding: 0 2px; }
.wspell-img {
  width: 168px; height: 168px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 0 0 2px var(--rose);
}

.flash-done {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--bg);
  text-align: center;
  padding: 24px;
}
.flash-done h2 { margin: 0; font-size: 24px; }
.flash-done p { margin: 0; color: var(--ink-3); font-size: 14px; max-width: 40ch; line-height: 1.7; }

/* 批末结算：漏网的那几张直接摆出来，比只报个数字有用 */
.flash-done.batch { place-content: center; align-content: center; }
.missed-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: min(76vw, 720px);
  max-height: 42vh;
  overflow-y: auto;
  padding: 4px;
}
.missed-grid:empty { display: none; }
.mini { margin: 0; width: 92px; }
.mini img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 0 0 2px var(--rose);
  display: block;
}
.mini figcaption {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  /* 图片墙顶栏的东西比学习页多，窄屏一行放不下。换行成两排，
     第一排切页 + 开关，第二排范围 + 张数——一个功能都不砍。 */
  .wall-page .topbar { flex-wrap: wrap; row-gap: 8px; }
  .wall-page .scope { order: 3; width: 100%; flex: none; }
  .wall-page .tools { flex: 1; }
  .switch .sw { padding: 5px 10px; font-size: 12.5px; }
  .icon.play { padding: 0 11px; }

  .wall { gap: 10px; padding: 12px 10px 24px; }
  .flash-ctl { gap: 6px; padding: 8px 10px; }
  .flash-pos { width: 100%; text-align: center; margin: 0 0 2px; }
  .flash-stage { gap: 16px; }
  .flash-stage img { max-height: 46vh; }
}

/* 学习页那条切页导航在窄屏也要能站住 */
@media (max-width: 420px) {
  .wall-page .wall-count { display: none; }
}
