/* ==========================================================================
   Mezgebe Qalat Design System Tokens
   Aesthetic: Linear / Stripe Docs / Notion (Calm, content-first, accessible)
   ========================================================================== */

/* Self-Hosted Fonts */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/static/fonts/Inter.woff2') format('woff2');
}

@font-face {
  font-family: 'Noto Sans Ethiopic';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/static/fonts/NotoSansEthiopic.woff2') format('woff2');
}

/* 8px Spacing Scale & Design Tokens */
:root,
html[data-theme="light"] {
  /* Spacing Scale (8px based) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Typography */
  --font-latin: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-geez: 'Noto Sans Ethiopic', 'Kefa', -apple-system, sans-serif;
  --font-sans: var(--font-latin), var(--font-geez);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Light Theme (WCAG AA Compliant) */
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-raised: #ffffff;
  --surface-inset: #f4f4f5;
  --border: #e4e4e7;
  --border-hover: #cbd5e1;
  --border-focus: #2563eb;

  --text: #09090b;
  --text-muted: #475569;
  --text-subtle: #64748b;

  /* Accent (Calm Indigo / Blue) */
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --accent-contrast: #ffffff;

  /* Shadows (1px subtle elevation) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);

  --max-width: 720px;
  --nav-height: 56px;
}

/* Dark Mode (High-contrast, calm slate surface) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b;
    --surface: #121215;
    --surface-raised: #18181b;
    --surface-inset: #202024;
    --border: #27272a;
    --border-hover: #3f3f46;
    --border-focus: #3b82f6;

    --text: #f8fafc;
    --text-muted: #cbd5e1;
    --text-subtle: #94a3b8;

    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: #1e293b;
    --accent-contrast: #ffffff;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  }
}

html[data-theme="dark"] {
  --bg: #09090b;
  --surface: #121215;
  --surface-raised: #18181b;
  --surface-inset: #202024;
  --border: #27272a;
  --border-hover: #3f3f46;
  --border-focus: #3b82f6;

  --text: #f8fafc;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: #1e293b;
  --accent-contrast: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Base Resets & Accessibility */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Accessibility: Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  text-decoration: none;
  transition: top 150ms ease;
}
.skip-link:focus {
  top: var(--space-3);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Focus Visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Typography Hierarchy (Weights: 400, 500, 600 only) */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 600;
  line-height: 1.25;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Ge'ez Script Spans */
:lang(ti) {
  font-family: var(--font-geez);
}

/* 1. Slim Top Navigation */
.site-nav {
  height: var(--nav-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

.nav-inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.brand-icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-geez {
  font-family: var(--font-geez);
  font-weight: 600;
  color: var(--text);
  font-size: 1.0625rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-link {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 150ms ease;
}
.nav-link:hover {
  color: var(--text);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.theme-toggle-btn:hover {
  color: var(--text);
  background: var(--surface-inset);
  border-color: var(--border);
}

.sun-icon { display: none; }
.moon-icon { display: block; }

html[data-theme="dark"] .sun-icon { display: block; }
html[data-theme="dark"] .moon-icon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun-icon { display: block; }
  :root:not([data-theme="light"]) .moon-icon { display: none; }
}

.nav-btn-app {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  min-height: 32px;
  transition: border-color 150ms ease, background 150ms ease;
}
.nav-btn-app:hover {
  border-color: var(--text-subtle);
  background: var(--surface);
}

/* 2. Main Container (Single centered column, max-width ~720px) */
.app-main {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-12);
  flex: 1;
}

/* 3. Compact Search Header */
.search-header {
  text-align: center;
  margin-bottom: var(--space-3);
}

.page-title {
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: var(--space-3);
}

/* Sticky Search & Filter Container */
.search-sticky-container {
  position: sticky;
  top: var(--nav-height);
  background: var(--bg);
  z-index: 40;
  padding-top: var(--space-1);
  padding-bottom: var(--space-2);
  transition: box-shadow 150ms ease, border-color 150ms ease;
}
.search-sticky-container.is-stuck {
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* Search Bar */
.search-form {
  position: relative;
  width: 100%;
}

.search-box-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.search-box-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-icon-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: var(--space-3);
  color: var(--text-subtle);
}

.search-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: var(--space-3) var(--space-2);
  font-size: 0.9375rem;
  color: var(--text);
  font-family: inherit;
  outline: none;
  min-height: 46px;
}
.search-input::placeholder {
  color: var(--text-subtle);
  font-size: 0.9375rem;
}

/* Desktop "/" Hint Badge */
.search-kbd-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-latin);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-subtle);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 20px;
  height: 20px;
  margin-right: var(--space-2);
  line-height: 1;
  user-select: none;
  pointer-events: none;
}
@media (hover: none) and (pointer: coarse) {
  .search-kbd-hint { display: none; }
}
@media (max-width: 640px) {
  .search-kbd-hint { display: none; }
}

/* Clear Button */
.clear-search-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  padding: var(--space-2);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.clear-search-btn.active {
  display: flex;
}

/* Direction Toggle Button with Swap Icon */
.dir-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  margin-right: var(--space-2);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
  transition: color 150ms ease, border-color 150ms ease;
}
.dir-toggle-btn:hover {
  color: var(--text);
  border-color: var(--text-subtle);
}

/* Autocomplete / Typeahead Dropdown */
.suggest-dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 50;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 100ms ease;
}
.suggest-item:last-child {
  border-bottom: none;
}
.suggest-item:hover, .suggest-item:focus {
  background: var(--surface-inset);
}
.suggest-word {
  font-weight: 500;
  font-family: var(--font-geez);
  color: var(--text);
}
.suggest-gloss {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  max-width: 55%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 4. Quiet Filter Bar with Edge Fades */
.filter-bar-wrapper {
  position: relative;
  width: 100%;
  margin-top: var(--space-2);
}
.filter-bar-wrapper::before,
.filter-bar-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 150ms ease;
}
.filter-bar-wrapper::before {
  left: 0;
  background: linear-gradient(to right, var(--bg), transparent);
}
.filter-bar-wrapper::after {
  right: 0;
  background: linear-gradient(to left, var(--bg), transparent);
}
.filter-bar-wrapper.has-overflow-start::before,
.filter-bar-wrapper.has-overflow-end::after {
  opacity: 1;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  background: transparent;
  border: 1px solid transparent;
  padding: 3px 10px;
  font-size: 0.75rem; /* 12px */
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}
.filter-chip:hover {
  color: var(--text);
  background: var(--surface-inset);
}
/* Quiet active state: subtle surface inset & border, NOT a large filled pill */
.filter-chip.active {
  background: var(--surface-inset);
  color: var(--text);
  border-color: var(--border);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Trending Searches Bar (Disappears when typed or searched) */
.trending-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-2) 0;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  scrollbar-width: none;
  transition: opacity 150ms ease, height 150ms ease;
}
.trending-bar.hidden {
  display: none !important;
}
.trending-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-subtle);
}
.trending-chip {
  color: var(--text-muted);
  background: var(--surface-inset);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}
.trending-chip:hover {
  color: var(--text);
  background: var(--border);
}

/* 5. Definition Cards (Flat, uniform border, subtle hover/focus) */
.results-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.word-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
/* All cards share uniform default style; deliberate subtle hover & focus */
.word-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}
.word-card:focus-within {
  border-color: var(--border-focus);
}

/* Card Header */
.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.headword-group {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.headword {
  font-size: 1.75rem;
  font-weight: 600;
  font-family: var(--font-geez);
  color: var(--text);
  line-height: 1.2;
}
.headword a {
  color: inherit;
  text-decoration: none;
  transition: color 150ms ease;
}
.headword a:hover {
  color: var(--accent);
}

/* Phonetics: body font, muted color, no square brackets */
.phonetic {
  font-family: var(--font-latin);
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Part of Speech Chip: Inter, 12px, medium weight (500), muted neutral */
.pos-chip {
  font-family: var(--font-latin);
  font-size: 0.75rem; /* 12px */
  font-weight: 500;
  text-transform: lowercase;
  color: var(--text-muted);
  background: var(--surface-inset);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
  line-height: 1.3;
}

/* Action Icons Toolbar (44px touch targets on mobile) */
.card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.action-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  padding: var(--space-1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px; /* 44px touch target */
  min-height: 44px;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.action-btn:hover {
  color: var(--text);
  background: var(--surface-inset);
  border-color: var(--border);
}

/* Definition Senses */
.definition-block {
  margin-bottom: var(--space-3);
}

.sense-en {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: var(--space-1);
}

.sense-ti {
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-family: var(--font-geez);
  line-height: 1.5;
}

.gloss-lang-label {
  font-size: 0.6875rem;
  font-family: var(--font-latin);
  color: var(--text-subtle);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

/* Example Sentences */
.example-box {
  border-left: 2px solid var(--border);
  padding-left: var(--space-3);
  margin-top: var(--space-3);
  margin-bottom: var(--space-3);
}

.example-ti {
  font-size: 1.0625rem; /* 17px */
  font-family: var(--font-geez);
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 2px;
}

.example-en {
  font-size: 0.9375rem; /* 15px */
  color: var(--text-muted);
  line-height: 1.5;
}

/* Semitic Root Meta */
.root-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin-top: var(--space-3);
}

.root-tag {
  color: #1e40af;
  background: #dbeafe;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
html[data-theme="dark"] .root-tag {
  color: #93c5fd;
  background: #1e293b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .root-tag {
    color: #93c5fd;
    background: #1e293b;
  }
}

/* 6. Details / Summary Disclosure (No hairline divider; spacing instead) */
.linguistic-details {
  margin-top: var(--space-4); /* Spacing instead of divider */
  padding-top: 0;
}

.linguistic-summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.linguistic-summary::-webkit-details-marker {
  display: none;
}

.summary-chevron {
  width: 14px;
  height: 14px;
  transition: transform 150ms ease;
}
.linguistic-details[open] .summary-chevron {
  transform: rotate(180deg);
}

.linguistic-panel {
  background: var(--surface-inset);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.derivations-header {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.derivations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
}

.derivation-tile {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 150ms ease;
}
.derivation-tile:hover {
  border-color: var(--accent);
}
.tile-word {
  font-weight: 600;
  font-family: var(--font-geez);
  color: var(--text);
}
.tile-def {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

/* 7. Default Home View: Word of the Day & Common Words */
.section-badge-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.badge-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.common-words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}

.common-word-tile {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  text-decoration: none;
}
.common-word-tile:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.common-word-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.common-word-text {
  font-size: 1.125rem;
  font-weight: 600;
  font-family: var(--font-geez);
  color: var(--text);
}

.common-word-phonetic {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.common-word-def {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* 8. Slim Dismissible Bottom App Banner (3 searches, 30-day dismissal) */
.install-bottom-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  z-index: 90;
  padding: var(--space-3) var(--space-4);
  animation: slideUp 200ms ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.install-banner-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.install-banner-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: var(--text);
}

.install-banner-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.install-btn-action {
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 150ms ease;
}
.install-btn-action:hover {
  background: var(--accent-hover);
}

.install-dismiss-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
}
.install-dismiss-btn:hover {
  color: var(--text);
}

/* 9. Skeleton Cards & htmx loading indicators */
.skeleton-container {
  display: none;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-3);
}
.htmx-request.skeleton-container {
  display: flex;
}
.skeleton-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
}
.skeleton-bone {
  background: var(--surface-inset);
  border-radius: var(--radius-sm);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.25; }
}

.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-load-more {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-5);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  min-height: 40px;
  transition: border-color 150ms ease, background 150ms ease;
}
.btn-load-more:hover {
  border-color: var(--border-hover);
  background: var(--surface);
}

.load-more-section {
  text-align: center;
  margin-top: var(--space-6);
}

/* 10. Toast Notification */
.toast-msg {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.toast-msg.show {
  opacity: 1;
}

/* 11. Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: var(--space-8) var(--space-4);
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
  text-align: center;
}
.footer-links {
  display: flex;
  gap: var(--space-4);
}
.footer-links a:hover {
  color: var(--text);
}

/* 12. Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Responsive Viewports */
@media (max-width: 640px) {
  .page-title {
    font-size: 1.375rem;
  }
  .app-main {
    padding-top: var(--space-3);
  }
  .headword {
    font-size: 1.5rem;
  }
  .install-banner-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .install-banner-actions {
    width: 100%;
    justify-content: space-between;
  }
}
