/* ============================================================
   BOYFRIEND CAMERA — design system
   Dark, embossed, skeuomorphic. Luxurious + tactile.
   Rhythm: 8/16px. Radius: 10-12px. Accents: pink/purple gradient.
   ============================================================ */

:root {
  --bg: #131417;
  --bg-deep: #0d0e10;
  --surface: #1b1d21;
  --surface-hi: #22252a;
  --surface-lo: #17181c;
  --line: rgba(255, 255, 255, 0.06);
  --text: #f2f3f5;
  --text-dim: #9aa0a8;
  --text-faint: #5c6169;
  --accent: #e8a33d;
  --accent-2: #d4691e;
  --accent-grad: linear-gradient(135deg, #edb45a 0%, #d4691e 100%);
  --gold: #e8c469;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  /* Embossed treatment: raised */
  --emboss: inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.45);
  /* Embossed treatment: sunken (wells, inputs, tracks) */
  --deboss: inset 0 2px 5px rgba(0, 0, 0, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body { overflow: hidden; }

h1, h2, h3, .title, .pt-name, .dc-title, .pc-name { font-family: "Clash Display", "Satoshi", sans-serif; font-weight: 600; letter-spacing: 0.005em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
small, .dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }

/* ---------- App frame ---------- */
#app { height: 100%; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--safe-t);
}
.screen.active { display: flex; }
.screen-scroll { flex: 1; overflow-y: auto; padding: 16px 20px calc(96px + var(--safe-b)); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 10px;
}
.topbar .title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.topbar .title .bc-mark { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Tab bar ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: stretch;
  padding: 8px 12px calc(10px + var(--safe-b));
  background: rgba(13, 14, 16, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0 4px; border: none; background: none; color: var(--text-faint);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; cursor: pointer;
  border-radius: var(--radius-sm); transition: color 0.15s;
}
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tab.active { color: var(--text); }
.tab.active .tab-dot { opacity: 1; transform: scale(1); }
.tab-dot {
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent-grad);
  opacity: 0; transform: scale(0); transition: all 0.2s;
}

/* ---------- Embossed components ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--emboss);
  padding: 16px;
  margin-bottom: 16px;
}
.card.pressable { cursor: pointer; transition: transform 0.08s; }
.card.pressable:active { transform: scale(0.985); box-shadow: var(--deboss); }

.well {
  background: var(--surface-lo);
  border-radius: var(--radius-sm);
  box-shadow: var(--deboss);
  padding: 10px 12px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border: none; border-radius: var(--radius);
  background: var(--surface-hi); color: var(--text);
  font-size: 14px; font-weight: 700; letter-spacing: 0.01em;
  box-shadow: var(--emboss); cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: translateY(1px); box-shadow: var(--deboss); }
.btn.primary { background: var(--accent-grad); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.btn.light { background: #e9eaec; color: #17181c; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--text-dim); }
.btn.small { padding: 8px 14px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; border: none;
  background: var(--surface-hi); color: var(--text-dim);
  font-size: 12px; font-weight: 600; cursor: pointer;
  box-shadow: var(--emboss); white-space: nowrap;
}
.chip.active { background: var(--accent-grad); color: #fff; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 20px 12px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--surface-hi); color: var(--text-dim); box-shadow: var(--emboss);
}
.badge.grad { background: var(--accent-grad); color: #fff; }
.badge.gold { color: var(--gold); }

/* ---------- Sliders (debossed track, embossed thumb) ---------- */
.param { margin-bottom: 4px; }
.param-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.param-head label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.param-head .val { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 700; min-width: 38px; text-align: right; }
.param-head .val.changed { color: var(--accent); }

input[type="range"] {
  width: 100%; height: 26px; appearance: none; -webkit-appearance: none; background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: var(--surface-lo); box-shadow: var(--deboss);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(180deg, #34373d, #24262b);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 2px 5px rgba(0,0,0,0.6);
  margin-top: -7px; cursor: grab;
}
input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }

/* ---------- Modals / sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none; transition: opacity 0.22s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.07);
  transform: translateY(102%); transition: transform 0.26s cubic-bezier(0.32, 0.72, 0.22, 1);
  padding-bottom: var(--safe-b);
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--text-faint); margin: 10px auto 4px; opacity: 0.5; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 20px 12px; }
.sheet-body { overflow-y: auto; padding: 0 20px 24px; }

/* ---------- Grids of cards ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- Pose cards ---------- */
.pose-card { padding: 0; overflow: hidden; margin-bottom: 0; }
.pose-thumb {
  height: 130px; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 100% at 50% 0%, #26282e 0%, #191b1f 100%);
  border-bottom: 1px solid var(--line);
}
.pose-thumb canvas { max-height: 116px; }
.pose-meta { padding: 10px 12px 12px; }
.pose-meta .name { font-size: 13px; font-weight: 700; line-height: 1.25; }
.pose-meta .sub { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

/* ---------- Camera screen ---------- */
#screen-shoot { background: #000; position: relative; }
#cam-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#cam-gl, #cam-overlay { position: absolute; max-width: 100%; max-height: 100%; }
#cam-overlay { touch-action: none; }
#cam-idle {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 32px;
}
.cam-hud-top {
  position: absolute; top: calc(10px + var(--safe-t)); left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center; gap: 8px; padding: 0 16px;
  flex-wrap: wrap;
}
.hud-btn {
  border: none; border-radius: 999px; padding: 9px 14px;
  background: rgba(20, 21, 25, 0.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text); font-size: 12px; font-weight: 700; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 8px rgba(0,0,0,0.4);
  display: inline-flex; align-items: center; gap: 6px;
}
.hud-btn.on { background: var(--accent-grad); }
.cam-hud-bottom {
  position: absolute; left: 0; right: 0; bottom: calc(86px + var(--safe-b)); z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 34px;
}
#btn-shutter {
  width: 76px; height: 76px; border-radius: 50%; border: none; cursor: pointer;
  background: radial-gradient(circle at 50% 35%, #ffffff, #d8d9dd 70%);
  box-shadow: 0 0 0 4px rgba(20,21,25,0.75), 0 0 0 6px rgba(255,255,255,0.85), 0 6px 18px rgba(0,0,0,0.6);
  transition: transform 0.08s;
}
#btn-shutter:active { transform: scale(0.92); }
#btn-shutter.recording { background: radial-gradient(circle at 50% 35%, #ff6b81, #e11d48 70%); }
.cam-side-btn {
  width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(20,21,25,0.72); color: var(--text);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 8px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.cam-side-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.cam-side-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

#prompt-card {
  position: absolute; left: 16px; right: 16px; bottom: calc(180px + var(--safe-b)); z-index: 9;
  background: rgba(19, 20, 23, 0.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius); box-shadow: var(--emboss); padding: 12px 14px;
  display: none;
}
#prompt-card.show { display: block; }
#prompt-card .pc-name { font-size: 13px; font-weight: 800; }
#prompt-card .pc-step { font-size: 13px; color: var(--text-dim); margin-top: 4px; min-height: 34px; }
#prompt-card .pc-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
#prompt-card .pc-settings { font-size: 10.5px; color: var(--gold); font-weight: 700; letter-spacing: 0.04em; }

/* Direct Me — the app's headline control */
#btn-direct {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent-grad); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  box-shadow: 0 0 0 3px rgba(20,21,25,0.7), 0 4px 16px rgba(212,105,30,0.45);
  transition: transform 0.1s;
}
#btn-direct svg { width: 24px; height: 24px; fill: #fff; stroke: none; }
#btn-direct:active { transform: scale(0.92); }
#btn-direct.thinking { animation: direct-pulse 0.9s ease-in-out infinite; }
@keyframes direct-pulse { 50% { box-shadow: 0 0 0 8px rgba(232,163,61,0.25), 0 4px 16px rgba(212,105,30,0.45); } }

#direct-card {
  position: absolute; left: 16px; right: 16px; bottom: calc(180px + var(--safe-b)); z-index: 12;
  background: rgba(19, 20, 23, 0.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius); box-shadow: var(--emboss); padding: 14px;
  display: none; transform: translateY(8px); opacity: 0;
  transition: transform 0.22s, opacity 0.22s;
}
#direct-card.show { display: block; transform: translateY(0); opacity: 1; }
#direct-card .dc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
#direct-card .dc-title { font-size: 15px; font-weight: 800; }
#direct-card .dc-scene { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
#direct-card .dc-line { font-size: 13px; color: var(--text-dim); margin-top: 5px; }
#direct-card .dc-row { display: flex; gap: 8px; margin-top: 11px; justify-content: flex-end; }

#rec-dot {
  position: absolute; top: calc(58px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 11;
  display: none; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: rgba(225, 29, 72, 0.92); font-size: 11px; font-weight: 800;
}
#rec-dot.show { display: inline-flex; }
#rec-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- Editor ---------- */
#screen-edit { background: var(--bg-deep); }
#edit-stage {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; background: #0a0b0c;
}
#edit-gl { max-width: 100%; max-height: 100%; }
#edit-empty { text-align: center; padding: 40px; }
#edit-toolstrip {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px;
  border-top: 1px solid var(--line); scrollbar-width: none; flex-shrink: 0;
  background: var(--bg);
}
#edit-toolstrip::-webkit-scrollbar { display: none; }
.toolbtn {
  flex-shrink: 0; border: none; border-radius: var(--radius-sm);
  padding: 9px 14px; background: var(--surface); color: var(--text-dim);
  font-size: 12px; font-weight: 700; cursor: pointer; box-shadow: var(--emboss);
}
.toolbtn.active { color: #fff; background: var(--accent-grad); }
#edit-panel {
  height: 260px; overflow-y: auto; padding: 14px 20px calc(14px + var(--safe-b));
  background: var(--bg); flex-shrink: 0;
}
#edit-panel.tall { height: 330px; }

/* Color wheels */
.wheel-row { display: flex; justify-content: space-around; gap: 8px; }
.wheel-unit { text-align: center; flex: 1; }
.wheel-unit .w-label { font-size: 11px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }
.wheel {
  position: relative; width: 92px; height: 92px; margin: 0 auto; border-radius: 50%;
  background:
    radial-gradient(circle, rgba(19,20,23,0.0) 0%, rgba(19,20,23,0.55) 72%, rgba(19,20,23,0.9) 100%),
    conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  box-shadow: var(--deboss), 0 0 0 3px var(--surface-lo);
  touch-action: none; cursor: crosshair;
}
.wheel .w-dot {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,0.6), 0 2px 5px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%); left: 50%; top: 50%; pointer-events: none;
}
.wheel-lum { width: 92px; margin: 8px auto 0; }

/* Curve editor */
#curve-wrap { position: relative; }
#curve-canvas {
  width: 100%; height: 170px; border-radius: var(--radius-sm);
  background: var(--surface-lo); box-shadow: var(--deboss); touch-action: none;
}

/* HSL channel strip */
.hsl-chan-row { display: flex; gap: 6px; margin-bottom: 12px; }
.hsl-chan {
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  box-shadow: var(--emboss); flex-shrink: 0;
}
.hsl-chan.active { outline: 2px solid #fff; outline-offset: 2px; }

/* Preset tiles */
.preset-tile { position: relative; padding: 0; overflow: hidden; margin: 0; }
.preset-tile img, .preset-tile .pt-swatch { width: 100%; height: 84px; object-fit: cover; display: block; }
.preset-tile .pt-name {
  padding: 8px 10px; font-size: 12px; font-weight: 700;
}
.preset-tile .pt-src { font-size: 9.5px; color: var(--text-faint); padding: 0 10px 8px; }

/* AI edit narration */
#ai-narration {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 8;
  background: rgba(19,20,23,0.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius); box-shadow: var(--emboss); padding: 12px 14px;
  display: none;
}
#ai-narration.show { display: block; }
#ai-narration .an-step { font-size: 13px; font-weight: 600; }
#ai-narration .an-think { font-size: 12px; color: var(--text-dim); margin-top: 3px; font-style: italic; }
#ai-narration .an-bar { height: 3px; border-radius: 2px; background: var(--surface-lo); margin-top: 10px; overflow: hidden; }
#ai-narration .an-bar i { display: block; height: 100%; background: var(--accent-grad); width: 0%; transition: width 0.3s; }

/* Masks */
.mask-pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* Video transport */
#vid-transport {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 7;
  display: flex; align-items: center; gap: 10px;
  background: rgba(19,20,23,0.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius); box-shadow: var(--emboss); padding: 10px 12px;
}
#vid-transport input[type="range"] { height: 16px; }

/* ---------- Boards ---------- */
.board-cover {
  height: 120px; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
  display: grid; grid-template-columns: 2fr 1fr; gap: 2px; background: var(--surface-lo);
}
.board-cover img { width: 100%; height: 100%; object-fit: cover; }
.board-cover .bc-half { display: grid; grid-template-rows: 1fr 1fr; gap: 2px; }
.board-imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.board-imgs .bi {
  position: relative; aspect-ratio: 3/4; border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: var(--emboss);
}
.board-imgs .bi img { width: 100%; height: 100%; object-fit: cover; }
.board-imgs .bi .bi-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: none;
  border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; font-size: 12px; cursor: pointer;
}
.swatch-row { display: flex; gap: 6px; margin: 10px 0; }
.swatch { width: 26px; height: 26px; border-radius: 8px; box-shadow: var(--emboss); }

/* ---------- Library ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lib-item {
  position: relative; aspect-ratio: 3/4; border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: var(--emboss); cursor: pointer; background: var(--surface-lo);
}
.lib-item img, .lib-item video { width: 100%; height: 100%; object-fit: cover; }
.lib-item .li-vid {
  position: absolute; top: 5px; right: 5px; font-size: 9px; font-weight: 800;
  background: rgba(0,0,0,0.65); border-radius: 4px; padding: 2px 5px;
}

/* ---------- Character builder ---------- */
#builder-preview {
  height: 240px; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 100% at 50% 0%, #26282e 0%, #17181c 100%);
  border-radius: var(--radius); box-shadow: var(--deboss); margin-bottom: 14px;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  z-index: 90; background: var(--surface-hi); color: var(--text);
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--emboss);
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: all 0.25s; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Section headers ---------- */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 12px; }
.sec-head h2 { font-size: 16px; }

/* ---------- Onboard hero ---------- */
.hero-card {
  background: radial-gradient(140% 120% at 20% 0%, rgba(232,163,61,0.14), rgba(212,105,30,0.07) 50%, transparent 80%), var(--surface);
}
.hero-card h1 { font-size: 22px; margin-bottom: 6px; }
.hero-card p { color: var(--text-dim); font-size: 13.5px; }

/* Flash animation on capture */
#flashfx { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 30; }
#flashfx.pop { animation: flashpop 0.28s ease-out; }
@keyframes flashpop { 0% { opacity: 0.9; } 100% { opacity: 0; } }

@media (min-width: 700px) {
  #app { max-width: 430px; margin: 0 auto; box-shadow: 0 0 80px rgba(0,0,0,0.8); }
  #tabbar { max-width: 430px; left: 50%; transform: translateX(-50%); }
}
