:root {
  --bg: #0b0f1a;
  --bg2: #10162a;
  --panel: #121a30;
  --line: rgba(255, 255, 255, 0.09);
  --ink: #f0f3fa;
  --sub: #97a0b8;
  --accent: #4f7cff;
  --radius: 12px;
  --control-h: 42px;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over explicit display rules. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.2px;
}

.brand svg { width: 24px; height: 24px; color: var(--accent); }

.topbar-hint { color: var(--sub); font-size: 13px; }

.studio {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 22px;
  padding: 22px;
  max-width: 1400px;
  margin: 0 auto;
  /* App layout: columns scroll independently, profile pins to the bottom. */
  height: calc(100vh - 67px);
  overflow: hidden;
}

.panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-right: 4px;
}

.stage { overflow-y: auto; }

/* ---------- profile row (anchored to the sidebar bottom) ---------- */
.profile-row {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 12px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.profile-who { flex: 1; min-width: 0; }
.profile-who strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-who span { display: block; font-size: 12px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile-row .btn.icon { flex-shrink: 0; width: 34px; height: 34px; }

/* ---------- Quick Cut drawer ---------- */
.quickcut details > summary {
  cursor: pointer;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--sub);
  font-weight: 700;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quickcut details > summary::after { content: "+"; font-size: 16px; }
.quickcut details[open] > summary::after { content: "-"; }
.quickcut details > summary::-webkit-details-marker { display: none; }
.quickcut details[open] > summary { margin-bottom: 12px; }

.punch-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

.char-count {
  text-align: right;
  font-size: 11.5px;
  color: var(--sub);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.char-count.warn { color: #f59b47; }
.char-count.over { color: #e07b7b; font-weight: 600; }

.group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.group h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--sub);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 6px;
}

label:first-of-type { margin-top: 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 0 12px;
}

/* Single-line controls share one height so selects match inputs. */
input[type="text"], input[type="email"], input[type="password"], input[type="url"], select { height: var(--control-h); }

textarea { padding: 10px 12px; resize: vertical; line-height: 1.45; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  color: var(--sub);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--ink); }
.dropzone svg { width: 30px; height: 30px; }
.dropzone p { margin: 8px 0 0; font-size: 13px; font-weight: 600; }

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb button {
  position: absolute;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.thumb button svg { width: 12px; height: 12px; }

.thumb-rm { top: 3px; right: 3px; }

/* ---------- video type switcher (Generate section) ---------- */
.model-switch {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.model-opt {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.model-opt[aria-checked="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--bg2));
}

.model-name { font-weight: 700; font-size: 14px; grid-row: 1; }
.model-sub { font-size: 11px; color: var(--sub); grid-row: 2; }
.model-cost {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- import row ---------- */
.import-row { display: flex; gap: 8px; }
.import-row input { flex: 1; height: var(--control-h); }

/* ---------- login wall ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 60; /* above the sticky topbar */
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
}

.gate[hidden] { display: none; } /* explicit display beats the hidden attr otherwise */

.gate-brand {
  justify-content: center;
  margin-bottom: 18px;
  display: flex;
}

/* ---------- social sign-in (canonical fleet spec) ---------- */
#socialwrap { display: grid; gap: 10px; margin-bottom: 18px; }
.gbtn-wrap { display: flex; justify-content: center; min-height: 44px; }
.gbtn-wrap > div { width: 100%; }
.socbtn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 44px; border-radius: 8px; border: none;
  background: #000; color: #fff; font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer;
}
.orline { text-align: center; color: var(--sub); font-size: 13px; position: relative; margin: 4px 0; }
.orline::before, .orline::after { content: ""; position: absolute; top: 50%; width: 34%; height: 1px; background: var(--line); }
.orline::before { left: 0; }
.orline::after { right: 0; }

/* ---------- account / auth ---------- */
.auth-swap {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--sub);
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.linklike:hover { text-decoration: underline; }
.auth-note { margin: 10px 0 0; font-size: 12.5px; color: var(--sub); line-height: 1.5; }
.acct-ok { color: #6fd18f; }
.acct-wait { color: var(--accent); }
.acct-no { color: #e07b7b; }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.acct-row strong { display: block; font-size: 14px; }
.acct-email { font-size: 12px; color: var(--sub); }

#adminBox { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.admin-who { flex: 1; min-width: 0; }
.admin-who span { display: block; color: var(--sub); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.admin-status { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.admin-pending { color: var(--accent); }
.admin-approved { color: #6fd18f; }
.admin-rejected { color: #e07b7b; }
.admin-actions { display: flex; gap: 6px; }
.admin-actions .btn { height: 30px; padding: 0 10px; font-size: 12px; }

/* ---------- AI status + result ---------- */
.ai-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg2);
  border: 1px solid var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.ai-result {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.ai-result h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--sub);
}

.ai-result video {
  width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  background: #000;
  display: block;
  margin-bottom: 12px;
}

#moodWrap { margin-top: 4px; }

.brief-preview {
  margin: 10px 0 0;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--sub);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  height: var(--control-h);
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip[aria-checked="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--bg2));
}

.accent-row { display: flex; gap: 8px; align-items: center; }

input[type="color"] {
  width: 56px;
  height: var(--control-h);
  padding: 4px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--control-h);
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn svg { width: 18px; height: 18px; }

.btn.primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:disabled { opacity: 0.55; cursor: default; }

.btn.ghost { background: transparent; }

.btn.icon { width: var(--control-h); padding: 0; }

.progress { margin-top: 12px; position: relative; height: 30px; background: var(--bg2); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.progress-bar { position: absolute; inset: 0; width: 0%; background: color-mix(in srgb, var(--accent) 45%, var(--bg2)); transition: width 0.15s; }
.progress-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; }

.stage { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.canvas-frame {
  position: relative;
  background: #05070d;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  padding: 18px;
  min-height: 320px;
}

#preview {
  max-width: 100%;
  max-height: 72vh;
  border-radius: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.bigplay {
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 14, 24, 0.75);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}

.bigplay svg { width: 34px; height: 34px; margin-left: 4px; }
.bigplay[hidden] { display: none; }

.transport {
  display: flex;
  align-items: center;
  gap: 12px;
}

#scrub { flex: 1; accent-color: var(--accent); }

.time { font-variant-numeric: tabular-nums; color: var(--sub); font-size: 13px; white-space: nowrap; }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .panel, .stage { overflow-y: visible; }
  .stage { order: -1; }
  .topbar-hint { display: none; }
  .profile-row { position: static; }
}
