/* ───────────────────────────────────────────────────────
   kariochi · components.css
   Every class uses only var(--token) from tokens.css.
   Imported SECOND, after tokens.css.
   ─────────────────────────────────────────────────────── */

/* ─── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--text-base);
  background: var(--bg-app);
  color: var(--fg-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button, input, select, textarea {
  font: inherit; color: inherit;
}
button { cursor: pointer; border: 0; background: transparent; }
a { color: inherit; text-decoration: none; }

/* ─── Page shell ────────────────────────────────────────────────────────── */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-8) var(--space-24);
}
.page-head { margin-bottom: var(--space-12); }
.page-head .eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-tertiary);
  margin-bottom: var(--space-3);
}
.page-head h1 {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.025em;
  line-height: 1.05;
}
.page-head p {
  margin-top: var(--space-3);
  color: var(--fg-secondary);
  max-width: 560px;
}

/* nav strip */
.toc {
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: var(--space-1); align-items: center;
  padding: var(--space-3) var(--space-2);
  margin: 0 calc(var(--space-8) * -1) var(--space-10);
  background: rgba(251,250,248,0.88);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}
.toc-item {
  display: inline-flex; align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--fg-secondary); white-space: nowrap;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.toc-item:hover { color: var(--fg-primary); background: var(--bg-hover); }
.toc-brand {
  display: inline-flex; align-items: baseline; gap: 0;
  font-family: "Bricolage Grotesque", Inter, sans-serif;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.04em;
  text-transform: lowercase;
  color: var(--fg-primary);
  padding-right: var(--space-4);
  margin-right: var(--space-2);
  border-right: 1px solid var(--border-subtle);
  font-optical-sizing: auto;
}
.toc-brand em {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  color: var(--brand-primary);
  letter-spacing: -0.02em;
}
.toc-brand .logo-dot { display: none; }
  display: grid; place-items: center;
  color: var(--fg-on-brand); font-size: 11px;
}

/* sections */
.section { margin-bottom: var(--space-16); scroll-margin-top: 80px; }
.section-head {
  margin-bottom: var(--space-6);
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: var(--space-3);
  align-items: baseline;
}
.section-head h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
}
.section-head .label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-tertiary);
  font-variant-numeric: tabular-nums;
}
.section-head .count-pill {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--fg-tertiary);
  background: var(--bg-subtle);
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums;
}
.section-head p {
  grid-column: 1 / -1;
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  max-width: 640px;
  margin-top: 6px;
  line-height: 1.55;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-6);
}

.row {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-3);
}
.row + .row { margin-top: var(--space-4); }
.row-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-tertiary);
  min-width: 96px;
}
.col { display: flex; flex-direction: column; gap: var(--space-3); }
.stack > * + * { margin-top: var(--space-3); }

/* ════════════════════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  height: 36px; padding: 0 var(--space-4);
  border-radius: var(--radius-md); /* 8px — action buttons are NOT pills */
  font-size: var(--text-base); font-weight: var(--weight-semibold);
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast),
              box-shadow var(--duration-fast), opacity var(--duration-fast),
              transform var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(26,158,110,0.20);
}
.btn:active:not(:disabled) { transform: scale(0.97); }

/* sizes */
.btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-sm); gap: 6px; }
.btn-md { height: 36px; padding: 0 var(--space-4); font-size: var(--text-base); }
.btn-lg { height: 44px; padding: 0 var(--space-5); font-size: var(--text-md); }

/* variants */
.btn-primary {
  background: var(--brand-primary); color: var(--fg-on-brand);
}
.btn-primary:hover:not(:disabled)  { background: var(--brand-primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--brand-primary-active); }

.btn-secondary {
  background: transparent; color: var(--fg-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-secondary:active:not(:disabled) { background: var(--bg-active); }

.btn-ghost {
  background: transparent; color: var(--fg-secondary);
}
.btn-ghost:hover:not(:disabled) { color: var(--fg-primary); background: var(--bg-hover); }
.btn-ghost:active:not(:disabled) { background: var(--bg-active); }

.btn-danger {
  background: transparent; color: var(--status-error-fg);
  border: 1px solid transparent;
}
.btn-danger:hover:not(:disabled)  { background: var(--status-error-bg); }
.btn-danger:active:not(:disabled) { background: rgba(199,52,52,0.18); }

.btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* spinner for loading */
.btn-spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}
.btn-sm .btn-spinner { width: 11px; height: 11px; border-width: 1.5px; }
.btn-lg .btn-spinner { width: 16px; height: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading { pointer-events: none; }

/* svg icon sizing within buttons */
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-sm svg { width: 12px; height: 12px; }
.btn-lg svg { width: 16px; height: 16px; }

/* ════════════════════════════════════════════════════════════════════════
   PILLS / BADGES
   ════════════════════════════════════════════════════════════════════════ */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px var(--space-3); height: 22px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }

.pill-draft     { background: var(--bg-subtle);          color: var(--fg-secondary); }
.pill-scheduled { background: var(--status-info-bg);     color: var(--status-info-fg); }
.pill-published { background: var(--status-success-bg);  color: var(--status-success-fg); }

.badge-count {
  display: inline-flex; align-items: center;
  height: 18px; padding: 0 7px;
  background: var(--bg-subtle); color: var(--fg-secondary);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}
.badge-count.is-brand { background: var(--bg-brand-soft); color: var(--fg-brand); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 var(--space-1) 0 var(--space-3);
  background: var(--bg-subtle);
  color: var(--fg-primary);
  border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
}
.tag-close {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--fg-tertiary);
  transition: background var(--duration-fast), color var(--duration-fast);
}
.tag-close:hover { background: var(--bg-active); color: var(--fg-primary); }
.tag-close svg { width: 9px; height: 9px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 var(--space-3);
  background: var(--bg-surface);
  color: var(--fg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast),
              border-color var(--duration-fast);
}
.chip:hover { background: var(--bg-hover); color: var(--fg-primary); }
.chip.is-on {
  background: var(--bg-brand-soft);
  color: var(--fg-brand);
  border-color: var(--border-brand);
}
.chip .count {
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xs); color: var(--fg-tertiary);
  font-weight: var(--weight-semibold);
}
.chip.is-on .count { color: var(--fg-brand); opacity: 0.7; }

/* ════════════════════════════════════════════════════════════════════════
   FILTERS
   ════════════════════════════════════════════════════════════════════════ */

.filter-bar {
  display: flex; align-items: center; gap: var(--space-2);
  flex-wrap: wrap;
}

.search-input {
  position: relative;
  display: inline-flex; align-items: center;
  width: 280px;
}
.search-input input {
  width: 100%; height: 36px;
  padding: 0 var(--space-3) 0 var(--space-8);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--fg-primary);
  outline: 0;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.search-input input::placeholder { color: var(--fg-tertiary); }
.search-input input:hover { border-color: var(--border-strong); }
.search-input input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,158,110,0.20);
}
.search-input svg {
  position: absolute; left: var(--space-3);
  width: 15px; height: 15px;
  color: var(--fg-tertiary);
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ════════════════════════════════════════════════════════════════════════ */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 240px; flex: 1; }
.field-label {
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
  color: var(--fg-primary); letter-spacing: -0.005em;
}
.field-help {
  font-size: var(--text-xs); color: var(--fg-tertiary);
}
.field.has-error .field-help { color: var(--status-error-fg); }

.input, .textarea, .select {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--fg-primary);
  outline: 0;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast),
              background var(--duration-fast);
}
.input { height: 36px; padding: 0 var(--space-3); }
.textarea { padding: var(--space-3); min-height: 96px; resize: vertical; line-height: 1.5; }
.select  { height: 36px; padding: 0 var(--space-8) 0 var(--space-3); appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='rgba(15,20,17,0.46)' d='M5 7L1.5 3h7z'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}
.input::placeholder, .textarea::placeholder { color: var(--fg-tertiary); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,158,110,0.20);
}
.input:disabled, .textarea:disabled, .select:disabled {
  opacity: 0.4; cursor: not-allowed; background: var(--bg-subtle);
}
.field.has-error .input,
.field.has-error .textarea,
.field.has-error .select {
  border-color: var(--status-error-fg);
}
.field.has-error .input:focus,
.field.has-error .textarea:focus {
  box-shadow: 0 0 0 3px rgba(199,52,52,0.18);
}

/* checkbox */
.checkbox {
  display: inline-flex; align-items: center; gap: var(--space-2);
  cursor: pointer; user-select: none;
  font-size: var(--text-base); color: var(--fg-primary);
}
.checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox .box {
  width: 18px; height: 18px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  transition: background var(--duration-fast), border-color var(--duration-fast),
              box-shadow var(--duration-fast);
}
.checkbox .box svg { width: 11px; height: 11px; color: var(--fg-on-brand); opacity: 0; transition: opacity var(--duration-fast); }
.checkbox:hover .box { border-color: var(--border-strong); }
.checkbox input:checked + .box { background: var(--brand-primary); border-color: var(--brand-primary); }
.checkbox input:checked + .box svg { opacity: 1; }
.checkbox input:focus-visible + .box { box-shadow: 0 0 0 3px rgba(26,158,110,0.20); }
.checkbox input:disabled + .box { opacity: 0.4; }

/* toggle switch */
.toggle {
  display: inline-flex; align-items: center; gap: var(--space-3);
  cursor: pointer; user-select: none; font-size: var(--text-base);
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: relative;
  width: 34px; height: 20px;
  border-radius: var(--radius-full);
  background: var(--border-default);
  transition: background var(--duration-base) var(--ease-out);
}
.toggle .track::after {
  content: ""; position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-base) var(--ease-out);
}
.toggle input:checked + .track { background: var(--brand-primary); }
.toggle input:checked + .track::after { transform: translateX(14px); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(26,158,110,0.20); }

/* ════════════════════════════════════════════════════════════════════════
   LISTS
   ════════════════════════════════════════════════════════════════════════ */

.track-list {
  display: flex; flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  background: var(--bg-surface);
}
.track-row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast);
}
.track-row:last-child { border-bottom: 0; }
.track-row:hover { background: var(--bg-hover); }
.track-row .info { min-width: 0; }
.track-row .title {
  font-size: var(--text-base); font-weight: var(--weight-semibold);
  color: var(--fg-primary); letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-row .sub {
  font-size: var(--text-sm); color: var(--fg-tertiary); margin-top: 1px;
}

.menu {
  display: flex; flex-direction: column;
  padding: var(--space-2);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-width: 220px;
  box-shadow: var(--shadow-md);
}
.menu-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-base); font-weight: var(--weight-medium);
  color: var(--fg-primary);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item svg { width: 15px; height: 15px; color: var(--fg-tertiary); flex-shrink: 0; }
.menu-item.is-danger { color: var(--status-error-fg); }
.menu-item.is-danger svg { color: var(--status-error-fg); }
.menu-divider { height: 1px; background: var(--border-subtle); margin: var(--space-1) 0; }

.list-bullet {
  list-style: none; padding: 0;
  display: flex; flex-direction: column; gap: var(--space-2);
}
.list-bullet li {
  display: flex; gap: var(--space-3); align-items: flex-start;
  font-size: var(--text-base); color: var(--fg-primary);
}
.list-bullet li::before {
  content: ""; flex-shrink: 0;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bg-brand);
  margin-top: 9px;
}
.list-ordered {
  counter-reset: ol-counter; list-style: none; padding: 0;
  display: flex; flex-direction: column; gap: var(--space-2);
}
.list-ordered li {
  display: flex; gap: var(--space-3); align-items: flex-start;
  font-size: var(--text-base); color: var(--fg-primary);
  counter-increment: ol-counter;
}
.list-ordered li::before {
  content: counter(ol-counter);
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: var(--bg-brand-soft); color: var(--fg-brand);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}

/* ════════════════════════════════════════════════════════════════════════
   AVATARS
   ════════════════════════════════════════════════════════════════════════ */

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; position: relative;
  background: var(--bg-subtle); color: var(--fg-tertiary);
  overflow: hidden;
}
.avatar svg { width: 50%; height: 50%; opacity: 0.55; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.av-square { border-radius: var(--radius-md); }
.av-round  { border-radius: 50%; }

.av-sm { width: 28px; height: 28px; font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.av-md { width: 44px; height: 44px; font-size: var(--text-base); font-weight: var(--weight-semibold); }
.av-lg { width: 72px; height: 72px; font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.av-md.av-square { border-radius: var(--radius-md); }
.av-lg.av-square { border-radius: var(--radius-lg); }

/* cover gradients */
.cover-1 { background: linear-gradient(135deg, #2db485 0%, #14704e 100%); color: rgba(255,255,255,0.85); }
.cover-2 { background: linear-gradient(135deg, #d08d1e 0%, #7c4a08 100%); color: rgba(255,255,255,0.85); }
.cover-3 { background: linear-gradient(135deg, #2e6dbf 0%, #163d72 100%); color: rgba(255,255,255,0.85); }

.av-badge {
  position: absolute;
  bottom: 0; right: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 2px solid var(--bg-surface);
}
.av-badge.is-warning { background: var(--status-warning-fg); }
.av-badge.is-offline { background: var(--fg-tertiary); }
.av-lg .av-badge { width: 16px; height: 16px; border-width: 3px; }

/* ═════════════════════════════════════════════════════════════════
   POLISH — reduced-motion, focus-visible, in-progress states
   ═════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: var(--duration-fast) !important;
  }
}

/* focus-visible on toggle-style interactive elements */
.chip:focus-visible,
.tag-close:focus-visible,
.toggle:focus-visible,
.menu-item:focus-visible,
.segmented button:focus-visible,
.tabs .tab:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(26,158,110,0.20);
}

/* In-progress pill states with spinner-as-dot */
.pill-rendering, .pill-uploading {
  background: var(--status-warning-bg);
  color: var(--status-warning-fg);
}
.pill-rendering .dot, .pill-uploading .dot {
  background: transparent;
  width: 8px; height: 8px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  opacity: 1;
}
.pill-failed {
  background: var(--status-error-bg);
  color: var(--status-error-fg);
}

/* Track-row cover doubles as a play button on hover */
.track-row .avatar { cursor: pointer; }
.track-row .avatar .play {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(0,0,0,0); color: #fff;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out),
              background var(--duration-base) var(--ease-out);
}
.track-row .avatar .play svg { width: 16px; height: 16px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35)); }
.track-row:hover .avatar .play,
.track-row .avatar:focus-visible .play { opacity: 1; background: rgba(0,0,0,0.42); }
.track-row .avatar.is-playing .play { opacity: 1; background: rgba(26,158,110,0.65); }

/* ═════════════════════════════════════════════════════════════════
   SLIDER — single + range
   ═════════════════════════════════════════════════════════════════ */

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
  outline: 0;
}
.slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border-default);
  border-radius: var(--radius-full);
}
.slider::-moz-range-track {
  height: 4px;
  background: var(--border-default);
  border-radius: var(--radius-full);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
  margin-top: -6px;
  cursor: grab;
  transition: transform var(--duration-fast);
}
.slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.slider:hover::-webkit-slider-thumb { transform: scale(1.1); }
.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: var(--shadow-sm), 0 0 0 4px rgba(26,158,110,0.20);
}
.slider:disabled { opacity: 0.4; cursor: not-allowed; }

/* Slider with filled-track look — for scrubbers */
.slider-track {
  position: relative; width: 100%; height: 28px;
  display: flex; align-items: center;
}
.slider-track .track-bg {
  position: absolute; left: 0; right: 0;
  height: 4px; background: var(--border-default); border-radius: var(--radius-full);
}
.slider-track .track-fill {
  position: absolute; left: 0;
  height: 4px; background: var(--brand-primary); border-radius: var(--radius-full);
}
.slider-track .track-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--brand-primary);
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

/* Range slider — two thumbs (waveform clip start/end) */
.range-slider {
  position: relative;
  width: 100%;
  height: 40px;
  display: flex; align-items: center;
  margin-top: var(--space-3);
}
.range-slider .rs-track {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  height: 4px; background: var(--border-default); border-radius: var(--radius-full);
}
.range-slider .rs-fill {
  position: absolute; top: 50%; transform: translateY(-50%);
  height: 4px; background: var(--brand-primary); border-radius: var(--radius-full);
}
.range-slider .rs-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--brand-primary);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.range-slider .rs-thumb::after {
  content: attr(data-value);
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: var(--weight-semibold);
}

/* Composite — waveform with active clip region (illustrative) */
.wf-slider {
  position: relative;
  height: 56px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  display: flex; align-items: center;
  padding: 0 var(--space-2);
  gap: 2px;
  overflow: hidden;
}
.wf-slider .wf-bar {
  flex: 1; min-width: 1.5px;
  background: var(--border-strong); border-radius: 1px;
}
.wf-slider .wf-bar.in-clip { background: var(--brand-primary); }
.wf-slider .clip-region {
  position: absolute; top: 4px; bottom: 4px;
  background: var(--bg-brand-soft);
  border: 1.5px solid var(--brand-primary);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* ═════════════════════════════════════════════════════════════════
   MODAL / DIALOG — info, destructive confirm
   ═════════════════════════════════════════════════════════════════ */

.modal {
  display: inline-flex; flex-direction: column;
  width: 440px; max-width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-3);
  gap: var(--space-4);
}
.modal-head .title-block {
  display: flex; align-items: center; gap: var(--space-3);
  min-width: 0; flex: 1;
}
.modal-head .icon-box {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg-brand-soft); color: var(--fg-brand);
}
.modal-head .icon-box svg { width: 18px; height: 18px; }
.modal-head h3 {
  font-size: var(--text-lg); font-weight: var(--weight-semibold);
  letter-spacing: -0.015em; color: var(--fg-primary);
}
.modal-head .close-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: var(--radius-sm); color: var(--fg-tertiary);
  transition: color var(--duration-fast), background var(--duration-fast);
  flex-shrink: 0;
}
.modal-head .close-btn:hover { color: var(--fg-primary); background: var(--bg-hover); }
.modal-head .close-btn svg { width: 12px; height: 12px; }
.modal-body {
  padding: 0 var(--space-5) var(--space-5);
  font-size: var(--text-base); color: var(--fg-secondary); line-height: 1.55;
}
.modal-body strong { color: var(--fg-primary); font-weight: var(--weight-semibold); }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-app);
  border-top: 1px solid var(--border-subtle);
}
.modal-danger .icon-box { background: var(--status-error-bg); color: var(--status-error-fg); }
.modal-danger .btn-confirm {
  background: var(--status-error-fg); color: var(--fg-on-brand);
}
.modal-danger .btn-confirm:hover { background: #962a2a; }

/* ═════════════════════════════════════════════════════════════════
   TOOLTIP
   ═════════════════════════════════════════════════════════════════ */

.tooltip-wrap {
  position: relative;
  display: inline-flex;
}
.tooltip-wrap .tooltip {
  position: absolute;
  z-index: 100;
  background: #0f1411;
  color: rgba(255,255,255,0.95);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: 5px var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: var(--shadow-md);
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.tooltip-wrap .tooltip.bottom {
  top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) translateY(-4px);
}
.tooltip-wrap .tooltip.top {
  bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) translateY(4px);
}
.tooltip-wrap:hover .tooltip,
.tooltip-wrap:focus-within .tooltip,
.tooltip-wrap .tooltip.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.tooltip-wrap .tooltip kbd {
  background: rgba(255,255,255,0.14);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--text-xs);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
}

/* ═════════════════════════════════════════════════════════════════
   TABS / SEGMENTED
   ═════════════════════════════════════════════════════════════════ */

.tabs {
  display: flex; align-items: center; gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
}
.tabs .tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: var(--space-3) var(--space-3) calc(var(--space-3) + 1px);
  font-size: var(--text-base); font-weight: var(--weight-medium);
  color: var(--fg-secondary);
  background: transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.tabs .tab:hover { color: var(--fg-primary); background: var(--bg-hover); }
.tabs .tab.is-active {
  color: var(--fg-primary);
  font-weight: var(--weight-semibold);
}
.tabs .tab.is-active::after {
  content: ""; position: absolute;
  left: var(--space-3); right: var(--space-3); bottom: 0;
  height: 2px; background: var(--brand-primary);
  border-radius: 2px 2px 0 0;
}
.tabs .tab .count {
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  color: var(--fg-tertiary);
  background: var(--bg-subtle);
  padding: 1px 6px; border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums;
}
.tabs .tab.is-active .count { background: var(--bg-brand-soft); color: var(--fg-brand); }

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  gap: 2px;
}
.segmented button {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--fg-secondary);
  background: transparent;
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast),
              box-shadow var(--duration-fast);
}
.segmented button:hover { color: var(--fg-primary); }
.segmented button.is-on {
  background: var(--bg-surface);
  color: var(--fg-primary);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}
.segmented button svg { width: 13px; height: 13px; }

/* ═════════════════════════════════════════════════════════════════
   CARD VARIANTS
   ═════════════════════════════════════════════════════════════════ */

.card-interactive {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.card-interactive:hover { background: var(--bg-hover); border-color: var(--border-default); }
.card-interactive:focus-visible {
  outline: 0;
  border-color: var(--border-brand);
  box-shadow: 0 0 0 3px rgba(26,158,110,0.20);
}
.card-interactive .title {
  font-size: var(--text-base); font-weight: var(--weight-semibold);
  color: var(--fg-primary); letter-spacing: -0.005em;
}
.card-interactive .sub {
  font-size: var(--text-sm); color: var(--fg-secondary); margin-top: 4px;
  line-height: 1.5;
}
.card-interactive .head {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.card-interactive .icon-box {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: var(--bg-brand-soft); color: var(--fg-brand);
  display: grid; place-items: center;
}
.card-interactive .icon-box svg { width: 16px; height: 16px; }

/* ═════════════════════════════════════════════════════════════════
   ANIMATIONS — entrance / exit
   ═════════════════════════════════════════════════════════════════ */

@keyframes slide-up-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Entrance animations — keyframes are exported for opt-in use.
   We DON'T auto-apply them to .modal / .toast / .menu in the gallery,
   because gallery items are static reference displays. In production,
   add the animation when the component is actually mounted on demand. */

/* ═════════════════════════════════════════════════════════════════
   HERO — page-level identity block
   ═════════════════════════════════════════════════════════════════ */

.hero {
  position: relative;
  padding: var(--space-12) 0 var(--space-16);
  margin-bottom: var(--space-12);
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
}
.hero .eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--fg-brand);
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 5px var(--space-3);
  background: var(--bg-brand-soft);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
}
.hero .eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-primary);
}
.hero h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: var(--weight-bold);
  letter-spacing: -0.04em;
  line-height: 1.0;
  color: var(--fg-primary);
}
.hero h1 em {
  font-style: italic;
  font-weight: var(--weight-semibold);
  color: var(--fg-brand);
}
.hero .lede {
  margin-top: var(--space-5);
  font-size: var(--text-lg);
  color: var(--fg-secondary);
  max-width: 580px;
  line-height: 1.5;
}
.hero .meta-row {
  display: flex; align-items: center; gap: var(--space-6);
  margin-top: var(--space-8);
  font-size: var(--text-sm); color: var(--fg-tertiary);
}
.hero .meta-row .item {
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.hero .meta-row .item b {
  color: var(--fg-primary); font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}
.hero .meta-row .dot {
  width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong);
  opacity: 0.7;
}
.hero-shortcut {
  margin-top: var(--space-6);
  display: inline-flex; align-items: center;
  font-size: var(--text-sm); color: var(--fg-secondary);
}

/* Section anchor offset for sticky TOC */
.section { scroll-margin-top: 80px; }

/* ═════════════════════════════════════════════════════════════════
   AVATAR GROUP — stacked
   ═════════════════════════════════════════════════════════════════ */

.avatar-group {
  display: inline-flex;
  align-items: center;
}
.avatar-group .avatar {
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
}
.avatar-group > * + * { margin-left: -8px; }
.avatar-group.dense > * + * { margin-left: -12px; }
.avatar-group .more {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.avatar-group.av-sm-group .more { width: 28px; height: 28px; }
.avatar-group.av-md-group .more { width: 44px; height: 44px; font-size: var(--text-sm); }

/* ═════════════════════════════════════════════════════════════════
   KBD — keyboard shortcut chips
   ═════════════════════════════════════════════════════════════════ */

kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--fg-secondary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kbd-row {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.kbd-row .plus { color: var(--fg-tertiary); }

/* ═════════════════════════════════════════════════════════════════
   DROPDOWN TRIGGER + ANCHORED MENU
   ═════════════════════════════════════════════════════════════════ */

.dropdown {
  position: relative;
  display: inline-flex;
}
.dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 220px;
  display: none;
}
.dropdown.is-open .dropdown-menu { display: block; animation: fade-in var(--duration-fast) var(--ease-out); }
.dropdown.is-open .caret { transform: rotate(180deg); transition: transform var(--duration-fast); }
.dropdown.align-right .dropdown-menu { left: auto; right: 0; }
.dropdown .caret {
  width: 12px; height: 12px;
  opacity: 0.6;
}
.dropdown .menu { box-shadow: var(--shadow-lg); }


