/* components.css - Homeaglow Admin generic component library (Claude/Anthropic warm-light).

   Loaded AFTER theme.css (consumes its TIER 2 semantic tokens only), and BEFORE app.css
   (so the auth overrides at the bottom must win on equal specificity via descendant selectors).

   RULES this file obeys:
     - Consumes ONLY semantic tokens (--bg, --surface, --accent, ...). Never primitives (--c-*).
     - Never hardcodes a color. transparent / currentColor / #fff are used only where no token fits.
     - Generic class names (.btn, .card, .table, ...). Does NOT redefine the app's per-feature classes.
     - 8px control radius, 500-weight controls, subtle shadows, serif display headings, calm hovers.

   FAMILIES (in order):
     Buttons - Forms - Filter bar - Tables - Badges/pills/chips/tags/dots - Cards/stat-card -
     Modals - Menus/dropdowns - Alerts - Toast - Tooltip - Pagination - Tabs/segmented -
     States (empty/loading/spinner/skeleton) - Misc (kbd/divider/avatar/titles) - Auth overrides
   ============================================================================ */

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  height: 34px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.btn:disabled,
.btn[disabled],
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Sizes */
.btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-md { height: 34px; padding: 0 var(--space-4); font-size: var(--text-base); }

/* Primary - clay solid */
.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); border-color: var(--accent-active); transform: translateY(1px); }

/* Secondary - transparent, hairline border, hover fills */
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-hover); }
.btn-secondary:active { background: var(--surface-sunken); transform: translateY(1px); }

/* Ghost - no border, hover fill */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-ghost:active { background: var(--surface-sunken); transform: translateY(1px); }

/* Danger */
.btn-danger {
  background: var(--danger);
  color: var(--text-on-accent);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger:active { transform: translateY(1px); }

/* Icon button - 32px square ghost */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }
.btn-icon:active { background: var(--surface-sunken); }
.btn-icon.btn-sm { width: 28px; height: 28px; }

/* ============================================================================
   FORMS
   ============================================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.input,
.select,
.textarea {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  height: 36px;
  width: 100%;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea {
  height: auto;
  min-height: 88px;
  padding: var(--space-3);
  resize: vertical;
  line-height: 1.5;
}
.input::placeholder,
.textarea::placeholder { color: var(--text-faint); }

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

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

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

/* Native select chevron, drawn with a token-tinted gradient (no color literal). */
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-7);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* Checkbox + radio - native control tinted to clay via accent-color token */
.checkbox,
.radio {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.checkbox { border-radius: var(--radius-xs); }
.radio { border-radius: var(--radius-full); }
.checkbox:hover,
.radio:hover { border-color: var(--accent); }
.checkbox::before {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease);
  box-shadow: inset 1em 1em var(--text-on-accent);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.radio::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease);
  box-shadow: inset 1em 1em var(--text-on-accent);
}
.checkbox:checked,
.radio:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::before,
.radio:checked::before { transform: scale(1); }
.checkbox:focus-visible,
.radio:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.checkbox:disabled,
.radio:disabled { opacity: 0.5; cursor: not-allowed; }

/* Switch (toggle) - markup: <label class="switch"><input type="checkbox"><span class="switch-track"></span></label> */
.switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transition: background var(--dur) var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-ring); }
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }

.field-hint { font-size: var(--text-sm); color: var(--text-muted); }
.field-error { font-size: var(--text-sm); color: var(--danger); }
/* When a field is in error, redden its control border. */
.field-error ~ .input,
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
  border-color: var(--danger);
}

/* ============================================================================
   FILTER BAR
   ============================================================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.filters .field { margin-bottom: 0; gap: var(--space-1); min-width: 160px; }
.filters .label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filters .input,
.filters .select { height: 34px; }
.filters .filters-actions { display: flex; gap: var(--space-2); margin-left: auto; }

/* ============================================================================
   TABLES
   ============================================================================ */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface);
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: var(--fw-semibold);
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: var(--surface-sunken);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.table th.num { text-align: right; }

/* Dense / compact data grid */
.table.table-dense { font-size: var(--text-sm); }
.table.table-dense thead th { padding: var(--space-2) var(--space-3); }
.table.table-dense tbody td { padding: var(--space-2) var(--space-3); }

/* ============================================================================
   BADGES / PILLS / CHIPS / TAGS / DOTS
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  line-height: 1;
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-warn    { background: var(--warn-tint);    color: var(--warn); }
.badge-danger  { background: var(--danger-tint);  color: var(--danger); }
.badge-info    { background: var(--info-tint);    color: var(--info); }
.badge-neutral { background: var(--surface-sunken); color: var(--text-muted); }
.badge-accent  { background: var(--accent-tint);  color: var(--accent-contrast-text); }

/* Pill - full radius badge */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  padding: 4px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Tag - small, removable */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--accent-contrast-text);
}
.tag .tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-full);
  opacity: 0.7;
  transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.tag .tag-remove:hover { opacity: 1; background: var(--accent-tint-strong); }

/* Status chip with leading dot */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  padding: 4px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
/* Status chip without a border: a leading dot + label, inline. The gap gives
   the dot a little breathing room from its text. */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--text-faint);
  flex: 0 0 auto;
}
.dot.dot-success { background: var(--success); }
.dot.dot-warn    { background: var(--warn); }
.dot.dot-danger  { background: var(--danger); }
.dot.dot-info    { background: var(--info); }
.dot.dot-accent  { background: var(--accent); }

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-weight: var(--fw-semibold);
  font-size: var(--text-md);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Stat card - big serif number + label */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.stat-card .stat-value {
  font-family: var(--font-serif);
  font-size: var(--text-4xl);
  font-weight: var(--fw-regular);
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card .stat-delta { font-size: var(--text-sm); font-weight: var(--fw-medium); }
.stat-card .stat-delta.is-up { color: var(--success); }
.stat-card .stat-delta.is-down { color: var(--danger); }

/* ============================================================================
   MODALS
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  z-index: 1000;
}
.modal {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - var(--space-8));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in var(--dur) var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.modal-header .modal-title {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: var(--fw-regular);
  color: var(--text);
}
.modal-body { padding: var(--space-5); overflow-y: auto; color: var(--text-muted); font-size: var(--text-md); }
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ============================================================================
   MENUS / DROPDOWNS / POPOVERS
   ============================================================================ */
.menu {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
  min-width: 180px;
  display: inline-flex;
  flex-direction: column;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.menu-item:hover { background: var(--surface-hover); }
.menu-item:focus-visible { outline: none; background: var(--surface-hover); box-shadow: 0 0 0 2px var(--accent-ring); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-tint); }
.menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
.menu-divider { height: 1px; background: var(--border); margin: var(--space-1) 0; }
.menu-label {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================================================
   ALERTS / BANNERS
   ============================================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--border-strong);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: var(--text-base);
}
.alert .alert-title { font-weight: var(--fw-semibold); display: block; margin-bottom: 2px; }
.alert .alert-body { color: var(--text-muted); }
.alert-success { background: var(--success-tint); border-left-color: var(--success); }
.alert-success .alert-title { color: var(--success); }
.alert-warn { background: var(--warn-tint); border-left-color: var(--warn); }
.alert-warn .alert-title { color: var(--warn); }
.alert-danger { background: var(--danger-tint); border-left-color: var(--danger); }
.alert-danger .alert-title { color: var(--danger); }
.alert-info { background: var(--info-tint); border-left-color: var(--info); }
.alert-info .alert-title { color: var(--info); }

/* ============================================================================
   TOAST
   ============================================================================ */
.toast-region {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 1100;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 240px;
  max-width: 360px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  color: var(--text);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}
.toast .toast-dot { flex: 0 0 auto; }
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-danger  { border-left: 3px solid var(--danger); }
.toast.toast-info    { border-left: 3px solid var(--info); }

/* ============================================================================
   TOOLTIP
   ============================================================================ */
.tooltip {
  position: relative;
  display: inline-flex;
}
.tooltip .tooltip-text {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text);
  color: var(--bg);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  line-height: 1.3;
  white-space: nowrap;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 1200;
}
.tooltip .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
}
.tooltip:hover .tooltip-text,
.tooltip:focus-within .tooltip-text {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================================
   PAGINATION
   ============================================================================ */
.pagination {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.page-btn:hover { background: var(--surface-hover); }
.page-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.page-btn.is-active {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================================
   TABS / SEGMENTED CONTROL
   ============================================================================ */
.tabs {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
}
.tab {
  position: relative;
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: var(--space-3) var(--space-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}
.tab::after {
  content: "";
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--radius-full);
  transform: scaleX(0);
  transition: transform var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab:focus-visible { outline: none; color: var(--text); box-shadow: 0 0 0 2px var(--accent-ring); border-radius: var(--radius-xs); }
.tab.is-active { color: var(--accent); }
.tab.is-active::after { transform: scaleX(1); }

/* Segmented control - active = surface pill */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.segment {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  height: 26px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.segment:hover { color: var(--text); }
.segment:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-ring); }
.segment.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ============================================================================
   STATES - empty / loading / spinner / skeleton
   ============================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-align: center;
  padding: var(--space-8) var(--space-5);
  color: var(--text-muted);
}
.empty-state .empty-title {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: var(--fw-regular);
  color: var(--text);
}
.empty-state .empty-body { font-size: var(--text-base); color: var(--text-muted); max-width: 360px; }
.empty-state .empty-icon { font-size: var(--text-4xl); color: var(--text-faint); margin-bottom: var(--space-2); }

/* .loading - the app's existing class name; calm muted centered text */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6);
  color: var(--text-muted);
  font-size: var(--text-base);
}

/* Spinner - clay ring */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent-tint-strong);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin var(--dur-slow) linear infinite;
  vertical-align: middle;
}
.spinner.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton - shimmer using surface tones */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  height: 14px;
  width: 100%;
}
.skeleton.skeleton-line { height: 12px; margin-bottom: var(--space-2); }
.skeleton.skeleton-line:last-child { margin-bottom: 0; }
.skeleton.skeleton-block { height: 80px; border-radius: var(--radius-md); }
.skeleton.skeleton-circle { width: 40px; height: 40px; border-radius: var(--radius-full); }
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--surface-hover), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ============================================================================
   MISC - kbd / divider / avatar / page + section titles
   ============================================================================ */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.divider { height: 1px; background: var(--border); border: none; margin: var(--space-5) 0; }
.divider.divider-vertical { width: 1px; height: auto; align-self: stretch; margin: 0 var(--space-3); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--text);
  color: var(--bg);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  flex: 0 0 auto;
  user-select: none;
}
.avatar.avatar-sm { width: 24px; height: 24px; font-size: var(--text-xs); }
.avatar.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }
.avatar.avatar-accent { background: var(--accent); color: var(--text-on-accent); }

.page-title {
  font-family: var(--font-serif);
  font-size: var(--text-4xl);
  font-weight: var(--fw-regular);
  line-height: 1.15;
  color: var(--text);
  letter-spacing: -0.01em;
}
.section-title {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--text);
  letter-spacing: -0.005em;
}

/* ============================================================================
   AUTH SCREENS (override app.css; descendant selectors to win on equal specificity)
   These class names live in the app's app.css. components.css loads first, so we
   beat app.css by carrying one extra ancestor (.auth-screen) on every rule.
   ============================================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--bg);
}
.auth-screen .auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-7);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.auth-screen .auth-card h2 {
  font-family: var(--font-serif);
  font-size: var(--text-3xl);
  font-weight: var(--fw-regular);
  line-height: 1.15;
  color: var(--text);
  letter-spacing: -0.01em;
}
.auth-screen .auth-subtitle {
  font-size: var(--text-md);
  color: var(--text-muted);
  margin-top: calc(-1 * var(--space-2));
}
.auth-screen .auth-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.auth-screen .auth-field label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
}
.auth-screen .auth-field input {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  height: 40px;
  width: 100%;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.auth-screen .auth-field input::placeholder { color: var(--text-faint); }
.auth-screen .auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.auth-screen .auth-btn {
  width: 100%;
  height: 42px;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--fw-medium);
  color: var(--text-on-accent);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.auth-screen .auth-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.auth-screen .auth-btn:active { background: var(--accent-active); border-color: var(--accent-active); transform: translateY(1px); }
.auth-screen .auth-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.auth-screen .auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-screen .auth-error {
  font-size: var(--text-sm);
  color: var(--danger);
  background: var(--danger-tint);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}
.auth-screen .auth-success {
  font-size: var(--text-sm);
  color: var(--success);
  background: var(--success-tint);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}
.auth-screen .auth-email-display {
  display: inline-flex;
  align-items: center;
  align-self: center;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
}
