/* ==========================================================================
   OBGNAUH English Learning Lab — components.css
   Buttons, glass panels, navigation, search, progress, forms, overlays
   ========================================================================== */

/* ---------- Glass panel ---------- */
.glass {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-md);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease),
    border-color 0.3s var(--ease), background 0.3s var(--ease);
}

.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(150deg, var(--sheen), transparent 34%, transparent 68%, rgba(255, 255, 255, 0.16));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.65;
}

.card {
  padding: var(--s-5);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-line);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.panel-title h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 620;
}

.panel-title .icon-tile {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

/* ---------- Icon tiles ---------- */
.icon-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
  transition: transform 0.35s var(--ease), background 0.3s;
}

.icon-tile svg { width: 21px; height: 21px; }
.icon-tile.mint { background: rgba(0, 191, 165, 0.12); color: #00a991; }
.icon-tile.violet { background: rgba(139, 92, 246, 0.13); color: #7c4dff; }
.icon-tile.amber { background: rgba(245, 158, 11, 0.14); color: #c2790b; }
.icon-tile.rose { background: rgba(244, 63, 127, 0.12); color: #e11d64; }
.icon-tile.slate { background: var(--code-bg); color: var(--text-2); }
[data-theme="dark"] .icon-tile.mint { color: #35e0c2; }
[data-theme="dark"] .icon-tile.violet { color: #b39dff; }
[data-theme="dark"] .icon-tile.amber { color: #ffc861; }
[data-theme="dark"] .icon-tile.rose { color: #ff86ac; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--r-pill);
  font-size: 0.93rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease), box-shadow 0.25s var(--ease),
    background 0.25s var(--ease), border-color 0.25s, opacity 0.2s;
}

.btn svg { width: 18px; height: 18px; flex: none; }

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.btn:active { transform: translateY(0) scale(0.985); }

.btn-primary {
  background: var(--grad-brand);
  background-size: 160% 160%;
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 24px -10px rgba(43, 107, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn-primary:hover {
  box-shadow: 0 18px 36px -12px rgba(43, 107, 255, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  background-position: 100% 50%;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  box-shadow: none;
}

.btn-soft:hover { background: var(--accent-line); }

.btn-sm { height: 36px; padding: 0 14px; font-size: 0.86rem; }
.btn-xs { height: 30px; padding: 0 12px; font-size: 0.79rem; gap: 6px; }
.btn-xs svg { width: 15px; height: 15px; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text-2);
  border: 1px solid transparent;
  transition: background 0.25s, color 0.25s, border-color 0.25s, transform 0.25s;
}

.icon-btn svg { width: 20px; height: 20px; }

.icon-btn:hover {
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--line);
}

/* ---------- Chips / tags / badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 13px;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  font-weight: 560;
  color: var(--text-2);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  white-space: nowrap;
  transition: all 0.22s var(--ease);
}

.chip:hover { color: var(--text); border-color: var(--line-strong); }

.chip.is-active {
  background: var(--text);
  color: var(--bg-elev);
  border-color: transparent;
}

[data-theme="dark"] .chip.is-active { background: #f2f5fa; color: #0a0d15; }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 0.71rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: var(--code-bg);
  color: var(--text-2);
  white-space: nowrap;
}

.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-demo { background: var(--warn-soft); color: var(--warn); border: 1px dashed currentColor; }
.badge-soon { background: var(--code-bg); color: var(--text-3); }

.badge-dot::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Navigation ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid transparent;
  transition: border-color 0.35s var(--ease), box-shadow 0.35s var(--ease), background 0.35s;
}

.site-nav.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 10px 30px -22px rgba(15, 23, 42, 0.4);
}

.nav-inner {
  width: min(100% - 40px, 1340px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: var(--s-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  margin-right: 6px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--grad-brand);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 8px 18px -8px rgba(43, 107, 255, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.brand-mark svg { width: 19px; height: 19px; }

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.45) 46%, transparent 60%);
  transform: translateX(-120%);
  animation: sheen 6s ease-in-out infinite;
}

@keyframes sheen {
  0%, 55% { transform: translateX(-120%); }
  85%, 100% { transform: translateX(120%); }
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-text b {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}

.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  position: relative;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 520;
  color: var(--text-2);
  white-space: nowrap;
  transition: color 0.22s, background 0.22s;
}

.nav-link:hover { color: var(--text); background: var(--surface-strong); }

.nav-link[aria-current="page"] {
  color: var(--text);
  font-weight: 620;
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

.nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad-brand);
  transform: translateX(-50%);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text-3);
  font-size: 0.84rem;
  transition: border-color 0.25s, background 0.25s, color 0.25s;
}

.search-trigger:hover { border-color: var(--line-strong); color: var(--text-2); background: var(--surface-strong); }
.search-trigger svg { width: 16px; height: 16px; }
.search-trigger kbd {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  color: var(--text-3);
}

/* Language switch */
.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--code-bg);
  border: 1px solid var(--line);
  height: 38px;
}

.lang-switch button {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--text-3);
  transition: all 0.24s var(--ease);
}

.lang-switch button.is-active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Mobile menu button */
.nav-toggle { display: none; }

/* Mobile drawer */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
}

.drawer.is-open { display: block; }

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 22, 0.42);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  animation: fadeIn 0.3s var(--ease) forwards;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(88vw, 360px);
  padding: 20px 18px 32px;
  background: var(--surface-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  transform: translateX(100%);
  animation: slideIn 0.4s var(--ease-out) forwards;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.drawer-links {
  display: grid;
  gap: 2px;
}

.drawer-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 12px;
  font-size: 0.96rem;
  font-weight: 520;
  color: var(--text-2);
  transition: background 0.2s, color 0.2s;
}

.drawer-links a:hover,
.drawer-links a[aria-current="page"] {
  background: var(--surface-soft);
  color: var(--text);
}

.drawer-links a[aria-current="page"] { font-weight: 640; }

.drawer-links .icon-tile { width: 34px; height: 34px; border-radius: 10px; }
.drawer-links .icon-tile svg { width: 17px; height: 17px; }

.drawer-foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

@keyframes slideIn { to { transform: none; } }
@keyframes fadeIn { to { opacity: 1; } }

/* ---------- Search overlay ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  padding: 12vh 16px 16px;
}

.search-overlay.is-open { display: block; }

.search-overlay .backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 18, 0.4);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  animation: fadeIn 0.25s var(--ease) forwards;
  opacity: 0;
}

.search-dialog {
  position: relative;
  width: min(100%, 660px);
  margin-inline: auto;
  border-radius: var(--r-xl);
  background: var(--surface-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-12px) scale(0.985);
  opacity: 0;
  animation: popIn 0.34s var(--ease-out) 0.02s forwards;
}

@keyframes popIn {
  to { transform: none; opacity: 1; }
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.search-bar svg { width: 20px; height: 20px; color: var(--text-3); flex: none; }

.search-bar input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.search-bar input::placeholder { color: var(--text-3); }

.search-bar kbd {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  color: var(--text-3);
}

.search-body {
  max-height: min(56vh, 460px);
  overflow-y: auto;
  padding: 10px;
}

.search-group-label {
  padding: 10px 12px 6px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--text-3);
}

.search-hit {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.16s;
}

.search-hit:hover,
.search-hit.is-active { background: var(--accent-soft); }

.search-hit .hit-main { min-width: 0; flex: 1; }
.search-hit .hit-title {
  font-size: 0.92rem;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-hit .hit-sub {
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-hit .hit-type {
  font-size: 0.68rem;
  color: var(--text-3);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 20px;
  flex: none;
}

.search-empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 0.9rem;
}

.search-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--text-3);
  flex-wrap: wrap;
}

.search-foot .keys { display: flex; gap: 12px; flex-wrap: wrap; }
.search-foot kbd {
  font-family: var(--font-sans);
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--code-bg);
  border: 1px solid var(--line);
}

/* ---------- Progress ---------- */
.progress {
  --val: 0;
  position: relative;
  height: 8px;
  border-radius: 99px;
  background: var(--code-bg);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  width: calc(var(--val) * 100%);
  border-radius: inherit;
  background: var(--grad-brand);
  transition: width 0.9s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.progress > i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  transform: translateX(-100%);
  animation: shimmer 2.6s ease-in-out infinite;
}

@keyframes shimmer { 60%, 100% { transform: translateX(100%); } }

.progress.thin { height: 5px; }
.progress.thick { height: 12px; }
.progress.mint > i { background: linear-gradient(90deg, #00c9a7, #52e0c4); }
.progress.amber > i { background: var(--grad-warm); }
.progress.violet > i { background: var(--grad-violet); }

/* Progress ring */
.ring {
  --p: 0;
  --size: 92px;
  --stroke: 8px;
  position: relative;
  width: var(--size);
  height: var(--size);
  flex: none;
  display: grid;
  place-items: center;
}

.ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring .track { stroke: var(--code-bg); }
.ring .bar {
  stroke: url(#ringGrad);
  stroke-linecap: round;
  stroke-dasharray: var(--circ, 264);
  stroke-dashoffset: calc(var(--circ, 264) * (1 - var(--p)));
  transition: stroke-dashoffset 1.1s var(--ease-out);
}

.ring .ring-label {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.ring .ring-label b {
  font-size: calc(var(--size) * 0.22);
  font-weight: 680;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.ring .ring-label span {
  font-size: calc(var(--size) * 0.105);
  color: var(--text-3);
  margin-top: 3px;
}

/* ---------- Stat ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat b {
  font-size: 1.6rem;
  font-weight: 680;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat span { font-size: 0.78rem; color: var(--text-3); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
}

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }

.field > label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.92rem;
  outline: 0;
  transition: border-color 0.22s, box-shadow 0.22s, background 0.22s;
}

.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--surface-strong);
}

.textarea { min-height: 150px; resize: vertical; line-height: 1.7; }

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23808a9b' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.switch {
  position: relative;
  width: 46px;
  height: 27px;
  border-radius: 99px;
  background: var(--line-strong);
  transition: background 0.28s var(--ease);
  flex: none;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s var(--ease-out);
}

.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(19px); }

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-pill);
  background: var(--code-bg);
  border: 1px solid var(--line);
}

.segmented button {
  height: 30px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  font-weight: 560;
  color: var(--text-3);
  transition: all 0.25s var(--ease);
}

.segmented button.is-active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Checkbox row */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  cursor: pointer;
  transition: all 0.24s var(--ease);
}

.check-row:hover { border-color: var(--line-strong); background: var(--surface-strong); }

.check-box {
  width: 21px;
  height: 21px;
  border-radius: 7px;
  border: 1.6px solid var(--line-strong);
  flex: none;
  display: grid;
  place-items: center;
  margin-top: 1px;
  transition: all 0.24s var(--ease);
  color: transparent;
}

.check-box svg { width: 13px; height: 13px; }

.check-row.is-done { opacity: 0.62; }
.check-row.is-done .check-box {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.check-row.is-done .task-name { text-decoration: line-through; text-decoration-color: var(--text-3); }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 220;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  background: var(--surface-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
  font-weight: 540;
  animation: toastIn 0.35s var(--ease-out);
  max-width: min(92vw, 480px);
}

.toast.is-out { animation: toastOut 0.3s var(--ease) forwards; }
.toast svg { width: 17px; height: 17px; flex: none; color: var(--ok); }

@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* ---------- Skeleton ---------- */
.skeleton {
  border-radius: 12px;
  background: linear-gradient(90deg, var(--code-bg) 25%, var(--surface-strong) 45%, var(--code-bg) 65%);
  background-size: 220% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
  color: transparent !important;
}

@keyframes skeleton { to { background-position: -220% 0; } }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent-line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.79rem;
  color: var(--text-3);
  padding-block: 18px 0;
}

.breadcrumbs a { transition: color 0.2s; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { opacity: 0.5; }
.breadcrumbs [aria-current] { color: var(--text-2); }

/* ---------- Page head ---------- */
.page-head {
  padding-block: 26px 8px;
}

.page-head h1 {
  margin-top: 10px;
  font-size: clamp(1.7rem, 1.38rem + 1.5vw, 2.5rem);
}

.page-head .lede {
  margin-top: 10px;
  color: var(--text-2);
  max-width: 68ch;
  font-size: 0.98rem;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: var(--s-8);
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.footer-main {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: var(--s-6);
  padding-block: var(--s-7) var(--s-6);
}

.footer-brand p {
  margin-top: 14px;
  font-size: 0.86rem;
  color: var(--text-2);
  max-width: 34ch;
  line-height: 1.7;
}

.footer-col h4 {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 14px;
  font-weight: 650;
}

.footer-col ul { display: grid; gap: 9px; }

.footer-col a {
  font-size: 0.86rem;
  color: var(--text-2);
  transition: color 0.2s, padding-left 0.25s var(--ease);
}

.footer-col a:hover { color: var(--accent); padding-left: 4px; }

.footer-bottom {
  border-top: 1px solid var(--line);
  padding-block: 18px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-3);
}

.footer-bottom .legal { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Empty state ---------- */
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-3);
}

.empty svg { width: 34px; height: 34px; margin: 0 auto 12px; opacity: 0.6; }

/* ---------- Tooltip ---------- */
[data-tip] { position: relative; }

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg-elev);
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ======================== read-aloud (TTS) ======================== */
.tts-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.tts-bar.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.tts-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  animation: pulse 1.2s ease-in-out infinite;
}
.tts-bar.is-paused .tts-dot { animation: none; background: var(--text-3); }
.tts-bar-text { display: grid; gap: 1px; line-height: 1.25; min-width: 0; }
.tts-bar-text b { font-size: 0.78rem; font-weight: 600; }
.tts-bar-text small { font-size: 0.66rem; color: var(--text-3); }
.tts-bar-actions { display: flex; gap: 4px; }
.tts-mini {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text-2);
  cursor: pointer;
}
.tts-mini:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.tts-mini svg { width: 14px; height: 14px; }
.tts-stop-ico {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
}

.tts-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
}
.tts-overlay[hidden] { display: none; }
.tts-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 12, 20, 0.46);
  backdrop-filter: blur(3px);
}
.tts-sheet {
  position: relative;
  width: min(460px, 100%);
  max-height: 86vh;
  overflow: auto;
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-lg);
}
.tts-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tts-sheet-head h3 { margin: 0; font-size: 1.05rem; letter-spacing: -0.01em; }
.tts-status { margin: 4px 0 0; font-size: 0.74rem; line-height: 1.5; color: var(--text-3); }
.tts-field { display: grid; gap: 6px; font-size: 0.8rem; color: var(--text-2); }
.tts-field label { display: flex; justify-content: space-between; gap: 8px; }
.tts-field label span { color: var(--accent); font-variant-numeric: tabular-nums; }
.tts-field select { width: 100%; }
.tts-field input[type="range"] { width: 100%; accent-color: var(--accent); }
.tts-hint { margin: 0; font-size: 0.74rem; line-height: 1.6; color: var(--text-3); }
.tts-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tts-note {
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 0.72rem;
  line-height: 1.7;
  color: var(--text-3);
}

@media (max-width: 560px) {
  .tts-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    justify-content: space-between;
    border-radius: 16px;
    transform: translateY(14px);
    padding: 9px 10px 9px 13px;
  }
  .tts-bar.is-on { transform: translateY(0); }
  .tts-bar-text small { display: none; }
  .tts-sheet { padding: 18px; }
}

/* ==========================================================================
   品牌标识 / 页脚订阅 / 备案信息
   ========================================================================== */
.brand-mark img,
.brand-logo {
  width: 19px;
  height: 19px;
  display: block;
  filter: drop-shadow(0 1px 1px rgba(4, 10, 26, 0.22));
}

.site-footer .subscribe {
  margin-top: 18px;
  max-width: 360px;
}

.sub-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--text-2);
  margin-bottom: 8px;
}

.sub-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.sub-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  color: var(--text);
  font-family: inherit;
  font-size: 0.86rem;
}

.sub-input::placeholder { color: var(--text-3); }

.sub-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.sub-row .btn { flex: none; height: 38px; }

.sub-msg {
  min-height: 18px;
  margin-top: 7px;
  font-size: 0.76rem;
  line-height: 1.55;
  color: var(--text-3);
}

.sub-msg.ok { color: var(--ok); }
.sub-msg.err { color: var(--danger); }

.sub-note {
  margin-top: 4px;
  line-height: 1.6;
  max-width: 36ch;
}

.sub-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.footer-bottom .legal a.tiny {
  color: var(--text-3);
  transition: color 0.2s;
}

.footer-bottom .legal a.tiny:hover { color: var(--accent); }

@media (max-width: 560px) {
  .site-footer .subscribe { max-width: none; }
  .sub-row .btn { padding-inline: 14px; }
}
