:root {
  --expl-ink: #0f172a;
  --expl-muted: #64748b;
  --expl-line: #e2e8f0;
  --expl-accent: #2563eb;
  --expl-accent-soft: rgba(37, 99, 235, 0.1);
}

body.explainer-page {
  /* Same warm paper texture as welcome.php / tools/index.php's card grid. */
  color: var(--expl-ink);
  background-color: #FBF6E9;
  background-image:
    repeating-linear-gradient(2deg, rgba(115, 91, 59, .018) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(91deg, rgba(255,255,255,.15) 0 1px, transparent 1px 11px),
    radial-gradient(ellipse at 16% 19%, rgba(230, 174, 47, .055) 0 1px, transparent 1.7px),
    radial-gradient(ellipse at 78% 67%, rgba(91, 70, 43, .04) 0 .8px, transparent 1.5px),
    linear-gradient(105deg, rgba(255,255,255,.08), transparent 38%, rgba(126,98,62,.025));
  background-size: auto, auto, 23px 21px, 31px 29px, 100% 100%;
  background-repeat: repeat, repeat, repeat, repeat, no-repeat;
  background-attachment: fixed;
}

.expl-app {
  min-height: calc(100svh - var(--topbar-h, 96px));
  padding: 0 20px 64px;
}

.expl-app__inner {
  width: min(1080px, 100%);
  margin: 0 auto;
}

/* ── Head ── */

.expl-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 28px 4px 18px;
}

.expl-head__icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.expl-head__icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.expl-head__text {
  flex: 1 1 auto;
}

.expl-head__text h1 {
  font-size: 26px;
  line-height: 1.15;
  margin: 0;
}

.expl-search {
  position: relative;
  flex: 0 1 260px;
}

.expl-search__icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--expl-muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.expl-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--expl-line);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  color: var(--expl-ink);
}

.expl-search input:focus-visible {
  outline: 2px solid var(--expl-accent);
  outline-offset: 1px;
}

/* ── Level picker ── same color scheme, pill shape and size as
   worksheets/index.php's .ws-lvl-inline-btn ── */

.expl-level-picker {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.expl-level-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  border: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.expl-level-chip:active {
  transform: scale(0.95);
}

/* Own vivid level colors, always visible (selected + unselected) */
.expl-level-chip[data-level="A1"] { background: #4DA9E6; color: #0b1220; }
.expl-level-chip[data-level="A2"] { background: #2EC4C6; color: #0b1220; }
.expl-level-chip[data-level="B1"] { background: #F2C94C; color: #0b1220; }
.expl-level-chip[data-level="B2"] { background: #F2994A; color: #0b1220; }
.expl-level-chip[data-level="C1"] { background: #7C3AED; color: #fff; }
.expl-level-chip--all              { background: #0F172A; color: #fff; }

.expl-level-chip:hover:not(.is-selected) {
  filter: brightness(1.08);
}

/* Selected: thick white border ring, color stays the same */
.expl-level-chip.is-selected {
  box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(15,23,42,0.18);
}

/* ── Groups ── */

.expl-groups {
  display: flex;
  flex-direction: column;
  gap: 26px;
  margin-top: 8px;
}

.expl-group {
  border: 1px solid var(--expl-line);
  border-radius: 18px;
  background: #fff;
  padding: 18px 22px 20px;
  scroll-margin-top: 90px;
}

.expl-group__title {
  font-size: 17px;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--expl-line);
}

.expl-group__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 18px;
}

.expl-item a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 6px;
  border-radius: 8px;
  color: var(--expl-ink);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.35;
}

.expl-item a:hover,
.expl-item a:focus-visible {
  background: var(--expl-accent-soft);
  color: var(--expl-accent);
}

.expl-item__names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.expl-item__title {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* English name under a translated title (zh-CN / vi only; never rendered in English). */
.expl-item__title-en,
.expl-group__title-en {
  display: block;
  color: var(--expl-muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: none;
}

.expl-item__title-en {
  margin-top: 1px;
  overflow-wrap: anywhere;
}

.expl-item a:hover .expl-item__title-en,
.expl-item a:focus-visible .expl-item__title-en {
  color: inherit;
  opacity: 0.75;
}

.expl-group__title-en {
  margin-top: 2px;
}

.expl-item__cefr {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--expl-muted);
}

.expl-empty {
  text-align: center;
  color: var(--expl-muted);
  font-size: 14px;
  padding: 40px 0;
}

@media (max-width: 900px) {
  .expl-group__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .expl-group__list { grid-template-columns: 1fr; }
  .expl-head { padding-top: 18px; flex-wrap: wrap; }
  .expl-search { flex: 1 1 100%; }
}
