/* ============================================================================
 * FractIOS — Sistema universal iOS feel
 * ============================================================================
 * Ley suprema 2026-04-28 (Juan):
 *   "TODO FractAIll tiene que sentirse, literalmente, como el sistema iOS y
 *    sus aplicaciones. Sin excepciones. En TODOS los viewports."
 *
 * Esta hoja reemplaza la lógica anterior macOS-desktop/iOS-móvil. Ahora
 * iOS feel es universal: web, móvil, tablet, desktop, embed. Toda superficie
 * FractAIll respira iOS 17+.
 *
 * Cargar como (manual o vía fract-shell.js):
 *   <link rel="stylesheet" href="https://fractaill.com/css/fract-ios.css">
 *
 * Versión: 2.0.0 · 2026-04-28 (universal iOS, sin rama macOS)
 * ============================================================================ */

/* ============================================================================
 * TOKENS iOS CANÓNICOS — extienden fract-tokens.css
 * ============================================================================ */
:root {
  /* ─── Type scale iOS HIG (Human Interface Guidelines) ────────────────── */
  --ios-text-largeTitle: 34px;
  --ios-text-title1:     28px;
  --ios-text-title2:     22px;
  --ios-text-title3:     20px;
  --ios-text-headline:   17px;
  --ios-text-body:       17px;
  --ios-text-callout:    16px;
  --ios-text-subhead:    15px;
  --ios-text-footnote:   13px;
  --ios-text-caption1:   12px;
  --ios-text-caption2:   11px;

  --ios-line-largeTitle: 41px;
  --ios-line-title1:     34px;
  --ios-line-title2:     28px;
  --ios-line-title3:     25px;
  --ios-line-headline:   22px;
  --ios-line-body:       22px;
  --ios-line-callout:    21px;
  --ios-line-subhead:    20px;
  --ios-line-footnote:   18px;
  --ios-line-caption:    16px;

  --ios-weight-regular:  400;
  --ios-weight-medium:   500;
  --ios-weight-semibold: 600;
  --ios-weight-bold:     700;

  /* ─── Palette iOS (System Colors iOS 17+) ─────────────────────────── */
  --ios-blue:      #007AFF;
  --ios-blue-2:    #0A84FF;     /* dark mode */
  --ios-green:     #34C759;
  --ios-green-2:   #30D158;
  --ios-indigo:    #5856D6;
  --ios-indigo-2:  #5E5CE6;
  --ios-orange:    #FF9500;
  --ios-orange-2:  #FF9F0A;
  --ios-pink:      #FF2D55;
  --ios-pink-2:    #FF375F;
  --ios-purple:    #AF52DE;
  --ios-purple-2:  #BF5AF2;
  --ios-red:       #FF3B30;
  --ios-red-2:     #FF453A;
  --ios-teal:      #30B0C7;
  --ios-teal-2:    #40C8E0;
  --ios-yellow:    #FFCC00;
  --ios-yellow-2:  #FFD60A;
  --ios-mint:      #00C7BE;
  --ios-cyan:      #32ADE6;

  /* ─── Grays iOS (UISystemGray 1..6) ─────────────────────────────── */
  --ios-gray-1: #8E8E93;
  --ios-gray-2: #AEAEB2;
  --ios-gray-3: #C7C7CC;
  --ios-gray-4: #D1D1D6;
  --ios-gray-5: #E5E5EA;
  --ios-gray-6: #F2F2F7;

  /* ─── Backgrounds iOS (system / secondary / tertiary, grouped) ─── */
  --ios-bg:           #FFFFFF;
  --ios-bg-secondary: #F2F2F7;
  --ios-bg-tertiary:  #FFFFFF;
  --ios-bg-grouped:   #F2F2F7;
  --ios-bg-grouped-2: #FFFFFF;
  --ios-bg-grouped-3: #F2F2F7;

  /* ─── Separator iOS ─────────────────────────────────────────────── */
  --ios-separator:        rgba(60,60,67,0.29);
  --ios-separator-opaque: #C6C6C8;

  /* ─── Label iOS (primary / secondary / tertiary / quaternary) ───── */
  --ios-label:            rgba(0,0,0,1);
  --ios-label-secondary:  rgba(60,60,67,0.60);
  --ios-label-tertiary:   rgba(60,60,67,0.30);
  --ios-label-quaternary: rgba(60,60,67,0.18);
  --ios-placeholder:      rgba(60,60,67,0.30);

  /* ─── Fill iOS (primary / secondary / tertiary / quaternary) ────── */
  --ios-fill:            rgba(120,120,128,0.20);
  --ios-fill-secondary:  rgba(120,120,128,0.16);
  --ios-fill-tertiary:   rgba(118,118,128,0.12);
  --ios-fill-quaternary: rgba(116,116,128,0.08);

  /* ─── Radii iOS canónicos ──────────────────────────────────────── */
  --ios-radius-xs:    6px;     /* tags, chips */
  --ios-radius-sm:    8px;     /* small buttons */
  --ios-radius-md:    10px;    /* fields, secondary buttons */
  --ios-radius-lg:    14px;    /* cards, primary buttons */
  --ios-radius-xl:    18px;    /* sheets inner */
  --ios-radius-2xl:   22px;    /* modal cards */
  --ios-radius-sheet: 28px;    /* bottom sheet (top-rounded) */
  --ios-radius-pill:  9999px;

  /* ─── Spacing iOS (4-grid) ─────────────────────────────────────── */
  --ios-space-1: 4px;
  --ios-space-2: 8px;
  --ios-space-3: 12px;
  --ios-space-4: 16px;
  --ios-space-5: 20px;
  --ios-space-6: 24px;
  --ios-space-7: 32px;
  --ios-space-8: 40px;

  /* ─── Glass / blur iOS (translucid materials) ─────────────────── */
  --ios-blur-thin:     blur(20px) saturate(180%);
  --ios-blur-regular:  blur(40px) saturate(180%);
  --ios-blur-thick:    blur(60px) saturate(190%);
  --ios-glass-thin:    rgba(255,255,255,0.72);
  --ios-glass-regular: rgba(255,255,255,0.80);
  --ios-glass-thick:   rgba(255,255,255,0.92);

  /* ─── Motion iOS (spring + standard) ──────────────────────────── */
  --ios-spring-soft:   cubic-bezier(0.34, 1.40, 0.64, 1);   /* tap rebote suave */
  --ios-spring-snap:   cubic-bezier(0.32, 1.56, 0.50, 1);   /* sheet/popover */
  --ios-ease-out:      cubic-bezier(0.25, 1, 0.50, 1);      /* nav transitions */
  --ios-ease-in-out:   cubic-bezier(0.42, 0, 0.58, 1);
  --ios-t-fast:        160ms var(--ios-ease-out);
  --ios-t:             280ms var(--ios-ease-out);
  --ios-t-slow:        420ms var(--ios-ease-out);
  --ios-tap-scale:     0.96;

  /* ─── Sombras iOS ─────────────────────────────────────────────── */
  --ios-shadow-sm:    0 1px 2px rgba(0,0,0,0.04), 0 2px 6px rgba(0,0,0,0.04);
  --ios-shadow-md:    0 4px 12px rgba(0,0,0,0.06), 0 12px 24px rgba(0,0,0,0.04);
  --ios-shadow-lg:    0 8px 24px rgba(0,0,0,0.08), 0 20px 48px rgba(0,0,0,0.10);
  --ios-shadow-sheet: 0 -4px 24px rgba(0,0,0,0.10);
  --ios-shadow-card:  0 1px 1px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.04);

  /* ─── Heights iOS ─────────────────────────────────────────────── */
  --ios-navbar-h:     44px;
  --ios-navbar-large: 96px;
  --ios-tabbar-h:     49px;
  --ios-cell-h:       44px;
  --ios-cell-h-large: 60px;
}

/* Dark mode iOS overrides */
[data-theme="dark"], 
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ios-blue: var(--ios-blue-2);
    --ios-green: var(--ios-green-2);
    --ios-orange: var(--ios-orange-2);
    --ios-red: var(--ios-red-2);
    --ios-yellow: var(--ios-yellow-2);
    --ios-purple: var(--ios-purple-2);
    --ios-pink: var(--ios-pink-2);
    --ios-teal: var(--ios-teal-2);
    --ios-indigo: var(--ios-indigo-2);

    --ios-bg:           #000000;
    --ios-bg-secondary: #1C1C1E;
    --ios-bg-tertiary:  #2C2C2E;
    --ios-bg-grouped:   #000000;
    --ios-bg-grouped-2: #1C1C1E;
    --ios-bg-grouped-3: #2C2C2E;

    --ios-separator:        rgba(84,84,88,0.65);
    --ios-separator-opaque: #38383A;

    --ios-label:            rgba(255,255,255,1);
    --ios-label-secondary:  rgba(235,235,245,0.60);
    --ios-label-tertiary:   rgba(235,235,245,0.30);
    --ios-label-quaternary: rgba(235,235,245,0.18);
    --ios-placeholder:      rgba(235,235,245,0.30);

    --ios-fill:            rgba(120,120,128,0.36);
    --ios-fill-secondary:  rgba(120,120,128,0.32);
    --ios-fill-tertiary:   rgba(118,118,128,0.24);
    --ios-fill-quaternary: rgba(116,116,128,0.18);

    --ios-glass-thin:    rgba(28,28,30,0.72);
    --ios-glass-regular: rgba(28,28,30,0.80);
    --ios-glass-thick:   rgba(28,28,30,0.92);

    --ios-shadow-sm:    0 1px 2px rgba(0,0,0,0.30);
    --ios-shadow-md:    0 4px 12px rgba(0,0,0,0.40);
    --ios-shadow-lg:    0 8px 24px rgba(0,0,0,0.50);
    --ios-shadow-sheet: 0 -4px 24px rgba(0,0,0,0.55);
  }
}


/* ============================================================================
 * BASE iOS — Tipografía y body universal
 * ============================================================================ */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, sans-serif;
  font-size: var(--ios-text-body);
  line-height: var(--ios-line-body);
  font-weight: var(--ios-weight-regular);
  color: var(--ios-label);
  background: var(--ios-bg-grouped);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
  text-rendering: optimizeLegibility;
}

/* Forzar SF Pro stack en TODA tipografía heredada */
button, input, select, textarea {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
input, textarea, select {
  font-size: var(--ios-text-body); /* evita zoom iOS */
}

/* iOS type scale clases */
.ios-large-title { font-size: var(--ios-text-largeTitle); line-height: var(--ios-line-largeTitle); font-weight: 700; letter-spacing: -0.022em; }
.ios-title-1     { font-size: var(--ios-text-title1);     line-height: var(--ios-line-title1);     font-weight: 700; letter-spacing: -0.020em; }
.ios-title-2     { font-size: var(--ios-text-title2);     line-height: var(--ios-line-title2);     font-weight: 700; letter-spacing: -0.018em; }
.ios-title-3     { font-size: var(--ios-text-title3);     line-height: var(--ios-line-title3);     font-weight: 600; letter-spacing: -0.015em; }
.ios-headline    { font-size: var(--ios-text-headline);   line-height: var(--ios-line-headline);   font-weight: 600; letter-spacing: -0.012em; }
.ios-body        { font-size: var(--ios-text-body);       line-height: var(--ios-line-body);       font-weight: 400; letter-spacing: -0.011em; }
.ios-callout     { font-size: var(--ios-text-callout);    line-height: var(--ios-line-callout);    font-weight: 400; letter-spacing: -0.008em; }
.ios-subhead     { font-size: var(--ios-text-subhead);    line-height: var(--ios-line-subhead);    font-weight: 400; letter-spacing: -0.005em; }
.ios-footnote    { font-size: var(--ios-text-footnote);   line-height: var(--ios-line-footnote);   font-weight: 400; }
.ios-caption-1   { font-size: var(--ios-text-caption1);   line-height: var(--ios-line-caption);    font-weight: 400; color: var(--ios-label-secondary); }
.ios-caption-2   { font-size: var(--ios-text-caption2);   line-height: var(--ios-line-caption);    font-weight: 400; color: var(--ios-label-tertiary); }

/* ============================================================================
 * BUTTONS iOS — primary, secondary, plain, destructive, pill
 * ============================================================================ */
.ios-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--ios-radius-lg);
  font-family: inherit;
  font-size: var(--ios-text-body);
  font-weight: var(--ios-weight-semibold);
  letter-spacing: -0.011em;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--ios-t-fast), background-color var(--ios-t-fast), opacity var(--ios-t-fast);
  text-decoration: none;
  line-height: 1.2;
  position: relative;
  overflow: hidden;
}
.ios-btn:active {
  transform: scale(var(--ios-tap-scale));
  transition: transform 80ms var(--ios-spring-soft);
}
.ios-btn:disabled, .ios-btn[aria-disabled="true"] {
  opacity: 0.4; cursor: not-allowed; transform: none !important;
}

/* Primary — gradient brand naranja */
.ios-btn-primary {
  background: linear-gradient(135deg, var(--fract-accent), var(--fract-accent-2));
  color: #fff;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08), 0 4px 12px rgba(255,122,41,0.30);
}
.ios-btn-primary:hover { filter: brightness(1.05); }

/* Filled (iOS system) */
.ios-btn-filled {
  background: var(--ios-blue);
  color: #fff;
}

/* Tinted — relleno con fill secondary */
.ios-btn-tinted {
  background: var(--ios-fill-secondary);
  color: var(--fract-accent);
}
.ios-btn-tinted:hover { background: var(--ios-fill); }

/* Plain — texto solo */
.ios-btn-plain {
  background: transparent;
  color: var(--fract-accent);
  padding: 10px 12px;
}
.ios-btn-plain:hover { background: var(--ios-fill-quaternary); }

/* Destructive */
.ios-btn-destructive {
  background: transparent;
  color: var(--ios-red);
}
.ios-btn-destructive.ios-btn-filled {
  background: var(--ios-red); color: #fff;
}

/* Pill (large CTA) */
.ios-btn-pill {
  border-radius: var(--ios-radius-pill);
  padding: 14px 28px;
  font-size: var(--ios-text-headline);
}

/* Block (full width) */
.ios-btn-block { display: flex; width: 100%; }

/* ============================================================================
 * NAVIGATION BAR iOS — large title + standard
 * ============================================================================ */
.ios-navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center;
  min-height: var(--ios-navbar-h);
  padding: 0 16px;
  background: var(--ios-glass-thick);
  backdrop-filter: var(--ios-blur-regular);
  -webkit-backdrop-filter: var(--ios-blur-regular);
  border-bottom: 0.5px solid var(--ios-separator);
  font-size: var(--ios-text-headline);
  font-weight: var(--ios-weight-semibold);
  color: var(--ios-label);
}
.ios-navbar-leading,
.ios-navbar-trailing {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0; min-width: 60px;
}
.ios-navbar-trailing { justify-content: flex-end; }
.ios-navbar-title {
  flex: 1; text-align: center;
  font-size: var(--ios-text-headline);
  font-weight: var(--ios-weight-semibold);
  letter-spacing: -0.012em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ios-navbar-back {
  display: inline-flex; align-items: center; gap: 2px;
  background: transparent; border: 0; padding: 8px 4px;
  color: var(--fract-accent); font-size: var(--ios-text-body);
  font-weight: var(--ios-weight-regular); cursor: pointer;
}
.ios-navbar-back:active { opacity: 0.4; }
.ios-navbar-back::before {
  content: "‹"; font-size: 26px; line-height: 0.7; font-weight: 300;
  margin-right: 2px;
}

/* Large title variant (collapses on scroll if JS hooks) */
.ios-navbar-large {
  flex-direction: column; align-items: stretch;
  padding: 0 16px 12px;
  min-height: var(--ios-navbar-large);
}
.ios-navbar-large .ios-navbar-row { display: flex; align-items: center; min-height: var(--ios-navbar-h); }
.ios-navbar-large .ios-navbar-largeTitle {
  font-size: var(--ios-text-largeTitle);
  line-height: var(--ios-line-largeTitle);
  font-weight: 700; letter-spacing: -0.022em;
  color: var(--ios-label); margin-top: 4px;
}

/* ============================================================================
 * TAB BAR iOS — bottom blurred + safe-area
 * ============================================================================ */
.ios-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex; justify-content: space-around; align-items: stretch;
  min-height: var(--ios-tabbar-h);
  padding-top: 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--ios-glass-thick);
  backdrop-filter: var(--ios-blur-thick);
  -webkit-backdrop-filter: var(--ios-blur-thick);
  border-top: 0.5px solid var(--ios-separator);
}
.ios-tabbar-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: transparent; border: 0; padding: 4px 0;
  color: var(--ios-gray-1);
  font-family: inherit; font-size: var(--ios-text-caption2);
  font-weight: var(--ios-weight-medium);
  cursor: pointer;
  transition: color var(--ios-t-fast), transform var(--ios-t-fast);
}
.ios-tabbar-item i, .ios-tabbar-item svg { font-size: 22px; line-height: 1; }
.ios-tabbar-item[aria-selected="true"],
.ios-tabbar-item.active {
  color: var(--fract-accent);
}
.ios-tabbar-item:active { transform: scale(0.92); }


/* ============================================================================
 * LIST cells iOS — grouped/inset/plain con chevron y separator
 * ============================================================================ */
.ios-list {
  list-style: none; margin: 0; padding: 0;
  background: var(--ios-bg-tertiary);
  border-radius: var(--ios-radius-lg);
  overflow: hidden;
  border: 0.5px solid var(--ios-separator);
}
.ios-list-inset {
  margin: 16px;
  border-radius: var(--ios-radius-lg);
}
.ios-list-section + .ios-list-section { margin-top: 24px; }
.ios-list-header,
.ios-list-footer {
  display: block;
  padding: 8px 16px;
  font-size: var(--ios-text-footnote);
  line-height: var(--ios-line-footnote);
  color: var(--ios-label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ios-list-footer { padding-top: 8px; text-transform: none; letter-spacing: 0; }

.ios-cell {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--ios-cell-h);
  padding: 11px 16px;
  background: var(--ios-bg-tertiary);
  color: var(--ios-label);
  font-size: var(--ios-text-body);
  border: 0; width: 100%;
  text-decoration: none; text-align: left;
  cursor: pointer; font-family: inherit;
  position: relative;
  transition: background-color 80ms linear;
}
.ios-cell:active,
.ios-cell.active {
  background: var(--ios-fill-tertiary);
}
.ios-cell + .ios-cell::before {
  content: ""; position: absolute; top: 0; left: 60px; right: 0;
  height: 0.5px; background: var(--ios-separator);
}
.ios-cell .ios-cell-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--ios-fill-secondary); color: var(--ios-label);
  flex-shrink: 0; font-size: 16px;
}
.ios-cell .ios-cell-icon-blue   { background: var(--ios-blue);   color: #fff; }
.ios-cell .ios-cell-icon-orange { background: var(--fract-accent); color: #fff; }
.ios-cell .ios-cell-icon-green  { background: var(--ios-green);  color: #fff; }
.ios-cell .ios-cell-icon-red    { background: var(--ios-red);    color: #fff; }
.ios-cell .ios-cell-icon-purple { background: var(--ios-purple); color: #fff; }

.ios-cell .ios-cell-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ios-cell .ios-cell-title { font-size: var(--ios-text-body); font-weight: 400; color: var(--ios-label); }
.ios-cell .ios-cell-subtitle { font-size: var(--ios-text-footnote); color: var(--ios-label-secondary); }
.ios-cell .ios-cell-value { color: var(--ios-label-secondary); font-size: var(--ios-text-body); margin-left: auto; }

.ios-cell.has-chevron::after {
  content: "›"; color: var(--ios-label-tertiary); font-size: 22px;
  font-weight: 300; line-height: 1; margin-left: 6px;
}

/* ============================================================================
 * SEGMENTED CONTROL iOS
 * ============================================================================ */
.ios-segmented {
  display: inline-flex; padding: 2px;
  background: var(--ios-fill-secondary);
  border-radius: var(--ios-radius-md);
  position: relative;
  font-family: inherit;
}
.ios-segmented button {
  position: relative; z-index: 1;
  padding: 6px 14px; min-height: 28px;
  background: transparent; border: 0;
  border-radius: 7px;
  color: var(--ios-label);
  font-family: inherit; font-size: 13px;
  font-weight: var(--ios-weight-medium);
  cursor: pointer;
  transition: color var(--ios-t-fast);
}
.ios-segmented button[aria-selected="true"],
.ios-segmented button.active {
  background: var(--ios-bg-tertiary);
  color: var(--ios-label);
  font-weight: var(--ios-weight-semibold);
  box-shadow: 0 3px 8px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
}

/* ============================================================================
 * SWITCH iOS (toggle)
 * ============================================================================ */
.ios-switch {
  position: relative; display: inline-block;
  width: 51px; height: 31px;
  vertical-align: middle;
}
.ios-switch input { display: none; }
.ios-switch-slider {
  position: absolute; inset: 0;
  background: var(--ios-fill);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 220ms var(--ios-ease-out);
}
.ios-switch-slider::before {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 27px; height: 27px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.06);
  transition: transform 220ms var(--ios-spring-snap);
}
.ios-switch input:checked + .ios-switch-slider {
  background: var(--ios-green);
}
.ios-switch input:checked + .ios-switch-slider::before {
  transform: translateX(20px);
}
.ios-switch.brand input:checked + .ios-switch-slider { background: var(--fract-accent); }

/* ============================================================================
 * INPUT / TEXTAREA / SELECT — iOS feel
 * ============================================================================ */
.ios-input,
.ios-textarea,
.ios-select {
  display: block; width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--ios-bg-tertiary);
  border: 0.5px solid var(--ios-separator);
  border-radius: var(--ios-radius-md);
  color: var(--ios-label);
  font-family: inherit;
  font-size: var(--ios-text-body);
  line-height: var(--ios-line-body);
  outline: none;
  transition: border-color var(--ios-t-fast), background-color var(--ios-t-fast);
  -webkit-appearance: none; appearance: none;
}
.ios-input::placeholder,
.ios-textarea::placeholder { color: var(--ios-placeholder); }
.ios-input:focus,
.ios-textarea:focus,
.ios-select:focus {
  border-color: var(--fract-accent);
  background: var(--ios-bg);
  box-shadow: 0 0 0 3px var(--fract-accent-soft);
}
.ios-textarea { min-height: 88px; resize: vertical; }
.ios-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16' fill='none'><path d='M4 6l4 4 4-4' stroke='%238E8E93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Search field iOS */
.ios-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--ios-fill-secondary);
  border-radius: var(--ios-radius-md);
}
.ios-search::before {
  content: ""; flex-shrink: 0; width: 16px; height: 16px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'><circle cx='7' cy='7' r='5' stroke='%238E8E93' stroke-width='1.6'/><path d='M11 11l3 3' stroke='%238E8E93' stroke-width='1.6' stroke-linecap='round'/></svg>") no-repeat center;
}
.ios-search input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--ios-label); font-family: inherit;
  font-size: var(--ios-text-body); padding: 4px 0;
  min-height: 28px;
}
.ios-search input::placeholder { color: var(--ios-placeholder); }

/* ============================================================================
 * SHEET MODAL iOS — bottom rounded with handle
 * ============================================================================ */
.ios-sheet-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.36);
  opacity: 0; pointer-events: none;
  transition: opacity 280ms var(--ios-ease-out);
}
.ios-sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.ios-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001;
  max-height: 92vh; overflow: hidden;
  background: var(--ios-bg-secondary);
  border-radius: var(--ios-radius-sheet) var(--ios-radius-sheet) 0 0;
  box-shadow: var(--ios-shadow-sheet);
  transform: translateY(100%);
  transition: transform 380ms var(--ios-spring-snap);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.ios-sheet.open { transform: translateY(0); }
.ios-sheet-handle {
  display: block; width: 36px; height: 5px;
  background: var(--ios-gray-3); border-radius: 999px;
  margin: 8px auto;
  cursor: grab;
}
.ios-sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 16px 12px;
  border-bottom: 0.5px solid var(--ios-separator);
}
.ios-sheet-title {
  font-size: var(--ios-text-headline); font-weight: var(--ios-weight-semibold);
  letter-spacing: -0.012em;
}
.ios-sheet-body { padding: 16px; overflow-y: auto; max-height: calc(92vh - 80px); }

/* Centered alert dialog iOS */
.ios-alert {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.94);
  z-index: 1002;
  width: min(280px, 92vw);
  background: var(--ios-glass-thick);
  backdrop-filter: var(--ios-blur-thick);
  -webkit-backdrop-filter: var(--ios-blur-thick);
  border-radius: var(--ios-radius-2xl);
  box-shadow: var(--ios-shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity 220ms var(--ios-ease-out), transform 220ms var(--ios-spring-snap);
  text-align: center;
  overflow: hidden;
}
.ios-alert.open { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.ios-alert-body { padding: 20px 16px 16px; }
.ios-alert-title { font-size: var(--ios-text-headline); font-weight: var(--ios-weight-semibold); margin: 0 0 4px; }
.ios-alert-msg { font-size: var(--ios-text-footnote); color: var(--ios-label-secondary); margin: 0; }
.ios-alert-actions { display: flex; border-top: 0.5px solid var(--ios-separator); }
.ios-alert-actions button {
  flex: 1; padding: 11px 8px;
  background: transparent; border: 0; cursor: pointer; font-family: inherit;
  font-size: var(--ios-text-body); color: var(--fract-accent);
  font-weight: var(--ios-weight-regular);
}
.ios-alert-actions button + button { border-left: 0.5px solid var(--ios-separator); }
.ios-alert-actions button.primary { font-weight: var(--ios-weight-semibold); }
.ios-alert-actions button.destructive { color: var(--ios-red); }
.ios-alert-actions button:active { background: var(--ios-fill-secondary); }


/* ============================================================================
 * CARD iOS — superficie elevada
 * ============================================================================ */
.ios-card {
  background: var(--ios-bg-tertiary);
  border-radius: var(--ios-radius-lg);
  padding: 16px;
  box-shadow: var(--ios-shadow-card);
  border: 0.5px solid var(--ios-separator);
  transition: transform var(--ios-t-fast), box-shadow var(--ios-t-fast);
}
.ios-card.tappable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ios-card.tappable:active { transform: scale(0.985); }

/* ============================================================================
 * BADGE iOS
 * ============================================================================ */
.ios-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  background: var(--ios-red); color: #fff;
  border-radius: 999px;
  font-size: var(--ios-text-caption2);
  font-weight: var(--ios-weight-semibold);
  letter-spacing: -0.005em;
}
.ios-badge-dot {
  width: 8px; height: 8px; padding: 0; min-width: 0;
  display: inline-block;
}

/* ============================================================================
 * SPINNER iOS (8 spokes radial)
 * ============================================================================ */
.ios-spinner {
  display: inline-block; width: 20px; height: 20px;
  position: relative;
}
.ios-spinner::before {
  content: ""; position: absolute; inset: 0;
  background: conic-gradient(from 0deg, transparent 0deg, var(--ios-label-secondary) 360deg);
  border-radius: 50%;
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 36%, #000 38%, #000 50%, transparent 52%);
          mask: radial-gradient(circle at 50% 50%, transparent 36%, #000 38%, #000 50%, transparent 52%);
  animation: ios-spin 900ms linear infinite;
}
@keyframes ios-spin { to { transform: rotate(360deg); } }

/* ============================================================================
 * TOAST iOS (top, blur)
 * ============================================================================ */
.ios-toast {
  position: fixed; left: 50%; top: 24px;
  transform: translate(-50%, -120%);
  z-index: 1100;
  padding: 10px 18px;
  background: var(--ios-glass-thick);
  backdrop-filter: var(--ios-blur-thick);
  -webkit-backdrop-filter: var(--ios-blur-thick);
  border-radius: var(--ios-radius-pill);
  box-shadow: var(--ios-shadow-md);
  font-size: var(--ios-text-footnote);
  font-weight: var(--ios-weight-medium);
  color: var(--ios-label);
  transition: transform 360ms var(--ios-spring-snap), opacity 200ms;
  opacity: 0;
}
.ios-toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ============================================================================
 * UTILITIES iOS
 * ============================================================================ */
.ios-blur-bg {
  background: var(--ios-glass-regular);
  backdrop-filter: var(--ios-blur-regular);
  -webkit-backdrop-filter: var(--ios-blur-regular);
}
.ios-tap { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ios-tap:active { opacity: 0.6; transition: opacity 80ms; }
.ios-tap-scale { transition: transform var(--ios-t-fast); }
.ios-tap-scale:active { transform: scale(var(--ios-tap-scale)); }

.ios-stack { display: flex; flex-direction: column; }
.ios-row   { display: flex; flex-direction: row; align-items: center; }
.ios-gap-1 { gap: var(--ios-space-1); }
.ios-gap-2 { gap: var(--ios-space-2); }
.ios-gap-3 { gap: var(--ios-space-3); }
.ios-gap-4 { gap: var(--ios-space-4); }
.ios-gap-5 { gap: var(--ios-space-5); }

.ios-divider { height: 0.5px; background: var(--ios-separator); margin: 0; }

.ios-safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
.ios-safe-top    { padding-top: env(safe-area-inset-top, 0); }
.ios-safe        { padding-top: env(safe-area-inset-top, 0); padding-bottom: env(safe-area-inset-bottom, 0); }

/* ============================================================================
 * iOS SHEET TOPCAP — ventanas que en pantalla grande se sienten también iOS
 * ============================================================================
 * En desktop la página se centra y mantiene radius como una "card iOS gigante"
 * (NO ventana macOS con traffic lights) → coherencia universal.
 * ============================================================================ */
@media (min-width: 768px) {
  body.ios-canvas {
    background: var(--ios-bg-grouped);
  }
  body.ios-canvas .ios-canvas-frame {
    max-width: 480px;
    margin: 24px auto;
    background: var(--ios-bg-secondary);
    border-radius: var(--ios-radius-2xl);
    box-shadow: var(--ios-shadow-lg);
    overflow: hidden;
  }
}

/* ============================================================================
 * COMPATIBILIDAD iOS — clases legacy heredadas las redirige a iOS feel
 * ============================================================================ */
.fract-card,
.fract-window,
.fract-panel,
.card {
  border-radius: var(--ios-radius-lg);
  background: var(--ios-bg-tertiary);
  border: 0.5px solid var(--ios-separator);
}
button:not([class*="ios-"]):not([class*="fract-"]):not(.no-ios) {
  -webkit-tap-highlight-color: transparent;
}

/* Forzar feel iOS también cuando el viewport es grande (anula macOS) */
.fract-traffic-lights { display: none !important; }
.fract-window { box-shadow: var(--ios-shadow-md) !important; border-radius: var(--ios-radius-2xl) !important; }
