/* Layer order first, so the pack's base and components layers sit below portal.css (unlayered). */
@layer base, components;

/* KAIRANA · Soulcare — canonical design tokens (DATA)
   Source of truth. Dark-luxe editorial is the DEFAULT theme (single theme, no toggle).
   Palette extracted from the official brandbook (Marfil Alba corrected from a brandbook typo
   via pixel-sampling). WCAG 2.2 AA verified via _ops/verify-a11y.mjs.
   No universal reset, no color-mix, declarations only — the pack owns base/reset/states. */
:root {
  /* color — brand */
  --color-primary: #E2D8C9;        /* Beige Lino — CTA on dark (brandbook p. 12) */
  --color-primary-hover: #FFFBF1;  /* Marfil Alba */
  --color-primary-fg: #0E0E0F;     /* Negro Silencio */
  --color-accent: #836E4B;         /* Ocre Sándalo — the single chromatic accent (5%) */
  --color-accent-hover: #9C8458;

  /* color — surfaces */
  --color-bg: #0E0E0F;             /* Negro Silencio */
  --color-fg: #E2D8C9;             /* Beige Lino — text on dark (brandbook p. 12) */
  --color-fg-muted: #B3A892;
  --color-fg-subtle: #938877;
  --color-surface: #1E1712;        /* Marrón Raíz — Pantone 440C */
  --color-surface-2: #2A2118;
  --color-border: #2C261D;
  --color-border-strong: #6E6456;
  --color-overlay: rgba(14, 14, 15, 0.66);
  --color-ring: #836E4B;

  /* color — on-colors (a11y verified) */
  --color-on-primary: #0E0E0F;
  --color-on-accent: #FFFBF1;
  --color-on-surface: #FFFBF1;

  /* color — interaction */
  --color-selection-bg: #836E4B;
  --color-selection-fg: #FFFBF1;
  --caret-color: #836E4B;

  /* color — semantic (dark-tuned; each indicator ≥3.0 on its -bg) */
  --color-success: #4ADE80; --color-success-bg: #0F2418; --color-success-fg: #86EFAC; --color-success-border: #1F3D2E;
  --color-warning: #FBBF24; --color-warning-bg: #2A1F08; --color-warning-fg: #FCD34D; --color-warning-border: #46340E;
  --color-error:   #F87171; --color-error-bg:   #2A1212; --color-error-fg:   #FCA5A5; --color-error-border:   #4A1F1F;
  --color-info:    #60A5FA; --color-info-bg:    #0F1E2E; --color-info-fg:    #93C5FD; --color-info-border:    #1E3A52;

  /* space — 4pt grid */
  --space-0: 0; --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px; --space-9: 96px;
  --space-section-y: 120px; --space-gutter: 24px;

  /* type scale — editorial, base 17, ratio ~1.25 */
  --text-xs: 12px; --text-sm: 14px; --text-base: 17px; --text-lg: 20px; --text-xl: 24px;
  --text-2xl: 30px; --text-3xl: 38px; --text-4xl: 48px; --text-5xl: 60px;
  --leading-tight: 1.08; --leading-snug: 1.2; --leading-normal: 1.6; --leading-relaxed: 1.75;
  --tracking-tight: -0.02em; --tracking-normal: 0; --tracking-wide: 0.14em;
  --font-weight-regular: 400; --font-weight-medium: 500; --font-weight-semibold: 600; --font-weight-bold: 700;
  --font-display: "Quiche Sans", "Marcellus", Georgia, serif;
  --font-body: "Lora", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  /* radius — soft, organic (pill controls echo the brand's stadium/oval motif) */
  --radius-none: 0; --radius-sm: 4px; --radius-md: 8px; --radius-lg: 16px; --radius-full: 9999px;
  --radius-control: 9999px; --radius-card: 16px; --radius-input: 8px;

  /* elevation — subtle; depth comes from tone + texture, not heavy shadow */
  --shadow-0: none;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 12px 40px rgba(0, 0, 0, 0.55);
  --shadow-focus: 0 0 0 var(--ring-offset) var(--color-bg), 0 0 0 calc(var(--ring-offset) + var(--ring-width)) var(--color-ring);

  /* z — MVP 4-rung */
  --z-base: 0; --z-sticky: 100; --z-overlay: 500; --z-toast: 700;

  /* motion — pausado y envolvente (slow, serene) */
  --dur-instant: 0ms; --dur-fast: 160ms; --dur-base: 280ms; --dur-slow: 480ms; --dur-reveal: 800ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);

  /* misc */
  --bw-0: 0; --bw-1: 1px; --bw-2: 2px;
  --opacity-disabled: 0.4; --opacity-muted: 0.64;
  --blur-sm: 4px; --blur-lg: 16px;

  /* breakpoints + containers (single source; the v4 bridge mirrors these) */
  --breakpoint-sm: 640px; --breakpoint-md: 768px; --breakpoint-lg: 1024px; --breakpoint-xl: 1280px; --breakpoint-2xl: 1536px;
  --container-sm: 640px; --container-md: 768px; --container-lg: 1024px; --container-xl: 1280px; --container-prose: 66ch;

  /* control + ring (spacious, luxe) */
  --control-h-sm: 40px; --control-h-md: 48px; --control-h-lg: 56px;
  --control-px-sm: 16px; --control-px-md: 24px; --control-px-lg: 32px;
  --control-fs-sm: 13px; --control-fs-md: 15px; --control-fs-lg: 16px;
  --control-gap: 8px; --tap-min: 44px; --ring-width: 2px; --ring-offset: 2px;

  /* transient */
  --scroll-offset: 80px; --toast-duration: 5000;
  --skeleton-base: #1E1712; --skeleton-shimmer: #2A2118; --skeleton-duration: 1600ms;
}

/* Section tones — brandbook p. 12 "Combinación de fondos". :root is the negro tone.
   Each tone sets the semantic tokens again; tokens composed from others (--shadow-focus)
   are declared again in kairana.css, because they would keep the :root value. */
.tone-marron {
  --color-bg: #1E1712; --color-surface: #2A2118; --color-surface-2: #32281E; --color-fg-subtle: #A09582;
  --color-border: #3A2F25; --color-primary-fg: #1E1712; --color-on-primary: #1E1712;
}
.tone-beige {
  --color-bg: #E2D8C9; --color-fg: #1E1712; --color-fg-muted: #5A4E41; --color-fg-subtle: #625545;
  --color-surface: #E2D8C9; --color-surface-2: #DACFBF; --color-border: #CFC3B0; --color-border-strong: #7A6C58;
  --color-primary: #1E1712; --color-primary-hover: #3A2E24; --color-primary-fg: #E2D8C9; --color-on-primary: #E2D8C9;
  --color-accent: #1E1712; --color-accent-hover: #3A2E24; --color-on-accent: #E2D8C9;
  --color-error: #9E3A2B; --color-error-fg: #9E3A2B;
  --color-success: #2F5A36; --color-success-bg: #E3EEDC; --color-success-fg: #2F5A36; --color-success-border: #B9D1B5;
  --shadow-1: 0 1px 2px rgba(30, 23, 18, 0.08);
}
.tone-marfil {
  --color-bg: #FFFBF1; --color-fg: #1E1712; --color-fg-muted: #5A4E41; --color-fg-subtle: #625545;
  --color-surface: #FFFBF1; --color-surface-2: #F3ECDF; --color-border: #E6DCCB; --color-border-strong: #7A6C58;
  --color-primary: #836E4B; --color-primary-hover: #6F5C3D; --color-primary-fg: #FFFBF1; --color-on-primary: #FFFBF1;
  --color-accent: #836E4B; --color-accent-hover: #6F5C3D; --color-on-accent: #FFFBF1;
  --color-error: #9E3A2B; --color-error-fg: #9E3A2B;
  --color-success: #2F5A36; --color-success-bg: #E3EEDC; --color-success-fg: #2F5A36; --color-success-border: #B9D1B5;
  --shadow-1: 0 1px 2px rgba(30, 23, 18, 0.08);
}

/* a11y floor (required by the v4-safety gate; the pack's base.css refines it) */
:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

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

/* base.css — @layer base ONLY. References semantic vars from tokens.css.
   The single home for reset/focus-ring/selection/scrollbar/scroll-margin/
   reduce-motion/forced-colors/visually-hidden/skip-link.
   Imported AFTER tokens-theme.css so Tailwind's @layer base wins over Preflight
   only where these zero-specificity :where() rules add intent; utilities always
   win because they sit in @layer utilities (declared last by the bridge). */
@layer base {
  /* Zero-specificity reset (never an unlayered `*{margin:0}`). */
  :where(body) {
    margin: 0;
    background-color: var(--color-bg);
    color: var(--color-fg);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  :where(h1, h2, h3, h4, h5, h6) {
    font-family: var(--font-display);
    font-weight: var(--font-weight-bold);
    line-height: var(--leading-tight);
    text-wrap: balance;
  }
  :where(a) { color: inherit; }
  :where(button, input, select, textarea) { font: inherit; color: inherit; }
  :where(img, svg, video, canvas) { display: block; max-width: 100%; }
  :where(:root) { caret-color: var(--caret-color); }

  /* Selection + scrollbar. */
  ::selection { background: var(--color-selection-bg); color: var(--color-selection-fg); }
  :where(*) { scrollbar-color: var(--color-border-strong) transparent; }
  ::-webkit-scrollbar { width: 12px; height: 12px; }
  ::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-full); }

  /* Focus ring — the single shared affordance. */
  :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
  }

  /* Smooth scroll + anchor offset under a sticky header (fixes the live anchored-nav bug). */
  :where(html) { scroll-behavior: smooth; }
  :where(:target), :where([id]) { scroll-margin-top: var(--scroll-offset); }

  /* Accessibility helpers. */
  .visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .skip-link {
    position: absolute; left: var(--space-2); top: calc(-1 * var(--space-9));
    z-index: var(--z-overlay); padding: var(--space-2) var(--space-4);
    background: var(--color-primary); color: var(--color-primary-fg);
    border-radius: var(--radius-md); transition: top var(--dur-fast) var(--ease-out);
  }
  .skip-link:focus { top: var(--space-2); }

  /* Reduce-motion — the single consolidated block; also kills scroll-behavior + view transitions. */
  @media (prefers-reduced-motion: reduce) {
    :where(html) { scroll-behavior: auto; }
    :where(*, ::before, ::after) {
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
    }
    ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
      animation: none !important;
    }
  }

  /* Forced-colors (Windows high-contrast) — keep affordances visible. */
  @media (forced-colors: active) {
    :where(a, button, input, select, textarea, summary):focus-visible {
      outline: 2px solid CanvasText; box-shadow: none;
    }
  }
}

/* primitives.css — @layer components. ~8 MVP primitives.
   References ONLY semantic vars from tokens.css. No @apply. No literal hex/px.
   Every color-mix() references a var() (never a literal #hex). */
@layer components {
  /* ---------- Button (variants × sizes × six states) ---------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--control-gap);
    height: var(--control-h-md); padding-inline: var(--control-px-md);
    font-size: var(--control-fs-md); font-weight: var(--font-weight-semibold);
    line-height: 1; border: var(--bw-1) solid transparent;
    border-radius: var(--radius-control); cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
    min-height: var(--tap-min);
  }
  .btn-sm { height: var(--control-h-sm); padding-inline: var(--control-px-sm); font-size: var(--control-fs-sm); }
  .btn-lg { height: var(--control-h-lg); padding-inline: var(--control-px-lg); font-size: var(--control-fs-lg); }
  .btn-icon { padding-inline: var(--space-2); aspect-ratio: 1; }

  .btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
  .btn-primary:hover { background: var(--color-primary-hover); }
  .btn-primary:active { transform: translateY(var(--bw-1)); }

  .btn-secondary { background: var(--color-surface); color: var(--color-fg); border-color: var(--color-border); }
  .btn-secondary:hover { background: var(--color-surface-2); border-color: var(--color-border-strong); }

  .btn-ghost { background: transparent; color: var(--color-fg); }
  .btn-ghost:hover { background: color-mix(in srgb, var(--color-fg) 8%, transparent); }

  .btn-destructive { background: var(--color-error); color: var(--color-bg); } /* Kairana: recolored to --color-error */
  .btn-destructive:hover { background: color-mix(in srgb, var(--color-error) 88%, black); }

  .btn-link { background: transparent; color: var(--color-accent); border: 0; min-height: auto; height: auto; padding: 0; }
  .btn-link:hover { color: var(--color-accent-hover); text-decoration: underline; }

  .btn[disabled], .btn[aria-disabled='true'] { opacity: var(--opacity-disabled); pointer-events: none; }

  .btn[data-loading='true'] { color: transparent; position: relative; pointer-events: none; }
  .btn[data-loading='true']::after {
    content: ''; position: absolute; width: 1em; height: 1em;
    border: var(--bw-2) solid currentColor; border-top-color: transparent;
    border-radius: var(--radius-full); animation: ds-spin var(--dur-slow) linear infinite;
    color: var(--color-on-primary);
  }
  @keyframes ds-spin { to { transform: rotate(360deg); } }

  /* ---------- Input + Textarea ---------- */
  .input, .textarea {
    display: block; width: 100%;
    min-height: var(--control-h-md); padding: var(--space-2) var(--space-3);
    font-size: var(--control-fs-md); color: var(--color-fg);
    background: var(--color-bg); border: var(--bw-1) solid var(--color-border);
    border-radius: var(--radius-input);
    transition: border-color var(--dur-fast) var(--ease-out);
  }
  .textarea { min-height: calc(var(--control-h-lg) * 2); resize: vertical; }
  .input::placeholder, .textarea::placeholder { color: var(--color-fg-subtle); }
  .input:hover, .textarea:hover { border-color: var(--color-border-strong); }
  .input[aria-invalid='true'], .textarea[aria-invalid='true'] { border-color: var(--color-error); } /* Kairana: recolored to --color-error */
  .input[disabled], .textarea[disabled] { opacity: var(--opacity-disabled); background: var(--color-surface); cursor: not-allowed; }

  /* ---------- Field wrapper (label + help + error, aria id-wiring) ---------- */
  .field { display: flex; flex-direction: column; gap: var(--space-1); }
  .field-label { font-size: var(--text-sm); font-weight: var(--font-weight-medium); color: var(--color-fg); }
  .field-help { font-size: var(--text-xs); color: var(--color-fg-muted); }
  .field-error { font-size: var(--text-xs); color: var(--color-error); } /* Kairana: recolored to --color-error */

  /* ---------- Card (static + interactive stretched-link) ---------- */
  .card {
    position: relative; background: var(--color-surface);
    border: var(--bw-1) solid var(--color-border); border-radius: var(--radius-card);
    padding: var(--space-5); box-shadow: var(--shadow-1);
  }
  .card-interactive { transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out); }
  .card-interactive:hover { transform: translateY(calc(-1 * var(--space-1))); box-shadow: var(--shadow-2); }
  .card-interactive:focus-within { box-shadow: var(--shadow-focus); }
  .card-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }

  /* ---------- Badge / Chip / Tag (semantic tints via color-mix from a var) ---------- */
  .badge {
    display: inline-flex; align-items: center; gap: var(--space-1);
    padding: var(--space-1) var(--space-2); font-size: var(--text-xs);
    font-weight: var(--font-weight-medium); border-radius: var(--radius-full);
    background: var(--color-surface-2); color: var(--color-fg);
  }
  .badge-success {
    background: color-mix(in srgb, var(--color-success) 14%, transparent);
    color: var(--color-success-fg);
  }
  .badge-accent {
    background: color-mix(in srgb, var(--color-accent) 14%, transparent);
    color: var(--color-accent);
  }

  /* ---------- Alert / Callout (role=status|alert) ---------- */
  .alert {
    display: flex; gap: var(--space-3); padding: var(--space-4);
    border: var(--bw-1) solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-surface); color: var(--color-fg);
  }
  .alert-success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success-fg); }

  /* ---------- Accordion (native <details>/<summary>, zero-JS) ---------- */
  .accordion { border: var(--bw-1) solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
  .accordion > summary {
    cursor: pointer; padding: var(--space-3) var(--space-4);
    font-weight: var(--font-weight-medium); list-style: none;
    display: flex; justify-content: space-between; align-items: center;
  }
  .accordion > summary::-webkit-details-marker { display: none; }
  .accordion > summary::after {
    content: '+'; color: var(--color-fg-muted);
    transition: transform var(--dur-base) var(--ease-out);
  }
  .accordion[open] > summary::after { content: '\2212'; } /* minus */
  .accordion .accordion-body { padding: 0 var(--space-4) var(--space-4); color: var(--color-fg-muted); }

  /* ---------- Skeleton (shimmer; reduce-motion pulse fallback) ---------- */
  .skeleton {
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--skeleton-base), var(--skeleton-shimmer), var(--skeleton-base));
    background-size: 200% 100%;
    animation: ds-shimmer var(--skeleton-duration) ease-in-out infinite;
  }
  @keyframes ds-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
  @media (prefers-reduced-motion: reduce) {
    .skeleton { animation: ds-pulse var(--skeleton-duration) ease-in-out infinite; background: var(--skeleton-base); }
  }
  @keyframes ds-pulse { 0%, 100% { opacity: 1; } 50% { opacity: var(--opacity-muted); } }
}

/* Self-hosted, same files as the landing (no Google hotlink). Served under /portal. */
@font-face { font-family: "Lora"; src: url("/portal/fonts/Lora-VariableFont_wght.ttf") format("truetype-variations"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Lora"; src: url("/portal/fonts/Lora-Italic-VariableFont_wght.ttf") format("truetype-variations"); font-weight: 400 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Marcellus"; src: url("/portal/fonts/Marcellus-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }

/* kairana-tones.css — section tones, textures and grain (brandbook p. 12 "Combinación de fondos"), shared by the
   landing (web/) and the portal (kairana-portal/). Token values live in tokens.css (.tone-*); here they are painted.
   --shadow-focus is composed from other tokens, so it is declared again or it would keep the :root colours.
   Texture strength matches p. 12 (measured: silk ≈3–5%, walnut ≈4%).
   Each app sets the texture files (--tex-seda, --tex-seda-espejo, --tex-nogal), because the landing serves them
   under /textures/ and the portal under /portal/textures/. Unlayered, like the rules it replaced in both apps. */
.tone-negro, .tone-marron, .tone-beige, .tone-marfil {
  background-color: var(--color-bg); color: var(--color-fg);
  --shadow-focus: 0 0 0 var(--ring-offset) var(--color-bg), 0 0 0 calc(var(--ring-offset) + var(--ring-width)) var(--color-ring);
}
.tex-seda {         /* silk ~2.5% (highlights are near-white, so it needs less) */
  background:
    linear-gradient(color-mix(in srgb, var(--color-bg) 97.5%, transparent), color-mix(in srgb, var(--color-bg) 97.5%, transparent)),
    var(--tex-seda) center / cover var(--color-bg);
}
.tex-seda-espejo {  /* mirrored silk ~1.5%: folds run the other way so the FAQ doesn't echo the hero */
  background:
    linear-gradient(color-mix(in srgb, var(--color-bg) 98.5%, transparent), color-mix(in srgb, var(--color-bg) 98.5%, transparent)),
    var(--tex-seda-espejo) center / cover var(--color-bg);
}
.tex-nogal {        /* walnut ~5% */
  background:
    linear-gradient(color-mix(in srgb, var(--color-bg) 95%, transparent), color-mix(in srgb, var(--color-bg) 95%, transparent)),
    var(--tex-nogal) center / cover var(--color-bg);
}

/* Subtle film grain over dark fields */
.grain::after {
  content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.09; mix-blend-mode: overlay; /* also dithers gradient banding on the dark grounds */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Inputs: boundary >=3:1 in every tone (WCAG 1.4.11) */
.input, .textarea { border-color: var(--color-border-strong); }

/* Kairana portal — the landing's identity (brandbook p. 12 pairings), token-driven, no literal brand hex.
   Ritual moments (sign-in, unlock) = Negro + silk; the library = Negro band + Marrón cards;
   Ana's CMS = flat Marfil with ocre (a working tool). */

/* Border-box everywhere (the landing gets this from Tailwind preflight; the portal has no Tailwind). */
:where(*, *::before, *::after) { box-sizing: border-box; }
:root { --font-numeric: "Quiche Sans", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; }
:where(h1, h2, h3) { font-family: var(--font-display); font-weight: var(--font-weight-regular); letter-spacing: var(--tracking-tight); margin: 0; }
body { font-family: var(--font-body); font-size: var(--text-base); line-height: var(--leading-normal); min-height: 100svh; display: flex; flex-direction: column; }
main { flex: 1; }
/* In the base layer, so the .btn colours (components layer) win on <a class="btn">. */
@layer base { a { color: inherit; } a.btn { text-decoration: none; } }
[hidden] { display: none !important; }

/* ---- Tones, textures and grain: ../design-system/styles/kairana-tones.css (shared with the landing).
   The texture files, as served under /portal: ---- */
:root { --tex-seda: url("/portal/textures/seda.webp"); --tex-nogal: url("/portal/textures/nogal.webp"); }

/* ---- Brand marks: SVG as a mask, painted in the tone's text colour ---- */
.mark { display: block; background: currentColor; -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat; }
.mark-isotipo { --src: url("/portal/logos/kairana-isotipo.svg"); width: 64px; aspect-ratio: 180.22 / 203.24; margin-inline: auto; }
.mark-wordmark { --src: url("/portal/logos/kairana-wordmark-soulcare.svg"); width: 128px; aspect-ratio: 429.44 / 109.85; }

/* ---- Shell ---- */
/* Same container as the landing (web/src/styles/kairana.css): max 1280, 24 px gutter on phones, up to 64 px. */
.wrap { width: 100%; max-width: var(--container-xl); margin-inline: auto; padding-inline: clamp(var(--space-gutter), 5vw, var(--space-8)); box-sizing: border-box; }
.portal-header { position: relative; z-index: 2; border-bottom: var(--bw-1) solid var(--color-border); }
.portal-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 64px; }
.portal-header nav { display: flex; align-items: center; gap: var(--space-4); }
.portal-footer { position: relative; z-index: 2; border-top: var(--bw-1) solid var(--color-border); padding-block: var(--space-5); font-size: var(--text-sm); color: var(--color-fg-muted); }
.portal-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
@media (max-width: 520px) { .portal-footer .wrap { display: grid; grid-template-columns: 1fr 1fr; } }
.portal-footer a { color: var(--color-fg-muted); text-decoration: none; display: inline-block; padding-block: var(--space-1); }
.portal-footer a:hover { color: var(--color-fg); }

/* Language switch + quiet text buttons */
.lang-switch { display: flex; gap: var(--space-1); font-size: var(--text-sm); }
.lang-switch button, .text-btn { background: none; border: 0; font: inherit; font-size: var(--text-sm); color: var(--color-fg-muted);
  min-height: var(--tap-min); padding-inline: var(--space-2); cursor: pointer; border-radius: var(--radius-sm); }
.lang-switch button[aria-current] { color: var(--color-fg); text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--color-accent); }
.lang-switch button:hover, .text-btn:hover { color: var(--color-fg); }

/* ---- Ritual frame: sign-in, unlock (centred, generous space, logo above) ---- */
.ritual { position: relative; z-index: 2; display: grid; place-items: center; padding-block: var(--space-8); flex: 1; }
main:has(> .ritual) { display: flex; flex-direction: column; }
.ritual-inner { width: 100%; max-width: 26rem; text-align: center; display: grid; gap: var(--space-5); }
.ritual .mark-isotipo { margin-bottom: var(--space-4); color: var(--color-accent-hover); }
.ritual h1 { font-size: clamp(var(--text-2xl), 7vw, var(--text-3xl)); line-height: var(--leading-snug); }
.lead { color: var(--color-fg-muted); font-size: var(--text-lg); margin: 0; }
.ritual form, .stack { display: grid; gap: var(--space-4); text-align: left; }
.ritual .btn { width: 100%; }
.note { font-size: var(--text-sm); color: var(--color-fg-muted); margin: 0; }
.error-text { font-size: var(--text-sm); color: var(--color-error-fg); margin: 0; min-height: 1em; }
.code-chip { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; letter-spacing: 0.12em; font-size: var(--text-sm);
  display: inline-block; padding: var(--space-2) var(--space-4); border: var(--bw-1) solid var(--color-border-strong); border-radius: var(--radius-full); color: var(--color-fg-muted); }
.ornament-rule { width: 48px; height: 1px; background: var(--color-accent); border: 0; margin: 0 auto; }

/* ---- Library: the usual audio-app layout (cover list -> full-screen player -> mini player) ---- */
.library-head { position: relative; z-index: 2; padding-block: var(--space-8) var(--space-6); text-align: center; }
.library-head .wrap { display: grid; gap: var(--space-5); justify-items: center; }
.library-head .mark-isotipo { width: 52px; color: var(--color-accent-hover); }
.library-head h1 { font-size: clamp(var(--text-3xl), 6vw, var(--text-4xl)); line-height: var(--leading-tight); }
.library { position: relative; z-index: 2; max-width: 40rem; padding-block: var(--space-5) var(--space-7); }
.link-grow { color: var(--color-accent-hover); text-decoration: none; background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat; background-position: 0 100%; background-size: 0 1px; transition: background-size var(--dur-base) var(--ease-out); }
.link-grow:hover { background-size: 100% 1px; }
.empty { text-align: center; max-width: 30rem; margin: 0 auto; display: grid; gap: var(--space-4); color: var(--color-fg-muted); }

.art { display: block; flex: none; background: var(--color-surface) center / cover no-repeat; border-radius: var(--radius-md); }
.tracks { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.track { width: 100%; display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3); margin: 0; border: 0; border-radius: var(--radius-lg);
  background: transparent; color: var(--color-fg); text-align: left; font: inherit; cursor: pointer; transition: background var(--dur-fast) var(--ease-out); }
button.track:hover, .track.is-current { background: var(--color-surface); }
.track .art { width: 64px; height: 64px; }
.track-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.track-title { font-family: var(--font-display); font-size: var(--text-lg); line-height: var(--leading-snug); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track.is-current .track-title { color: var(--color-accent-hover); }
.track-meta { font-family: var(--font-numeric); font-size: var(--text-sm); color: var(--color-fg-subtle); min-height: 1.4em; }
.track-play { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-full);
  border: var(--bw-1) solid var(--color-border-strong); color: var(--color-fg); transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.track-play svg { width: 16px; height: 16px; }
button.track:hover .track-play, .track.is-current .track-play { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.track.is-locked { cursor: default; }
.track.is-locked .art { filter: grayscale(0.6) brightness(0.5); }
.track.is-locked .track-meta { font-family: var(--font-body); }

/* Shared controls */
.play-toggle { border: 0; cursor: pointer; display: grid; place-items: center; border-radius: var(--radius-full);
  background: var(--color-primary); color: var(--color-on-primary); transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.play-toggle:hover { background: var(--color-primary-hover); }
.play-toggle:active { transform: scale(0.96); }
.skip { min-width: 52px; min-height: 52px; border-radius: var(--radius-full); background: transparent; border: 0; padding: 0;
  color: var(--color-fg); cursor: pointer; display: grid; place-items: center; }
.skip svg { width: 36px; height: 36px; }
.skip text { font-family: var(--font-numeric); font-size: 7.5px; fill: currentColor; }
.skip:hover { color: var(--color-accent-hover); }
.player-times { display: flex; justify-content: space-between; font-family: var(--font-numeric); font-variant-numeric: tabular-nums;
  font-size: var(--text-xs); color: var(--color-fg-subtle); }

/* Mini player: sticks to the bottom of the screen while browsing and stops above the footer */
main:has(.mini) { display: flex; flex-direction: column; }
.mini { position: sticky; z-index: var(--z-sticky); bottom: max(var(--space-3), env(safe-area-inset-bottom)); margin: auto auto var(--space-5);
  width: min(40rem - 2 * var(--space-gutter), calc(100% - 2 * var(--space-gutter))); display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); border-radius: var(--radius-lg); overflow: hidden;
  background: var(--color-surface-2); border: var(--bw-1) solid var(--color-border); box-shadow: var(--shadow-3); }
.mini[hidden] { display: none; }
.mini-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-3); background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.mini .art { width: 44px; height: 44px; border-radius: var(--radius-sm); }
.mini-title { font-family: var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-play { width: 44px; height: 44px; flex: none; }
.mini-play svg { width: 16px; height: 16px; }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--color-accent-hover); transform: scaleX(0); transform-origin: left; }

/* Now playing: full screen, the cover large, blurred cover behind */
.now { position: fixed; inset: 0; z-index: var(--z-overlay); overflow: auto; display: grid; place-items: center; padding: var(--space-5) var(--space-gutter); }
.now[hidden] { display: none; }
.now-bg { position: fixed; inset: -10%; background: center / cover no-repeat; filter: blur(48px) saturate(0.9); opacity: 0.3; }
.now::before { content: ""; position: fixed; inset: 0; background: linear-gradient(color-mix(in srgb, var(--color-bg) 55%, transparent), var(--color-bg) 85%); }
.now-inner { position: relative; width: 100%; max-width: 24rem; display: grid; gap: var(--space-5); }
.now-close { justify-self: start; width: 44px; height: 44px; margin-left: calc(-1 * var(--space-2)); display: grid; place-items: center; border: 0; border-radius: var(--radius-full); background: transparent; color: var(--color-fg); cursor: pointer; }
.now-close svg { width: 28px; height: 28px; }
.now-art { width: 100%; aspect-ratio: 1; border-radius: var(--radius-lg); box-shadow: var(--shadow-3); }
.now-text { display: grid; gap: var(--space-2); }
.now-text h2 { font-size: var(--text-3xl); line-height: var(--leading-snug); }
.now-desc { margin: 0; color: var(--color-fg-muted); }
.now-note:empty { display: none; }
.now-seek { display: grid; gap: var(--space-1); }
.now-controls { display: flex; align-items: center; justify-content: center; gap: var(--space-6); }
.now-play { width: 72px; height: 72px; }
.now-play svg { width: 24px; height: 24px; }
@media (max-height: 700px) { .now-art { max-width: 15rem; justify-self: center; } }
:root.now-open { overflow: hidden; }

/* Seek bar: a hairline in the tone's border colour, an ocre thumb (no white browser track). */
.now input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; min-height: var(--tap-min); margin: 0; background: transparent; cursor: pointer; }
.now input[type="range"]::-webkit-slider-runnable-track { height: 2px; border-radius: var(--radius-full);
  background: linear-gradient(to right, var(--color-accent-hover) var(--pct, 0%), var(--color-border-strong) var(--pct, 0%)); }
.now input[type="range"]::-moz-range-track { height: 2px; background: var(--color-border-strong); border-radius: var(--radius-full); }
.now input[type="range"]::-moz-range-progress { height: 2px; background: var(--color-accent-hover); }
.now input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: var(--color-accent-hover); border: 0; }
.now input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--color-accent-hover); border: 0; }
.now input[type="range"]:focus-visible { box-shadow: none; }
.now input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--shadow-focus); }
.now input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: var(--shadow-focus); }

/* ---- Admin (Marfil, flat) ---- */
.admin { position: relative; z-index: 2; padding-block: var(--space-7) var(--space-8); }
.admin h1 { font-size: var(--text-3xl); margin-bottom: var(--space-6); }
.admin-grid { display: grid; gap: var(--space-7); }
@media (min-width: 960px) { .admin-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.admin-list { list-style: none; margin: 0; padding: 0; border-top: var(--bw-1) solid var(--color-border); }
.admin-item { display: grid; gap: var(--space-3); padding-block: var(--space-5); border-bottom: var(--bw-1) solid var(--color-border); }
.admin-item h2 { font-size: var(--text-xl); }
.admin-item .badge { justify-self: start; }
.admin-item .row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.admin-form { display: grid; gap: var(--space-5); }
.admin-form h2 { font-size: var(--text-2xl); }
.upload { display: grid; gap: var(--space-2); padding: var(--space-4); border: var(--bw-1) dashed var(--color-border-strong); border-radius: var(--radius-md); }
.upload .row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.upload label.btn { cursor: pointer; }
.upload input:focus-visible + label.btn { outline: none; box-shadow: var(--shadow-focus); }
.upload input:disabled + label.btn { opacity: 0.5; pointer-events: none; }
.upload progress { width: 100%; accent-color: var(--color-accent); }
.ok-text { color: var(--color-success-fg); font-size: var(--text-sm); }

/* ---- Admin: "give access to an email" (2026-10-14) ---- */
.admin-access { margin-top: var(--space-8); display: grid; gap: var(--space-5); max-width: 40rem; }
.admin-access h2 { font-size: var(--text-2xl); }
.access-email { margin: 0; overflow-wrap: anywhere; }


/* ---- Admin: "are you sure" (native <dialog>). Sized to its text; on phones the buttons stack full width, the
   destructive one at the bottom, so no button ever sits alone on a second row (rubric 3.2). ---- */
.confirm { width: min(32rem, calc(100% - 2 * var(--space-4))); max-width: none; padding: var(--space-6); border: var(--bw-1) solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3); display: grid; gap: var(--space-4); }
.confirm:not([open]) { display: none; }
.confirm::backdrop { background: rgba(14, 14, 15, 0.55); }
.confirm h2 { font-size: var(--text-2xl); line-height: var(--leading-snug); text-wrap: balance; }
.confirm p { margin: 0; text-wrap: pretty; }
.confirm-actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-2); }
@media (max-width: 520px) {
  .confirm { padding: var(--space-5); }
  .confirm-actions { flex-direction: column; align-items: stretch; }
  .confirm-actions .btn { width: 100%; height: 48px; }
}

/* ---- Admin: one message line at the bottom of the screen for every action (rubric 1.2, 1.3) ---- */
.toast-region { background: none; position: fixed; inset-inline: 0; bottom: max(var(--space-5), env(safe-area-inset-bottom)); z-index: var(--z-toast);
  display: grid; justify-items: center; padding-inline: var(--space-4); pointer-events: none; }
/* Clicks pass through a message to the page under it; only a message with a link takes them. */
.toast { pointer-events: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); max-width: 34rem; padding: var(--space-3) var(--space-5) var(--space-3) var(--space-3);
  background: var(--color-fg); color: var(--color-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); font-size: var(--text-base); line-height: var(--leading-snug);
  animation: toast-in 200ms ease-out; }
.toast > span:not(.toast-icon) { flex: 1 1 14rem; }
.toast:has(a) { pointer-events: auto; }
.toast a { margin-inline-start: auto; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.toast-icon { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 15px; font-weight: 700; }
.toast-ok .toast-icon { background: var(--color-success-bg); color: var(--color-success-fg); }
.toast-error .toast-icon { background: var(--color-error); color: var(--color-bg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---- Admin: a failed save, inside the form next to its button ---- */
.form-error { margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm);
  background: color-mix(in srgb, var(--color-error) 10%, transparent); color: var(--color-error-fg); border: var(--bw-1) solid color-mix(in srgb, var(--color-error) 35%, transparent); }
.admin .btn[aria-busy="true"] { cursor: progress; opacity: 0.75; }

/* ---- Admin on phones: every control at least 44 px high (rubric 6.2) ---- */
@media (max-width: 520px) { .admin .btn-sm { height: 44px; } }

/* ---- Admin: states readable at a glance (2026-10-14 UX pass) ---- */
.badge-draft { background: transparent; border: var(--bw-1) dashed var(--color-border-strong); color: var(--color-fg-muted); }
.btn-danger-text { color: var(--color-error-fg); }
.btn-danger-text:hover { background: color-mix(in srgb, var(--color-error) 10%, transparent); }
.admin-panel { scroll-margin-top: var(--space-5); }
.admin-form .row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.admin-grid:not(:has([data-admin-panel])) { grid-template-columns: minmax(0, 40rem); }
