/* Tra cứu: page title, glass tabs, chapter rail, portrait-tile grid, floating card viewer. */

.app-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100dvh;
}

/* ---- toolbar: title, type tabs, search ---- */
.toolbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  gap: 22px;
  padding: 0 var(--pad);
}

/* heavy italic caps with a script flourish over its corner: the logo's own pairing */
.page-title {
  position: relative;
  flex: none;
  margin: 0 0 8px;
  padding-right: 52px;
  line-height: 1;
}
.page-title .t1 {
  display: block;
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 3px 0 rgb(0 0 0 / 0.4), 0 12px 24px rgb(0 0 0 / 0.4);
}
.page-title .t2 {
  position: absolute;
  right: 0;
  bottom: -12px;
  font-family: var(--font-script);
  font-size: 1.75rem;
  line-height: 1;
  color: var(--brand-cream);
  rotate: -7deg;
  text-shadow: 0 2px 0 rgb(139 18 41 / 0.7), 0 5px 12px rgb(0 0 0 / 0.35);
}

.tabs { position: relative; display: flex; align-items: flex-end; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-top: 8px; }
.tabs::-webkit-scrollbar { display: none; }

/* angular glass slabs; the current one turns to bright glass */
.tab {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  flex: none;
  width: 176px;
  height: 58px;
  padding: 0 22px 0 16px;
  border: 0;
  border-top: 2px solid rgb(255 255 255 / 0.4);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.16), rgb(255 255 255 / 0.05));
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  color: var(--text-2);
  text-align: left;
  z-index: 1;
  transition: background var(--t-mid), color var(--t-mid);
}
.tab:hover { background: linear-gradient(180deg, rgb(255 255 255 / 0.26), rgb(255 255 255 / 0.1)); color: #fff; }
.tab:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-hi); }
.tab-icon { width: 24px; height: 24px; }
.tab-text { display: grid; gap: 3px; min-width: 0; }
.tab-name { font-size: var(--fs-md); font-weight: 600; line-height: 1.15; white-space: nowrap; }
.tab-cap {
  font-family: var(--font-tech);
  font-size: var(--fs-cap);
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-3);
}
.tab .n { font-family: var(--font-tech); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-3); }

/* the bright plate of the current tab is its own element (TabBar), so it can slide between tabs */
.tab[aria-selected="true"] {
  border-top-color: transparent;
  background: transparent;
  color: var(--accent-deep);
}
.tab-plate {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  width: 0;
  height: 0;
  box-sizing: border-box;
  border-top: 2px solid #fff;
  background: linear-gradient(115deg, #eef3ff 0%, #b7cbff 52%, #dde7ff 100%);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  pointer-events: none;
  transition: transform 480ms var(--ease); /* size is set outright: the tabs share one size, only the position travels */
}
.tab[aria-selected="true"] .tab-cap,
.tab[aria-selected="true"] .n { color: var(--accent-deep); }

.search {
  position: relative;
  align-self: center;
  margin-left: auto;
  width: min(320px, 100%);
}
.search .icon { position: absolute; z-index: 1; left: 17px; top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 46px;
  background: rgb(17 24 62 / 0.72);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  font-size: var(--fs-md);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.search input::placeholder { color: var(--text-3); }
.search input:hover { border-color: var(--glass-line-strong); }
.search input:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 1px; border-color: var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute;
  z-index: 1;
  right: 6px; top: 50%;
  translate: 0 -50%;
  width: 32px; height: 32px;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-3);
}
.search-clear:hover { color: #fff; background: var(--glass-soft); }
.search.has-value .search-clear { display: grid; }

/* ---- workspace: three glass panels ---- */
.workspace {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--detail-w);
  grid-template-areas: "rail list detail";
  gap: 16px;
  min-height: 0;
  padding: 14px var(--pad) 12px;
}

/* Frosted display areas. The streaked sky behind them must not show sharply, and a live backdrop blur costs too much
   while the card sways and the grid scrolls (measured), so the frost is a dense, smooth tint: the sky only glows through. */
.rail, .list, .detail {
  background: var(--glass-list);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-lg);
}
.detail { background: var(--glass-text); }

.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding: 16px 10px;
}
.rail-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 0 10px;
  font-family: var(--font-tech);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--accent);
}
.rail-title::before { content: ""; width: 7px; height: 7px; rotate: 45deg; background: var(--accent-grad); flex: none; }

/* filter entries carry the official radio marker */
.rail-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.rail-btn.has-logo::before { display: none; }
.rail-btn::before {
  content: "";
  flex: none;
  width: 15px;
  height: 15px;
  border: 1.5px solid rgb(170 188 255 / 0.65);
  border-radius: 50%;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.rail-btn > span:first-of-type { flex: 1; min-width: 0; }
.rail-btn .n { font-family: var(--font-tech); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-3); }
.rail-btn:hover { background: var(--glass-soft); color: #fff; }
.rail-btn[aria-current="true"] { background: var(--accent-wash); color: #fff; font-weight: 700; }
.rail-btn[aria-current="true"]::before { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 38%, transparent 42%); }
.rail-btn[aria-current="true"] .n { color: var(--accent); }
.rail-btn[disabled] { opacity: 0.4; cursor: default; background: none; color: var(--text-3); }

.list {
  grid-area: list;
  position: relative;
  overflow-y: auto;
  padding: 0 20px 44px;
  scroll-behavior: smooth;
  outline: none;
}

.status { padding: 14px 0 2px; color: var(--text-3); font-size: var(--fs-sm); }
.status strong { color: var(--text-2); font-weight: 600; }
/* the spinner is a child node so it's cleared for free the first time JS touches .status
   (replaceChildren, textContent = '', or hidden = true all remove it) */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid var(--glass-line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chapter-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -20px;
  padding: 16px 20px 10px;
  background: rgb(46 60 128 / 0.9);
}
/* a small diamond leading in, a rule fading out to the right edge */
.chapter-head::before {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  rotate: 45deg;
  border-radius: 1px;
  background: var(--accent-grad);
}
.chapter-head::after {
  content: "";
  flex: 1;
  height: 1px;
  min-width: 24px;
  background: linear-gradient(90deg, var(--accent-lo), transparent);
}
.chapter-head h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  line-height: 1.25;
  text-transform: uppercase;
}
.chapter-head .n { font-family: var(--font-tech); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-3); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  justify-items: center;
  gap: 20px 4px;
  padding: 14px 4px 24px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 92px;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-2);
  text-align: center;
}
.tile[hidden] { display: none; }
.tile:focus-visible { outline: none; }
.tile:focus-visible .tile-art { outline: 2px solid var(--accent-hi); outline-offset: 3px; }

/* the tile is a small card: a thin light frame around a portrait */
.tile-art {
  position: relative;
  width: 64px;
  padding: 2px;
  border-radius: 12px;
  background: linear-gradient(160deg, rgb(255 255 255 / 0.65), rgb(153 180 254 / 0.3) 58%, rgb(255 255 255 / 0.4));
  transition: background var(--t-fast), transform var(--t-mid) var(--ease), box-shadow var(--t-mid);
}
.tile-face {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 10px;
  background: rgb(15 21 56 / 0.85);
}
.tile--icon .tile-face { aspect-ratio: 1; background: radial-gradient(circle at 50% 40%, rgb(153 180 254 / 0.28), rgb(15 21 56 / 0.9) 72%); }
.tile-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0;
  transform: scale(2);
  transform-origin: 60% 8%;
}
.tile--icon .tile-img { object-fit: contain; padding: 9%; object-position: 50% 50%; transform: none; }
.tile-badge { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; }

.tile:hover .tile-art { background: linear-gradient(160deg, #fff, var(--accent)); transform: translateY(-3px); }

/* selected: the tile seats itself in a bright frame with four corner brackets */
.tile[aria-pressed="true"] .tile-art {
  background: var(--accent-grad);
  box-shadow: 0 10px 20px rgb(0 0 0 / 0.5);
  animation: seat 320ms var(--ease);
}
.tile[aria-pressed="true"] .tile-art::before {
  content: "";
  position: absolute;
  inset: -6px;
  pointer-events: none;
  background:
    linear-gradient(var(--accent-hi), var(--accent-hi)) 0 0 / 10px 2px,
    linear-gradient(var(--accent-hi), var(--accent-hi)) 0 0 / 2px 10px,
    linear-gradient(var(--accent-hi), var(--accent-hi)) 100% 0 / 10px 2px,
    linear-gradient(var(--accent-hi), var(--accent-hi)) 100% 0 / 2px 10px,
    linear-gradient(var(--accent-hi), var(--accent-hi)) 0 100% / 10px 2px,
    linear-gradient(var(--accent-hi), var(--accent-hi)) 0 100% / 2px 10px,
    linear-gradient(var(--accent-hi), var(--accent-hi)) 100% 100% / 10px 2px,
    linear-gradient(var(--accent-hi), var(--accent-hi)) 100% 100% / 2px 10px;
  background-repeat: no-repeat;
  animation: brackets 320ms var(--ease);
}
@keyframes seat { from { transform: scale(0.92); } to { transform: none; } }
@keyframes brackets { from { scale: 1.3; opacity: 0; } to { scale: 1; opacity: 1; } }


.tile-face.is-loading { background: linear-gradient(160deg, rgb(15 21 56 / 0.85), rgb(60 78 150 / 0.6)); }
.tile-face.is-broken::after { content: attr(data-ch); font-family: var(--font-cjk); font-size: 1.6rem; color: var(--text-3); }
.tile-face.is-broken .tile-img { display: none; }
@keyframes breathe { from { opacity: 0.25; } to { opacity: 1; } }

.tile-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  font-size: var(--fs-xs);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.tile.is-zh .tile-name { font-family: var(--font-cjk); font-size: var(--fs-sm); line-height: 1.25; }
.tile[aria-pressed="true"] .tile-name { color: #fff; font-weight: 600; }

.empty {
  display: grid;
  gap: 6px;
  max-width: 46ch;
  margin-top: 40px;
  padding: 22px;
  border: 1px dashed var(--glass-line-strong);
  border-radius: var(--r-md);
  color: var(--text-2);
}
.empty strong { font-size: var(--fs-lg); color: #fff; }
.empty button { justify-self: start; margin-top: 8px; }

.legal {
  max-width: 62ch;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--glass-line);
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: 1.6;
}

/* ---- card viewer ---- */
.detail {
  grid-area: detail;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden auto;
  padding: 16px 18px 20px;
}
.detail > * { flex: none; }
.grab { display: none; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stage-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-line);
}
.stage-controls .variants { grid-column: 1; }
.stage-controls #chep-lien-ket { grid-column: 2; justify-self: end; }

.icon-btn, .btn {
  display: inline-grid;
  place-items: center;
  height: 40px;
  background: rgb(255 255 255 / 0.1);
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  color: var(--text-2);
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.icon-btn { width: 40px; }
.icon-btn .i-done { display: none; }
.icon-btn.is-done .i-link { display: none; }
.icon-btn.is-done .i-done { display: block; color: var(--accent-hi); }
.icon-btn.is-done { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 0 16px; font-size: var(--fs-sm); font-weight: 600; }
.icon-btn:hover, .btn:hover { border-color: var(--accent); color: #fff; background: rgb(255 255 255 / 0.18); }
.icon-btn[disabled] { opacity: 0.4; cursor: default; }
.detail-close { display: none; }

.info { min-width: 0; flex: 1; }
.name { font-family: var(--font-display); font-size: 1.75rem; font-weight: 400; letter-spacing: 0.04em; line-height: 1.2; text-transform: uppercase; text-wrap: balance; }
.name.is-zh { font-family: var(--font-cjk); font-size: var(--fs-xl); font-weight: 700; letter-spacing: 0; text-transform: none; }
.name-zh { margin-top: 2px; color: var(--text-3); font-family: var(--font-cjk); font-size: var(--fs-md); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill {
  padding: 3px 11px;
  border: 1px solid var(--glass-line);
  border-radius: 99px;
  background: rgb(255 255 255 / 0.06);
  color: var(--text-2);
  font-size: var(--fs-xs);
}
.pill--todo { border-style: dashed; color: var(--text-3); }
.pill--accent { border-color: transparent; background: var(--accent-grad); color: var(--accent-deep); }
.pill-logo { display: inline-block; width: 16px; height: 16px; margin: -3px 6px -3px -4px; vertical-align: middle; }

/* the stage: the card floats in front of a backlight and sways in 3D like on the official site */
.stage {
  position: relative;
  display: grid;
  place-items: center;
  /* takes whatever height the text above and the controls below leave, and the card is sized from it */
  flex: 1 1 auto;
  min-height: 250px;
  container-type: size;
  perspective: 1200px;
  isolation: isolate;
}
.stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  width: 118%;
  aspect-ratio: 1;
  translate: -50% -52%;
  background: radial-gradient(closest-side, rgb(153 180 254 / 0.5), rgb(153 180 254 / 0.14) 55%, transparent 74%);
}
.stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: 6px;
  width: 64%;
  height: 22px;
  translate: -50% 0;
  background: radial-gradient(closest-side, rgb(4 8 34 / 0.6), transparent);
}
.swing { animation: sway 25s infinite; will-change: transform; }
@keyframes sway {
  0%, 100% { transform: rotateY(0deg); }
  10%, 30%, 50%, 70%, 90% { transform: rotateY(-10deg); }
  20%, 40%, 60%, 80% { transform: rotateY(10deg); }
}

.frame {
  /* the largest card that fits the stage, so the Vietnamese text above it never needs a scroll to reach */
  position: relative;
  width: min(100cqw, calc((100cqh - 28px) * 0.708));
  aspect-ratio: 400 / 565;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 22px 32px rgb(0 0 0 / 0.5);
}
.frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--t-mid) var(--ease); }
.frame[data-state="ready"] img { opacity: 1; }
.frame.is-settling { animation: settle 360ms var(--ease); }
@keyframes settle { from { translate: 0 10px; scale: 0.965; } to { translate: none; scale: 1; } }
.frame[data-state="loading"] { background: rgb(15 21 56 / 0.7); }
.frame[data-state="loading"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgb(120 145 230 / 0.34), rgb(120 145 230 / 0.08));
  animation: breathe 1.1s ease-in-out infinite alternate;
}
.frame-err {
  position: absolute; inset: 0;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  color: var(--text-2);
}
.frame[data-state="error"] .frame-err { display: grid; }
.frame[data-state="error"] img { display: none; }

/* image versions as dots, the current one a pill (clip-path, so nothing reflows) */
.variants { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0; }
.variants .cap { margin-right: 6px; color: var(--text); font-size: var(--fs-xs); }
.variant {
  position: relative;
  width: 30px;
  height: 24px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 12px;
  font-size: 0;
}
.variant::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: 26px;
  height: 9px;
  background: rgb(255 255 255 / 0.6);
  clip-path: inset(0 8.5px round 99px);
  transition: clip-path var(--t-mid) var(--ease), background var(--t-fast);
}
.variant:hover::before { background: #fff; }
.variant[aria-pressed="true"]::before { background: #fff; clip-path: inset(0 0 round 99px); }

/* the Vietnamese effect text is what the player came for: it sits right under the name, on its own panel */
.desc {
  padding: 12px 16px 14px;
  background: rgb(255 255 255 / 0.09);
  border: 1px solid var(--glass-line-strong);
  border-radius: 14px;
}
.desc h3 {
  margin-bottom: 6px;
  color: var(--accent-hi);
  font-family: var(--font-tech);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.desc p { font-size: 1.0625rem; font-weight: 500; line-height: 1.6; color: #fff; text-wrap: pretty; white-space: pre-line; }
.desc .variant-name { margin-bottom: 4px; font-weight: 700; color: var(--accent-hi); }
.desc .todo { font-size: var(--fs-md); font-weight: 400; color: var(--text-2); }

.scrim { display: none; }

/* ---- narrower desktops: the rail becomes a strip of chapter chips, the page title steps aside ---- */
@media (max-width: 1399px) {
  .page-title { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); padding: 0; }
}

@media (max-width: 1179px) {
  :root { --detail-w: 340px; }
  .tab { width: 156px; grid-template-columns: 1fr auto; }
  .tab-icon { display: none; }
  .workspace {
    grid-template-columns: minmax(0, 1fr) var(--detail-w);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "rail rail" "list detail";
    gap: 12px;
  }
  .rail {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px;
  }
  .rail-title { display: none; }
  .rail-btn { width: auto; flex: none; padding: 6px 12px 6px 10px; border: 1px solid var(--glass-line); border-radius: 99px; white-space: nowrap; }
  .rail-btn[aria-current="true"] { border-color: var(--accent); }
}

/* ---- phones: viewer becomes a bottom sheet ---- */
@media (max-width: 819px) {
  .toolbar { flex-wrap: wrap; gap: 0; padding: 0; }
  .tabs { width: 100%; padding: 4px 10px 0; gap: 3px; }
  .tab { flex: 1 1 0; width: auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 0; height: 52px; padding: 0 6px; text-align: center; }
  .tab-icon, .tab-cap { display: none; }
  .tab-name { font-size: var(--fs-sm); }
  .tab .n { font-size: var(--fs-xs); }
  .search { width: auto; flex: 1 1 100%; margin: 10px 10px 4px; }
  .status[data-q="0"] { display: none; }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "rail" "list";
    gap: 8px;
    padding: 6px 10px 10px;
  }
  .list { padding-inline: 12px; border-radius: 16px; }
  .chapter-head { margin-inline: -12px; padding-inline: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 18px 2px; padding-inline: 0; }
  .tile { max-width: 80px; }
  .tile-art { width: 58px; }
  .tile-badge { width: 16px; height: 16px; }
  .chapter-head h2 { font-size: 1.3rem; }

  .detail {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    max-height: 90dvh;
    padding: 8px 18px calc(24px + env(safe-area-inset-bottom, 0px));
    background: var(--glass-strong);
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
    transform: translateY(104%);
    visibility: hidden;
    transition: transform var(--t-mid) var(--ease), visibility 0s linear var(--t-mid);
  }
  .detail[data-open="true"] { transform: none; visibility: visible; transition: transform var(--t-mid) var(--ease); }
  .grab { display: block; width: 40px; height: 4px; margin: 0 auto 12px; border-radius: 4px; background: var(--glass-line-strong); }
  .detail-close { display: inline-grid; }
  .icon-btn { width: 44px; height: 44px; }
  .btn { height: 44px; }
  .rail-btn { padding: 8px 14px 8px 10px; }
  .search-clear { width: 40px; height: 40px; right: 2px; }
  .stage { flex: none; min-height: 0; container-type: normal; padding: 4px 0 6px; }
  .frame { width: min(58vw, 240px); }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgb(6 10 34 / 0.7); }
  .scrim[hidden] { display: none; }
  .scrim:not([hidden]) { display: block; }
}

/* keep the card from resizing as descriptions of different lengths come and go: reserve room for a typical one */
@media (min-width: 820px) {
  .desc { min-height: 8.25rem; }
}

/* ---- motion: how things arrive ---- */
@keyframes rise { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
@keyframes swap { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
@keyframes tile-in { from { opacity: 0; translate: 0 16px; scale: 0.9; } to { opacity: 1; translate: 0 0; scale: 1; } }

/* switching card kind: the chapters rise one after another and the first tiles arrive in a short cascade */
#cac-chuong.is-entering .chapter { animation: rise 520ms var(--ease) both; animation-delay: calc(var(--i, 0) * 110ms); }
#cac-chuong.is-entering .tile[style*="--t"] { animation: tile-in 420ms var(--ease) both; animation-delay: calc(60ms + var(--t) * 14ms); }

/* choosing another card or version: the words in the viewer settle in */
.is-changing { animation: swap 320ms var(--ease) both; }


/* ---- game keywords: highlighted in descriptions, explained in a small box ---- */
.kw {
  font-weight: 700;
  color: var(--accent-hi);
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 3px;
  cursor: help;
}
.kw-icon { display: inline-block; width: 16px; height: 16px; margin: -2px 4px 0 0; vertical-align: middle; }
.kwbox-list dt { display: flex; align-items: center; gap: 6px; }
.kwbox {
  margin-top: 12px;
  padding: 10px 14px 12px;
  background: rgb(255 255 255 / 0.06);
  border: 1px solid var(--glass-line);
  border-radius: 12px;
}
.kwbox-title { margin-bottom: 6px; font-family: var(--font-tech); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.kwbox-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; margin: 0; }
.kwbox-list dt { font-weight: 700; color: var(--accent-hi); }
.kwbox-list dd { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-2); }
/* inside the description panel the explanation is a quiet footnote, not a second box */
.desc .kwbox { margin-top: 10px; padding: 10px 0 0; background: none; border: 0; border-top: 1px solid var(--glass-line); border-radius: 0; }

/* ---- faction emblems ---- */
.rail-logo { flex: none; width: 24px; height: 24px; object-fit: contain; opacity: 0.8; transition: opacity var(--t-fast), scale var(--t-mid) var(--ease); }
.rail-btn:hover .rail-logo, .rail-btn[aria-current="true"] .rail-logo { opacity: 1; }
.rail-btn[aria-current="true"] .rail-logo { scale: 1.12; }
.chapter-logo { flex: none; width: 30px; height: 30px; object-fit: contain; margin-right: -2px; }
.chapter-head:has(.chapter-logo)::before { display: none; }

/* ---- card info tabs: description, skill, stats ---- */
.info-block { display: grid; gap: 10px; }
.info-tabs { display: flex; gap: 4px; padding: 4px; background: rgb(15 21 56 / 0.4); border: 1px solid var(--glass-line); border-radius: 14px; }
.info-tabs[hidden] { display: none; }
.itab {
  flex: 1;
  height: 34px;
  padding: 0 8px;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast);
}
.itab:hover { background: var(--glass-soft); color: #fff; }
.itab[aria-selected="true"] { background: var(--accent-grad); color: var(--accent-deep); font-weight: 700; }
.itab:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 1px; }
.desc[hidden] { display: none; }

.skill-head { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: center; margin-bottom: 8px; }
.skill-icon { width: 56px; height: 56px; object-fit: cover; border-radius: 16px; box-shadow: 0 0 0 1.5px rgb(255 255 255 / 0.4), 0 4px 10px rgb(0 0 0 / 0.35); }
.desc .skill-name { margin: 0; font-family: var(--font-display); font-size: 1.25rem; font-weight: 400; letter-spacing: 0.04em; line-height: 1.2; text-transform: uppercase; color: #fff; }
.desc .skill-name[lang="zh-Hans"] { font-family: var(--font-cjk); font-size: var(--fs-lg); font-weight: 700; letter-spacing: 0; text-transform: none; }
.skill-zh { margin-top: 2px; font-family: var(--font-cjk); font-size: var(--fs-sm); color: var(--text-3); }
.desc .skill-desc { font-size: var(--fs-md); font-weight: 500; line-height: 1.6; color: #fff; }
.skill-ups-title { margin: 14px 0 8px; font-family: var(--font-tech); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.skill-ups { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.skill-up { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; align-items: start; }
.skill-lv { padding: 2px 0; border-radius: 8px; background: var(--accent-wash); border: 1px solid var(--accent); font-family: var(--font-tech); font-size: var(--fs-xs); font-weight: 700; text-align: center; color: var(--accent-hi); }
.desc .skill-up-text { font-size: var(--fs-sm); line-height: 1.55; color: var(--text); }
.is-zh { font-family: var(--font-cjk); }

.stats { display: grid; gap: 4px; margin: 0; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px; background: rgb(255 255 255 / 0.07); border: 1px solid var(--glass-line); border-radius: 10px; }
.stat-label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.stat-label .icon { width: 16px; height: 16px; color: var(--accent); }
.stat-value { margin: 0; font-family: var(--font-tech); font-size: 1.0625rem; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; }
