/* Smile Studio — brand-matched to Oráculo Transparente
   Ink #0A0E1A · Signal #3B82F6 · Mist #F4F6FA · Verify #10B981 */
:root {
  --ink: #0A0E1A; --ink-2: #121829; --signal: #3B82F6; --signal-soft: rgba(59,130,246,.12);
  --mist: #F4F6FA; --hairline: #E2E6EE; --slate: #6B7280; --verify: #10B981; --alert: #F59E0B;
  --text: #0A0E1A; --text-soft: #4b5263; --bg: #ffffff;
  --radius: 14px; --radius-lg: 20px;
  --font-display: "Inter Tight", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --shadow-sm: 0 1px 2px rgba(10,14,26,.04), 0 4px 16px rgba(10,14,26,.05);
  --shadow-md: 0 8px 30px rgba(10,14,26,.08);
}
/* Dark grey theme — toggled via <html data-theme="dark"> (default). */
[data-theme="dark"] {
  color-scheme: dark;
  --ink: #0b0e13; --ink-2: #171b22; --signal: #4b8bf5; --signal-soft: rgba(75,139,245,.16);
  --mist: #15181e; --hairline: #2b313b; --slate: #98a1ae; --verify: #34d399; --alert: #fbbf24;
  --text: #e7eaf0; --text-soft: #aeb6c2; --bg: #1e222a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35), 0 4px 16px rgba(0,0,0,.28);
  --shadow-md: 0 10px 30px rgba(0,0,0,.45);
}
*,*::before,*::after { box-sizing: border-box; }
* { margin: 0; }
body { font-family: var(--font-body); color: var(--text); background: var(--mist); line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, canvas, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; }
h1,h2,h3,h4 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -.02em; font-weight: 700; }
a { color: var(--signal); text-decoration: none; }

.boot { display: grid; place-items: center; min-height: 100vh; color: var(--slate); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .62rem 1.05rem; border-radius: 11px;
  background: var(--ink); color: #fff; font-weight: 600; font-size: .95rem; transition: .15s; }
.btn:hover { background: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--signal); }
.btn.primary:hover { background: #2f6fe0; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--hairline); }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: .42rem .75rem; font-size: .85rem; border-radius: 9px; }
.btn.danger { background: transparent; color: #c0392b; border: 1px solid #f0c9c4; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2238 0%, var(--ink) 60%); }
.auth-card { width: min(100%, 400px); background: var(--bg); color: var(--text); border-radius: var(--radius-lg); padding: 34px; box-shadow: var(--shadow-md); }
.brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.4rem; }
.brand .dot { width: 30px; height: 30px; border-radius: 9px; background: var(--signal);
  display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 700; }
.brand small { color: var(--slate); display: block; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-soft); }
.field input, .field textarea, .field select {
  width: 100%; padding: .62rem .75rem; border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--bg); color: var(--text); }
.field input:focus, .field textarea:focus { outline: 2px solid var(--signal-soft); border-color: var(--signal); }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.2rem; background: var(--ink); color: #fff; }
.topbar .who { display: flex; align-items: center; gap: .8rem; font-size: .9rem; color: #c7cfde; }
.crumbs { display: flex; gap: .4rem; align-items: center; font-size: .9rem; color: #aab4c6; }
.crumbs a { color: #fff; }
.crumbs span.sep { opacity: .4; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.6rem 1.2rem 4rem; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.muted { color: var(--slate); }
.pill { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .6rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; background: var(--signal-soft); color: var(--signal); }
.pill.ok { background: rgba(16,185,129,.12); color: var(--verify); }
.pill.warn { background: rgba(245,158,11,.14); color: #b97e0a; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { background: var(--bg); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow-sm); }
.card.click { cursor: pointer; transition: .15s; }
.card.click:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card h3 { font-size: 1.05rem; }
.card .meta { font-size: .82rem; color: var(--slate); margin-top: .2rem; }

/* ---------- Case workspace ---------- */
.workspace { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .workspace { grid-template-columns: 1fr; } }
.stage-img-wrap { position: relative; background: #0c1120; border-radius: var(--radius); overflow: hidden; }
.stage-img-wrap img { width: 100%; }
.mask-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin: .7rem 0; }

.controls .ctl { margin-bottom: .95rem; }
.controls .ctl .row { display: flex; justify-content: space-between; align-items: baseline; }
.controls label { font-weight: 600; font-size: .9rem; }
.controls .val { font-variant-numeric: tabular-nums; color: var(--signal); font-weight: 600; font-size: .85rem; }
.controls .help { font-size: .76rem; color: var(--slate); }
.controls input[type=range] { width: 100%; accent-color: var(--signal); margin-top: .3rem; }
.controls select { width: 100%; padding: .5rem; border: 1px solid var(--hairline); border-radius: 9px; background: var(--bg); color: var(--text); }

.analysis { background: var(--mist); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.analysis ul { padding-left: 1.1rem; margin-top: .4rem; }
.analysis li { font-size: .88rem; }

/* ---------- Evolution viewer ---------- */
.evo { margin-top: 1.6rem; }
.evo-main { background: #0c1120; border-radius: var(--radius-lg); padding: 1rem; }
.evo-main img { width: 100%; border-radius: var(--radius); }
.evo-compare { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.evo-compare figure { margin: 0; }
.evo-compare figcaption { color: #aab4c6; font-size: .78rem; text-align: center; padding-top: .35rem; }
.scrubber { margin: 1rem 0 .5rem; }
.scrubber input { width: 100%; accent-color: var(--signal); }
.thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; margin-top: .8rem; }
.thumbs button { border: 2px solid transparent; border-radius: 10px; overflow: hidden; padding: 0; background: #0c1120; }
.thumbs button.active { border-color: var(--signal); }
.thumbs img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.thumbs .lbl { color: #c7cfde; font-size: .66rem; padding: .25rem; text-align: center; }
.evo-narr { background: var(--bg); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--slate); }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; flex: none; }
.spinner.dark { border-color: rgba(10,14,26,.18); border-top-color: var(--signal); }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 11px; box-shadow: var(--shadow-md);
  transition: .25s; pointer-events: none; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b0322a; }
.row-split { display: flex; gap: .6rem; }
.banner { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #8a5d06;
  padding: .7rem .9rem; border-radius: 11px; font-size: .85rem; margin-bottom: 1rem; }
.consent { display: flex; gap: .5rem; align-items: flex-start; font-size: .85rem; color: var(--text-soft); }
.consent input { margin-top: .25rem; }

/* ---------- Modal (API-info popup while generating) ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px;
  background: rgba(6,8,12,.55); backdrop-filter: blur(3px); opacity: 0; transition: opacity .2s; }
.modal-overlay.show { opacity: 1; }
.modal { width: min(100%, 460px); background: var(--bg); color: var(--text); border: 1px solid var(--hairline);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 1.3rem 1.4rem;
  transform: translateY(10px); transition: transform .2s; }
.modal-overlay.show .modal { transform: translateY(0); }
.modal-head { display: flex; align-items: center; gap: .5rem; font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 700; margin-bottom: .95rem; }
.api-info { border: 1px solid var(--hairline); border-radius: 12px; overflow: hidden; margin-bottom: 1rem; }
.api-row { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .8rem; font-size: .84rem; }
.api-row:nth-child(odd) { background: var(--mist); }
.api-k { color: var(--slate); flex: none; }
.api-v { font-family: ui-monospace, "JetBrains Mono", monospace; font-weight: 600; text-align: right; word-break: break-all; }
.api-status { font-size: .9rem; color: var(--text-soft); }
.api-done { color: var(--verify); font-weight: 700; font-size: .92rem; }
.api-warn { color: var(--alert); font-size: .82rem; margin-top: .45rem; word-break: break-word; }
.api-err { color: #ef6a5f; font-weight: 700; }
