@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

/* ==========================================================================
   Compass HQ Labs -- one theme for every page.
   Every page (app, landing, login/signup, legal) reads these same tokens, so a
   color or font change here changes the whole site.
   ========================================================================== */
:root {
  --bg: #08080c;
  --bg-soft: #0c0c12;
  --surface: #111118;
  --surface-2: #17171f;
  --surface-3: #1e1e28;
  --border: #23232d;
  --border-strong: #32323e;
  --text: #f4f4f7;
  --muted: #9b9bab;
  --faint: #6c6c7b;
  --accent: #7c5cff;
  --accent-hover: #9376ff;
  --accent-2: #4f7cff;
  --accent-soft: rgba(124, 92, 255, .14);
  --accent-glow: rgba(124, 92, 255, .35);
  --grad: linear-gradient(135deg, #a78bfa 0%, #7c5cff 45%, #4f7cff 100%);
  --success: #34d399;
  --danger-bg: #2a1419;
  --danger-border: #5c2531;
  --danger-text: #f7a8b8;
  --radius: 14px;
  --radius-sm: 10px;
  --font-heading: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 248px;
  /* kept for older inline styles that still say var(--card) */
  --card: var(--surface);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-heading); letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 6px; }
h2 { font-size: 1.15rem; font-weight: 700; }
p.sub, .sub { color: var(--muted); }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { color: #b3a1ff; }
img, video { max-width: 100%; }
::selection { background: var(--accent-soft); }

/* ---------- Brand mark ---------- */
.brand-logo {
  font-family: var(--font-heading);
  font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em;
  color: var(--text); white-space: nowrap;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.brand-logo:hover { color: var(--text); }
.brand-logo span { font-size: .6rem; font-weight: 700; letter-spacing: .12em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 12px; padding: 11px 20px;
  font: 600 .95rem/1.2 var(--font-body);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--grad); color: #fff;
  cursor: pointer; text-decoration: none;
  box-shadow: 0 6px 20px -8px var(--accent-glow);
  transition: filter .15s, box-shadow .15s, transform .1s, background-color .15s, border-color .15s;
}
button:hover, .btn:hover { color: #fff; filter: brightness(1.08); box-shadow: 0 8px 26px -8px var(--accent-glow), 0 0 0 3px var(--accent-soft); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, button:disabled:hover {
  background: var(--surface-3); color: var(--faint); border-color: var(--border);
  cursor: not-allowed; box-shadow: none; filter: none;
}
.btn-sm, button.btn-sm {
  margin-top: 0; padding: 6px 12px; font-size: .8rem; font-weight: 600;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); box-shadow: none;
}
.btn-sm:hover, button.btn-sm:hover { background: var(--surface-3); color: var(--text); border-color: var(--accent); box-shadow: none; filter: none; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--accent); box-shadow: none; filter: none; }
.btn-block { width: 100%; }

/* ---------- Form fields ---------- */
textarea, input[type=email], input[type=password], input[type=text], input[type=number], input[type=file] {
  width: 100%; font: 1rem/1.5 var(--font-body);
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea::placeholder, input::placeholder { color: var(--faint); }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { height: 110px; resize: vertical; }
input[type=file] { padding: 10px; cursor: pointer; font-size: .9rem; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
select {
  appearance: none; -webkit-appearance: none;
  font: 500 .88rem/1.2 var(--font-body);
  padding: 9px 34px 9px 12px; border-radius: 999px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%239b9bab' stroke-width='1.6'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 13px center;
  color: var(--text); border: 1px solid var(--border-strong); cursor: pointer;
  max-width: 100%;
}
select:hover { border-color: var(--accent); }
optgroup, option { background: var(--surface-2); color: var(--text); }
form { margin-top: 20px; }
label { display: block; margin-top: 14px; margin-bottom: 6px; font-size: .85rem; font-weight: 500; color: var(--muted); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.flash { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-text); padding: 11px 14px; border-radius: var(--radius-sm); margin: 0 0 16px; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: block; overflow-x: auto; }
tbody, thead { display: table; width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { color: var(--text); }
tr:last-child td { border-bottom: none; }
th { color: var(--faint); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 150px; }
.stat .num { font-family: var(--font-heading); font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.stat .label { color: var(--muted); font-size: .8rem; }
.kind-tag {
  display: inline-block; font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #c4b5fd; background: var(--accent-soft); border: 1px solid rgba(124, 92, 255, .35);
  padding: 3px 9px; border-radius: 999px; margin-bottom: 10px;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
#status { margin-top: 14px; color: var(--muted); font-size: .9rem; }
.export-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ==========================================================================
   App shell: sidebar + main column (every logged-in page)
   ========================================================================== */
body.app { padding-left: var(--sidebar-w); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 20;
  display: flex; flex-direction: column; gap: 8px;
  padding: 22px 14px 16px;
  background: var(--bg-soft); border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 14px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-label { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 16px 10px 6px; }
.side-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--muted); font-size: .9rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.side-link svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--accent-soft); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.side-link.active svg { color: #c4b5fd; }
.side-logout { margin-top: 6px; }
.credit-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.credit-label { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.credit-box .balance { display: block; font-family: var(--font-heading); font-size: 1.2rem; font-weight: 800; color: var(--text); margin: 4px 0 10px; }
.credit-box .btn { margin-top: 0; padding: 8px 12px; font-size: .85rem; }
.balance-mobile { display: none; }

.app-main { max-width: 960px; margin: 0 auto; padding: 44px 40px 80px; }
.app-main > h1:first-child, .page-head { margin-top: 0; }
.app-main > .sub:first-of-type { margin-top: 0; }
.app-main h1 + p.sub { margin: 0 0 22px; }
.app-main h2 { margin: 32px 0 6px; }
.app-main h2 + p.sub { margin-top: 0; }

/* ---------- Generator pages: the "composer" box ---------- */
.composer {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px;
  padding: 6px; box-shadow: 0 20px 50px -30px rgba(0,0,0,.8);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 4px var(--accent-soft), 0 20px 50px -30px rgba(0,0,0,.8); }
.composer > textarea, .composer textarea.composer-input {
  border: none; background: transparent; box-shadow: none; padding: 14px 14px 8px; height: 120px; font-size: 1rem;
}
.composer > textarea:focus { box-shadow: none; }
.composer-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px; border-top: 1px solid var(--border); margin-top: 4px;
}
.composer-bar .row { margin: 0; }
.composer-bar .spacer { flex: 1; }
.composer-bar button#go { margin: 0; }
.composer-extra { padding: 4px 8px 10px; }
.composer-extra label { margin-top: 6px; }
.composer-extra textarea { background: var(--bg-soft); }
.cost-line { margin: 10px 4px 0; font-size: .85rem; color: var(--muted); }

/* results */
main video#result, video#result { display: none; }
#result { margin-top: 20px; border-radius: var(--radius); border: 1px solid var(--border); background: #000; width: 100%; }
audio#result { background: transparent; border: none; }
audio { color-scheme: dark; }

/* drag-and-drop start frame */
.drop-zone {
  margin: 4px 8px 8px; border: 1.5px dashed var(--border-strong); border-radius: 12px;
  padding: 14px; text-align: center; color: var(--muted); cursor: pointer; font-size: .88rem;
  background: var(--bg-soft); transition: border-color .15s, color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.drop-zone.disabled { opacity: .5; cursor: not-allowed; }
.drop-zone img { max-width: 100%; max-height: 160px; border-radius: 8px; display: block; margin: 0 auto 10px; }

/* ---------- "Help me write it" scene writer ---------- */
.script-panel { margin: 0 0 16px; padding: 0; border-color: var(--border); }
.script-panel summary { cursor: pointer; list-style: none; padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.script-panel summary::-webkit-details-marker { display: none; }
.script-panel summary::before { content: "✦"; color: #c4b5fd; font-size: .9rem; }
.script-panel[open] summary { border-bottom: 1px solid var(--border); }
.script-title { font-weight: 700; }
.script-hint { color: var(--muted); font-size: .85rem; }
.script-panel > :not(summary) { margin-left: 16px; margin-right: 16px; }
.script-panel[open] { padding-bottom: 16px; }
.idea-box { height: 72px; width: calc(100% - 32px); margin-top: 14px; }
.script-row { align-items: center; }
.script-row .btn-write { margin-top: 0; }
.script-status { margin-top: 10px; color: var(--muted); font-size: .88rem; }
.scene-list { margin-top: 12px; padding-left: 0; list-style: none; counter-reset: scene; }
.scene { counter-increment: scene; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-top: 10px; background: var(--bg-soft); transition: border-color .15s; }
.scene.in-use { border-color: var(--accent); background: var(--accent-soft); }
.scene-name { font-weight: 600; font-size: .9rem; }
.scene-name::before { content: counter(scene) ". "; color: #c4b5fd; }
.scene-text { margin: 6px 0 10px; font-size: .9rem; line-height: 1.5; }
.recent-scripts { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.recent-label { color: var(--faint); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.recent-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%;
  margin-top: 6px; padding: 9px 12px; text-align: left; font-size: .88rem; font-weight: 500;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: none;
}
.recent-item:hover, .recent-item.active { background: var(--surface-2); border-color: var(--accent); box-shadow: none; filter: none; }
.recent-idea { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ---------- Voice page: My voices ---------- */
.voices-card { margin-top: 36px; }
.section-title { font-size: 1.1rem; margin: 0 0 4px; }
.sub.small { font-size: .85rem; margin: 4px 0 8px; }
.voice-item { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-top: 10px; background: var(--bg-soft); }
.voice-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.voice-name { font-weight: 600; }
.voice-actions { display: flex; gap: 6px; }
.voice-item audio { width: 100%; margin-top: 8px; height: 36px; }
.clone-box { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.clone-box summary { cursor: pointer; font-weight: 600; color: #c4b5fd; }
.clone-tips { color: var(--muted); font-size: .85rem; padding-left: 18px; margin: 10px 0 4px; }
label.consent { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: .88rem; margin-top: 14px; }
label.consent input { margin-top: 2px; flex: none; }

/* ---------- Library ---------- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-top: 22px; }
.video-card { position: relative; margin-top: 0; padding: 12px; display: flex; flex-direction: column; transition: border-color .15s, transform .15s; }
.video-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.video-card video { width: 100%; border-radius: 10px; display: block; background: #000; aspect-ratio: 16/9; object-fit: cover; }
.video-card audio { width: 100%; display: block; margin-top: 4px; }
.video-card p.sub { font-size: .88rem; }
.video-card .export-row { margin-top: auto; padding-top: 10px; }

/* ---------- Credit packs ---------- */
.pkg-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 16px; }
.pkg { text-align: center; margin-top: 0; display: flex; flex-direction: column; }
.pkg:nth-child(2) { border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 1px var(--accent-soft), 0 20px 40px -24px var(--accent-glow); }
.pkg-name { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.pkg .num { font-family: var(--font-heading); font-size: 2rem; font-weight: 800; margin-top: 6px; }
.pkg .label { color: var(--muted); font-size: .85rem; margin-bottom: 2px; }
.pkg form { margin-top: auto; padding-top: 14px; }
.pkg button { width: 100%; margin-top: 0; }

/* ==========================================================================
   Login / signup
   ========================================================================== */
body.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px;
  background:
    radial-gradient(600px 380px at 50% -5%, rgba(124,92,255,.22), transparent 70%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; box-shadow: 0 30px 80px -40px rgba(0,0,0,.9); }
.auth-card .brand-logo { margin-bottom: 26px; }
.auth-card h1 { font-size: 1.5rem; }
.auth-card form { margin-top: 18px; }
.auth-card button[type=submit] { width: 100%; margin-top: 20px; padding: 12px; }
.auth-foot { margin: 18px 0 0; font-size: .9rem; text-align: center; }

/* ==========================================================================
   Terms / privacy
   ========================================================================== */
.site-bar { border-bottom: 1px solid var(--border); background: rgba(8,8,12,.85); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; }
.site-bar-inner { max-width: 1100px; margin: 0 auto; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-bar nav { display: flex; align-items: center; gap: 18px; font-size: .9rem; }
.site-bar nav a { color: var(--muted); }
.site-bar nav a:hover { color: var(--text); }
.site-bar nav .btn { margin: 0; padding: 8px 16px; color: #fff; }
.doc { max-width: 760px; margin: 0 auto; padding: 48px 24px 80px; line-height: 1.7; }
.doc h1 { font-size: 2rem; }
.doc h2 { font-size: 1.15rem; margin-top: 34px; }
.doc li { margin-bottom: 6px; color: #d7d7df; }
.doc p { color: #d7d7df; }

/* ==========================================================================
   Phones and small tablets
   ========================================================================== */
@media (max-width: 860px) {
  body.app { padding-left: 0; }
  .sidebar {
    position: sticky; top: 0; inset: auto; width: auto; height: auto;
    flex-direction: column; gap: 0; padding: 12px 0 0;
    background: rgba(12,12,18,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-right: none; border-bottom: 1px solid var(--border); overflow: visible;
  }
  .sidebar-top { padding: 0 16px 10px; }
  .balance-mobile { display: inline-block; font-size: .8rem; font-weight: 600; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); padding: 4px 11px; border-radius: 999px; }
  .side-nav { flex-direction: row; overflow-x: auto; gap: 4px; padding: 0 12px 10px; scrollbar-width: none; }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-label { display: none; }
  .side-link { flex: none; padding: 7px 12px; border-radius: 999px; font-size: .84rem; border: 1px solid var(--border); }
  .side-link.active { box-shadow: none; border-color: rgba(124,92,255,.5); }
  .side-link svg { width: 16px; height: 16px; }
  .side-logout { margin-top: 0; }
  .credit-box { display: none; }
  .app-main { padding: 26px 16px 64px; }
  h1 { font-size: 1.5rem; }
  .composer-bar .spacer { display: none; }
  .composer-bar button#go { width: 100%; }
  .script-row .btn-write { flex: 1; }
  .stat .num { font-size: 1.4rem; }
}

/* ---------- Edit image ---------- */
.tool-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin: 4px 0 6px; scrollbar-width: none; }
.tool-tabs::-webkit-scrollbar { display: none; }
.tool-tab, button.tool-tab {
  margin: 0; flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; font-size: .86rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border-strong); box-shadow: none;
}
.tool-tab:hover, button.tool-tab:hover { color: var(--text); border-color: var(--accent); background: var(--surface-3); box-shadow: none; filter: none; }
.tool-tab.active, button.tool-tab.active { background: var(--accent-soft); color: #fff; border-color: var(--accent); }
.tool-hint { margin: 4px 2px 14px; }
.edit-stage { padding: 8px; display: flex; justify-content: center; background: var(--bg-soft); border-radius: 12px; margin: 4px 8px 8px; }
.stage-inner { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.stage-inner img { display: block; max-width: 100%; max-height: 62vh; border-radius: 8px;
  background: repeating-conic-gradient(#1e1e28 0% 25%, #15151c 0% 50%) 50% / 20px 20px; }
.stage-inner canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; border-radius: 8px; touch-action: none; }
.stage-inner canvas.painting { cursor: crosshair; }
.brush-row { padding: 0 10px 6px; margin-top: 0; }
.brush-row .brush-label { margin: 0; }
.brush-row input[type=range] { width: 160px; accent-color: var(--accent); }
.composer-bar .btn-sm { margin: 0; }
#resultWrap img#result { display: block; max-height: 70vh; width: auto; max-width: 100%;
  background: repeating-conic-gradient(#1e1e28 0% 25%, #15151c 0% 50%) 50% / 20px 20px; }
