/* ==========================================================================
   Falcon AI shared design system.

   This stylesheet is served at /assets/app.css by the FastAPI StaticFiles
   mount in app/main.py. Every cadet + admin HTML links it, and every
   <svg class="icon"><use href="#icon-foo"/></svg> relies on the sprite loaded
   from /assets/icons.svg.

   Per-page CSS (things like .res-subtabs, .leo-story, .kw-panel, .uploads-table)
   stays inline in its page so this file is only the cross-cutting primitives.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design tokens. Individual pages may define :root first with base colours
   (--bg, --panel, --text, --muted, --accent, --border, --danger, --ok); we
   additively extend with everything else. These "double-checked" :root
   declarations are safe because any missing token falls back to a sensible
   default where it's used.
   -------------------------------------------------------------------------- */
:root {
  --accent-hover: #5a9dfe;
  --accent-dim: rgba(61, 139, 253, 0.15);
  --accent-glow: rgba(61, 139, 253, 0.28);
  --warn: #f0c674;
  --warn-bg: rgba(240, 198, 116, 0.12);
  --warn-border: rgba(240, 198, 116, 0.35);
  --danger: #ff6b6b;
  --danger-bg: rgba(255, 107, 107, 0.10);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, 0.12);
  --surface-1: #1f2a3c;
  --surface-2: #243247;
  --card: #1a2332;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
  --shadow-card: 0 12px 36px rgba(0,0,0,0.45);
}

/* --------------------------------------------------------------------------
   Icons. Symbols are loaded once from /assets/icons.svg and referenced via
   <svg class="icon" aria-hidden="true"><use href="#icon-foo"/></svg>.
   -------------------------------------------------------------------------- */
.icon {
  width: 1.1em; height: 1.1em;
  flex-shrink: 0;
  vertical-align: -0.18em;
  color: inherit;
  stroke-width: 1.75;
}
.icon-sm { width: 0.95em; height: 0.95em; }
.icon-lg { width: 1.4em; height: 1.4em; }
.icon-xl { width: 1.9em; height: 1.9em; }
.icon-hero { width: 2.6rem; height: 2.6rem; }
svg.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* --------------------------------------------------------------------------
   Page / section headers.
   -------------------------------------------------------------------------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin: 0 0 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.page-header .ph-main { min-width: 0; flex: 1 1 280px; }
.page-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 0.55rem;
  line-height: 1.2;
}
.page-header h2 .ph-icon {
  width: 1.8rem; height: 1.8rem;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.page-header h2 .ph-icon .icon { width: 1.05rem; height: 1.05rem; }
.page-header .ph-sub {
  margin: 0; color: var(--muted); font-size: 0.88rem; max-width: 64ch;
  line-height: 1.5;
}
.page-header .ph-actions {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  flex-shrink: 0;
}
.page-header .ph-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  margin-left: 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(61,139,253,0.35);
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  vertical-align: middle;
}

/* Inside a .panel the border-bottom on .page-header reads as a second frame;
   keep it but make it a dashed divider so it clearly marks the header. */
.panel .page-header { border-bottom-style: dashed; }

.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.75rem; margin: 1.25rem 0 0.6rem;
}
.section-header h3, .section-header h4 {
  margin: 0; font-size: 0.98rem; font-weight: 600; color: var(--text);
  display: inline-flex; align-items: baseline; gap: 0.45rem;
}
.section-header h3 .icon,
.section-header h4 .icon { color: var(--accent); align-self: center; }
.section-header .sh-sub { color: var(--muted); font-size: 0.82rem; margin: 0; }
.section-header .sh-actions {
  display: inline-flex; gap: 0.3rem; align-items: center;
}
.section-header .sh-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.72rem; font-weight: 700;
  flex-shrink: 0;
  align-self: center;
}

/* --------------------------------------------------------------------------
   KPI cards.
   -------------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex; flex-direction: column; gap: 0.25rem;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--accent); opacity: 0.6;
}
.kpi-card .kpi-label {
  color: var(--muted); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.kpi-card .kpi-label .icon { color: var(--accent); }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.15; }
.kpi-card .kpi-trend { font-size: 0.76rem; color: var(--muted); }
.kpi-card .kpi-trend.up { color: var(--ok); }
.kpi-card .kpi-trend.down { color: var(--danger); }

/* --------------------------------------------------------------------------
   Chat-shell primitives (used by Ask + Guidance tabs).
   -------------------------------------------------------------------------- */
.chat-shell {
  display: flex; flex-direction: column;
  gap: 0.5rem;
  min-height: 420px;
}
.chat-transcript {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.95rem;
  flex: 1 1 auto;
  min-height: 280px;
  max-height: 520px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.chat-empty {
  color: var(--muted); font-size: 0.88rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.6rem; min-height: 220px; text-align: center; padding: 1rem;
}
.chat-empty .icon { color: var(--accent); }
.chat-empty strong { color: var(--text); font-weight: 600; font-size: 1rem; }
.chat-empty p { margin: 0; max-width: 36ch; line-height: 1.5; }
.chat-bubble {
  display: flex; gap: 0.55rem; align-items: flex-start;
  max-width: 92%;
}
.chat-bubble.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble .bubble-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 0.72rem; font-weight: 700;
}
.chat-bubble.assistant .bubble-avatar {
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid rgba(61,139,253,0.35);
}
.chat-bubble.user .bubble-avatar {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
}
.chat-bubble .bubble-body {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem; line-height: 1.5;
  position: relative;
}
.chat-bubble.assistant .bubble-body { border-color: var(--border); }
.chat-bubble.user .bubble-body {
  background: var(--accent-dim);
  border-color: rgba(61,139,253,0.35);
}

.chat-composer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.7rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: end;
  box-shadow: var(--shadow-sm);
}
.chat-composer textarea {
  background: transparent !important;
  border: none !important;
  padding: 0.35rem 0.25rem !important;
  min-height: 64px !important;
  resize: vertical;
  width: 100%;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
}
.chat-composer textarea:focus { outline: none; box-shadow: none; }
.chat-composer .composer-actions {
  display: flex; flex-direction: column; gap: 0.35rem;
  align-items: stretch;
}
.chat-composer .composer-actions .btn-primary,
.chat-composer .composer-actions .btn-secondary {
  min-width: 132px;
}
.chat-composer .composer-hint {
  grid-column: 1 / -1;
  color: var(--muted); font-size: 0.72rem;
  display: flex; justify-content: space-between; gap: 0.5rem;
  padding: 0 0.25rem;
}
@media (max-width: 600px) {
  .chat-composer { grid-template-columns: 1fr; }
  .chat-composer .composer-actions { flex-direction: row; }
  .chat-composer .composer-actions .btn-primary,
  .chat-composer .composer-actions .btn-secondary { flex: 1; min-width: 0; }
}

/* Auto-hide the chat-empty state when a transcript becomes visible. */
.chat-shell:has(#askTranscript:not([hidden])) #askTranscriptEmpty,
.chat-shell:has(#guidTranscript:not([hidden])) #guidTranscriptEmpty { display: none; }
.chat-shell #askOut {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}
.chat-shell #askOut::before {
  content: "Latest answer details";
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.chat-shell #askOut pre.answer-text {
  background: rgba(255,255,255,0.02);
  border-left: 3px solid var(--border);
  padding: 0.5rem 0.75rem;
  margin: 0 0 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  opacity: 0.92;
}

/* --------------------------------------------------------------------------
   Button system.
   -------------------------------------------------------------------------- */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-ok {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
  line-height: 1.2;
}
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface-1); color: var(--text); border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--muted); border-color: transparent;
  padding: 0.4rem 0.6rem;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-1); }
.btn-ghost.danger { color: var(--danger); border-color: rgba(255,107,107,0.35); }
.btn-ghost.danger:hover:not(:disabled) { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ok {
  background: var(--ok); color: #09301a; border-color: var(--ok);
}
.btn-ok:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ok:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-icon-only {
  padding: 0.45rem; width: 2.2rem; height: 2.2rem;
}
.btn-icon-only .icon { margin: 0; }

/* --------------------------------------------------------------------------
   Advanced-options disclosure.
   -------------------------------------------------------------------------- */
.advanced-disclosure {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0;
  margin: 0.75rem 0;
  overflow: hidden;
}
.advanced-disclosure > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--text); font-size: 0.88rem; font-weight: 500;
  user-select: none;
}
.advanced-disclosure > summary::-webkit-details-marker { display: none; }
.advanced-disclosure > summary .chev {
  margin-left: auto;
  transition: transform 180ms ease;
  color: var(--muted);
}
.advanced-disclosure[open] > summary .chev { transform: rotate(180deg); }
.advanced-disclosure > summary:hover { background: var(--surface-1); }
.advanced-disclosure > summary .ad-icon { color: var(--accent); }
.advanced-disclosure .ad-body {
  padding: 0.2rem 0.9rem 0.9rem;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.2rem;
}
.advanced-disclosure .ad-body label { margin-top: 0.7rem; }
.advanced-disclosure .ad-hint {
  color: var(--muted); font-size: 0.78rem; margin: 0.2rem 0 0;
}

/* --------------------------------------------------------------------------
   Segmented control.
   -------------------------------------------------------------------------- */
.segmented {
  display: inline-flex;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}
.segmented button {
  background: transparent; color: var(--muted); border: none;
  padding: 0.35rem 0.85rem; border-radius: var(--radius-pill);
  font-size: 0.8rem; font-weight: 500;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 0.35rem;
  transition: background 120ms ease, color 120ms ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.segmented button.active .icon { color: #fff; }

/* --------------------------------------------------------------------------
   Input with leading icon.
   -------------------------------------------------------------------------- */
.input-with-icon {
  position: relative;
  display: inline-block;
}
.input-with-icon > .icon {
  position: absolute; left: 0.7rem; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.input-with-icon > input {
  padding-left: 2.1rem !important;
}

/* --------------------------------------------------------------------------
   Empty state hero (illustrated).
   -------------------------------------------------------------------------- */
.empty-hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 2rem 1rem;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
}
.empty-hero .empty-hero-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 0.35rem;
}
.empty-hero .empty-hero-icon .icon { width: 1.6rem; height: 1.6rem; }
.empty-hero strong { color: var(--text); font-size: 1rem; }
.empty-hero p { margin: 0; max-width: 40ch; line-height: 1.5; font-size: 0.88rem; }

/* --------------------------------------------------------------------------
   Setup card (Quiz / Flashcards / Admin forms).
   -------------------------------------------------------------------------- */
.setup-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 1rem;
}
.setup-card h3 {
  margin: 0 0 0.15rem; font-size: 0.98rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 0.45rem;
}
.setup-card h3 .icon { color: var(--accent); }
.setup-card p.setup-sub {
  margin: 0 0 0.85rem; color: var(--muted); font-size: 0.82rem;
}
.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem 1rem;
}
.setup-grid > .full { grid-column: 1 / -1; }
.setup-grid label { margin-top: 0.25rem; }
.setup-footer {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Sticky header + nav polish. Pages that have the cadet-style <header> /
   <nav id="mainNav"> get this look automatically; the admin <header> +
   <nav class="admin-tabs"> opts in via data-attributes below.
   -------------------------------------------------------------------------- */
body > header, body.app-chrome > header {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(10px);
  background: rgba(26,35,50,0.82);
}
body > header h1, body.app-chrome > header h1 {
  display: inline-flex; align-items: center; gap: 0.55rem;
}
body > header h1 .logo, body.app-chrome > header h1 .logo {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 0 0 3px var(--accent-dim);
  flex-shrink: 0;
}
body > header h1 .logo .icon,
body.app-chrome > header h1 .logo .icon {
  color: #fff; width: 1.05rem; height: 1.05rem;
}

/* Cadet main nav (index.html only). */
body > nav#mainNav {
  position: sticky; top: 72px; z-index: 25;
  background: rgba(15,20,25,0.86);
  backdrop-filter: blur(8px);
}
nav#mainNav button.tab {
  display: inline-flex; align-items: center; gap: 0.4rem;
}
nav#mainNav button.tab .icon { color: var(--muted); }
nav#mainNav button.tab.active .icon { color: var(--accent); }

/* Admin tab bar (admin.html). Keeps the existing .admin-tabs / .admin-tab
   classes intact, just gives them the same sticky-blur treatment and icon
   alignment as the cadet nav. */
nav.admin-tabs {
  position: sticky;
  top: 72px;
  z-index: 25;
  background: rgba(15,20,25,0.86);
  backdrop-filter: blur(8px);
}
nav.admin-tabs .admin-tab {
  display: inline-flex; align-items: center; gap: 0.45rem;
}
nav.admin-tabs .admin-tab .icon { color: var(--muted); }
nav.admin-tabs .admin-tab.active .icon { color: var(--accent); }

/* --------------------------------------------------------------------------
   Feedback FAB polish.
   -------------------------------------------------------------------------- */
.report-fab { padding: 0.6rem 1rem 0.6rem 0.85rem; }
.report-fab .icon { color: #fff; }
.report-fab > span[aria-hidden="true"] {
  background: rgba(255,255,255,0.18);
}

/* --------------------------------------------------------------------------
   Disclaimer banner (cadet Ask / Guidance).
   -------------------------------------------------------------------------- */
.disclaimer-banner::before { display: none !important; }
.disclaimer-banner .disc-icon {
  background: var(--warn); color: #1a2332;
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.disclaimer-banner .disc-icon .icon { width: 0.95rem; height: 0.95rem; }

/* --------------------------------------------------------------------------
   Toasts.
   -------------------------------------------------------------------------- */
.toast { display: flex; align-items: flex-start; gap: 0.55rem; }
.toast .toast-icon {
  color: var(--accent); flex-shrink: 0; margin-top: 0.1rem;
}
.toast.error .toast-icon { color: var(--danger); }
.toast.ok .toast-icon { color: var(--ok); }
.toast.warn .toast-icon { color: var(--warn); }

/* --------------------------------------------------------------------------
   Welcome tab quick-cards (cadet).
   -------------------------------------------------------------------------- */
.quick-card {
  position: relative;
  overflow: hidden;
}
.quick-card .card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-md);
  background: var(--accent-dim); color: var(--accent);
  margin-bottom: 0.5rem;
}
.quick-card .card-icon .icon { width: 1.2rem; height: 1.2rem; }
.quick-card .card-arrow {
  position: absolute; top: 0.9rem; right: 0.9rem;
  color: var(--muted); opacity: 0; transform: translateX(-4px);
  transition: opacity 140ms ease, transform 140ms ease, color 140ms ease;
}
.quick-card:hover .card-arrow { opacity: 1; transform: translateX(0); color: var(--accent); }

/* --------------------------------------------------------------------------
   Flashcard gentle flip animation.
   -------------------------------------------------------------------------- */
.flash-card { transition: transform 220ms ease; }
.flash-card.flipping { transform: rotateX(6deg) scale(0.985); }

/* --------------------------------------------------------------------------
   Thread list (Ask / Guidance).
   -------------------------------------------------------------------------- */
.ask-threads header h4 { display: inline-flex; align-items: center; gap: 0.35rem; }
.ask-threads header h4::before {
  content: "";
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,139,253,0.2);
}
.ask-threads button.new { display: inline-flex; align-items: center; gap: 0.25rem; }
.ask-threads button.new .icon { color: #fff; width: 0.85rem; height: 0.85rem; }

/* --------------------------------------------------------------------------
   Source picker icon.
   -------------------------------------------------------------------------- */
.src-picker-btn .src-icon { color: var(--accent); }
.src-picker-btn .src-icon.icon { width: 1rem; height: 1rem; }

/* --------------------------------------------------------------------------
   Drop zone.
   -------------------------------------------------------------------------- */
.drop-zone {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
}
.drop-zone .icon { color: var(--accent); }

/* --------------------------------------------------------------------------
   Admin-specific primitives.
   Kept here (not in admin.html) so we can build more admin-style dashboards
   later without duplicating.
   -------------------------------------------------------------------------- */

/* Dashed admin divider used between tool rows inside a panel. */
.tool-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
}
.tool-row .spacer { flex: 1; }

/* Admin session badge sitting next to "Falcon AI" in the header. */
.admin-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(61,139,253,0.35);
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
}
.admin-pill .icon { width: 0.85rem; height: 0.85rem; }

/* --------------------------------------------------------------------------
   Login polish hooks (static/login.html).
   -------------------------------------------------------------------------- */
.login-logo {
  display: inline-flex; align-items: center; gap: 0.55rem;
  margin-bottom: 0.35rem;
}
.login-logo .logo-mark {
  width: 36px; height: 36px;
  background: var(--accent, #3d8bfd);
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(61,139,253,0.2);
}
.login-logo .logo-mark svg { width: 1.2rem; height: 1.2rem; }
.login-security {
  margin-top: 1rem; display: flex; align-items: center; gap: 0.45rem;
  color: var(--muted, #8b9cb3); font-size: 0.74rem;
}
.login-security svg { width: 0.95rem; height: 0.95rem; color: var(--accent, #3d8bfd); }

/* --------------------------------------------------------------------------
   K-Test extra quiz / flashcard creator — objective checklist.

   ``index.html`` applies a global ``label { text-transform: uppercase; … }``
   rule; these rows need normal casing and a fixed checkbox column so boxes
   stay vertically aligned when labels wrap.
   -------------------------------------------------------------------------- */
.ktest-extras-objectives {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.ktest-extras-objectives__row {
  display: grid;
  grid-template-columns: 1.125rem minmax(0, 1fr);
  column-gap: 0.55rem;
  align-items: start;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text, #e8eef7);
}
.ktest-extras-objectives__check {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  margin: 0.18rem 0 0;
  padding: 0;
  vertical-align: top;
  accent-color: var(--accent, #3d8bfd);
  cursor: pointer;
}
.ktest-extras-objectives__label {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ktest-extras-objectives__label strong {
  font-weight: 600;
  color: var(--text, #e8eef7);
}

/* Recommended-source chips (Ask "All sources" refine UI). */
.rec-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  font-size: 0.8rem;
  line-height: 1.2;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel, rgba(255, 255, 255, 0.03));
  color: var(--text, #e8eef7);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.rec-chip:hover,
.rec-chip:focus-visible {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

/* ---------- Premium Image Insights ---------- */
.img-scan-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.img-scan-bar .img-scan-hint {
  font-size: 0.78rem;
  color: var(--muted);
}
.img-scan-pick {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
}
.res-card { position: relative; }
.img-scan-drawer {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1rem;
}
.img-scan-result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
}
.img-scan-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.img-scan-total { font-size: 0.8rem; color: var(--muted); }
.img-scan-pages {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
}
.img-scan-badge {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 6px;
  padding: 0 0.35rem;
  border: 1px solid var(--border);
}
.img-scan-badge.ok { color: var(--accent); border-color: var(--accent); }
.img-scan-badge.muted { color: var(--muted); }
.ask-image-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
}
.ask-image-chip {
  position: relative;
  display: inline-flex;
}
.ask-image-chip img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.ask-image-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

/* ---------- Plan & Billing ---------- */
.plan-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.plan-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  background: var(--panel);
}
.plan-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.plan-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.plan-badge.premium { background: rgba(99, 102, 241, 0.16); color: #6366f1; }
.plan-badge.free { background: var(--border); color: var(--muted); }
.plan-metric { font-size: 1.7rem; font-weight: 700; margin-top: 0.4rem; }
.plan-metric-unit { font-size: 0.9rem; font-weight: 400; color: var(--muted); }
.plan-sub { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0 0.75rem; }
.plan-bundles { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.plan-ledger { list-style: none; margin: 0.75rem 0 0; padding: 0; font-size: 0.82rem; color: var(--muted); }
.plan-ledger li {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-top: 1px solid var(--border);
}
.plan-loading { color: var(--muted); padding: 1rem 0; }

.upgrade-banner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0.5rem 0 1rem;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.10), transparent);
}
.upgrade-banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.18);
  color: #6366f1;
  flex: 0 0 auto;
}
.upgrade-banner-text { display: flex; flex-direction: column; line-height: 1.3; flex: 1 1 auto; }
.upgrade-banner-text strong { font-size: 0.95rem; }
.upgrade-banner-text span { color: var(--muted); font-size: 0.85rem; }
.upgrade-banner .btn-primary { flex: 0 0 auto; }
