/* ============================================================
   Cascalho — Selectable theme families (skins)
   Loaded AFTER tokens.css so these override the base by source order.

   Model: 5 FAMILIES × 2 SCHEMES (light/dark).
     - data-theme        = family   (editorial | midnight | calm | warm | terminal)
     - data-color-scheme = light|dark
   The header sun/moon toggles the SCHEME within the current family; the
   Aparência picker chooses the FAMILY (keeping the current scheme).

   Editorial needs NO block here: editorial-light = tokens.css :root,
   editorial-dark = tokens.css [data-color-scheme="dark"] (the universal
   dark base). The other four families override only their deltas, per
   scheme. Dark variants inherit the dark shadows + ledger-origin palette
   from the editorial-dark base.

   Selectors are :root[data-theme="x"][data-color-scheme="y"] (specificity
   0,3,0) so they beat both the base (0,1,0) and the OS-dark fallback.
   ============================================================ */

/* ============================ MIDNIGHT — private banking, gold ============================ */
:root[data-theme="midnight"][data-color-scheme="light"] {
  --primary:#9c7d2e; --primary-dark:#7d6323; --primary-500:#b08f3a; --primary-600:#9c7d2e; --primary-700:#7d6323;
  --primary-50:#f7f1df; --primary-100:#efe5c6; --primary-accent:#3f6f5c; --accent-gold:#bf9b3a; --accent-gold-50:#f7f1df;
  --secondary:#b06a4b; --secondary-dark:#925338; --secondary-50:#f6eae3;
  --person1:#9c7d2e; --person1-bg:#f3ecd8; --person2:#b06a4b; --person2-bg:#f6eae3;
  --success:#3f6f5c; --success-bg:#e8f0eb; --success-text:#274b3d;
  --danger:#a8443a; --danger-bg:#f6e7e5; --danger-text:#6e2a23;
  --warning:#9c7d2e; --warning-bg:#f7f1df; --warning-text:#5e4a14;
  --info:#3a6b8a; --info-bg:#e8eff4; --info-text:#23445a;
  --surface-app:#f1ebdd; --surface:#faf5ea; --surface-elevated:#fffdf8; --surface-muted:#ece2cd;
  --surface-hero:#16201c; --surface-hero-text:#e8d49a; --surface-overlay:rgba(28,24,18,.5);
  --surface-tint-green:#ecf2ee; --surface-tint-terra:#f6eae3; --surface-tint-gold:#f7f1df;
  --text:#2a2620; --text-muted:#6a6254; --text-subtle:#756e5f; --text-link:#7d6323;
  --border:#e3d9c3; --border-strong:#d2c5a8; --border-focus:#9c7d2e;
  --gray-50:#faf5ea; --gray-100:#ece2cd; --gray-200:#e3d9c3; --gray-300:#d2c5a8;
  --dark:#2a2620; --gray:#6a6254; --light:#ece2cd;
  --font-display:'Cormorant Garamond','Fraunces',Georgia,serif;
  --font-sans:'Outfit','Hanken Grotesk',-apple-system,sans-serif;
  --font-number:'Cormorant Garamond','Fraunces',Georgia,serif;
  --display-tracking:0;
}
:root[data-theme="midnight"][data-color-scheme="dark"] {
  --primary:#d4b568; --primary-dark:#b89640; --primary-500:#d4b568; --primary-600:#c8a951; --primary-700:#b89640;
  --primary-50:rgba(212,181,104,.10); --primary-100:rgba(212,181,104,.18);
  --primary-accent:#7fb39a; --accent-gold:#e8d49a; --accent-gold-50:rgba(232,212,154,.12);
  --secondary:#d19a7f; --secondary-dark:#b87a5c; --secondary-50:rgba(209,154,127,.12);
  --person1:#d4b568; --person1-bg:rgba(212,181,104,.14); --person2:#d19a7f; --person2-bg:rgba(209,154,127,.14);
  --success:#7fb39a; --success-bg:rgba(127,179,154,.14); --success-text:#a7d0bd;
  --danger:#d18a8a; --danger-bg:rgba(209,138,138,.16); --danger-text:#e6b3b3;
  --warning:#d4b568; --warning-bg:rgba(212,181,104,.14); --warning-text:#e8d49a;
  --info:#82a0be; --info-bg:rgba(130,160,190,.14); --info-text:#aac3da;
  --surface-app:#0b0f0e; --surface:#0f1513; --surface-elevated:#141b18; --surface-muted:#161d1a;
  --surface-hero:#0a1f17; --surface-hero-text:#e8d49a; --surface-overlay:rgba(0,0,0,.72);
  --surface-tint-green:#0e1d16; --surface-tint-terra:#1d1510; --surface-tint-gold:#1a160e;
  --text:#ece7da; --text-muted:#9a9588; --text-subtle:#817f76; --text-link:#e8d49a;
  --border:rgba(212,181,104,.16); --border-strong:rgba(212,181,104,.30); --border-focus:#d4b568;
  --gray-50:#0f1513; --gray-100:#141b18; --gray-200:rgba(255,255,255,.08); --gray-300:rgba(255,255,255,.14);
  --dark:#ece7da; --gray:#9a9588; --light:#141b18;
  --font-display:'Cormorant Garamond','Fraunces',Georgia,serif;
  --font-sans:'Outfit','Hanken Grotesk',-apple-system,sans-serif;
  --font-number:'Cormorant Garamond','Fraunces',Georgia,serif;
  --display-tracking:0;
}

/* ============================ CALM — airy, soft green ============================ */
:root[data-theme="calm"][data-color-scheme="light"] {
  --primary:#0e7c5a; --primary-dark:#0a5d44; --primary-500:#0e7c5a; --primary-600:#0c6b4e; --primary-700:#0a5d44;
  --primary-50:#eef7f3; --primary-100:#dcefe6; --primary-accent:#9ccdb9; --accent-gold:#caa75a; --accent-gold-50:#f7efdc;
  --secondary:#d96a55; --secondary-dark:#bf5340; --secondary-50:#fbeae6;
  --person1:#0e7c5a; --person1-bg:#e6f3ee; --person2:#d96a55; --person2-bg:#fbeae6;
  --success:#1f7a3d; --success-bg:#e6f3ee; --success-text:#0a5d44;
  --danger:#c2533f; --danger-bg:#fbeae6; --danger-text:#8a3322;
  --warning:#b5891f; --warning-bg:#f7efdc; --warning-text:#6b4e09;
  --info:#3a7ca5; --info-bg:#e7f0f5; --info-text:#1f455c;
  --surface-app:#fbfbf9; --surface:#ffffff; --surface-elevated:#ffffff; --surface-muted:#f4f5f2;
  --surface-hero:#0e7c5a; --surface-hero-text:#eafaf3; --surface-overlay:rgba(28,29,26,.45);
  --surface-tint-green:#eef6f2; --surface-tint-terra:#fbeae6; --surface-tint-gold:#f7efdc;
  --text:#1c1d1a; --text-muted:#5b5f59; --text-subtle:#737771; --text-link:#0e7c5a;
  --border:#ecedea; --border-strong:#dcdedb; --border-focus:#0e7c5a;
  --gray-50:#fbfbf9; --gray-100:#f4f5f2; --gray-200:#ecedea; --gray-300:#dcdedb;
  --dark:#1c1d1a; --gray:#5b5f59; --light:#f4f5f2;
  --font-display:'Fraunces',Georgia,serif; --font-sans:'Figtree','Inter',-apple-system,sans-serif; --font-number:'Fraunces',Georgia,serif;
  --r-sm:10px; --r-md:14px; --r-lg:18px; --r-xl:22px; --r-2xl:28px;
}
:root[data-theme="calm"][data-color-scheme="dark"] {
  --primary:#5ec4a0; --primary-dark:#46a888; --primary-500:#5ec4a0; --primary-600:#4fb593; --primary-700:#46a888;
  --primary-50:rgba(94,196,160,.12); --primary-100:rgba(94,196,160,.20); --primary-accent:#9fdcc6; --accent-gold:#d8b873;
  --secondary:#e0907c; --secondary-dark:#c9755f; --secondary-50:rgba(224,144,124,.14);
  --person1:#5ec4a0; --person1-bg:rgba(94,196,160,.14); --person2:#e0907c; --person2-bg:rgba(224,144,124,.14);
  --success:#4ade80; --success-bg:rgba(74,222,128,.14); --success-text:#9fdcc6;
  --danger:#e0907c; --danger-bg:rgba(224,144,124,.16); --danger-text:#f0b6a8;
  --warning:#d8b873; --warning-bg:rgba(216,184,115,.14); --warning-text:#ecd29a;
  --info:#7fb0d4; --info-bg:rgba(127,176,212,.14); --info-text:#aacce6;
  --surface-app:#12181a; --surface:#1a2123; --surface-elevated:#222a2c; --surface-muted:#222a2c;
  --surface-hero:#0e7c5a; --surface-hero-text:#eafaf3; --surface-overlay:rgba(0,0,0,.6);
  --surface-tint-green:#15241e; --surface-tint-terra:#241a17; --surface-tint-gold:#232014;
  --text:#e8ece9; --text-muted:#9aa6a1; --text-subtle:#818b87; --text-link:#9fdcc6;
  --border:#293133; --border-strong:#3a4446; --border-focus:#5ec4a0;
  --gray-50:#1a2123; --gray-100:#222a2c; --gray-200:#293133; --gray-300:#3a4446;
  --dark:#e8ece9; --gray:#9aa6a1; --light:#222a2c;
  --font-display:'Fraunces',Georgia,serif; --font-sans:'Figtree','Inter',-apple-system,sans-serif; --font-number:'Fraunces',Georgia,serif;
  --r-sm:10px; --r-md:14px; --r-lg:18px; --r-xl:22px; --r-2xl:28px;
}

/* ============================ WARM — rounded, partner colors ============================ */
:root[data-theme="warm"][data-color-scheme="light"] {
  --primary:#2f9e7d; --primary-dark:#26876a; --primary-500:#2f9e7d; --primary-600:#2a8f71; --primary-700:#26876a;
  --primary-50:#e3f5ee; --primary-100:#cdeee1; --primary-accent:#8fd4bd; --accent-gold:#f4b740; --accent-gold-50:#fdf3dc;
  --secondary:#ef8354; --secondary-dark:#e06a39; --secondary-50:#fdeee5;
  --person1:#2f9e7d; --person1-bg:#e3f5ee; --person2:#ef8354; --person2-bg:#fdeee5;
  --success:#1f7a3d; --success-bg:#e3f5ee; --success-text:#1f6b54;
  --danger:#e9573f; --danger-bg:#fde7e2; --danger-text:#a3331f;
  --warning:#e0a020; --warning-bg:#fdf3dc; --warning-text:#8a6310;
  --info:#5aa9e6; --info-bg:#e7f1fb; --info-text:#2a6491;
  --surface-app:#fff7ee; --surface:#ffffff; --surface-elevated:#ffffff; --surface-muted:#fdf0e2;
  --surface-hero:#2f9e7d; --surface-hero-text:#ffffff; --surface-overlay:rgba(58,46,38,.5);
  --surface-tint-green:#e3f5ee; --surface-tint-terra:#fdeee5; --surface-tint-gold:#fdf3dc;
  --text:#3a2e26; --text-muted:#7d6e62; --text-subtle:#7f746a; --text-link:#2f9e7d;
  --border:#f0e4d6; --border-strong:#e6d6c4; --border-focus:#2f9e7d;
  --gray-50:#fff7ee; --gray-100:#fdf0e2; --gray-200:#f0e4d6; --gray-300:#e6d6c4;
  --dark:#3a2e26; --gray:#7d6e62; --light:#fdf0e2;
  --font-display:'Baloo 2','Fraunces',cursive; --font-sans:'Nunito','Inter',-apple-system,sans-serif; --font-number:'Baloo 2','Nunito',sans-serif;
  --r-xs:8px; --r-sm:12px; --r-md:16px; --r-lg:22px; --r-xl:28px; --r-2xl:32px;
}
:root[data-theme="warm"][data-color-scheme="dark"] {
  --primary:#46c79f; --primary-dark:#37b08a; --primary-500:#46c79f; --primary-600:#3fbb95; --primary-700:#37b08a;
  --primary-50:rgba(70,199,159,.12); --primary-100:rgba(70,199,159,.20); --primary-accent:#8fe0c8; --accent-gold:#f4b740;
  --secondary:#f5926a; --secondary-dark:#e07a52; --secondary-50:rgba(245,146,106,.14);
  --person1:#46c79f; --person1-bg:rgba(70,199,159,.16); --person2:#f5926a; --person2-bg:rgba(245,146,106,.16);
  --success:#4ade80; --success-bg:rgba(74,222,128,.14); --success-text:#8fe0c8;
  --danger:#f0795c; --danger-bg:rgba(240,121,92,.16); --danger-text:#f7a892;
  --warning:#f4b740; --warning-bg:rgba(244,183,64,.14); --warning-text:#f7cd78;
  --info:#6fb6e6; --info-bg:rgba(111,182,230,.14); --info-text:#a3d0f0;
  --surface-app:#1c1610; --surface:#261f17; --surface-elevated:#2e261d; --surface-muted:#2e261d;
  --surface-hero:#2f9e7d; --surface-hero-text:#ffffff; --surface-overlay:rgba(0,0,0,.6);
  --surface-tint-green:#16241d; --surface-tint-terra:#2a1d14; --surface-tint-gold:#2a2310;
  --text:#f2e9dd; --text-muted:#b6a897; --text-subtle:#928678; --text-link:#8fe0c8;
  --border:#3a3026; --border-strong:#4c4032; --border-focus:#46c79f;
  --gray-50:#261f17; --gray-100:#2e261d; --gray-200:#3a3026; --gray-300:#4c4032;
  --dark:#f2e9dd; --gray:#b6a897; --light:#2e261d;
  --font-display:'Baloo 2','Fraunces',cursive; --font-sans:'Nunito','Inter',-apple-system,sans-serif; --font-number:'Baloo 2','Nunito',sans-serif;
  --r-xs:8px; --r-sm:12px; --r-md:16px; --r-lg:22px; --r-xl:28px; --r-2xl:32px;
}

/* ============================ TERMINAL — mono, tight ============================ */
:root[data-theme="terminal"][data-color-scheme="light"] {
  --primary:#1f8a5b; --primary-dark:#156b46; --primary-500:#1f8a5b; --primary-600:#1a7a50; --primary-700:#156b46;
  --primary-50:#e6f4ec; --primary-100:#d0ebdc; --primary-accent:#4a8fc0; --accent-gold:#b97e2e; --accent-gold-50:#f6eeda;
  --secondary:#c07a2e; --secondary-dark:#a36322; --secondary-50:#f6eeda;
  --person1:#1f8a5b; --person1-bg:#e6f4ec; --person2:#c07a2e; --person2-bg:#f6eeda;
  --success:#1f7a3d; --success-bg:#e6f4ec; --success-text:#135838;
  --danger:#c0453f; --danger-bg:#f6e7e6; --danger-text:#7e2823;
  --warning:#a8791f; --warning-bg:#f6eeda; --warning-text:#5e440f;
  --info:#2f6f9c; --info-bg:#e6eff5; --info-text:#1c4259;
  --surface-app:#eef0ec; --surface:#ffffff; --surface-elevated:#ffffff; --surface-muted:#e6e9e3;
  --surface-hero:#10241b; --surface-hero-text:#7fd3ab; --surface-overlay:rgba(20,26,20,.5);
  --surface-tint-green:#e6f4ec; --surface-tint-terra:#f6eeda; --surface-tint-gold:#f6eeda;
  --text:#16201a; --text-muted:#566056; --text-subtle:#6f786f; --text-link:#156b46;
  --border:#dde1da; --border-strong:#c8cdc2; --border-focus:#1f8a5b;
  --gray-50:#ffffff; --gray-100:#e6e9e3; --gray-200:#dde1da; --gray-300:#c8cdc2;
  --dark:#16201a; --gray:#566056; --light:#e6e9e3;
  --font-display:'JetBrains Mono',ui-monospace,monospace; --font-number:'JetBrains Mono',ui-monospace,monospace; --font-sans:'Inter',-apple-system,sans-serif;
  --r-xs:2px; --r-sm:3px; --r-md:4px; --r-lg:6px; --r-xl:8px; --r-2xl:10px;
}
:root[data-theme="terminal"][data-color-scheme="dark"] {
  --primary:#3fb27f; --primary-dark:#2f9168; --primary-500:#3fb27f; --primary-600:#379c70; --primary-700:#2f9168;
  --primary-50:rgba(63,178,127,.10); --primary-100:rgba(63,178,127,.18);
  --primary-accent:#5aa9e6; --accent-gold:#e0a458; --accent-gold-50:rgba(224,164,88,.12);
  --secondary:#e0a458; --secondary-dark:#c98a3e; --secondary-50:rgba(224,164,88,.12);
  --person1:#3fb27f; --person1-bg:rgba(63,178,127,.14); --person2:#e0a458; --person2-bg:rgba(224,164,88,.14);
  --success:#4ade80; --success-bg:rgba(63,178,127,.14); --success-text:#7fd3ab;
  --danger:#e06c75; --danger-bg:rgba(224,108,117,.16); --danger-text:#f0a3a9;
  --warning:#e0a458; --warning-bg:rgba(224,164,88,.14); --warning-text:#f0c690;
  --info:#5aa9e6; --info-bg:rgba(90,169,230,.14); --info-text:#9ccaf0;
  --surface-app:#0d1117; --surface:#141a23; --surface-elevated:#1a212c; --surface-muted:#1a212c;
  --surface-hero:#0a0e14; --surface-hero-text:#e0a458; --surface-overlay:rgba(0,0,0,.75);
  --surface-tint-green:#10241b; --surface-tint-terra:#241a10; --surface-tint-gold:#221c10;
  --text:#d6dde6; --text-muted:#7c8796; --text-subtle:#7b8492; --text-link:#5aa9e6;
  --border:#232c39; --border-strong:#2d3848; --border-focus:#3fb27f;
  --gray-50:#141a23; --gray-100:#1a212c; --gray-200:#232c39; --gray-300:#2d3848;
  --dark:#d6dde6; --gray:#7c8796; --light:#1a212c;
  --font-display:'JetBrains Mono',ui-monospace,monospace; --font-number:'JetBrains Mono',ui-monospace,monospace; --font-sans:'Inter',-apple-system,sans-serif;
  --r-xs:2px; --r-sm:3px; --r-md:4px; --r-lg:6px; --r-xl:8px; --r-2xl:10px;
}

/* ============================================================
   Theme chooser cards — rendered into #themeChooser (Aparência)
   ============================================================ */
.theme-chooser {
  display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin-top:4px;
}
.theme-card {
  display:flex; flex-direction:column; gap:10px; padding:12px; cursor:pointer; text-align:left;
  background:var(--surface); border:1.5px solid var(--border); border-radius:var(--r-lg);
  transition:transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  font-family:var(--font-sans);
}
.theme-card:hover { transform:translateY(-2px); border-color:var(--primary); box-shadow:var(--shadow-md); }
.theme-card:focus-visible { outline:none; box-shadow:var(--shadow-focus); }
.theme-card.is-active { border-color:var(--primary); box-shadow:0 0 0 1.5px var(--primary); }
.theme-card__swatch {
  height:46px; border-radius:var(--r-md); display:flex; align-items:flex-end; gap:5px; padding:8px; overflow:hidden;
  border:1px solid rgba(0,0,0,.06);
}
.theme-card__swatch > span { width:16px; height:16px; border-radius:50%; box-shadow:0 1px 2px rgba(0,0,0,.25); }
.theme-card__row { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.theme-card__label { font-weight:600; font-size:13px; color:var(--text); }
.theme-card__scheme {
  font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.05em; color:var(--text-subtle);
  padding:2px 7px; border-radius:var(--r-full); background:var(--surface-muted);
}
.theme-card__check { color:var(--primary); opacity:0; transition:opacity var(--dur-fast); flex-shrink:0; }
.theme-card.is-active .theme-card__check { opacity:1; }

/* Claro / Escuro segmented control above the family grid */
.theme-scheme {
  display:inline-flex; gap:4px; padding:4px; margin-bottom:14px;
  background:var(--surface-muted); border:1px solid var(--border); border-radius:var(--r-full);
}
.theme-scheme__btn {
  border:none; cursor:pointer; font-family:var(--font-sans); font-weight:600; font-size:13px;
  color:var(--text-muted); background:transparent; padding:7px 16px; border-radius:var(--r-full);
  transition:background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.theme-scheme__btn.is-on { background:var(--surface-elevated); color:var(--text); box-shadow:var(--shadow-sm); }
.theme-scheme__btn:focus-visible { outline:none; box-shadow:var(--shadow-focus); }
