:where(:root) {
  --gl-surface: #ffffff;
  --gl-surface-2: #f0f0ed;
  --gl-surface-3: #e6e6e2;
  --gl-text: #18181b;
  --gl-muted: #6b6b73;
  --gl-line: #e4e4e0;
  --gl-line-strong: #c9c9c4;
  --gl-accent: #4f46e5;
  --gl-accent-hover: #4338ca;
  --gl-on-accent: #ffffff;
  /* rgb() channels instead of color-mix(): school PCs may have Chrome 109 at most. */
  --gl-accent-rgb: 79 70 229;
  --gl-danger: #dc2626;
  --gl-danger-hover: #c21f1f;
  --gl-danger-soft: #fdecec;
  --gl-ok: #15803d;
  --gl-warn: #b45309;
  --gl-radius: 14px;
  --gl-radius-sm: 10px;
  --gl-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.05);
  --gl-shadow-lg: 0 12px 40px rgb(0 0 0 / 0.16);
}
:where(:root[data-theme='dark']) {
  --gl-surface: #1b1b1f;
  --gl-surface-2: #232328;
  --gl-surface-3: #2c2c32;
  --gl-text: #ececef;
  --gl-muted: #9b9ba4;
  --gl-line: #2d2d33;
  --gl-line-strong: #3f3f47;
  --gl-accent: #7c74ff;
  --gl-accent-hover: #8f88ff;
  --gl-accent-rgb: 124 116 255;
  --gl-danger: #f05252;
  --gl-danger-hover: #d94343;
  --gl-danger-soft: #3a1d1f;
  --gl-warn: #f0a44b;
  --gl-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  --gl-shadow-lg: 0 12px 40px rgb(0 0 0 / 0.5);
}

.gl-page, .gl-page *, .gl-term-panel, .gl-term-panel *, .gl-admin, .gl-admin *, .gl-modal, .gl-modal *, .gl-toasts, .gl-toasts * { box-sizing: border-box; }
.gl-page, .gl-term-panel, .gl-admin, .gl-modal { color: var(--gl-text); font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; }
.gl-page button, .gl-term-panel button, .gl-admin button, .gl-modal button, .gl-toasts button { font: inherit; cursor: pointer; }
.gl-page { max-width: 960px; margin: 0 auto; }
.gl-muted { color: var(--gl-muted); }
.gl-small { font-size: 14px; }
.gl-back-link { background: none; border: 0; padding: 0; color: var(--gl-muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.gl-tip[hidden] { display: none; }
.gl-tip { pointer-events: none; }
.gl-tip b { display: block; }
.gl-tip span { display: block; }
.gl-copy-link { cursor: pointer; }
a.gl-term {
  color: inherit;
  text-decoration: underline dotted rgb(var(--gl-accent-rgb) / 0.55);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  border-radius: 4px;
  transition:
    background 0.15s,
    color 0.15s;
}
a.gl-term:hover {
  background: rgb(var(--gl-accent-rgb) / 0.1);
  color: var(--gl-accent);
  text-decoration-color: var(--gl-accent);
}

.gl-muted {
  color: var(--gl-muted);
}
/* ---------- buttons and inputs ---------- */
.gl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--gl-radius-sm);
  border: 1px solid var(--gl-line);
  background: var(--gl-surface);
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.05s;
}
.gl-btn:hover:not(:disabled) {
  background: var(--gl-surface-2);
}
.gl-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.gl-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.gl-btn.primary {
  background: var(--gl-accent);
  border-color: var(--gl-accent);
  color: var(--gl-on-accent);
}
.gl-btn.primary:hover:not(:disabled) {
  background: var(--gl-accent-hover);
}
.gl-btn.danger {
  background: var(--gl-danger);
  border-color: var(--gl-danger);
  color: #fff;
}
.gl-btn.danger:hover:not(:disabled) {
  background: var(--gl-danger-hover);
}
.gl-btn.subtle {
  border-color: transparent;
  background: var(--gl-surface-2);
}
.gl-btn.subtle:hover:not(:disabled) {
  background: var(--gl-surface-3);
}
.gl-btn.danger-text {
  border-color: transparent;
  background: transparent;
}
.gl-btn.danger-text:hover {
  background: var(--gl-danger-soft) !important;
}
.gl-btn.lg {
  height: 50px;
  padding: 0 22px;
  font-size: 17px;
  border-radius: 12px;
}
.gl-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gl-muted);
  text-decoration: none;
  flex: none;
}
.gl-icon-btn:hover {
  background: var(--gl-surface-2);
  color: var(--gl-text);
}
.gl-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gl-muted);
  text-decoration: none;
  font-weight: 550;
  border: 0;
  background: none;
  padding: 6px 0;
}
.gl-back-link:hover {
  color: var(--gl-text);
}
.gl-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--gl-line);
  border-radius: var(--gl-radius-sm);
  background: var(--gl-surface);
  transition: border-color 0.15s;
}
.gl-input:hover {
  border-color: var(--gl-line-strong);
}
.gl-input:focus {
  outline: none;
  border-color: var(--gl-accent);
  box-shadow: 0 0 0 3px rgb(var(--gl-accent-rgb) / 0.18);
}
.gl-input.lg {
  height: 50px;
  font-size: 17px;
}
.gl-search {
  position: relative;
  margin-bottom: 16px;
}
.gl-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gl-muted);
}
.gl-search .gl-input {
  padding-left: 42px;
}
.gl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--gl-line);
  border-radius: 999px;
  background: var(--gl-surface);
  font-weight: 600;
}
.gl-chip.lg {
  height: 44px;
  padding: 0 18px;
  font-size: 17px;
}
.gl-chip:hover {
  border-color: var(--gl-accent);
}
.gl-spinner {
  display: inline-block;
  border: 2.5px solid rgba(128, 128, 128, 0.28);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: gl-spin 0.7s linear infinite;
}
.gl-lead {
  font-size: 18px;
  color: var(--gl-muted);
  margin: 0;
  max-width: 520px;
}
.gl-info-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.gl-prose {
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.gl-prose > :first-child {
  margin-top: 0;
}
.gl-prose > :last-child {
  margin-bottom: 0;
}
.gl-prose h1,
.gl-prose h2,
.gl-prose h3 {
  margin: 1.3em 0 0.5em;
}
.gl-prose h1 {
  font-size: 26px;
}
.gl-prose h2 {
  font-size: 21px;
}
.gl-prose a {
  color: var(--gl-accent);
}
.gl-prose img {
  max-width: 100%;
  border-radius: 8px;
}
.gl-prose pre {
  background: var(--gl-surface-2);
  padding: 12px 14px;
  border-radius: 10px;
  overflow: auto;
}
.gl-prose pre code {
  background: none;
  padding: 0;
}
.gl-prose blockquote {
  margin: 1em 0;
  padding: 2px 16px;
  border-left: 3px solid var(--gl-accent);
  color: var(--gl-muted);
}
.gl-page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 40px 64px;
}
/* A term on a slide: invisible until hovered. */
.gl-spot {
  position: absolute;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition:
    background 0.15s,
    box-shadow 0.15s;
}
.gl-spot:hover,
.gl-spot:focus-visible {
  background: rgb(var(--gl-accent-rgb) / 0.14);
  box-shadow: 0 0 0 2px rgb(var(--gl-accent-rgb) / 0.45);
  outline: none;
}
.gl-tip {
  position: fixed;
  z-index: 120;
  transform: translate(-50%, -100%);
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #222226;
  color: #f4f4f5;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: var(--gl-shadow-lg);
  pointer-events: none;
  animation: gl-fade 0.12s;
}
.gl-tip.below {
  transform: translate(-50%, 0);
}
.gl-tip span {
  color: #c8c8cf;
}
.gl-term-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 24px calc(24px + env(safe-area-inset-bottom));
  overflow: auto;
  background: var(--gl-surface);
  color: var(--gl-text);
  box-shadow: var(--gl-shadow-lg);
  animation: gl-slide-in 0.2s ease-out;
  user-select: text;
}
.gl-term-panel .gl-info-head {
  width: 100%;
  align-items: center;
  margin: 0;
}
.gl-term-panel .gl-prose {
  width: 100%;
}
.gl-term-kicker {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gl-muted);
}
.gl-term-panel-title {
  font-size: 26px;
}
.gl-term-short {
  margin: 0;
  font-size: 17px;
  color: var(--gl-muted);
}
.gl-term-short.lg {
  font-size: 20px;
  margin: 6px 0 22px;
}
.gl-term-section {
  font-size: 17px;
  margin: 28px 0 12px;
}
.gl-term-panel .gl-term-section {
  margin: 12px 0 0;
}
.gl-related {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  width: 100%;
}
.gl-related-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--gl-line);
  border-radius: var(--gl-radius-sm);
  background: var(--gl-surface);
  text-align: left;
  text-decoration: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.gl-related-card:hover {
  border-color: rgb(var(--gl-accent-rgb) / 0.5);
  box-shadow: var(--gl-shadow);
}
.gl-related-card span {
  font-size: 13px;
  color: var(--gl-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gl-terms-page .gl-prose {
  font-size: 17px;
}
.gl-terms-h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 20px;
}
.gl-term-title {
  font-size: 36px;
  margin-top: 10px;
}
.gl-terms-group {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  margin-top: 18px;
}
.gl-terms-letter {
  font-size: 24px;
  font-weight: 750;
  color: var(--gl-accent);
  line-height: 1.3;
}
.gl-terms-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--gl-line);
}
.gl-terms-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--gl-line);
  text-decoration: none;
}
.gl-terms-item:hover b {
  color: var(--gl-accent);
}
.gl-terms-item .gl-muted {
  font-size: 14px;
}
.gl-places {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gl-places .gl-chip {
  text-decoration: none;
}
/* ---------- timetable ---------- */
.gl-page.wide {
  max-width: 1240px;
}
.gl-terms-count {
  margin: -4px 0 6px;
  font-size: 14px;
}
.gl-terms-group.found {
  grid-template-columns: 1fr;
}
.gl-terms-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--gl-line);
}
.gl-terms-row .gl-terms-item {
  flex: 1;
  min-width: 0;
  border-bottom: 0;
}
.gl-why {
  font-size: 14px;
}
.gl-copy-link {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gl-muted);
  opacity: 0.55;
  transition:
    opacity 0.15s,
    background 0.15s;
}
.gl-copy-link:hover,
.gl-copy-link:focus-visible {
  opacity: 1;
  background: var(--gl-surface-2);
  color: var(--gl-accent);
}
.gl-terms-row:hover .gl-copy-link,
.gl-related-wrap:hover .gl-copy-link {
  opacity: 1;
}
.gl-term-title,
.gl-term-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.gl-related-wrap {
  position: relative;
}
.gl-related-wrap .gl-related-card {
  width: 100%;
  height: 100%;
  padding-right: 38px;
}
.gl-related-wrap .gl-copy-link {
  position: absolute;
  top: 6px;
  right: 6px;
}
/* A page fades in when it mounts (on navigation and when its data arrives). No movement: nothing jumps. */
.gl-page {
  animation: gl-fade-in 160ms ease-out;
}
.gl-btn,
.gl-chip,
.gl-icon-btn {
  transition:
    background-color 120ms,
    color 120ms,
    border-color 120ms,
    box-shadow 120ms,
    opacity 120ms;
}
/* Glossary placeholders while terms load: grey bars of about the right size. */
.gl-skeleton {
  display: block;
  border-radius: 6px;
  background: var(--gl-surface-2);
  animation: gl-blink 1.4s ease-in-out infinite;
}
.gl-terms-skeleton-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--gl-line);
}
/* A term's content fades in; while the next one loads, the current one stays, dimmed. */
.gl-term-body {
  animation: gl-fade-in 160ms ease-out;
  transition: opacity 120ms;
}
.gl-term-body.loading {
  opacity: 0.6;
}
.gl-terms-count {
  min-height: 24px;
}
/* ---------- glossary: history and Excel import (admin) ---------- */
.gl-btn.sm {
  height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

@keyframes gl-blink { 50% { opacity: 0.55; } }
@keyframes gl-spin { to { transform: rotate(360deg); } }
@keyframes gl-rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gl-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes gl-pop-in { from { transform: scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gl-slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .gl-skeleton, .gl-tip, .gl-term-panel, .gl-toast, .gl-modal, .gl-modal-backdrop { animation: none; }
}
