/* ============================================================
   Vensent Apple Design System — vnss-apple.css
   Inspired by macOS / Apple HIG
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── CSS Custom Properties: Light (default) ────────────────── */
:root {
  /* Apple System Colors */
  --apple-blue:   #007AFF;
  --apple-green:  #34C759;
  --apple-red:    #FF3B30;
  --apple-orange: #FF9500;
  --apple-yellow: #FFCC00;
  --apple-purple: #AF52DE;
  --apple-pink:   #FF2D55;
  --apple-teal:   #5AC8FA;
  --apple-indigo: #5856D6;
  --apple-mint:   #00C7BE;

  /* Gray scale (Apple HIG) */
  --gray-1: #8E8E93;
  --gray-2: #AEAEB2;
  --gray-3: #C7C7CC;
  --gray-4: #D1D1D6;
  --gray-5: #E5E5EA;
  --gray-6: #F2F2F7;

  /* Semantic Backgrounds */
  --bg-primary:    #FFFFFF;
  --bg-secondary:  #F2F2F7;
  --bg-tertiary:   #FFFFFF;
  --bg-grouped:    #F2F2F7;
  --bg-elevated:   #FFFFFF;
  --bg-hover:      rgba(0, 0, 0, 0.04);
  --bg-active:     rgba(0, 122, 255, 0.12);

  /* Material / Vibrancy */
  --material-thin:    rgba(255, 255, 255, 0.6);
  --material-regular: rgba(246, 246, 246, 0.85);
  --material-thick:   rgba(255, 255, 255, 0.92);
  --material-sidebar:  rgba(246, 246, 246, 0.82);
  --material-toolbar:  rgba(255, 255, 255, 0.72);
  --material-popover:  rgba(255, 255, 255, 0.95);

  /* Tahoe 26 Glass Materials */
  --material-glass:       rgba(255, 255, 255, 0.55);
  --material-glass-thick: rgba(255, 255, 255, 0.72);
  --material-glass-ultra: rgba(255, 255, 255, 0.82);

  /* Semantic Text */
  --text-primary:   #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary:  #98989D;
  --text-quaternary:#C7C7CC;
  --text-on-accent: #FFFFFF;

  /* Separators */
  --separator:        rgba(60, 60, 67, 0.12);
  --separator-opaque: #C6C6C8;
  --separator-heavy:  rgba(60, 60, 67, 0.29);

  /* Fills (for backgrounds on top of content) */
  --fill-primary:    rgba(120, 120, 128, 0.2);
  --fill-secondary:  rgba(120, 120, 128, 0.16);
  --fill-tertiary:   rgba(120, 120, 128, 0.12);
  --fill-quaternary: rgba(120, 120, 128, 0.08);

  /* Shadows (Apple layered) */
  --shadow-xs:      0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-lg:      0 8px 28px rgba(0,0,0,0.12), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-xl:      0 16px 48px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-popover: 0 25px 50px -12px rgba(0,0,0,0.15), 0 0 0 0.5px rgba(0,0,0,0.06);
  --shadow-float:   0 8px 40px rgba(0,0,0,0.12), 0 2px 12px rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.06);

  /* Border Radius (macOS Tahoe 26) */
  --radius-xs:    4px;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-xl:    22px;
  --radius-2xl:   28px;
  --radius-panel: 24px;
  --radius-pill:  100px;
  --radius-full:  100px;

  /* Spacing (4px grid) */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Motion (macOS Tahoe 26 spring) */
  --ease-default: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring:  cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring-heavy: cubic-bezier(0.22, 0.68, 0, 1.1);
  --ease-out:     cubic-bezier(0, 0, 0.58, 1);
  --ease-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out:  cubic-bezier(0.45, 0, 0.55, 1);
  --dur-fast:     0.15s;
  --dur-normal:   0.25s;
  --dur-slow:     0.4s;
  --dur-slower:   0.6s;
  --dur-spring:   0.45s;
  --dur-dropdown: 0.35s;

  /* Typography */
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Segoe UI", system-ui, Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", var(--font-system);

  /* Font-size tokens (Apple HIG scale) */
  --fs-large-title: 34px;
  --fs-title-1: 28px;
  --fs-title-2: 22px;
  --fs-title-3: 20px;
  --fs-headline: 17px;
  --fs-body: 17px;
  --fs-callout: 16px;
  --fs-subheadline: 15px;
  --fs-footnote: 13px;
  --fs-caption-1: 12px;
  --fs-caption-2: 11px;
  --font-mono: "SF Mono", ui-monospace, "Menlo", "Cascadia Code", monospace;

  /* Layout */
  --sidebar-width: 260px;
  --toolbar-height: 52px;
  --bottom-nav-height: 58px;
  --content-max-width: 900px;

  /* Tahoe 26 Layout — floating bar insets */
  --float-gap: 8px;
  --bar-inset: 12px;
  --toolbar-height-float: calc(var(--toolbar-height) + var(--bar-inset) * 2 + var(--float-gap));
  --glass-border: 0.5px solid rgba(255, 255, 255, 0.25);
  --glass-border-subtle: 0.5px solid rgba(255, 255, 255, 0.15);
}

/* ── Dark Mode ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-primary:    #1C1C1E;
  --bg-secondary:  #2C2C2E;
  --bg-tertiary:   #3A3A3C;
  --bg-grouped:    #000000;
  --bg-elevated:   #2C2C2E;
  --bg-hover:      rgba(255, 255, 255, 0.06);
  --bg-active:     rgba(0, 122, 255, 0.2);

  --material-thin:    rgba(30, 30, 30, 0.5);
  --material-regular: rgba(36, 36, 36, 0.82);
  --material-thick:   rgba(44, 44, 44, 0.9);
  --material-sidebar:  rgba(28, 28, 30, 0.82);
  --material-toolbar:  rgba(28, 28, 30, 0.72);
  --material-popover:  rgba(44, 44, 46, 0.95);

  /* Tahoe 26 Dark Glass */
  --material-glass:       rgba(44, 44, 46, 0.55);
  --material-glass-thick: rgba(44, 44, 46, 0.72);
  --material-glass-ultra: rgba(44, 44, 46, 0.82);

  --shadow-float: 0 8px 40px rgba(0,0,0,0.35), 0 2px 12px rgba(0,0,0,0.2), 0 0 0 0.5px rgba(255,255,255,0.06);
  --glass-border: 0.5px solid rgba(255, 255, 255, 0.1);
  --glass-border-subtle: 0.5px solid rgba(255, 255, 255, 0.06);

  --text-primary:   #F5F5F7;
  --text-secondary: #98989D;
  --text-tertiary:  #6E6E73;
  --text-quaternary:#48484A;
  --text-on-accent: #FFFFFF;

  --separator:        rgba(84, 84, 88, 0.36);
  --separator-opaque: #38383A;
  --separator-heavy:  rgba(84, 84, 88, 0.55);

  --fill-primary:    rgba(120, 120, 128, 0.36);
  --fill-secondary:  rgba(120, 120, 128, 0.32);
  --fill-tertiary:   rgba(120, 120, 128, 0.24);
  --fill-quaternary: rgba(120, 120, 128, 0.18);

  --shadow-xs:      0 0 0 0.5px rgba(0,0,0,0.2);
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.2), 0 0 0 0.5px rgba(0,0,0,0.15);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.3), 0 0 0 0.5px rgba(255,255,255,0.04);
  --shadow-lg:      0 8px 28px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(255,255,255,0.04);
  --shadow-xl:      0 16px 48px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.04);
  --shadow-popover: 0 25px 50px -12px rgba(0,0,0,0.5), 0 0 0 0.5px rgba(255,255,255,0.06);

  /* Adjusted gray scale for dark */
  --gray-1: #8E8E93;
  --gray-2: #636366;
  --gray-3: #48484A;
  --gray-4: #3A3A3C;
  --gray-5: #2C2C2E;
  --gray-6: #1C1C1E;
}

/* ── Base ──────────────────────────────────────────────────── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-system);
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  background: var(--bg-grouped);
  background-image: linear-gradient(135deg, rgba(102, 126, 234, 0.04), rgba(118, 75, 162, 0.06));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

[data-theme="dark"] body {
  background-image: linear-gradient(135deg, rgba(30, 30, 60, 0.15), rgba(50, 20, 70, 0.12));
}

/* ── Typography Scale (Apple HIG) ─────────────────────────── */
.text-large-title {
  font-size: 34px; line-height: 1.18;
  font-weight: 700; letter-spacing: -0.02em;
}
.text-title-1 {
  font-size: 28px; line-height: 1.21;
  font-weight: 700; letter-spacing: -0.02em;
}
.text-title-2 {
  font-size: 22px; line-height: 1.27;
  font-weight: 700; letter-spacing: -0.01em;
}
.text-title-3 {
  font-size: 20px; line-height: 1.25;
  font-weight: 600; letter-spacing: -0.01em;
}
.text-headline {
  font-size: 17px; line-height: 1.29;
  font-weight: 600; letter-spacing: -0.01em;
}
.text-body {
  font-size: 17px; line-height: 1.29;
  font-weight: 400; letter-spacing: -0.01em;
}
.text-callout {
  font-size: 16px; line-height: 1.31;
  font-weight: 400;
}
.text-subhead {
  font-size: 15px; line-height: 1.33;
  font-weight: 400;
}
.text-footnote {
  font-size: 13px; line-height: 1.38;
  font-weight: 400; letter-spacing: -0.005em;
}
.text-caption {
  font-size: 12px; line-height: 1.33;
  font-weight: 400;
}
.text-caption-2 {
  font-size: 11px; line-height: 1.27;
  font-weight: 400; letter-spacing: 0.01em;
}

.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-mono    { font-family: var(--font-mono); }

.text-secondary  { color: var(--text-secondary); }
.text-tertiary   { color: var(--text-tertiary); }
.text-accent     { color: var(--apple-blue); }
.text-success    { color: var(--apple-green); }
.text-warning    { color: var(--apple-orange); }
.text-danger     { color: var(--apple-red); }

/* ── Scrollbar (macOS thin style) ─────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.12) transparent;
}
[data-theme="dark"] * {
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* ── Focus Ring (Accessibility) ───────────────────────────── */
:focus-visible {
  outline: 3px solid var(--apple-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Selection ────────────────────────────────────────────── */
::selection {
  background: rgba(0, 122, 255, 0.2);
  color: inherit;
}

/* ── Keyframe Animations ──────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

@keyframes checkmark-draw {
  from { stroke-dashoffset: 24; }
  to   { stroke-dashoffset: 0; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Tahoe 26 Animations */
@keyframes tahoeScaleIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes tahoeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes tahoeDropIn {
  from { opacity: 0; transform: scale(0.92) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes tahoeDropOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to   { opacity: 0; transform: scale(0.95) translateY(-4px); }
}

@keyframes tahoeFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes tahoeSlideDown {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered animation utility */
.stagger-1 { animation-delay: 0.04s; }
.stagger-2 { animation-delay: 0.08s; }
.stagger-3 { animation-delay: 0.12s; }
.stagger-4 { animation-delay: 0.16s; }
.stagger-5 { animation-delay: 0.20s; }
.stagger-6 { animation-delay: 0.24s; }
.stagger-7 { animation-delay: 0.28s; }
.stagger-8 { animation-delay: 0.32s; }

.animate-fade-in    { animation: tahoeFadeIn var(--dur-normal) var(--ease-spring) both; }
.animate-slide-up   { animation: tahoeSlideUp var(--dur-spring) var(--ease-spring) both; }
.animate-slide-down { animation: tahoeSlideDown var(--dur-spring) var(--ease-spring) both; }
.animate-scale-in   { animation: tahoeScaleIn 0.3s var(--ease-spring) both; }
.animate-slide-left { animation: slideInLeft 0.3s var(--ease-spring) both; }
.animate-shake      { animation: shake 0.5s var(--ease-default); }

/* ── Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ── Apple Sidebar ────────────────────────────────────────── */
.apple-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--material-glass-thick);
  backdrop-filter: blur(50px) saturate(200%);
  -webkit-backdrop-filter: blur(50px) saturate(200%);
  border-right: var(--glass-border-subtle);
  box-shadow: inset 0 0 0 0.5px rgba(255,255,255,0.15);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  transition: transform 0.35s var(--ease-spring);
}

.sidebar-header {
  padding: var(--space-4) var(--space-4) var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--toolbar-height);
}

.sidebar-header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.sidebar-header-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.sidebar-section {
  padding: var(--space-1) var(--space-3);
}

.sidebar-section-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  cursor: default;
  user-select: none;
}

.sidebar-section-label .disclosure {
  font-size: 9px;
  transition: transform var(--dur-fast) var(--ease-default);
  color: var(--text-quaternary);
}

.sidebar-section-label .disclosure.open {
  transform: rotate(90deg);
}

.sidebar-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  min-height: 32px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition:
    background 0.2s var(--ease-spring),
    color var(--dur-fast) var(--ease-default),
    transform 0.15s var(--ease-spring);
  text-decoration: none;
}

.sidebar-row:hover {
  background: var(--bg-hover);
}

.sidebar-row:active {
  transform: scale(0.98);
}

.sidebar-row.active {
  background: var(--bg-active);
  color: var(--apple-blue);
  font-weight: 500;
}

.sidebar-row i, .sidebar-row .ph {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-row.active i,
.sidebar-row.active .ph {
  opacity: 1;
}

.sidebar-row .badge {
  margin-left: auto;
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-3) var(--space-4);
  border-top: 0.5px solid var(--separator);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fill-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Apple Toolbar (Tahoe 26 Floating) ────────────────────── */
.apple-toolbar {
  position: fixed;
  top: var(--bar-inset);
  right: var(--bar-inset);
  left: calc(var(--sidebar-width) + var(--bar-inset));
  height: var(--toolbar-height);
  background: var(--material-glass-thick);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border: var(--glass-border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  gap: var(--space-3);
  z-index: 100;
  will-change: transform;
}

.toolbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  flex: 1;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Segmented Control (macOS style) ──────────────────────── */
.segmented-control {
  display: inline-flex;
  background: var(--fill-quaternary);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 1px;
  position: relative;
}

.segment {
  position: relative;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  user-select: none;
  transition:
    color var(--dur-fast) var(--ease-default),
    background var(--dur-fast) var(--ease-default),
    box-shadow var(--dur-fast) var(--ease-default);
  white-space: nowrap;
  z-index: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  line-height: 1.3;
}

.segment:hover {
  color: var(--text-primary);
}

.segment.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Apple Card (Tahoe 26 Glass) ──────────────────────────── */
.apple-card {
  background: var(--material-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: var(--radius-lg);
  border: var(--glass-border-subtle);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  transition:
    box-shadow var(--dur-normal) var(--ease-default),
    transform var(--dur-normal) var(--ease-spring);
  will-change: transform;
}

.apple-card.hoverable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.apple-card.clickable {
  cursor: pointer;
}

.apple-card.clickable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.apple-card.clickable:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-sm);
}

/* ── Apple List Row ───────────────────────────────────────── */
.apple-list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-height: 44px;
  border-bottom: 0.5px solid var(--separator);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-default);
}

.apple-list-row:hover {
  background: var(--bg-hover);
}

.apple-list-row:last-child {
  border-bottom: none;
}

.apple-list-row .row-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.apple-list-row .row-content {
  flex: 1;
  min-width: 0;
}

.apple-list-row .row-title {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apple-list-row .row-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.apple-list-row .row-chevron {
  color: var(--text-quaternary);
  font-size: 12px;
  flex-shrink: 0;
}

.apple-list-row .row-detail {
  font-size: 15px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-apple {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 18px;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font-system);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition:
    background var(--dur-fast) var(--ease-default),
    transform 0.1s var(--ease-spring),
    box-shadow var(--dur-fast) var(--ease-default),
    opacity var(--dur-fast) var(--ease-default);
  text-decoration: none;
  line-height: 1.3;
}

.btn-apple:active {
  transform: scale(0.97);
}

.btn-apple:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn-apple i, .btn-apple .ph {
  font-size: 16px;
}

/* Primary */
.btn-apple-primary,
.btn-apple.primary {
  background: var(--apple-blue);
  color: var(--text-on-accent);
}

.btn-apple-primary:hover,
.btn-apple.primary:hover {
  background: #0066D6;
}

/* Secondary */
.btn-apple-secondary,
.btn-apple.secondary {
  background: var(--fill-quaternary);
  color: var(--text-primary);
}

.btn-apple-secondary:hover,
.btn-apple.secondary:hover {
  background: var(--fill-tertiary);
}

/* Ghost */
.btn-apple-ghost,
.btn-apple.ghost {
  background: transparent;
  color: var(--apple-blue);
  padding: 8px 12px;
}

.btn-apple-ghost:hover,
.btn-apple.ghost:hover {
  background: var(--bg-hover);
}

/* Danger */
.btn-apple-danger,
.btn-apple.danger {
  background: transparent;
  color: var(--apple-red);
  padding: 8px 12px;
}

.btn-apple-danger:hover,
.btn-apple.danger:hover {
  background: rgba(255, 59, 48, 0.08);
}

/* Danger Filled */
.btn-apple-danger-fill,
.btn-apple.danger-fill {
  background: var(--apple-red);
  color: var(--text-on-accent);
}

.btn-apple-danger-fill:hover,
.btn-apple.danger-fill:hover {
  background: #E6342B;
}

/* Success */
.btn-apple-success,
.btn-apple.success {
  background: var(--apple-green);
  color: var(--text-on-accent);
}

.btn-apple-success:hover,
.btn-apple.success:hover {
  background: #2DB84E;
}

/* Icon-only button */
.btn-apple-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-default),
    color var(--dur-fast) var(--ease-default),
    transform 0.1s var(--ease-spring);
  font-family: inherit;
}

.btn-apple-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-apple-icon:active {
  transform: scale(0.92);
}

.btn-apple-icon.active {
  color: var(--apple-blue);
  background: var(--bg-active);
}

/* Small button variant */
.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-sm i, .btn-sm .ph {
  font-size: 14px;
}

/* ── Badges ───────────────────────────────────────────────── */
.apple-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.badge-blue {
  background: rgba(0, 122, 255, 0.12);
  color: var(--apple-blue);
}
.badge-green {
  background: rgba(52, 199, 89, 0.12);
  color: var(--apple-green);
}
.badge-red {
  background: rgba(255, 59, 48, 0.12);
  color: var(--apple-red);
}
.badge-orange {
  background: rgba(255, 149, 0, 0.12);
  color: var(--apple-orange);
}
.badge-yellow {
  background: rgba(255, 204, 0, 0.14);
  color: #B89400;
}
[data-theme="dark"] .badge-yellow {
  color: var(--apple-yellow);
}
.badge-purple {
  background: rgba(175, 82, 222, 0.12);
  color: var(--apple-purple);
}
.badge-gray {
  background: var(--fill-quaternary);
  color: var(--text-secondary);
}
.badge-teal {
  background: rgba(90, 200, 250, 0.12);
  color: var(--apple-teal);
}

/* Mini notification badge (counter) */
.badge-notify {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  background: var(--apple-red);
  color: white;
  line-height: 1;
}

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.status-dot.green  { background: var(--apple-green); }
.status-dot.red    { background: var(--apple-red); }
.status-dot.orange { background: var(--apple-orange); }
.status-dot.gray   { background: var(--gray-3); }
.status-dot.blue   { background: var(--apple-blue); }

.status-dot.pulse {
  animation: pulse-dot 2s ease-in-out infinite;
}

/* ── Input Fields ─────────────────────────────────────────── */
.apple-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 15px;
  font-family: var(--font-system);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--separator-opaque);
  border-radius: var(--radius-md);
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease-default),
    box-shadow var(--dur-fast) var(--ease-default);
  line-height: 1.4;
}

.apple-input::placeholder {
  color: var(--text-quaternary);
}

.apple-input:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.apple-input.error {
  border-color: var(--apple-red);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15);
}

.apple-input:disabled {
  opacity: 0.5;
  background: var(--fill-quaternary);
}

/* Input with icon */
.input-with-icon {
  position: relative;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 15px;
  pointer-events: none;
}

.input-with-icon .apple-input {
  padding-left: 36px;
}

/* Textarea */
textarea.apple-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* Select */
.apple-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 8px 32px 8px 12px;
  font-size: 15px;
  font-family: var(--font-system);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--separator-opaque);
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z' fill='%238E8E93'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  transition:
    border-color var(--dur-fast) var(--ease-default),
    box-shadow var(--dur-fast) var(--ease-default);
}

.apple-select:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

/* Form Label */
.apple-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
  letter-spacing: -0.005em;
}

.apple-label .required {
  color: var(--apple-red);
  margin-left: 2px;
}

/* Form Group */
.form-group {
  margin-bottom: var(--space-4);
}

.form-row {
  display: grid;
  gap: var(--space-4);
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.form-error {
  font-size: 12px;
  color: var(--apple-red);
  margin-top: var(--space-1);
}

/* ── Toggle Switch (macOS style) ──────────────────────────── */
.apple-toggle {
  position: relative;
  width: 42px;
  height: 26px;
  flex-shrink: 0;
}

.apple-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.apple-toggle .toggle-track {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--fill-secondary);
  border-radius: 13px;
  cursor: pointer;
  transition: background var(--dur-normal) var(--ease-default);
}

.apple-toggle .toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15), 0 0 0 0.5px rgba(0,0,0,0.04);
  transition: transform var(--dur-normal) var(--ease-spring);
  pointer-events: none;
}

.apple-toggle input:checked + .toggle-track {
  background: var(--apple-green);
}

.apple-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}

.apple-toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.3);
}

/* ── Apple Search Field ───────────────────────────────────── */
.apple-search {
  position: relative;
  display: flex;
  align-items: center;
}

.apple-search-input {
  width: 100%;
  padding: 7px 12px 7px 30px;
  font-size: 13px;
  font-family: var(--font-system);
  color: var(--text-primary);
  background: var(--fill-quaternary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  outline: none;
  transition:
    background var(--dur-fast) var(--ease-default),
    border-color var(--dur-fast) var(--ease-default),
    box-shadow var(--dur-fast) var(--ease-default);
}

.apple-search-input:focus {
  background: var(--bg-primary);
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.apple-search-input::placeholder {
  color: var(--text-tertiary);
}

.apple-search-icon {
  position: absolute;
  left: 9px;
  font-size: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.apple-search-shortcut {
  position: absolute;
  right: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--fill-quaternary);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  pointer-events: none;
}

/* ── Sheet / Modal ────────────────────────────────────────── */
.apple-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-normal) var(--ease-default);
}

.apple-sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.apple-sheet {
  background: var(--material-glass-ultra);
  backdrop-filter: blur(50px) saturate(200%);
  -webkit-backdrop-filter: blur(50px) saturate(200%);
  border-radius: var(--radius-panel);
  border: var(--glass-border);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-10px) scale(0.92);
  transition:
    transform var(--dur-spring) var(--ease-spring),
    opacity var(--dur-normal) var(--ease-default);
  opacity: 0;
  will-change: transform;
}

.apple-sheet-overlay.open .apple-sheet {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.apple-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 0.5px solid var(--separator);
  min-height: 48px;
}

.apple-sheet-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  flex: 1;
}

.apple-sheet-action {
  font-size: 15px;
  font-weight: 400;
  color: var(--apple-blue);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-system);
  transition: background var(--dur-fast) var(--ease-default);
  min-width: 64px;
}

.apple-sheet-action:hover {
  background: var(--bg-hover);
}

.apple-sheet-action.primary {
  font-weight: 600;
}

.apple-sheet-action.danger {
  color: var(--apple-red);
}

.apple-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.apple-sheet-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 0.5px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  background: var(--material-thick);
}

/* Wide sheet variant */
.apple-sheet.wide {
  max-width: 720px;
}

/* Full-width sheet variant */
.apple-sheet.full {
  max-width: 90vw;
  max-height: 85vh;
}

/* ── Popover ──────────────────────────────────────────────── */
.apple-popover {
  position: absolute;
  background: var(--material-glass-ultra);
  backdrop-filter: blur(50px) saturate(200%);
  -webkit-backdrop-filter: blur(50px) saturate(200%);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  padding: var(--space-1);
  min-width: 200px;
  z-index: 300;
  animation: tahoeScaleIn 0.25s var(--ease-spring) both;
  will-change: transform;
}

.popover-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-3);
  font-size: 13px;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-fast) var(--ease-default);
}

.popover-item:hover {
  background: var(--apple-blue);
  color: white;
}

.popover-item i, .popover-item .ph {
  width: 18px;
  text-align: center;
  font-size: 14px;
  opacity: 0.8;
}

.popover-item:hover i,
.popover-item:hover .ph {
  opacity: 1;
}

.popover-separator {
  height: 0.5px;
  background: var(--separator);
  margin: var(--space-1) 0;
}

.popover-item.danger { color: var(--apple-red); }
.popover-item.danger:hover {
  background: var(--apple-red);
  color: white;
}

/* ── Toast Notification ───────────────────────────────────── */
.apple-toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.apple-toast {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 18px;
  background: var(--material-glass-ultra);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border: var(--glass-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-float);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  pointer-events: auto;
  animation: tahoeSlideDown 0.45s var(--ease-spring) both;
  white-space: nowrap;
  will-change: transform;
}

.apple-toast.dismissing {
  animation: fadeOut 0.2s var(--ease-default) forwards;
}

.apple-toast .toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.apple-toast.success .toast-icon { color: var(--apple-green); }
.apple-toast.error .toast-icon   { color: var(--apple-red); }
.apple-toast.info .toast-icon    { color: var(--apple-blue); }
.apple-toast.warning .toast-icon { color: var(--apple-orange); }

/* ── KPI Card ─────────────────────────────────────────────── */
.apple-kpi {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.apple-kpi .kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: var(--space-1);
}

.apple-kpi .kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-primary);
}

.apple-kpi .kpi-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.apple-kpi .kpi-change {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.apple-kpi .kpi-change.up   { color: var(--apple-green); }
.apple-kpi .kpi-change.down { color: var(--apple-red); }

/* ── Skeleton Loader ──────────────────────────────────────── */
.apple-skeleton {
  background: linear-gradient(
    90deg,
    var(--fill-quaternary) 25%,
    var(--fill-tertiary) 50%,
    var(--fill-quaternary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.wide { width: 100%; }

.skeleton-heading {
  height: 22px;
  width: 50%;
  margin-bottom: var(--space-3);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-card {
  height: 100px;
  border-radius: var(--radius-lg);
}

/* ── Bottom Navigation Dock ───────────────────────────────── */
.apple-dock {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--material-toolbar);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 200;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-1) var(--space-3);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
  transition:
    color var(--dur-fast) var(--ease-default),
    transform 0.1s var(--ease-spring);
  font-family: var(--font-system);
  position: relative;
}

.dock-item:active {
  transform: scale(0.88);
}

.dock-item i, .dock-item .ph {
  font-size: 22px;
  line-height: 1;
}

.dock-item.active {
  color: var(--apple-blue);
}

.dock-item .dock-badge {
  position: absolute;
  top: 0;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--apple-red);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Empty State ──────────────────────────────────────────── */
.apple-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-6);
  gap: var(--space-3);
}

.apple-empty .empty-icon {
  font-size: 48px;
  color: var(--text-quaternary);
  margin-bottom: var(--space-2);
}

.apple-empty .empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.apple-empty .empty-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 300px;
  line-height: 1.4;
}

/* ── Spinner ──────────────────────────────────────────────── */
.apple-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--fill-secondary);
  border-top-color: var(--apple-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.apple-spinner.white {
  border-color: rgba(255,255,255,0.3);
  border-top-color: white;
}

.apple-spinner.sm { width: 14px; height: 14px; border-width: 1.5px; }
.apple-spinner.lg { width: 28px; height: 28px; border-width: 3px; }

/* ── Grouped List (iOS Settings style) ────────────────────── */
.apple-grouped-list {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--separator);
  overflow: hidden;
}

.apple-grouped-list .apple-list-row:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.apple-grouped-list .apple-list-row:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-bottom: none;
}

.grouped-list-header {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  padding: var(--space-6) var(--space-4) var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.grouped-list-footer {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: var(--space-2) var(--space-4) var(--space-4);
  line-height: 1.4;
}

/* ── Progress Bar ─────────────────────────────────────────── */
.apple-progress {
  width: 100%;
  height: 4px;
  background: var(--fill-quaternary);
  border-radius: 2px;
  overflow: hidden;
}

.apple-progress .progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--apple-blue);
  transition: width 0.5s var(--ease-spring);
}

.apple-progress .progress-fill.green { background: var(--apple-green); }
.apple-progress .progress-fill.orange { background: var(--apple-orange); }
.apple-progress .progress-fill.red { background: var(--apple-red); }

/* ── Divider ──────────────────────────────────────────────── */
.apple-divider {
  height: 0.5px;
  background: var(--separator);
  margin: var(--space-3) 0;
}

.apple-divider.inset {
  margin-left: var(--space-10);
}

/* ── Chip / Tag ───────────────────────────────────────────── */
.apple-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  background: var(--fill-quaternary);
  color: var(--text-primary);
  white-space: nowrap;
  user-select: none;
}

.apple-chip.selected {
  background: var(--apple-blue);
  color: white;
}

.apple-chip i, .apple-chip .ph {
  font-size: 14px;
}

/* ── Collapsible Section ──────────────────────────────────── */
.apple-collapse-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease-default);
}

.apple-collapse-header:hover {
  background: var(--bg-hover);
}

.apple-collapse-header .collapse-chevron {
  font-size: 11px;
  color: var(--text-tertiary);
  transition: transform var(--dur-normal) var(--ease-spring);
}

.apple-collapse-header.open .collapse-chevron {
  transform: rotate(90deg);
}

.apple-collapse-body {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height var(--dur-slow) var(--ease-default),
    opacity var(--dur-normal) var(--ease-default);
}

.apple-collapse-body.open {
  max-height: 2000px;
  opacity: 1;
}

/* ── iMessage-style Chat Bubbles ──────────────────────────── */
.chat-bubble {
  max-width: 80%;
  padding: var(--space-2) var(--space-3);
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-bubble.incoming {
  background: var(--fill-quaternary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.chat-bubble.outgoing {
  background: var(--apple-blue);
  color: white;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.chat-timestamp {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  margin: var(--space-2) 0;
}

/* ── Color Swatch ─────────────────────────────────────────── */
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring), border-color 0.15s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected {
  border-color: var(--apple-blue);
  transform: scale(1.15);
}

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */

/* Main content area (used when sidebar is present) */
.apple-main {
  margin-left: var(--sidebar-width);
  padding-top: var(--toolbar-height-float);
  padding-bottom: calc(var(--bottom-nav-height) + var(--bar-inset) * 2 + var(--float-gap));
  min-height: 100vh;
}

.apple-content {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-5);
}

/* Grid helpers */
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* Flex helpers */
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* Spacing */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

/* Text utilities */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }

/* Visibility */
.hidden    { display: none !important; }
.sr-only   {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .apple-sidebar {
    transform: translateX(-100%);
    border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
  }

  .apple-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-float);
  }

  .apple-toolbar {
    left: var(--float-gap);
    right: var(--float-gap);
    top: var(--float-gap);
  }

  .apple-main {
    margin-left: 0;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .grid-auto {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr;
  }

  .apple-sheet {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-panel) var(--radius-panel) 0 0;
    max-height: 90vh;
  }

  .apple-sheet-overlay {
    padding-top: 0;
    align-items: flex-end;
  }

  .apple-dock {
    left: var(--float-gap);
    right: var(--float-gap);
    bottom: var(--float-gap);
    transform: none;
    width: auto;
    min-width: auto;
  }

  /* Hide on mobile */
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  /* Hide on desktop */
  .hide-desktop { display: none !important; }

  .apple-dock {
    display: none;
  }
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-normal) var(--ease-default);
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Theme Toggle Button ──────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  transition:
    background var(--dur-fast) var(--ease-default),
    color var(--dur-fast) var(--ease-default),
    transform 0.3s var(--ease-spring);
  font-family: inherit;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.theme-toggle:active {
  transform: scale(0.88) rotate(15deg);
}

/* ── Hamburger Button ─────────────────────────────────────── */
.hamburger-btn {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  padding: 0;
  gap: 5px;
}

.hamburger-btn span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text-primary);
  border-radius: 1px;
  transition:
    transform 0.3s var(--ease-spring),
    opacity var(--dur-fast) var(--ease-default);
}

.hamburger-btn.open span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.hamburger-btn.open span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn.open span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: flex;
  }
}

/* ── Tahoe 26: Backdrop-filter Fallback ───────────────────── */
@supports not (backdrop-filter: blur(1px)) {
  .apple-sidebar,
  .apple-toolbar,
  .apple-dock,
  .apple-popover,
  .apple-toast,
  .apple-sheet,
  .apple-card,
  .apple-kpi {
    background: var(--bg-primary);
    border: 0.5px solid var(--separator);
  }
}

/* ── Tahoe 26: GPU Performance Hints ──────────────────────── */
.apple-sidebar,
.apple-toolbar,
.apple-dock,
.apple-popover,
.apple-sheet {
  contain: layout style paint;
}
