* {
  box-sizing: border-box;
}

/* Ensure [hidden] always hides regardless of other display rules */
[hidden] {
  display: none !important;
}


body {
  overscroll-behavior-y: contain;
}

:root {
  --page-bg: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;

  --text-main: #0f172a;
  --text-body: #1f2937;
  --text-muted: #667085;
  --text-subtle: #475467;

  --input-border: #d7deea;
  --input-border-soft: #e4e9f2;
  --input-focus: #93c5fd;

  --line-soft: #edf1f7;

  --button-secondary-bg: #eef2f7;
  --button-secondary-text: #334155;

  --button-primary-bg: #2563eb;
  --button-primary-text: #ffffff;

  --color-navy: #1e3a8a;

  --notice-bg: #fff7ed;
  --notice-border: #fdba74;
  --notice-text: #9a3412;
}

/* ===== RTL support ===== */

[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .feedback-link,
[dir="rtl"] .about-links {
  flex-direction: row-reverse;
}

[dir="rtl"] .topbar-nav,
[dir="rtl"] .topbar-nav-right,
[dir="rtl"] .topbar-body,
[dir="rtl"] .func-panel {
  flex-direction: row-reverse;
}

[dir="rtl"] .vb-filter-row,
[dir="rtl"] .vb-search-row {
  flex-direction: row-reverse;
}

[dir="rtl"] .vb-filter-toggle {
  flex-direction: row-reverse;
}

[dir="rtl"] .vb-count {
  text-align: left;
}

[dir="rtl"] .search-suggestion {
  text-align: right;
}

/* ===== Secondary button ===== */

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  background: var(--button-secondary-bg);
  color: var(--button-secondary-text);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: filter 0.1s ease;
}

.btn-secondary:hover {
  filter: brightness(0.95);
}

.auth-btn {
  margin-left: 10px;
  gap: 6px;
}

/* In nav rows and action rows, auth button matches the pill size of siblings */
.topbar-nav-right .auth-btn,
.actions .auth-btn {
  padding: 10px 16px;
  border-radius: 999px;
  border-color: #d1d5db;
  font-size: inherit;
  font-weight: 600;
}

.auth-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* ===== Nav pill button (back / practice next etc.) ===== */

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--color-navy);
  color: white;
  border: none;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.nav-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.nav-btn:active {
  transform: translateY(0);
}

/* Ghost variant: matches .feedback-link weight — for the Back link in topbar-nav */
.nav-btn--ghost {
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
  font-weight: 600;
}

.nav-btn--ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  filter: none;
}

.nav-arrow {
  font-size: 20px;
  line-height: 1;
}

/* ===== Primary pill button (navy) ===== */

.btn-pill-navy {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border: none;
  border-radius: 999px;
  background: var(--color-navy);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.12s ease;
}

.btn-pill-navy:hover {
  filter: brightness(1.12);
}

.btn-pill-navy:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: none;
}

/* ===== Search submit button (shared: home + verbs) ===== */

.search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 44px;
  padding: 10px 18px;

  border-radius: 999px;
  border: 1.5px solid var(--button-primary-bg);

  background: var(--button-primary-bg);
  color: var(--button-primary-text);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);

  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  white-space: nowrap;

  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;

  transition:
    filter 0.12s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

.search-btn:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.search-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== Feedback link ===== */

.feedback-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.feedback-link:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

/* ===== Shared page nav row ===== */

.topbar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 14px;
}

.topbar-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* ===== Learn-page content row + function panel ===== */

.topbar-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
}

.func-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ===== No-match notice (shared: home + verbs) ===== */

.notice {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fffaf5;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  color: #92400e;
  font-size: 0.92rem;
  line-height: 1.35;
}

.notice b {
  font-weight: 600;
}

/* ===== Search row header: label + mode pills (shared: home + verbs) ===== */

.search-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 6px;
  margin-bottom: 10px;
}

.search-row-header label {
  margin-bottom: 0;
}

/* ===== Search mode pills (shared: home + verbs) ===== */

.search-mode-pills {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

[dir="rtl"] .search-mode-pills {
  flex-direction: row-reverse;
}

.search-mode-pill {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--input-border);
  background: #e2e8f0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.5;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.search-mode-pill.active {
  background: var(--color-navy);
  color: white;
  border-color: var(--color-navy);
}

.search-mode-pill:hover:not(.active) {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

/* ===== Progress bar (shared: home + verbs) ===== */

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #dde5ef;
}

.progress-fill {
  height: 100%;
  background: #4a90e2;
  width: 0%;
  transition: width 0.2s ease;
}

.progress-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  white-space: nowrap;
}

.progress-star {
  font-size: 14px;
  color: #f97316;
  line-height: 1;
}

.progress-count,
.progress-total {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.progress-total {
  font-weight: 400;
  color: var(--text-muted);
}

/* ===== Bottom navigation (mobile / PWA) ===== */

.bottom-nav {
  display: none;
}

@media (max-width: 639px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #ffffff;
    border-top: 1px solid var(--card-border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
  }

  [dir="rtl"] .bottom-nav {
    flex-direction: row-reverse;
  }

  [dir="rtl"] .bnav-tab[aria-label="Back"] svg {
    transform: scaleX(-1);
  }

  .bnav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    padding: 6px 2px;
    border: none;
    background: none;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: color 0.12s ease;
  }

  .bnav-tab--active {
    color: #2d6a4f;
  }

  .bnav-tab:hover {
    color: #2d6a4f;
  }

  .bnav-tab:active {
    color: #2d6a4f;
    background: rgba(45, 106, 79, 0.08);
  }

  /* Per-page bottom clearance so content doesn't hide under the nav */
  .page,
  .vb-page {
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
