/* alphaTrack UI — components.
 *
 * Everything in this file reads only the semantic tokens declared in
 * tokens.css (and overridden by themes.css / apps.css). Never hardcode
 * a hex colour here.
 *
 * Order: reset → layout → typography → controls → patterns → overlays.
 * Apps link tokens.css + themes.css + apps.css + ui.css in that order.
 */

/* ── reset & base ───────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--ui-font);
  background: var(--ui-bg);
  color: var(--ui-text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Bare <a> inherits its container's color so app-specific text (video
   titles, card headings, etc.) doesn't pick up the brand accent by
   default. Apps opt in to accent-styled links via .btn-link or by
   setting color: var(--ui-accent) on their own classes. */
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* `hidden` must always win — components flip [hidden] on/off and we don't
   want a stray display:flex/grid keeping them visible. */
[hidden] { display: none !important; }

/* visually hidden but accessible */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── themed scrollbars ──────────────────────────────────────────── */
/* Native scrollbars look out of place against the dark surfaces (bright
   track + bright thumb). Style them to use border/muted tokens so they
   blend into whichever theme is active.
   - `scrollbar-color` + `scrollbar-width` cover Firefox and Chromium.
   - `::-webkit-scrollbar` pseudo-elements cover Chrome/Safari/Edge with
     finer control (rounded thumb, hover state).
   Apply globally via *, so scrolling containers (modals, .search-results,
   any overflow:auto block) inherit the styling without per-element rules. */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--ui-border) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--ui-border);
  border-radius: var(--ui-radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ui-muted);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* ── layout primitives ──────────────────────────────────────────── */

.panel {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: var(--ui-space-4);
}
.panel-2 {
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: var(--ui-space-4);
}
.panel-flush { padding: 0; }

.card {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  overflow: hidden;
  transition: border-color var(--ui-trans-fast), transform var(--ui-trans-fast);
}
.card.is-clickable { cursor: pointer; }
.card.is-clickable:hover { border-color: var(--ui-accent); }

.stack { display: flex; flex-direction: column; gap: var(--ui-space-3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--ui-space-2); }
.row { display: flex; align-items: center; gap: var(--ui-space-2); }
.row-end { justify-content: flex-end; }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }

/* ── typography ─────────────────────────────────────────────────── */

h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted, .text-muted { color: var(--ui-muted); }
.dim, .text-dim { color: var(--ui-text-dim); }
.text-danger  { color: var(--ui-danger); }
.text-success { color: var(--ui-success); }
.text-warning { color: var(--ui-warning); }
.text-accent  { color: var(--ui-accent); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-mono { font-family: var(--ui-font-mono); }
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── buttons ────────────────────────────────────────────────────── */

.btn-primary, .btn-ghost, .btn-danger, .btn-link, .btn-icon {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--ui-radius);
  padding: 0.55rem 0.95rem;
  font-size: 0.9rem;
  line-height: 1.2;
  border: 1px solid transparent;
  transition: filter var(--ui-trans-fast),
              background-color var(--ui-trans-fast),
              border-color var(--ui-trans-fast),
              color var(--ui-trans-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
}

.btn-primary {
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  border-color: var(--ui-accent);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { filter: brightness(0.94); }

.btn-ghost {
  background: var(--ui-panel);
  color: var(--ui-text);
  border-color: var(--ui-border);
}
.btn-ghost:hover { background: var(--ui-panel-hover); border-color: var(--ui-muted); }

.btn-danger {
  background: var(--ui-danger);
  color: #fff;
  border-color: var(--ui-danger);
}
.btn-danger:hover { filter: brightness(1.08); }

.btn-link {
  background: none;
  color: var(--ui-accent);
  padding: 0;
  border: 0;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

.btn-icon {
  background: none;
  color: var(--ui-text-dim);
  border: 0;
  padding: 0.35rem;
  border-radius: var(--ui-radius-sm);
  font-size: 1.1rem;
}
.btn-icon:hover { background: var(--ui-panel-hover); color: var(--ui-text); }

.btn-primary:disabled,
.btn-ghost:disabled,
.btn-danger:disabled,
.btn-link:disabled,
.btn-icon:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

/* size modifiers */
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.2rem; font-size: 1rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* focus rings — accessible without being garish */
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.btn-danger:focus-visible,
.btn-link:focus-visible,
.btn-icon:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}

/* ── forms ──────────────────────────────────────────────────────── */

.form-input,
input[type="text"].form-input,
input[type="number"].form-input,
input[type="email"].form-input,
input[type="password"].form-input,
input[type="date"].form-input,
input[type="search"].form-input,
input[type="url"].form-input,
input[type="tel"].form-input,
select.form-input,
textarea.form-input {
  width: 100%;
  background: var(--ui-panel-2);
  color: var(--ui-text);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--ui-trans-fast);
}
.form-input:focus,
input.form-input:focus,
select.form-input:focus,
textarea.form-input:focus {
  border-color: var(--ui-accent);
}
.form-input::placeholder { color: var(--ui-muted); }
textarea.form-input { resize: vertical; min-height: 4.5rem; }

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--ui-accent);
  cursor: pointer;
}

/* ── base styling for UNCLASSED native controls ──────────────────────
   Plain <input>/<select>/<textarea> (no .form-input class) pick up the
   theme automatically, so apps don't have to class every field. Wrapped
   in :where() so specificity stays 0 — .form-input, .search-bar input,
   and any app-local rule still override these. Checkboxes/radios are
   excluded here (they keep their native box + accent-color above);
   buttons, range, color, and file inputs are left to their own styling. */
:where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]),
  select,
  textarea
) {
  background-color: var(--ui-panel-2);
  color: var(--ui-text);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: 0.5rem 0.65rem;
  font: inherit;
  box-sizing: border-box;
  outline: none;
  transition: border-color var(--ui-trans-fast),
              box-shadow var(--ui-trans-fast);
}
:where(input, select, textarea):focus-visible {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-accent) 30%, transparent);
}
:where(input, textarea)::placeholder { color: var(--ui-muted); opacity: 1; }
:where(input, select, textarea):disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
:where(textarea) { resize: vertical; min-height: 4rem; }

/* Custom caret for selects (native appearance varies per-OS/theme and the
   default arrow is often invisible on dark panels). The popup option list
   itself stays OS-rendered — we theme the option rows where the browser
   allows (Firefox, some Chromium builds). */
:where(select) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.9rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%238a8f9c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 0.7rem;
}
:where(select) option {
  background-color: var(--ui-panel);
  color: var(--ui-text);
}

/* label/control rows in a settings-style form */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-3);
}
.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--ui-muted);
}
.settings-form label > span {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  color: var(--ui-muted);
}
.settings-row {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  padding: 0.4rem 0;
}
.settings-row .settings-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--ui-text);
}
.settings-desc {
  font-size: 0.78rem;
  color: var(--ui-text-dim);
  margin-top: 0.2rem;
  line-height: 1.4;
}
.settings-sep {
  border: 0;
  border-top: 1px solid var(--ui-border);
  margin: var(--ui-space-4) 0;
}

/* ── search bar (mtrack model) ──────────────────────────────────── */

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.search-input-wrap {
  flex: 1;
  position: relative;
}
.search-bar input {
  width: 100%;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  color: var(--ui-text);
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--ui-trans-fast);
}
.search-bar input:focus { border-color: var(--ui-accent); }
.search-bar input::placeholder { color: var(--ui-muted); }
/* Hide the browser's native clear button on type=search — we render our own
   .search-clear ×, and showing both is a duplicate. */
.search-bar input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-bar input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: var(--ui-text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: var(--ui-radius-sm);
}
.search-clear:hover { color: var(--ui-text); background: var(--ui-panel-hover); }

.search-bar button.search-submit {
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  border: 0;
  border-radius: var(--ui-radius);
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--ui-trans-fast);
}
.search-bar button.search-submit:hover { filter: brightness(1.08); }
.search-bar button.search-submit:disabled { opacity: 0.5; cursor: default; filter: none; }

/* horizontal-scroll cards for search results (mtrack/btrack/gtrack) */
.search-results {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--ui-border) transparent;
}
.search-card {
  flex: 0 0 140px;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--ui-trans-fast);
  display: flex;
  flex-direction: column;
}
.search-card:hover { border-color: var(--ui-accent); }
.search-card-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--ui-panel-2);
  object-fit: cover;
  display: block;
}
.search-card-info {
  padding: 0.4rem 0.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}
.search-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-card-meta {
  font-size: 0.75rem;
  color: var(--ui-muted);
}

/* ── tabs (rtrack model) ────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--ui-border);
}
.tab {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ui-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 0.5rem;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--ui-trans-fast), border-color var(--ui-trans-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.tab:hover { color: var(--ui-text); }
.tab.is-active {
  color: var(--ui-accent);
  border-bottom-color: var(--ui-accent);
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.1rem;
  padding: 0 0.4rem;
  background: var(--ui-panel-hover);
  color: var(--ui-text);
  border-radius: var(--ui-radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
}
.tab.is-active .tab-count {
  background: var(--ui-accent);
  color: var(--ui-on-accent);
}

/* pill / segmented subtabs (gtrack model) */
.subtabs {
  display: inline-flex;
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-pill);
  padding: 0.15rem;
}
.subtab {
  background: none;
  border: 0;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ui-muted);
  padding: 0.35rem 0.85rem;
  border-radius: var(--ui-radius-pill);
  cursor: pointer;
  transition: background var(--ui-trans-fast), color var(--ui-trans-fast);
}
.subtab:hover { color: var(--ui-text); }
.subtab.is-active {
  background: var(--ui-accent);
  color: var(--ui-on-accent);
}

/* ── badges & chips (btrack model) ──────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--ui-radius-pill);
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-accent  { background: var(--ui-accent);  color: var(--ui-on-accent); border-color: transparent; }
.badge-success { background: var(--ui-success); color: #0c1410; border-color: transparent; }
.badge-warning { background: var(--ui-warning); color: #1a1410; border-color: transparent; }
.badge-danger  { background: var(--ui-danger);  color: #fff;    border-color: transparent; }
.badge-info    { background: var(--ui-info);    color: #0c111c; border-color: transparent; }
.badge-muted   { color: var(--ui-muted); }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  border-radius: var(--ui-radius-pill);
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
}
.tag-chip .tag-x {
  background: none;
  border: 0;
  color: var(--ui-text-dim);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.tag-chip .tag-x:hover { color: var(--ui-danger); }

/* ── list rows (btrack model) ───────────────────────────────────── */

.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.list-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  transition: border-color var(--ui-trans-fast);
}
.list-row:hover { border-color: var(--ui-accent); }
.list-row.is-clickable { cursor: pointer; }
.row-cover {
  flex: 0 0 auto;
  aspect-ratio: 2 / 3;
  width: 40px;
  background: var(--ui-panel-2);
  border-radius: var(--ui-radius-sm);
  overflow: hidden;
  object-fit: cover;
}
.row-cover.row-cover-wide { aspect-ratio: 16 / 9; width: 80px; }
.row-info { flex: 1; min-width: 0; }
.row-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  font-size: 0.78rem;
  color: var(--ui-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-actions {
  display: flex;
  gap: 0.3rem;
  margin-left: auto;
  flex: 0 0 auto;
}

/* ── modals (btrack model) ──────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: var(--ui-z-modal);
}
/* Lock background scroll whenever any declarative modal-overlay is
   visible. UI.modal() factory mounts/unmounts so the selector also
   matches dynamically-created modals naturally. */
body:has(.modal-overlay:not([hidden])) { overflow: hidden; }
.modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--ui-shadow-lg);
}
.modal-sm      { max-width: 360px; }
.modal-md      { max-width: 560px; }
.modal-lg      { max-width: 720px; }
.modal-xl      { max-width: 960px; }
.modal-confirm { max-width: 360px; text-align: center; padding: 1.5rem; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: none;
  border: 0;
  color: var(--ui-text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--ui-radius-sm);
}
.modal-close:hover { background: var(--ui-panel-hover); color: var(--ui-text); }
.modal-body { margin-bottom: 0.75rem; }
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}
.confirm-msg {
  margin: 0 0 1rem;
  color: var(--ui-text);
  font-size: 0.95rem;
  line-height: 1.4;
}

/* ── toasts ─────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  border-radius: var(--ui-radius);
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  z-index: var(--ui-z-toast);
  opacity: 0;
  transition: transform var(--ui-trans), opacity var(--ui-trans);
  box-shadow: var(--ui-shadow);
  max-width: min(420px, calc(100vw - 2rem));
}
.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast[data-kind="ok"]   { border-color: var(--ui-success); color: var(--ui-success); }
.toast[data-kind="warn"] { border-color: var(--ui-warning); color: var(--ui-warning); }
.toast[data-kind="err"]  { border-color: var(--ui-danger);  color: var(--ui-danger); }

/* ── header (btrack model) ──────────────────────────────────────── */

.app-header {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--ui-border);
  max-width: 760px;
  margin: 0 auto;
  background: var(--ui-bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.brand h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ui-accent);
}
.tagline { color: var(--ui-muted); font-size: 0.85rem; }
.header-actions { display: flex; gap: 0.4rem; align-items: center; }

/* ── user menu (universal) ──────────────────────────────────────── */

.user-menu { position: relative; flex-shrink: 0; }
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  border: 0;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  transition: filter var(--ui-trans-fast);
}
.user-avatar:hover { filter: brightness(1.1); }
.user-avatar:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 14rem;
  max-width: 18rem;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-lg);
  z-index: var(--ui-z-dropdown);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.user-dropdown-email {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--ui-text);
  border-radius: var(--ui-radius-sm);
}
.user-dropdown-email:hover {
  background: var(--ui-panel-2);
  text-decoration: none;
}
.user-dropdown-email .email-line { font-size: 0.85rem; font-weight: 600; }
.user-dropdown-email .role-line  { font-size: 0.72rem; color: var(--ui-muted); }

.user-dropdown-item {
  background: none;
  border: 0;
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  color: var(--ui-text);
  font: inherit;
  font-size: 0.88rem;
  border-radius: var(--ui-radius-sm);
  cursor: pointer;
  text-decoration: none;
}
.user-dropdown-item:hover {
  background: var(--ui-panel-2);
  color: var(--ui-accent);
  text-decoration: none;
}
.user-dropdown-sep {
  border: 0;
  border-top: 1px solid var(--ui-border);
  margin: 0.25rem 0;
}

/* ── auth overlay (universal cloned pattern) ────────────────────── */

.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--ui-bg);
  z-index: var(--ui-z-auth);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-panel {
  width: 100%;
  max-width: 380px;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--ui-shadow);
}
.auth-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  text-align: center;
  color: var(--ui-text);
}
.auth-panel p {
  margin: 0 0 1rem;
  color: var(--ui-muted);
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.45;
}
.auth-cta {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  width: 100%;
  margin-bottom: 0.5rem;
}
.auth-error {
  background: color-mix(in srgb, var(--ui-danger) 15%, transparent);
  color: var(--ui-danger);
  border: 1px solid color-mix(in srgb, var(--ui-danger) 40%, transparent);
  border-radius: var(--ui-radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* ── dropdown (generic) ─────────────────────────────────────────── */

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 12rem;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: 0.3rem;
  z-index: var(--ui-z-dropdown);
  box-shadow: var(--ui-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.dropdown-menu.is-right { left: auto; right: 0; }
.dropdown-menu button,
.dropdown-menu a {
  background: none;
  border: 0;
  color: var(--ui-text);
  text-align: left;
  padding: 0.45rem 0.65rem;
  border-radius: var(--ui-radius-sm);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  display: block;
  width: 100%;
}
.dropdown-menu button:hover,
.dropdown-menu a:hover {
  background: var(--ui-panel-hover);
  color: var(--ui-accent);
}
/* leading icon (item.icon) — fixed width so labels align */
.dropdown-menu .dropdown-icon {
  display: inline-block;
  width: 1.25em;
  margin-right: 0.55em;
  text-align: center;
  opacity: 0.9;
}
/* destructive item (item.kind: 'danger') */
.dropdown-menu .dropdown-danger { color: var(--ui-danger); }
.dropdown-menu .dropdown-danger:hover { background: var(--ui-panel-hover); color: var(--ui-danger); }
/* separator between item groups (pass an <hr class="dropdown-sep"> as an item) */
.dropdown-menu .dropdown-sep {
  border: 0;
  border-top: 1px solid var(--ui-border);
  margin: 4px 2px;
}

/* ── empty state ────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  color: var(--ui-muted);
  padding: 2.5rem 1rem;
  font-size: 0.95rem;
}
.empty-state p { margin: 0 0 0.5rem; }

/* ── loading (mtrack model) ─────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--ui-z-modal);
  background: color-mix(in srgb, var(--ui-bg) 92%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--ui-muted);
  font-size: 0.9rem;
}
.loading-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--ui-border);
  border-top-color: var(--ui-accent);
  border-radius: 50%;
  animation: ui-spin 0.85s linear infinite;
}
@keyframes ui-spin {
  to { transform: rotate(360deg); }
}

/* ── theme docs link (sits next to in-app theme pickers) ─────────── */
/* Always wraps to its own line (display: block + width: max-content)
   so it never gets squished into a horizontal flex row alongside the
   select. UI.theme.attachDocsLink also tries to place it as a sibling
   of the select's containing row, but if it ends up inside a flex
   container these rules still keep it readable. */
.theme-docs-link {
  display: block;
  width: max-content;
  max-width: 100%;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ui-accent);
  text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--ui-accent) 50%, transparent);
  padding-bottom: 1px;
}
.theme-docs-link:hover {
  filter: brightness(1.1);
  border-bottom-style: solid;
  text-decoration: none;
}

/* ── utility ────────────────────────────────────────────────────── */

.flex-1 { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 0.75rem; } .mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; } .mb-4 { margin-bottom: 1rem; }
