/* ==========================================================================
   MIRROR STUDIO — SLATE-POWERED UI COMPONENTS
   Built on public/slate/slate.css + tokens.css. Zero hardcoded surfaces or timings.
   ========================================================================== */

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

html, body {
  height: 100%;
  background: var(--surface-canvas);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-control);
  border-radius: var(--radius-pill);
}

/* ---------- 1. BUTTONS & INTERACTIVE CONTROLS ---------- */
.vl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  padding: 9px 17px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
  text-decoration: none;
  white-space: nowrap;
}

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

.vl-btn-primary {
  background: var(--accent-blue);
  color: var(--accent-on);
  --on: var(--accent);
}
.vl-btn-primary:hover:not(:disabled) {
  background: var(--accent-blue-hover);
}

.vl-btn-secondary {
  background: var(--surface-control);
  color: var(--ink-primary);
  border-color: transparent;
  --on: var(--surface-3);
}
.vl-btn-secondary:hover:not(:disabled) {
  background: var(--surface-control-hover);
}

.vl-btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
}
.vl-btn-ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--ink-primary);
}

.vl-btn-danger {
  background: transparent;
  color: var(--accent-red);
  border-color: color-mix(in oklab, var(--bad-fill) 40%, transparent);
}
.vl-btn-danger:hover:not(:disabled) {
  background: color-mix(in oklab, var(--bad-fill) 16%, transparent);
}

.vl-btn-sm {
  padding: 7px 14px;
  font-size: var(--text-xs);
}

.vl-btn-pill {
  border-radius: var(--radius-pill);
}

.vl-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.vl-icon-btn:hover {
  background: var(--hover);
  color: var(--ink-primary);
}
.vl-icon-btn.active {
  background: var(--surface-control-hover);
  color: var(--ink-primary);
}

.vl-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent-blue);
  color: var(--accent-on);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.vl-send-btn:hover {
  background: var(--accent-blue-hover);
  transform: scale(1.03);
}

/* ---------- 2. BADGES, CHIPS & MASCOT AVATARS ---------- */
.vl-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  color: var(--ink-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
  white-space: nowrap;
  --on: var(--surface-2);
}
.vl-chip:hover {
  background: var(--hover);
  color: var(--ink-primary);
  border-color: var(--border-control);
}
.vl-chip.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: var(--accent-on);
}

.vl-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-control);
  color: var(--ink-secondary);
}
.vl-badge-green {
  background: var(--good-fill);
  color: var(--on-fill);
}
.vl-badge-blue {
  background: var(--accent-blue);
  color: var(--accent-on);
}
.vl-badge-amber {
  background: var(--warn-fill);
  color: var(--on-warn);
}

.vl-mascot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
}
.vl-mascot::before,
.vl-mascot::after {
  content: '';
  width: 5px;
  height: 6px;
  border-radius: 50%;
  background: var(--on-fill);
  box-shadow: inset 1.5px 0 0 1px var(--scene);
}

.vl-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-control);
  color: var(--ink-primary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- 3. CARDS & MEDIA CONTAINERS ---------- */
.vl-card {
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--card-shadow);
  --on: var(--surface-2);
}

.vl-card-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--ink-primary);
  margin-bottom: var(--space-3);
}

.vl-card-caption {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  line-height: var(--leading-normal);
  margin-top: var(--space-3);
}

.vl-media-frame {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-canvas);
  border: 1px solid var(--border-hairline);
}
.vl-media-frame img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* ---------- 4. CHAT PRIMITIVES ---------- */
.vl-attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-control);
  color: var(--ink-primary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  max-width: 260px;
}
.vl-attachment-pill img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}
.vl-attachment-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vl-user-bubble {
  background: var(--accent-blue);
  color: var(--accent-on);
  font-size: var(--text-prose);
  font-weight: var(--weight-medium);
  padding: 11px 18px;
  border-radius: var(--radius-lg);
  line-height: 1.45;
  max-width: 85%;
}

.vl-assistant-prose {
  color: var(--ink-body);
  font-size: var(--text-prose);
  line-height: var(--leading-relaxed);
  max-width: 100%;
}
.vl-assistant-prose strong {
  color: var(--ink-primary);
  font-weight: var(--weight-semibold);
}

.vl-composer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 8px 10px 8px 16px;
  box-shadow: var(--card-shadow);
  transition: border-color var(--fast) var(--ease);
  --on: var(--surface-2);
}
.vl-composer:focus-within {
  border-color: var(--accent-blue);
}
.vl-composer textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.45;
  resize: none;
  outline: none;
  max-height: 120px;
  padding: 4px 0;
}
.vl-composer textarea::placeholder {
  color: var(--ink-muted);
}

/* ---------- 5. FORM CONTROLS & TOGGLES ---------- */
.vl-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.vl-field-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--ink-secondary);
}

.vl-input,
.vl-select,
.vl-textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink-primary);
  background: var(--surface-card);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--fast) var(--ease);
}
.vl-input:focus,
.vl-select:focus,
.vl-textarea:focus {
  border-color: var(--accent-blue);
}
.vl-input::placeholder,
.vl-textarea::placeholder {
  color: var(--ink-muted);
}

.vl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: var(--text-sm);
  color: var(--ink-body);
  cursor: pointer;
  user-select: none;
}
.vl-toggle input {
  display: none;
}
.vl-toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-control);
  position: relative;
  transition: background var(--fast) var(--ease);
}
.vl-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--on-fill);
  transition: transform var(--slow) var(--ease);
}
.vl-toggle input:checked + .vl-toggle-track {
  background: var(--switch-on);
}
.vl-toggle input:checked + .vl-toggle-track::after {
  transform: translateX(16px);
}

/* ---------- 6. NAVIGATION & SESSION ROWS ---------- */
.vl-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  text-decoration: none;
  text-align: left;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.vl-nav-item svg {
  flex-shrink: 0;
}
.vl-nav-item:hover {
  background: var(--hover);
  color: var(--ink-primary);
}
.vl-nav-item.active {
  background: var(--accent-blue);
  color: var(--accent-on);
}
.vl-nav-item.active .vl-nav-count {
  color: var(--accent-on);
  opacity: 0.85;
}
.vl-nav-item .vl-nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-muted);
}

.vl-session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--ink-body);
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--fast) var(--ease);
}
.vl-session-row:hover {
  background: var(--hover);
}
.vl-session-row.active {
  background: var(--surface-control);
  color: var(--ink-primary);
  font-weight: var(--weight-semibold);
}
.vl-session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vl-session-meta {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  flex-shrink: 0;
}
.vl-session-check {
  color: var(--accent-green);
  flex-shrink: 0;
}

/* ---------- 7. BEFORE/AFTER COMPARE SLIDER ---------- */
.vl-compare {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-md);
  overflow: hidden;
  user-select: none;
  cursor: ew-resize;
  background: var(--surface-canvas);
  border: 1px solid var(--border-hairline);
}
.vl-compare-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.vl-compare-before {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0);
  pointer-events: none;
}
.vl-compare-before img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vl-compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--on-fill);
  transform: translateX(-50%);
  pointer-events: none;
}
.vl-compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--pop-shadow);
}
.vl-compare-tag {
  position: absolute;
  top: 10px;
  font-size: 11px;
  font-weight: var(--weight-semibold);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--scene) 84%, transparent);
  color: var(--ink-primary);
  backdrop-filter: blur(8px);
}
.vl-compare-tag.left { left: 10px; }
.vl-compare-tag.right { right: 10px; }

/* ---------- 8. MODALS & TOASTS ---------- */
.vl-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-5);
}
.vl-modal {
  background: var(--surface-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  width: min(500px, 100%);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  --on: var(--surface);
}
.vl-modal-lg {
  width: min(640px, 100%);
}
.vl-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-hairline);
}
.vl-modal-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.vl-modal-body {
  padding: 18px 20px;
}
.vl-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 12px 20px;
  border-top: 1px solid var(--border-hairline);
}

.vl-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-control);
  color: var(--ink-primary);
  border: 1px solid var(--border-control);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-modal);
  z-index: 200;
}
