/* ============================================================
   ATLAS Component Primitives — single source of truth.

   Both web/index.html (landing) and web/app.html (app shell)
   reference these primitives via <link rel="stylesheet" href="/shared/primitives.css">.

   Every declaration uses tokens from /shared/tokens.css.
   Do NOT duplicate component CSS in inline <style> blocks.
   See BRAND.md for design intent + usage guidance.
   ============================================================ */

/* ============================================================
   1. TYPOGRAPHY PRESETS — 8 named styles used everywhere
   ============================================================ */

.text-display {
  font-family: var(--font-head);
  font-size: var(--text-display-1);
  font-weight: var(--weight-black);
  line-height: var(--leading-tight);
  letter-spacing: 0;
  margin: 0;
}

.text-brand {
  font-family: var(--font-head);
  font-size: var(--text-xl);
  font-weight: var(--weight-extrabold);
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text);
}

.text-page-title {
  font-family: var(--font-head);
  font-size: clamp(18px, 2vw, var(--text-2xl));
  font-weight: var(--weight-extrabold);
  line-height: var(--leading-tight);
  letter-spacing: 0;
  margin: 0;
  color: var(--text);
}

.text-section {
  font-family: var(--font-head);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  margin: 0;
  color: var(--text);
}

.text-card-title {
  font-family: var(--font-head);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  margin: 0;
  color: var(--text);
}

.text-body {
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
  color: var(--text);
}

.text-meta {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  color: var(--muted);
}

.text-eyebrow {
  font-family: var(--font-head);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================================================
   ICONS — inline SVG utility sizes
   ============================================================ */

.icon {
  display: inline-block;
  flex-shrink: 0;
}

.icon--14 { width: 14px; height: 14px; }
.icon--16 { width: 16px; height: 16px; }
.icon--20 { width: 20px; height: 20px; }
.icon--24 { width: 24px; height: 24px; }

/* ============================================================
   1. BUTTONS
   ============================================================ */

.button,
.button-primary,
.button-ghost,
.button-discord,
.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-normal);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--duration-base) var(--ease-out-soft),
              background var(--duration-base) var(--ease-out-soft),
              border-color var(--duration-base) var(--ease-out-soft),
              box-shadow var(--duration-base) var(--ease-out-soft),
              color var(--duration-base) var(--ease-out-soft);
}

.button:disabled,
.button-primary:disabled,
.button-ghost:disabled,
.button-discord:disabled,
.button-danger:disabled,
.button--danger:disabled,
.button[aria-disabled="true"],
.button-primary[aria-disabled="true"],
.button-ghost[aria-disabled="true"],
.button-discord[aria-disabled="true"],
.button-danger[aria-disabled="true"],
.button--danger[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.button--small  { min-height: var(--control-height-sm); padding: 0 var(--space-3); font-size: var(--text-sm); }
.button--mini   { min-height: var(--control-height-xs); padding: 0 var(--space-2); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.button--icon   { min-height: var(--control-height-sm); width: var(--control-height-sm); padding: 0; border-radius: var(--radius-md); }
.button--large { min-height: var(--control-height-lg); padding: 0 var(--space-6); font-size: var(--text-lg); }

/* Variant: primary (default action) — brand sky */
.button--primary,
.button-primary {
  border-color: var(--sky-border);
  background: var(--sky);
  color: var(--text-on-accent);
  box-shadow: 0 10px 22px rgba(34, 154, 208, 0.20);
}
.button--primary:hover,
.button-primary:hover {
  transform: translateY(-1px);
  background: var(--sky-hover);
  border-color: var(--sky-border-hover);
  box-shadow: 0 14px 28px rgba(34, 154, 208, 0.28);
}

/* Variant: ghost — translucent neutral */
.button--ghost,
.button-ghost {
  border-color: var(--line-faint);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--glass-inset);
}
.button--ghost:hover,
.button-ghost:hover {
  transform: translateY(-1px);
  background: var(--surface-strong);
  border-color: var(--control-border-hover);
  box-shadow: var(--shadow-md);
}

.button-ghost.is-on,
.button-ghost.is-active {
  background: linear-gradient(145deg, var(--active-glass-top), var(--sky-wash));
  border-color: var(--sky-border);
  color: var(--sky);
}
.button-ghost.is-danger {
  background: linear-gradient(145deg, var(--active-glass-top-danger), var(--danger-wash));
  border-color: var(--danger-border);
  color: var(--danger);
}

/* Variant: discord (signature CTA) */
.button--discord,
.button-discord {
  border-color: var(--discord-border);
  background: var(--discord);
  color: var(--text-on-accent);
  box-shadow: 0 14px 30px rgba(92, 105, 242, 0.24);
}
.button--discord:hover,
.button-discord:hover {
  transform: translateY(-1px);
  background: var(--discord-hover);
  box-shadow: 0 18px 38px rgba(92, 105, 242, 0.30);
}

/* Variant: danger (destructive) */
.button--danger,
.button-danger {
  border-color: var(--danger-border);
  background: var(--danger);
  color: var(--text-on-accent);
  box-shadow: 0 10px 22px rgba(184, 80, 64, 0.24);
}
.button--danger:hover,
.button-danger:hover {
  transform: translateY(-1px);
  background: var(--danger-hover);
  box-shadow: 0 14px 28px var(--danger-border);
}

/* Variant: soft-link (subtle text-link, no button chrome) */
.button--soft-link,
.is-authed-soft {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out-soft), transform var(--duration-fast) var(--ease-out-soft);
}
.button--soft-link:hover,
.is-authed-soft:hover {
  color: var(--sky);
  transform: translateX(2px);
}

/* Active / press state — applies to all variants */
.button:active,
.button--primary:active, .button-primary:active,
.button--ghost:active, .button-ghost:active,
.button--discord:active, .button-discord:active,
.button--danger:active, .button-danger:active {
  transform: translateY(0);
  transition-duration: 80ms;  /* intentional micro-motion for :active press */
}

/* ============================================================
   2. SURFACES — cards / panels / glass treatments
   ============================================================ */

.surface-flat {
  background: var(--surface);
  border: var(--border-thin) solid var(--line);
  border-radius: var(--radius);
}

.surface-elevated {
  background: var(--surface-strong);
  border: var(--border-thin) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.surface-glass {
  background: var(--glass-bg);
  border: var(--border-thin) solid var(--glass-border);
  border-radius: var(--radius);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-inset), var(--glass-shadow-soft);
}

.surface-glass--strong,
.surface-glass-strong {
  background: var(--glass-bg-strong);
  border: var(--border-thin) solid var(--glass-border-strong);
  border-radius: var(--radius);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-inset), var(--glass-shadow);
}

/* ============================================================
   3. FORM INPUTS — scaffolded placeholders
   ============================================================ */

/* Phase 1 ships base styles; richer states added when forms are actually wired. */

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-height: var(--control-height);
  padding: var(--space-1) var(--space-3);
  border: var(--border-thin) solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  transition: border-color var(--duration-fast) var(--ease-out-soft),
              box-shadow var(--duration-fast) var(--ease-out-soft),
              background var(--duration-fast) var(--ease-out-soft);
}
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.input::placeholder,
.textarea::placeholder { color: var(--muted-soft); }

.textarea {
  resize: vertical;
  min-height: 72px;
}

.input--small { min-height: var(--control-height-sm); font-size: var(--text-sm); }

/* ============================================================
   4. MODALS + DIALOGS — canonical popup primitive
   (Use `<dialog>` element or div+role="dialog"; classes apply to either.)
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(15, 20, 26, 0.46);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: var(--space-4);
}

.modal,
.dialog {
  position: relative;
  width: min(100%, 480px);
  max-height: calc(100vh - var(--space-16));
  overflow-y: auto;
  padding: var(--space-6);
  background: var(--surface-strong);
  border: var(--border-thin) solid var(--glass-border);
  border-radius: var(--radius-large);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-2xl), var(--glass-inset);
  color: var(--text);
}

.modal__close,
.dialog__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-xl);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out-soft), color var(--duration-fast) var(--ease-out-soft);
}
.modal__close:hover,
.dialog__close:hover {
  background: var(--surface);
  color: var(--text);
}

/* ============================================================
   5. TOASTS / ALERTS — scaffolded
   ============================================================ */

.toast {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: var(--border-thin) solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
}

.toast--success { border-color: var(--success-border); background: var(--success-soft); }
.toast--danger  { border-color: var(--danger-border); background: var(--danger-soft); }
.toast--warning { border-color: var(--warning-border); background: var(--warning-soft); }
.toast--info    { border-color: var(--sky-border); background: var(--info-soft); }

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast-container > .toast { pointer-events: auto; }

/* ============================================================
   6. TOOLTIPS — scaffolded
   ============================================================ */

.tooltip {
  position: absolute;
  z-index: var(--z-overlay);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-small);
  background: var(--tooltip-bg);
  color: var(--text-on-accent);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out-soft);
}
.tooltip[data-visible="true"] { opacity: 1; }

/* ============================================================
   7. LOADING STATES — atlas-loader spinner + skeletons
   ============================================================ */

@keyframes atlas-loader-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes atlas-loader-pulse {
  0%, 100% { opacity: 0.65; }
  50%      { opacity: 1; }
}

.atlas-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--sky);
}
.atlas-loader svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.skeleton {
  display: block;
  background: linear-gradient(90deg,
    var(--surface) 0%,
    var(--surface-strong) 50%,
    var(--surface) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-small);
  animation: atlas-loader-pulse 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .atlas-loader,
  .skeleton { animation: none; }
}

/* ============================================================
   8. TABLES — scaffolded
   ============================================================ */

.table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
}

.table thead {
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--muted);
  border-bottom: var(--border-thin) solid var(--line);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-thin) solid var(--line-soft);
}

.table tbody tr {
  transition: background var(--duration-fast) var(--ease-out-soft);
}
.table tbody tr:hover { background: var(--surface-soft); }

/* ============================================================
   9. TABS + ACCORDIONS — scaffolded
   ============================================================ */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: var(--border-thin) solid var(--line);
}
.tab {
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out-soft), border-color var(--duration-fast) var(--ease-out-soft);
  border-bottom: var(--border-medium) solid transparent;
}
.tab[aria-selected="true"],
.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--sky);
}

.accordion-item {
  padding: var(--space-5) 0;
  border-top: var(--border-thin) solid var(--line);
}
.accordion-item:last-child { border-bottom: var(--border-thin) solid var(--line); }
.accordion-item__summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-head);
  font-size: var(--text-lg);
  font-weight: var(--weight-extrabold);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.accordion-item__summary::-webkit-details-marker { display: none; }
.accordion-item__summary .icon {
  color: var(--sky);
  transition: transform var(--duration-base) var(--ease-out-soft);
}
.accordion-item[open] .accordion-item__summary .icon {
  transform: rotate(180deg);
}

/* Monitor offer-tier ladder: compact in-cell <details> expander listing every
   served Qogita offer tier (selected highlighted, alternates greyed). Reuses the
   native-<details> + chevron-rotate pattern above, sized for a table cell. */
.offer-ladder { margin-top: var(--space-1); }
.offer-ladder__summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--muted);
}
.offer-ladder__summary::-webkit-details-marker { display: none; }
.offer-ladder__summary .icon {
  color: var(--sky);
  transition: transform var(--duration-fast) var(--ease-out-soft);
}
.offer-ladder[open] .offer-ladder__summary .icon { transform: rotate(180deg); }
.offer-ladder__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
/* One supplier per group: a single identity header, then its price ladder. */
.offer-ladder__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.offer-ladder__group + .offer-ladder__group {
  padding-top: var(--space-2);
  border-top: var(--border-thin) solid var(--line-soft);
}
.offer-ladder__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-xs);
}
.offer-ladder__code {
  font-weight: var(--weight-semibold);
  color: var(--text);
  letter-spacing: 0.02em;
}
.offer-ladder__group--buying .offer-ladder__code { color: var(--sky); }
.offer-ladder__stock { color: var(--muted-soft); }
.offer-ladder__rungs {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.offer-ladder__rung {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--muted);
}
.offer-ladder__rung--selected {
  background: var(--sky-soft);
  color: var(--text);
  font-weight: var(--weight-semibold);
}
.offer-ladder__price { font-variant-numeric: tabular-nums; }
.offer-ladder__mov {
  margin-left: auto;
  color: var(--muted-soft);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   10. AVATARS
   ============================================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--blossom-soft);
  color: var(--text);
  font-family: var(--font-head);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-normal);
  text-transform: uppercase;
  overflow: hidden;
}
.avatar--xs { width: 20px; height: 20px; font-size: var(--text-2xs); }
.avatar--sm { width: 24px; height: 24px; font-size: var(--text-xs); }
.avatar--md { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar--lg { width: 40px; height: 40px; font-size: var(--text-base); }

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ============================================================
   11. BADGES / PILLS / CHIPS
   ============================================================ */

.badge,
.pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: var(--border-thin) solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text);
  letter-spacing: var(--tracking-normal);
}

.badge--success { border-color: var(--success-border); background: var(--success-soft); color: var(--success); }
.badge--danger  { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.badge--warning { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning-text-alt); }
.badge--info    { border-color: var(--sky-border); background: var(--info-soft); color: var(--sky-strong); }

/* Pill (alias) for partner-pill / region-chip etc. */
.pill { gap: var(--space-2); padding: 4px 10px 4px 6px; font-size: var(--text-sm); }

/* ============================================================
   12. FOCUS RINGS — utility
   ============================================================ */

.focus-ring,
[data-focus-ring] {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.button:focus-visible,
.button-primary:focus-visible,
.button-ghost:focus-visible,
.button-discord:focus-visible,
.button--primary:focus-visible,
.button--ghost:focus-visible,
.button--discord:focus-visible,
.button--danger:focus-visible,
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.tab:focus-visible,
.accordion-item__summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ============================================================
   13. NAV PATTERNS — scaffolded shared bits
   ============================================================ */

.nav-base {
  display: grid;
  align-items: center;
  gap: var(--space-4);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  transition: background var(--duration-base) var(--ease-out-soft),
              border-color var(--duration-base) var(--ease-out-soft),
              box-shadow var(--duration-base) var(--ease-out-soft),
              -webkit-backdrop-filter var(--duration-base) var(--ease-out-soft),
              backdrop-filter var(--duration-base) var(--ease-out-soft);
}

.nav-base.is-scrolled {
  border-color: var(--glass-border);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-inset), var(--shadow-md);
}

.nav-anchors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: clamp(var(--space-6), 3.6vw, var(--space-12));
}
.nav-anchors a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) 2px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--nav-anchor-text);
  text-decoration: none;
  transition: color var(--duration-base) var(--ease-out-soft);
}
.nav-anchors a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  width: 100%;
  height: 1.5px;
  background: var(--sky);
  border-radius: 2px;
  transition: transform var(--duration-base) var(--ease-out-soft);
}
.nav-anchors a:hover,
.nav-anchors a:focus-visible { color: var(--text); }
.nav-anchors a:hover::after,
.nav-anchors a:focus-visible::after { transform: translateX(-50%) scaleX(0.8); }

/* ============================================================
   3. FORM PRIMITIVES — input / select / textarea / switch
   ============================================================ */

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-height: var(--control-height);
  padding: 4px 8px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  background:
    linear-gradient(145deg, var(--glass-grad-top), var(--glass-grad-bottom));
  box-shadow: var(--control-shadow);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text);
  transition: border-color var(--duration-base) var(--ease-out-soft),
              box-shadow var(--duration-base) var(--ease-out-soft);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--control-border-strong);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px var(--focus-ring), var(--control-shadow);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-soft, var(--muted));
}

.input--small { min-height: var(--control-height-sm); padding: 4px 8px; font-size: var(--text-sm); }
.input--mini  { min-height: var(--control-height-xs); padding: 3px 8px; font-size: var(--text-xs); border-radius: var(--radius-sm); }

.input.has-error,
.select.has-error,
.textarea.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(184, 80, 64, 0.20);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-faint);
  color: var(--muted-soft, var(--muted));
  cursor: not-allowed;
}

.textarea { min-height: 64px; padding: 6px 8px; resize: vertical; }

/* Select chevron supplied by the shared select primitive. */
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-color: var(--surface-dim);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%233f4854' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='3.5 5.25 7 8.75 10.5 5.25'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.language-select-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.language-flag {
  display: inline-block;
  flex: 0 0 auto;
  width: 20px;
  height: 14px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(20, 36, 54, 0.18);
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  pointer-events: none;
  vertical-align: -2px;
}

.language-select-shell > .language-flag {
  position: absolute;
  left: 12px;
  z-index: 1;
}

.language-select-shell > .language-flag + .select {
  padding-left: 40px;
}

.language-select-shell > .language-flag + .input--mini.select {
  padding-left: 34px;
}

.language-picker {
  overflow: visible;
}

.settings-row:has([data-language-picker-button][aria-expanded="true"]) {
  position: relative;
  z-index: var(--z-overlay);
}

.language-picker__button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  text-align: left;
  cursor: pointer;
}

.language-picker__menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 100%;
  padding: var(--space-1);
  border: var(--border-thin) solid var(--control-border);
  border-radius: var(--radius-md);
  background: var(--surface-menu);
  box-shadow: var(--shadow-lg);
}

.language-picker__menu[hidden] {
  display: none;
}

.language-picker__option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 28px;
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.language-picker__option:hover,
.language-picker__option:focus-visible,
.language-picker__option.is-selected {
  background: var(--sky-soft);
  outline: none;
}

.language-flag--en { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 36'%3E%3Cpath fill='%23012169' d='M0 0h60v36H0z'/%3E%3Cpath stroke='%23fff' stroke-width='8' d='M0 0l60 36M60 0L0 36'/%3E%3Cpath stroke='%23C8102E' stroke-width='4' d='M0 0l60 36M60 0L0 36'/%3E%3Cpath stroke='%23fff' stroke-width='14' d='M30 0v36M0 18h60'/%3E%3Cpath stroke='%23C8102E' stroke-width='8' d='M30 0v36M0 18h60'/%3E%3C/svg%3E"); }
.language-flag--de { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 36'%3E%3Cpath d='M0 0h60v12H0z'/%3E%3Cpath fill='%23DD0000' d='M0 12h60v12H0z'/%3E%3Cpath fill='%23FFCE00' d='M0 24h60v12H0z'/%3E%3C/svg%3E"); }
.language-flag--fr { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 36'%3E%3Cpath fill='%23002395' d='M0 0h20v36H0z'/%3E%3Cpath fill='%23fff' d='M20 0h20v36H20z'/%3E%3Cpath fill='%23ED2939' d='M40 0h20v36H40z'/%3E%3C/svg%3E"); }
.language-flag--it { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 36'%3E%3Cpath fill='%23009246' d='M0 0h20v36H0z'/%3E%3Cpath fill='%23fff' d='M20 0h20v36H20z'/%3E%3Cpath fill='%23CE2B37' d='M40 0h20v36H40z'/%3E%3C/svg%3E"); }
.language-flag--es { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 36'%3E%3Cpath fill='%23AA151B' d='M0 0h60v9H0zm0 27h60v9H0z'/%3E%3Cpath fill='%23F1BF00' d='M0 9h60v18H0z'/%3E%3C/svg%3E"); }

.settings-row-control > .language-select-shell {
  min-width: 178px;
}

/* Matches the 980px breakpoint where .settings-row stacks (app.html), so the
   language shell widens together with the sibling Theme/Currency selects. */
@media (max-width: 980px) {
  .settings-row-control > .language-select-shell,
  .settings-row-control > .language-select-shell .select {
    width: 100%;
  }
}

/* Switch — pill toggle with accessible underlying input */
.switch {
  display: inline-flex;
  align-items: center;
  position: relative;
  width: 40px;
  height: 24px;
  cursor: pointer;
}
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;          /* keep focusable, just invisible */
  cursor: pointer;
}
.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--control-border);
  transition: background var(--duration-base) var(--ease-out-soft);
}
.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform var(--duration-base) var(--ease-out-soft);
}
.switch input:checked ~ .switch__track { background: var(--sky); }
.switch input:checked ~ .switch__knob   { transform: translateX(16px); }
.switch input:focus-visible ~ .switch__track {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ============================================================
   PILLS / BADGES / CHIPS — single primitive, semantic variants
   ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1, 4px);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: var(--surface-dim);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
}

.pill--sm  { padding: 2px 6px; font-size: var(--text-2xs); }
.pill--neutral { background: var(--surface-dim); border-color: var(--control-border); color: var(--text); }
.pill--info    { background: var(--info-tint); border-color: var(--info-tint-border); color: var(--info-text); }
.pill--success { background: var(--success-tint); border-color: var(--success-tint-border); color: var(--success-text); }
.pill--warning { background: var(--warning-tint); border-color: var(--warning-tint-border); color: var(--warning-text); }
.pill--danger  { background: var(--danger-tint); border-color: var(--danger-tint-border); color: var(--danger-text); }

.pill svg { width: 12px; height: 12px; }
.pill--sm svg { width: 10px; height: 10px; }

/* ============================================================
   CARDS — 4 variants for every panel-like container
   ============================================================ */

.card-glass,
.card-solid,
.card-interactive,
.card-nested {
  border-radius: var(--radius-lg, 18px);
  border: 1px solid var(--control-border);
  background: var(--surface);
}

.card-glass {
  background: var(--glass-card-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-color: var(--line);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    0 18px 44px rgba(20, 36, 54, 0.10);
}

.card-solid {
  background: var(--surface-solid);
  box-shadow: var(--shadow-md, 0 8px 20px rgba(20, 30, 45, 0.06));
}

.card-interactive {
  background: linear-gradient(145deg, var(--glass-grad-top), var(--glass-grad-bottom));
  cursor: pointer;
  transition: transform var(--duration-base) var(--ease-out-soft),
              box-shadow var(--duration-base) var(--ease-out-soft),
              border-color var(--duration-base) var(--ease-out-soft);
}
.card-interactive:hover {
  transform: translateY(-1px);
  border-color: var(--control-border-strong);
  box-shadow: var(--shadow-lg, 0 12px 28px rgba(20, 30, 45, 0.10));
}
.card-interactive:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.card-nested {
  background: linear-gradient(150deg, var(--glass-bg), var(--glass-grad-soft));
  backdrop-filter: var(--glass-blur-soft);
  -webkit-backdrop-filter: var(--glass-blur-soft);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 12px 30px rgba(31, 48, 66, 0.08);
}

/* ============================================================
   TABS + SEGMENTED CONTROLS
   ============================================================ */

.tabs {
  display: inline-flex;
  gap: var(--space-1, 4px);
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-faint);
  border: 1px solid var(--control-border);
}
.tabs__item {
  padding: 4px 10px;
  border-radius: 999px;
  background: transparent;
  border: none;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--duration-base) var(--ease-out-soft),
              color var(--duration-base) var(--ease-out-soft);
}
.tabs__item:hover { color: var(--text); }
.tabs__item:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.tabs__item--active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--control-shadow);
}

.segmented {
  display: inline-flex;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  border: 0;
  overflow: visible;
  background: transparent;
}
.segmented__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height-sm);
  padding: 0 var(--space-3);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--glass-inset);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--muted);
  cursor: pointer;
  transition: transform var(--duration-base) var(--ease-out-soft),
              background var(--duration-base) var(--ease-out-soft),
              border-color var(--duration-base) var(--ease-out-soft),
              box-shadow var(--duration-base) var(--ease-out-soft),
              color var(--duration-base) var(--ease-out-soft);
}
.segmented__item:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--surface-strong);
  border-color: var(--control-border-hover);
  box-shadow: var(--shadow-md);
  color: var(--text);
}
.segmented__item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus-ring), var(--shadow-xs); }
.segmented__item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.segmented__item--active {
  background: linear-gradient(145deg, var(--active-glass-top), var(--sky-wash));
  border-color: var(--sky-border);
  color: var(--sky);
}
.segmented__item--active:hover:not(:disabled) {
  background: linear-gradient(145deg, var(--active-glass-top), var(--sky-wash));
  border-color: var(--sky-border);
  color: var(--sky);
}

/* ============================================================
   MODAL / DIALOG (universal)
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: var(--space-5);
}
.modal {
  width: min(560px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(20, 30, 45, 0.30);
  padding: var(--space-6);
  z-index: var(--z-modal);
}
.modal--wide {
  width: min(1180px, 100%);
  max-height: calc(100vh - 28px);
  border-radius: var(--radius-lg);
}
.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  cursor: pointer;
}
.modal__close:hover { background: var(--hover-wash); }

/* ============================================================
   EMPTY STATE / SKELETON / SPINNER
   ============================================================ */

.empty-state {
  display: grid;
  place-items: center;
  gap: var(--space-3, 8px);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--control-border);
  border-radius: var(--radius-lg);
}
.empty-state__icon {
  width: 40px;
  height: 40px;
  color: var(--muted-soft, var(--muted));
}
.empty-state__title { font-size: var(--text-md); font-weight: var(--weight-bold); color: var(--text); margin: 0; }
.empty-state__body  { font-size: var(--text-base); line-height: 1.5; max-width: 360px; margin: 0; }

.skeleton {
  display: block;
  background:
    linear-gradient(90deg,
      var(--skeleton-base) 25%,
      var(--line-faint) 37%,
      var(--skeleton-base) 63%);
  background-size: 400% 100%;
  border-radius: var(--radius-md);
  animation: skeleton-shimmer 1.4s linear infinite;
}
.skeleton--text { height: 11px; margin: 5px 0; }
.skeleton--title { height: 16px; margin: 6px 0; }
.skeleton--avatar { width: 32px; height: 32px; border-radius: 999px; }
@keyframes skeleton-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.spinner {
  --loading-spinner-size: 40px;
  width: var(--loading-spinner-size);
  height: var(--loading-spinner-size);
  background: url("/atlas-loaders/atlas-loader-black-12-left-forward.svg?v=animated2") center / contain no-repeat;
}

/* Universal focus-visible — overrides any previous outline:none */
.button:focus-visible,
.button-primary:focus-visible,
.button-ghost:focus-visible,
.button-discord:focus-visible,
.button-danger:focus-visible,
.button--icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring), var(--glass-inset, 0 0 0 0 transparent);
}

/* Keep translated UI copy inside fixed-size controls instead of letting it escape. */
.ui-truncate-text,
:where(.button, .button-primary, .button-ghost, .button-discord, .button-danger, .button--primary, .button--ghost, .button--discord, .button--danger, .tabs__item, .segmented__item, .badge, .pill, .chip) > :where(span, strong, em, small) {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-truncate-text {
  display: inline-block;
}

:where(.button, .button-primary, .button-ghost, .button-discord, .button-danger, .button--primary, .button--ghost, .button--discord, .button--danger, .tabs__item, .segmented__item, .badge, .pill, .chip) {
  min-width: 0;
  max-width: 100%;
}

:where(.button, .button-primary, .button-ghost, .button-discord, .button-danger, .button--primary, .button--ghost, .button--discord, .button--danger, .tabs__item, .segmented__item, .badge, .pill, .chip):not(.button--icon) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:where(.badge, .pill, .chip) > :where(button, svg, .icon) {
  flex: 0 0 auto;
}

/* ============================================================
   Dark theme (night blossom) — component-level corrections.
   Token values live in tokens.css; only rules that can't be
   expressed as a token swap belong here.
   ============================================================ */

/* The brightened dark accent fills (--sky #4FB8E8, --danger #F0917F) fail
   contrast under the white --text-on-accent (2.3:1); labels flip to night
   ink (12.2:1 / 9.8:1). Discord stays canonical blurple + white (4.6:1). */
:root[data-theme="dark"] .button--primary,
:root[data-theme="dark"] .button-primary,
:root[data-theme="dark"] .button--danger,
:root[data-theme="dark"] .button-danger {
  color: #06121D;
}

/* Chevron stroke #3f4854 disappears on dark control surfaces. :not(:disabled)
   keeps this below the `.select:disabled` background shorthand, which is what
   removes the chevron on disabled selects in both themes. */
:root[data-theme="dark"] .select:not(:disabled) {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%23A9B4C0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='3.5 5.25 7 8.75 10.5 5.25'/></svg>");
}
