/* ==========================================================================
   ANI Team — base, layout & component system
   ========================================================================== */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  letter-spacing: var(--tracking-tight);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

:root[data-theme-changing] * { transition: none !important; }

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: var(--tracking-tighter); line-height: 1.2; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

::selection { background: var(--fg); color: var(--bg); }

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: fixed; top: -100px; left: 12px; z-index: 200;
  background: var(--solid); color: var(--solid-fg);
  padding: 10px 16px; border-radius: var(--r-md); font-weight: 500;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; }

/* Scrollbars ------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Typography helpers
   ========================================================================== */
.display {
  font-size: clamp(34px, 6.2vw, var(--text-6xl));
  line-height: 1.04;
  letter-spacing: var(--tracking-display);
  font-weight: 600;
}
.h1 { font-size: clamp(26px, 3.6vw, var(--text-4xl)); letter-spacing: var(--tracking-display); }
.h2 { font-size: var(--text-2xl); letter-spacing: var(--tracking-tighter); }
.h3 { font-size: var(--text-lg); }
.h4 { font-size: var(--text-md); }

.lead { font-size: clamp(15px, 1.7vw, var(--text-lg)); color: var(--fg-muted); line-height: 1.6; }
.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }
.small { font-size: var(--text-sm); }
.xsmall { font-size: var(--text-xs); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.eyebrow {
  font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--fg-subtle);
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.gap-7 { gap: var(--sp-7); } .gap-8 { gap: var(--sp-8); }
.grow { flex: 1 1 auto; min-width: 0; }
.center { align-items: center; } .between { justify-content: space-between; }
.hidden { display: none !important; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app-root { min-height: 100dvh; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

/* Sidebar ---------------------------------------------------------------- */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-3) var(--sp-3);
  gap: var(--sp-2);
  z-index: var(--z-sticky);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 14px;
  min-width: 0;
}
.brand-mark {
  width: 28px; height: 28px; flex: none;
  border-radius: 8px;
  background: var(--solid);
  color: var(--solid-fg);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: -0.04em;
  box-shadow: var(--shadow-xs);
}
.brand-name {
  font-size: var(--text-sm); font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase;
}
.brand-sub { font-size: var(--text-2xs); color: var(--fg-subtle); letter-spacing: 0.04em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
  font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-subtle);
  padding: var(--sp-4) 10px var(--sp-2);
}

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--fg-muted);
  font-size: var(--text-base); font-weight: 450;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-in-out),
              color var(--dur-fast) var(--ease-in-out),
              border-color var(--dur-fast) var(--ease-in-out);
  user-select: none;
}
.nav-item svg { flex: none; width: 16px; height: 16px; opacity: 0.85; }
.nav-item:hover { background: var(--surface-hover); color: var(--fg); }
.nav-item[aria-current="page"] {
  background: var(--surface);
  border-color: var(--border);
  color: var(--fg);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}
.nav-item[aria-current="page"] svg { opacity: 1; }
.nav-item .nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--solid); color: var(--solid-fg);
  font-size: var(--text-2xs); font-weight: 600;
  display: grid; place-items: center;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2); }

.eco-switch {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.eco-title { font-size: var(--text-2xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-subtle); font-weight: 600; }
.eco-row { display: flex; align-items: center; gap: 3px; }
.eco-pill {
  flex: 1; text-align: center;
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 5px 2px; border-radius: var(--r-sm);
  color: var(--fg-subtle); border: 1px solid transparent;
  cursor: pointer; background: none;
  transition: all var(--dur-fast) var(--ease-in-out);
  white-space: nowrap;
}
.eco-pill:hover { background: var(--surface-hover); color: var(--fg-secondary); }
.eco-pill.is-current { background: var(--solid); color: var(--solid-fg); cursor: default; }
.eco-arrow { color: var(--fg-subtle); font-size: 9px; }

/* Main column ------------------------------------------------------------ */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.topbar-title { font-size: var(--text-md); font-weight: 600; letter-spacing: var(--tracking-tighter); }
.topbar-crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb-sep { color: var(--border-strong); }
.crumb-link { color: var(--fg-muted); font-size: var(--text-base); cursor: pointer; }
.crumb-link:hover { color: var(--fg); }

.topbar-search { position: relative; flex: 0 1 300px; margin-left: auto; }
.topbar-search > svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--fg-subtle); pointer-events: none;
}
.topbar-search input { padding-left: 32px; height: 34px; }
.kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 10px; color: var(--fg-subtle);
  border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 1px 5px; background: var(--bg-inset); pointer-events: none;
}

.icon-btn {
  position: relative;
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent; color: var(--fg-muted);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-in-out);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--fg); border-color: var(--border); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg);
}

.avatar-btn {
  border-radius: var(--r-full); padding: 2px; border: 1px solid transparent;
  background: transparent; cursor: pointer; display: grid; place-items: center;
  transition: all var(--dur-fast) var(--ease-in-out);
}
.avatar-btn:hover { border-color: var(--border-hover); }

.view {
  flex: 1 1 auto;
  padding: var(--sp-8) var(--sp-6) var(--sp-11);
  animation: view-in var(--dur-slow) var(--ease) both;
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.container { width: 100%; max-width: var(--content-max); margin: 0 auto; }
.container-wide { width: 100%; max-width: 1420px; margin: 0 auto; }
.view.flush { padding: 0; animation: none; }

/* Page header ------------------------------------------------------------ */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-5); flex-wrap: wrap;
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-7);
}
.page-head .titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  --btn-h: 36px;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--btn-h); padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--fg);
  font-size: var(--text-base); font-weight: 500; letter-spacing: var(--tracking-tight);
  white-space: nowrap; cursor: pointer;
  transition: background var(--dur-fast) var(--ease-in-out),
              border-color var(--dur-fast) var(--ease-in-out),
              color var(--dur-fast) var(--ease-in-out),
              opacity var(--dur-fast) var(--ease-in-out),
              transform var(--dur-fast) var(--ease-in-out),
              box-shadow var(--dur-fast) var(--ease-in-out);
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:hover { background: var(--surface-hover); border-color: var(--border-hover); }
.btn:active { transform: scale(0.985); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: var(--solid); color: var(--solid-fg); border-color: var(--solid);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--solid-hover); border-color: var(--solid-hover); }

.btn-accent { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--fg); border-color: transparent; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger-soft { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.btn-danger-soft:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { --btn-h: 30px; padding: 0 10px; font-size: var(--text-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { --btn-h: 44px; padding: 0 22px; font-size: var(--text-md); border-radius: var(--r-lg); }
.btn-xl { --btn-h: 52px; padding: 0 28px; font-size: var(--text-lg); border-radius: var(--r-lg); font-weight: 600; }
.btn-block { width: 100%; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--solid-fg); border-top-color: transparent;
  animation: spin 0.6s linear infinite;
}
.btn:not(.btn-primary):not(.btn-accent):not(.btn-danger).is-loading::after {
  border-color: var(--fg); border-top-color: transparent;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-group { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ==========================================================================
   Badges, pills, chips
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--fg-secondary);
  font-size: var(--text-xs); font-weight: 500; letter-spacing: 0;
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge-solid { background: var(--solid); color: var(--solid-fg); border-color: var(--solid); }
.badge-outline { background: transparent; }
.badge-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.badge-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.badge-accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.badge-violet { background: var(--violet-soft); border-color: var(--violet-border); color: var(--violet); }
.badge-lg { height: 26px; padding: 0 11px; font-size: var(--text-sm); }

.dot-mark { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dot-pulse { position: relative; }
.dot-pulse::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 1px solid currentColor; opacity: 0.5;
  animation: pulse-ring 2s var(--ease-in-out) infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.6; }
  70% { transform: scale(1.6); opacity: 0; }
  100% { opacity: 0; }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-muted);
  font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-in-out);
}
.chip:hover { border-color: var(--border-hover); color: var(--fg); background: var(--surface-hover); }
.chip[aria-pressed="true"] { background: var(--solid); border-color: var(--solid); color: var(--solid-fg); }
.chip svg { width: 13px; height: 13px; }
.chip-count { font-variant-numeric: tabular-nums; opacity: 0.6; }

/* ==========================================================================
   Cards & surfaces
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease-in-out),
              box-shadow var(--dur) var(--ease-in-out),
              transform var(--dur) var(--ease-in-out),
              background var(--dur) var(--ease-in-out);
}
.card-pad { padding: var(--sp-5); }
.card-hover { cursor: pointer; }
.card-hover:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-hover:active { transform: translateY(-1px); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.panel-body { padding: var(--sp-5); }
.panel-foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  flex-wrap: wrap;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

.list-row {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast) var(--ease-in-out);
}
.list-row:last-child { border-bottom: 0; }
.list-row.clickable { cursor: pointer; }
.list-row.clickable:hover { background: var(--surface-hover); }

.grid { display: grid; gap: var(--sp-5); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.grid-people { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Avatars ---------------------------------------------------------------- */
.avatar {
  flex: none;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  font-weight: 600; letter-spacing: -0.02em;
  color: #fff;
  overflow: hidden;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.avatar-xs { width: 20px; height: 20px; font-size: 9px; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-xl { width: 72px; height: 72px; font-size: 24px; border-radius: var(--r-2xl); }
.avatar-2xl { width: 104px; height: 104px; font-size: 34px; border-radius: 26px; }

.avatar-stack { display: flex; align-items: center; }
.avatar-stack .avatar { margin-left: -7px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-stack .more {
  margin-left: -7px; box-shadow: 0 0 0 2px var(--surface);
  background: var(--bg-inset); color: var(--fg-muted);
  border: 1px solid var(--border);
}

.presence { position: relative; }
.presence::after {
  content: ""; position: absolute; right: -1px; bottom: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--fg-subtle);
}
.presence[data-status="online"]::after { background: #3ba55d; }
.presence[data-status="idle"]::after { background: #faa81a; }
.presence[data-status="dnd"]::after { background: #ed4245; }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: var(--text-sm); font-weight: 500; color: var(--fg); }
.hint { font-size: var(--text-xs); color: var(--fg-muted); line-height: 1.5; }
.error-text { font-size: var(--text-xs); color: var(--danger); }

.input, .textarea, .select {
  width: 100%;
  height: 38px; padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: var(--text-base);
  transition: border-color var(--dur-fast) var(--ease-in-out),
              box-shadow var(--dur-fast) var(--ease-in-out),
              background var(--dur-fast) var(--ease-in-out);
  appearance: none;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.select {
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input::placeholder, .textarea::placeholder { color: var(--fg-subtle); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-hover); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--border-focus) 12%, transparent);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled, .textarea:disabled, .select:disabled { opacity: 0.55; cursor: not-allowed; background: var(--bg-inset); }

.input-lg { height: 44px; font-size: var(--text-md); border-radius: var(--r-lg); }
.char-count { font-size: var(--text-2xs); color: var(--fg-subtle); font-variant-numeric: tabular-nums; }

/* Selectable option rows (checkbox / radio) ------------------------------ */
.option {
  position: relative;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-in-out);
}
.option:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.option[data-selected="true"] {
  border-color: var(--fg);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--fg);
}
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option-mark {
  flex: none; width: 17px; height: 17px; margin-top: 1px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  display: grid; place-items: center;
  background: var(--surface);
  transition: all var(--dur-fast) var(--ease-in-out);
}
.option-mark.radio { border-radius: 50%; }
.option-mark svg { width: 11px; height: 11px; opacity: 0; color: var(--solid-fg); transition: opacity var(--dur-fast); }
.option[data-selected="true"] .option-mark { background: var(--solid); border-color: var(--solid); }
.option[data-selected="true"] .option-mark svg { opacity: 1; }
.option[data-selected="true"] .option-mark.radio { background: var(--surface); border-color: var(--fg); }
.option-mark.radio::after {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--fg); transform: scale(0);
  transition: transform var(--dur) var(--ease);
}
.option[data-selected="true"] .option-mark.radio::after { transform: scale(1); }
.option-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.option-title { font-size: var(--text-base); font-weight: 500; }
.option-desc { font-size: var(--text-xs); color: var(--fg-muted); line-height: 1.5; }
.option-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); }

/* Switch ----------------------------------------------------------------- */
.switch {
  position: relative; flex: none;
  width: 38px; height: 22px; border-radius: var(--r-full);
  background: var(--border-strong); border: none; cursor: pointer; padding: 0;
  transition: background var(--dur) var(--ease-in-out);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-xs);
  transition: transform var(--dur) var(--ease);
}
.switch[aria-checked="true"] { background: var(--solid); }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--solid-fg); }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5);
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: 0; }

/* Segmented control ------------------------------------------------------ */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  max-width: 100%;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: none; }
.segmented button {
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 13px; border-radius: var(--r-sm);
  font-size: var(--text-sm); font-weight: 500; color: var(--fg-muted);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--dur-fast) var(--ease-in-out);
  white-space: nowrap;
}
.segmented button:hover { color: var(--fg); }
.segmented button[aria-selected="true"] {
  background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow-xs);
}
.segmented button svg { width: 14px; height: 14px; }

/* Tabs ------------------------------------------------------------------- */
.tabs {
  display: flex; align-items: center; gap: var(--sp-6);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  padding: 0 2px 13px;
  background: none; border: 0; cursor: pointer;
  font-size: var(--text-base); font-weight: 500; letter-spacing: 0.01em;
  color: var(--fg-muted);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-in-out);
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); }
.tab::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 1.5px; background: var(--fg);
  transform: scaleX(0); transform-origin: center;
  transition: transform var(--dur) var(--ease);
}
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab svg { width: 15px; height: 15px; }
.tab-caps { text-transform: uppercase; font-size: var(--text-sm); letter-spacing: 0.06em; font-weight: 600; }

/* ==========================================================================
   Overlays: modal, drawer, dropdown
   ========================================================================== */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--scrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
  animation: fade-in var(--dur) var(--ease-in-out) both;
  overflow-y: auto;
}
.scrim.is-closing { animation: fade-out var(--dur-fast) var(--ease-in-out) both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

.modal {
  width: 100%; max-width: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 2 * var(--sp-5));
  animation: modal-in var(--dur-slow) var(--ease) both;
  margin: auto;
}
.scrim.is-closing .modal { animation: modal-out var(--dur-fast) var(--ease-in-out) both; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.975); }
  to { opacity: 1; transform: none; }
}
@keyframes modal-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(6px) scale(0.99); }
}
.modal-md { max-width: 620px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 920px; }

.modal-head {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-6) var(--sp-6) var(--sp-4);
}
.modal-head .titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.modal-title { font-size: var(--text-xl); letter-spacing: var(--tracking-tighter); font-weight: 600; }
.modal-desc { font-size: var(--text-base); color: var(--fg-muted); line-height: 1.55; }
.modal-body { padding: 0 var(--sp-6) var(--sp-5); overflow-y: auto; flex: 1 1 auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--r-2xl) var(--r-2xl);
  flex-wrap: wrap;
}
.modal-foot .spread { margin-right: auto; }

/* Dropdown --------------------------------------------------------------- */
.dropdown {
  position: fixed; z-index: var(--z-modal);
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  animation: dd-in var(--dur) var(--ease) both;
  max-height: min(70vh, 560px); overflow-y: auto;
}
@keyframes dd-in {
  from { opacity: 0; transform: translateY(-5px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  font-size: var(--text-base); color: var(--fg-secondary);
  cursor: pointer; width: 100%; border: 0; background: none; text-align: left;
  transition: background var(--dur-fast) var(--ease-in-out), color var(--dur-fast);
}
.dd-item:hover { background: var(--surface-hover); color: var(--fg); }
.dd-item svg { width: 15px; height: 15px; opacity: 0.8; flex: none; }
.dd-item.danger { color: var(--danger); }
.dd-item.danger:hover { background: var(--danger-soft); }
.dd-sep { height: 1px; background: var(--border); margin: 5px 0; }
.dd-label {
  padding: 8px 10px 5px; font-size: var(--text-2xs); font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-subtle);
}
.dd-header { padding: 11px 11px 9px; border-bottom: 1px solid var(--border); margin: -5px -5px 5px; }

/* Notifications panel ---------------------------------------------------- */
.notif-panel { width: min(400px, calc(100vw - 32px)); padding: 0; }
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 15px; border-bottom: 1px solid var(--border);
}
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 11px; padding: 13px 15px 13px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; position: relative;
  transition: background var(--dur-fast) var(--ease-in-out);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-hover); }
.notif-item[data-unread="true"]::before {
  content: ""; position: absolute; left: 8px; top: 21px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.notif-icon {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--bg-inset); border: 1px solid var(--border); color: var(--fg-muted);
}
.notif-icon svg { width: 14px; height: 14px; }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-text { font-size: var(--text-sm); line-height: 1.5; }
.notif-time { font-size: var(--text-2xs); color: var(--fg-subtle); }

/* Toasts ----------------------------------------------------------------- */
.toast-root {
  position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none; max-width: min(400px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 15px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-slow) var(--ease) both;
}
.toast.is-closing { animation: toast-out var(--dur) var(--ease-in-out) both; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(20px) scale(0.97); }
}
.toast-icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.toast-icon svg { width: 18px; height: 18px; }
.toast[data-kind="success"] .toast-icon { color: var(--success); }
.toast[data-kind="error"] .toast-icon { color: var(--danger); }
.toast[data-kind="info"] .toast-icon { color: var(--accent); }
.toast-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.toast-title { font-size: var(--text-sm); font-weight: 500; }
.toast-desc { font-size: var(--text-xs); color: var(--fg-muted); line-height: 1.5; }
.toast-close { border: 0; background: none; color: var(--fg-subtle); cursor: pointer; padding: 0; margin-top: 1px; }
.toast-close:hover { color: var(--fg); }
.toast-close svg { width: 14px; height: 14px; }

/* ==========================================================================
   Skeletons, empty & loading states
   ========================================================================== */
.sk {
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 37%, var(--skeleton-a) 63%);
  background-size: 400% 100%;
  animation: sk 1.35s var(--ease-in-out) infinite;
  border-radius: var(--r-sm);
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-text { height: 11px; }
.sk-title { height: 18px; border-radius: var(--r-xs); }
.sk-cover { aspect-ratio: 16 / 9; border-radius: 0; }
.sk-circle { border-radius: 50%; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: var(--sp-11) var(--sp-6);
  gap: var(--sp-3);
}
.empty-icon {
  width: 52px; height: 52px; border-radius: var(--r-xl);
  display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--bg-sunken);
  color: var(--fg-subtle); margin-bottom: var(--sp-2);
}
.empty-icon svg { width: 22px; height: 22px; }
.empty-title { font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-tighter); }
.empty-desc { font-size: var(--text-base); color: var(--fg-muted); max-width: 420px; line-height: 1.6; }
.empty-actions { margin-top: var(--sp-3); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--fg);
  animation: spin 0.65s linear infinite; flex: none;
}
.loading-block {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: var(--sp-10); color: var(--fg-muted); font-size: var(--text-sm);
}

/* Callout ---------------------------------------------------------------- */
.callout {
  display: flex; gap: 11px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-sunken);
  font-size: var(--text-sm); line-height: 1.6; color: var(--fg-secondary);
}
.callout > svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--fg-muted); }
.callout strong { color: var(--fg); font-weight: 600; }
.callout-info { background: var(--accent-soft); border-color: var(--accent-border); }
.callout-info > svg { color: var(--accent); }
.callout-warn { background: var(--warning-soft); border-color: var(--warning-border); }
.callout-warn > svg { color: var(--warning); }
.callout-danger { background: var(--danger-soft); border-color: var(--danger-border); }
.callout-danger > svg { color: var(--danger); }
.callout-success { background: var(--success-soft); border-color: var(--success-border); }
.callout-success > svg { color: var(--success); }

/* Progress --------------------------------------------------------------- */
.progress { height: 5px; border-radius: var(--r-full); background: var(--bg-inset); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--fg); border-radius: inherit; transition: width var(--dur-slow) var(--ease); }

.steps { display: flex; align-items: center; gap: 0; }
.step-dot { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--fg-subtle); white-space: nowrap; }
.step-dot i {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1px solid var(--border-strong); display: grid; place-items: center;
  font-size: 10px; font-weight: 600; font-style: normal;
  transition: all var(--dur) var(--ease-in-out);
}
.step-dot[data-state="active"] { color: var(--fg); font-weight: 500; }
.step-dot[data-state="active"] i { background: var(--solid); border-color: var(--solid); color: var(--solid-fg); }
.step-dot[data-state="done"] { color: var(--fg-muted); }
.step-dot[data-state="done"] i { background: var(--surface); border-color: var(--fg); color: var(--fg); }
.step-line { flex: 1; height: 1px; background: var(--border); margin: 0 10px; min-width: 12px; }

/* Table ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  text-align: left; font-weight: 500; color: var(--fg-muted);
  font-size: var(--text-xs); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 11px var(--sp-5); border-bottom: 1px solid var(--border);
  background: var(--bg-sunken); white-space: nowrap;
}
.table td { padding: 13px var(--sp-5); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-fast) var(--ease-in-out); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-hover); }

/* Mobile navigation ------------------------------------------------------ */
.mobile-topbar { display: none; }
.mobile-tabbar { display: none; }
.drawer-scrim {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  background: var(--scrim); backdrop-filter: blur(2px);
  animation: fade-in var(--dur) var(--ease-in-out) both;
}
.drawer-scrim.is-closing { animation: fade-out var(--dur-fast) both; }
.drawer {
  position: absolute; inset: 0 auto 0 0;
  width: min(300px, 86vw);
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-2);
  animation: drawer-in var(--dur-slow) var(--ease) both;
  overflow-y: auto;
}
.drawer-scrim.is-closing .drawer { animation: drawer-out var(--dur) var(--ease-in-out) both; }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes drawer-out { from { transform: none; } to { transform: translateX(-100%); } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1180px) {
  :root { --sidebar-w: 220px; }
  .view { padding: var(--sp-7) var(--sp-5) var(--sp-11); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { display: none; }

  .mobile-topbar {
    display: flex; align-items: center; gap: var(--sp-2);
    position: sticky; top: 0; z-index: var(--z-sticky);
    height: 56px; padding: 0 var(--sp-4);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
  }

  .mobile-tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky);
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mtab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; border: 0; background: none; cursor: pointer;
    color: var(--fg-subtle); font-size: 10px; font-weight: 500;
    border-radius: var(--r-md);
    transition: color var(--dur-fast) var(--ease-in-out);
  }
  .mtab svg { width: 19px; height: 19px; }
  .mtab[aria-current="page"] { color: var(--fg); }
  .mtab:active { background: var(--surface-hover); }

  .view { padding: var(--sp-6) var(--sp-4) calc(var(--sp-12) + 20px); }
  .page-head { margin-bottom: var(--sp-5); padding-bottom: var(--sp-4); align-items: flex-start; }
  .modal-head { padding: var(--sp-5) var(--sp-5) var(--sp-3); }
  .modal-body { padding: 0 var(--sp-5) var(--sp-4); }
  .modal-foot { padding: var(--sp-4) var(--sp-5); }
  .modal-foot .btn { flex: 1 1 auto; }
  .scrim { padding: var(--sp-3); align-items: flex-end; }
  .modal { max-height: calc(100dvh - 2 * var(--sp-3)); }
  .toast-root { left: var(--sp-4); right: var(--sp-4); bottom: calc(72px + env(safe-area-inset-bottom)); max-width: none; }
  .grid-cards { grid-template-columns: minmax(0, 1fr); }
  .grid { gap: var(--sp-4); }
}

@media (max-width: 560px) {
  .grid-people { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .btn-xl { --btn-h: 48px; font-size: var(--text-md); }
  .display { font-size: clamp(30px, 8.5vw, 42px); }
}

@media (hover: none) {
  .card-hover:hover { transform: none; box-shadow: none; border-color: var(--border); }
  .card-hover:active { border-color: var(--border-hover); background: var(--surface-hover); }
}

/* --------------------------------------------------------------------------
   Picker — the replacement for <select>
   --------------------------------------------------------------------------
   A native select lets you style the closed box and then draws its open list
   with the operating system's own corners, colours and font. On a page made
   of hairlines and soft radii that is always the one element that looks
   borrowed from somewhere else. Here both halves are ours, so they match
   each other and everything around them.
   -------------------------------------------------------------------------- */
.picker { position: relative; width: 100%; }

.picker-trigger {
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-height: 38px; padding: 6px 10px 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: var(--text-base);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-in-out),
              box-shadow var(--dur-fast) var(--ease-in-out);
}
.picker-trigger:hover { border-color: var(--fg-muted); }
.picker-trigger:focus-visible,
.picker-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--fg);
  box-shadow: 0 0 0 3px var(--ring);
}
.picker-trigger svg { flex: none; color: var(--fg-muted); margin-left: auto; }
.picker-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }

.picker-label { min-width: 0; flex: 1; }
.picker-placeholder { color: var(--fg-subtle); }

.picker-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.picker-chip {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--text-xs);
}

/* -- The open list ---------------------------------------------------------- */

.picker-panel {
  position: fixed; z-index: var(--z-modal);
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: dd-in var(--dur) var(--ease) both;
}

.picker-search {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.picker-search svg { flex: none; color: var(--fg-subtle); }
.picker-search input {
  flex: 1; min-width: 0;
  border: 0; background: none; outline: none;
  color: var(--fg); font-size: var(--text-sm); font-family: inherit;
}

.picker-rows { overflow-y: auto; padding: 5px; flex: 1; min-height: 0; }

.picker-option {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 10px;
  background: none; border: 0; border-radius: var(--r-md);
  color: var(--fg); font-family: inherit; text-align: left;
  cursor: pointer;
}
.picker-option:hover,
.picker-option.is-active { background: var(--bg-subtle); }
.picker-option[aria-selected="true"] { background: var(--bg-subtle); font-weight: 500; }
.picker-option svg { flex: none; margin-left: auto; color: var(--fg); }
.picker-option-label { font-size: var(--text-sm); }
.picker-option-desc {
  font-size: var(--text-xs); color: var(--fg-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.picker-none { padding: 14px 12px; font-size: var(--text-sm); color: var(--fg-muted); margin: 0; }

.picker-note {
  padding: 9px 12px; margin: 0;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--fg-muted);
  flex: none;
}
