/* ============================================================
   Banuba SDK Showcase — shared styles
   ============================================================ */
:root {
  --bg: #0a0b12;
  --bg-2: #12141f;
  --panel: #171a27;
  --panel-2: #1e2231;
  --line: #2a2f42;
  --txt: #eef1f8;
  --txt-dim: #99a0b5;
  --brand: #6c5cff;
  --brand-2: #00e0c6;
  --accent: #ff5c8a;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --grad: linear-gradient(120deg, var(--brand), var(--accent) 55%, var(--brand-2));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 80% -10%, #1b1d33 0%, transparent 60%),
              radial-gradient(900px 600px at -10% 10%, #16233a 0%, transparent 55%), var(--bg);
  color: var(--txt);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.02em; }

.gradient-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Top nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 26px;
  background: rgba(10, 11, 18, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand .dot { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); box-shadow: 0 0 22px rgba(108, 92, 255, .6); }
.nav .spacer { flex: 1; }
.nav a.link { color: var(--txt-dim); font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.nav a.link:hover, .nav a.link.active { color: var(--txt); background: var(--panel-2); }
.token-pill { font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); }
.token-pill.ok { color: var(--ok); border-color: rgba(52, 211, 153, .4); }
.token-pill.bad { color: var(--warn); border-color: rgba(251, 191, 36, .4); }

/* ---------- Landing ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 26px; }
.hero { padding: 74px 0 40px; text-align: center; }
.hero .eyebrow { color: var(--brand-2); font-weight: 700; letter-spacing: .18em; text-transform: uppercase; font-size: 12px; }
.hero h1 { font-size: clamp(34px, 6vw, 62px); margin: 16px 0 18px; }
.hero p.lead { color: var(--txt-dim); font-size: 18px; max-width: 640px; margin: 0 auto 30px; }
.cta-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 22px; border-radius: 12px; font-weight: 700; font-size: 15px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--txt);
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s;
}
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: var(--grad); border: none; box-shadow: 0 10px 30px rgba(108, 92, 255, .45); }
.btn.ghost:hover { background: var(--panel); }

.section-title { text-align: center; margin: 60px 0 8px; font-size: 28px; }
.section-sub { text-align: center; color: var(--txt-dim); margin-bottom: 30px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  transition: transform .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-4px); border-color: rgba(108, 92, 255, .5); }
.card .emoji { font-size: 30px; }
.card h3 { margin: 12px 0 8px; font-size: 19px; }
.card p { color: var(--txt-dim); font-size: 14px; margin: 0; }

.notice {
  margin: 34px auto; max-width: 900px; padding: 18px 22px; border-radius: var(--radius);
  border: 1px solid rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .07);
}
.notice.ok { border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .07); }
.notice code { background: #000; padding: 2px 7px; border-radius: 6px; color: var(--brand-2); font-size: 13px; }
.footer { text-align: center; color: var(--txt-dim); font-size: 13px; padding: 50px 0 40px; }

/* ---------- Studio layout ---------- */
.studio { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 57px); }
.studio.beauty { grid-template-columns: 380px 1fr; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); overflow-y: auto; padding: 18px; }
.sidebar h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .12em; color: var(--txt-dim); margin-bottom: 6px; }
.sidebar .blurb { color: var(--txt-dim); font-size: 13px; margin: 4px 0 16px; }

.stage-col { position: relative; display: flex; flex-direction: column; min-width: 0; background: #05060b; }
.stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#webar { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#webar > canvas { max-width: 100%; max-height: 100%; object-fit: contain; }

.stage-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-top: 1px solid var(--line); background: rgba(10, 11, 18, .8);
}
.stage-bar .fps { color: var(--txt-dim); font-size: 12px; font-variant-numeric: tabular-nums; margin-left: auto; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--txt); cursor: pointer; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s, transform .1s;
}
.iconbtn:hover { background: var(--panel); }
.iconbtn:active { transform: scale(.94); }
.iconbtn.rec.on { color: var(--accent); border-color: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- Category tabs + effect tiles (Face AR) ---------- */
.cat-tabs { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.cat-tab {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--txt-dim); font-weight: 600; border: 1px solid transparent;
}
.cat-tab:hover { background: var(--panel); color: var(--txt); }
.cat-tab.active { background: var(--panel-2); color: var(--txt); border-color: var(--line); }
.cat-tab .ic { font-size: 18px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 6px; }
.tile {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 12px; cursor: pointer; background: var(--panel);
  font-size: 13px; font-weight: 600; text-align: center; min-height: 66px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, transform .1s, background .15s;
}
.tile:hover { border-color: rgba(108, 92, 255, .6); }
.tile:active { transform: scale(.97); }
.tile.active { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 24px rgba(108, 92, 255, .4); }

/* inline control (slider / toggle) under active tile */
.effect-control { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); }
.effect-control .name { font-size: 13px; color: var(--txt-dim); margin-bottom: 10px; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.switch { position: relative; width: 46px; height: 26px; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; transition: .2s; }
.switch .track::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: var(--txt-dim); top: 2px; left: 3px; transition: .2s; }
.switch input:checked + .track { background: var(--grad); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(19px); background: #fff; }

.readout {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.6); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px; font-weight: 700; font-size: 15px; display: none; align-items: center; gap: 8px;
}
.tip-toast {
  position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.7); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; color: var(--txt); display: none;
}

/* ---------- Beauty panels ---------- */
.bpanel { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden; background: var(--panel); }
.bpanel > summary {
  list-style: none; cursor: pointer; padding: 13px 15px; font-weight: 700;
  display: flex; align-items: center; gap: 10px; user-select: none;
}
.bpanel > summary::-webkit-details-marker { display: none; }
.bpanel > summary .chev { margin-left: auto; color: var(--txt-dim); transition: transform .2s; }
.bpanel[open] > summary .chev { transform: rotate(90deg); }
.bpanel .body { padding: 6px 15px 15px; }

.ctrl { margin: 12px 0; }
.ctrl .lab { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--txt-dim); margin-bottom: 7px; }
.ctrl .lab b { color: var(--txt); font-weight: 600; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] { width: 42px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; padding: 0; }
.color-row input[type="range"] { flex: 1; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.swatch { border: 2px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--panel-2); }
.swatch.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(108,92,255,.35); }
.swatch img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.swatch .cap { font-size: 11px; text-align: center; padding: 4px 2px; color: var(--txt-dim); }
.swatch.none { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; font-size: 12px; color: var(--txt-dim); }

/* ---------- Start screen / source picker ---------- */
.gate {
  position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 6, 11, .92); backdrop-filter: blur(8px); text-align: center; padding: 24px;
}
.gate .box { max-width: 460px; }
.gate h2 { font-size: 26px; margin-bottom: 12px; }
.gate p { color: var(--txt-dim); margin: 0 auto 22px; }
.gate .choices { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--brand); animation: spin 1s linear infinite; margin: 0 auto 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.file-label { cursor: pointer; }
.file-label input { display: none; }

@media (max-width: 820px) {
  .studio, .studio.beauty { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 44vh; }
  .stage-col { height: 56vh; }
}
