:root {
  --paper: #fbfaf7;
  --paper-2: #f5f3ee;
  --ink: #141413;
  --ink-soft: #3a3936;
  --mute: #807d76;
  --line: #e8e5df;
  --line-soft: #f1efea;
  --accent: #5a3dcf;
  --accent-soft: #ece7fa;
  --good: #2f7d53;
  --good-soft: #e4f1ea;
  --warn: #a85b1f;
  --warn-soft: #f7ebdc;
  --bad: #a8312c;
  --bad-soft: #f6e1df;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 14px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Brand mark ─────────────────────────────────────────────── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--ink);
}
.brand::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--paper) 0 42%, transparent 43%),
    conic-gradient(from 210deg, #ff5fb4, #8b5cf6, #4a6cf7, #ff5fb4);
  flex: 0 0 auto;
}

/* ─── App shell ──────────────────────────────────────────────── */
#app-root { display: contents; }

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}
.shell.no-sidebar { grid-template-columns: 1fr; }
.shell.no-sidebar aside { display: none; }

/* ─── Sidebar ────────────────────────────────────────────────── */
aside.sidebar {
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  min-height: 0;
}

.sidebar-brand { padding: 0 18px 18px; }

.sidebar-heading {
  padding: 0 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--mute);
  font-weight: 600;
}
.sidebar-heading .count { text-transform: none; letter-spacing: 0; font-weight: 500; }

.sidebar-search {
  margin: 0 14px 10px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  font-size: 12px;
  color: var(--mute);
}
.sidebar-search input {
  flex: 1;
  border: 0;
  outline: none;
  font: inherit;
  background: transparent;
  color: var(--ink);
  min-width: 0;
}
.sidebar-search input::placeholder { color: var(--mute); }
.sidebar-search .kbd {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: var(--mute);
}

.sessions {
  list-style: none;
  padding: 0 8px;
  margin: 0;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sessions .empty {
  padding: 16px 14px;
  color: var(--mute);
  font-size: 12.5px;
  line-height: 1.45;
}

.sessions li.session {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.sessions li.session:hover { background: rgba(255, 255, 255, 0.6); }
.sessions li.session.active {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.thumb {
  width: 42px;
  height: 30px;
  border-radius: 4px;
  background:
    radial-gradient(ellipse at 35% 45%, #3c3f4a 0%, transparent 60%),
    linear-gradient(180deg, #1c1e25, #0e0f12);
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
}

.session-body { flex: 1; min-width: 0; }
.session-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--mute);
  margin-top: 2px;
}
.session-meta .sep { opacity: 0.5; }
.session-progress {
  height: 2px;
  background: var(--line-soft);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.session-progress > div {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.3s ease;
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mute);
  flex: 0 0 auto;
}
.dot.ready { background: var(--good); }
.dot.processing { background: var(--accent); }
.dot.failed { background: var(--bad); }

.archive-btn {
  background: transparent;
  border: 0;
  padding: 4px;
  border-radius: 4px;
  color: var(--mute);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: opacity 0.1s, background 0.1s, color 0.1s;
}
.archive-btn svg { display: block; }
.sessions li.session:hover .archive-btn { opacity: 0.85; }
.archive-btn:hover { color: var(--bad); background: var(--bad-soft); opacity: 1; }
.archive-btn[disabled] { opacity: 0.3; cursor: wait; }

.sidebar-foot {
  padding: 10px 14px 0;
  border-top: 1px solid var(--line);
}
.new-video-btn {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.new-video-btn:hover { filter: brightness(1.1); }
.new-video-btn .plus { font-size: 16px; line-height: 1; }

.user-chip {
  margin-top: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.user-chip .avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex: 0 0 auto;
}
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .who .name {
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip .who .org { color: var(--mute); font-size: 11px; }

/* ─── Main pane ──────────────────────────────────────────────── */
main {
  overflow: hidden;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
}
.topbar-title {
  flex: 1;
  min-width: 0;
}
.topbar-title .name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-title .sub {
  font-size: 11px;
  color: var(--mute);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .signed-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.topbar.simple {
  padding: 18px 24px;
  justify-content: space-between;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.icon-btn:hover { background: var(--paper-2); }
.icon-btn.muted { color: var(--mute); }

.labeled-btn {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.labeled-btn:hover { background: var(--paper-2); }
.labeled-btn[disabled] { opacity: 0.5; cursor: wait; }
.labeled-btn .glyph { font-size: 14px; line-height: 1; }

.ghost-link {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.ghost-link:hover { text-decoration: underline; }

/* ─── Overlay toggle ────────────────────────────────────────── */
.overlay-toggle {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.overlay-toggle label {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.overlay-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.overlay-toggle label:has(input:checked) {
  background: var(--ink);
  color: var(--paper);
}

/* ─── Content pane ──────────────────────────────────────────── */
.pane {
  padding: 24px;
  overflow: hidden;
  min-height: 0;
  display: grid;
  gap: 20px;
}

.pane.viewer-pane {
  grid-template-columns: 1fr 280px;
}
.pane.center {
  place-items: center;
  padding: 40px;
}

/* ─── Drop zone ─────────────────────────────────────────────── */
.dropzone {
  width: 100%;
  max-width: 680px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  padding: 72px 48px;
  background: var(--accent-soft);
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.dropzone:hover { background: #e4ddf8; }
.dropzone.drag-over {
  background: #d8cff5;
  transform: scale(1.01);
}
.dropzone .arrow {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--accent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.dropzone h2 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin: 0;
}
.dropzone .hint {
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 8px;
}
.dropzone .footnote {
  font-size: 12px;
  color: var(--mute);
  margin-top: 24px;
}

/* ─── Viewer ────────────────────────────────────────────────── */
.viewer-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
  background: #0e0f12;
  border-radius: var(--radius);
  overflow: hidden;
}
.viewer-stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.viewer-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.steps-rail {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.steps-rail h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--mute);
  font-weight: 600;
  margin: 0 0 10px;
}
.steps-rail .step-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  min-height: 0;
}
.steps-rail .step {
  display: flex;
  gap: 10px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  align-items: flex-start;
  cursor: pointer;
}
.steps-rail .step:hover { background: var(--line-soft); }
.steps-rail .step.active { background: var(--accent-soft); }
.steps-rail .step .num {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--line-soft);
  color: var(--mute);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.steps-rail .step.active .num { background: var(--accent); color: #fff; }
.steps-rail .step-title { font-size: 13px; font-weight: 500; color: var(--ink); }
.steps-rail .step-time {
  font-size: 11px;
  color: var(--mute);
  margin-top: 1px;
  font-family: ui-monospace, Menlo, monospace;
}
.steps-rail .empty {
  color: var(--mute);
  font-size: 12.5px;
  padding: 8px 6px;
}

/* ─── Processing pane ───────────────────────────────────────── */
.processing-wrap {
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow: auto;
}
.processing-card { width: 100%; max-width: 560px; }

.processing-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0e0f12;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  margin-bottom: 28px;
}
.processing-thumb .scrim {
  position: absolute;
  inset: 0;
  background: rgba(14, 15, 18, 0.5);
}
.processing-thumb .track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
}
.processing-thumb .track > div {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.4s ease;
}

.stage-tracker {
  display: flex;
  gap: 0;
}
.stage {
  flex: 1;
  position: relative;
}
.stage-head { display: flex; align-items: center; }
.stage-bullet {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.stage.done .stage-bullet { background: var(--ink); border-color: var(--ink); }
.stage.active .stage-bullet { background: var(--accent); border-color: var(--accent); }
.stage.pending .stage-bullet { color: var(--mute); background: #fff; }
.stage-bar {
  flex: 1;
  height: 2px;
  background: var(--line);
  margin-left: -1px;
}
.stage.done .stage-bar { background: var(--ink); }
.stage-label {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}
.stage.pending .stage-label { color: var(--mute); }
.stage.active .stage-label { font-weight: 600; }
.stage-sub {
  font-size: 11px;
  color: var(--mute);
  margin-top: 2px;
}

.email-note {
  margin-top: 28px;
  font-size: 12px;
  color: var(--mute);
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.email-note .dot { margin-top: 5px; }

.processing-error {
  margin-top: 20px;
  padding: 12px;
  border-radius: 8px;
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid #e9c6c3;
  font-size: 13px;
}

/* ─── Sign-in page ──────────────────────────────────────────── */
.signin-split {
  display: grid;
  grid-template-columns: 1fr 420px;
  height: 100vh;
  background: var(--paper);
}
@media (max-width: 900px) {
  .signin-split { grid-template-columns: 1fr; }
  .signin-pitch { display: none; }
}
.signin-pitch {
  padding: 40px;
  position: relative;
  overflow: hidden;
}
.signin-pitch h2 {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -1.2px;
  line-height: 1.05;
  margin: 48px 0 0;
  max-width: 440px;
}
.signin-pitch p {
  font-size: 15px;
  color: var(--mute);
  margin-top: 16px;
  max-width: 440px;
  line-height: 1.55;
}
.signin-pitch .peek {
  position: absolute;
  right: -80px;
  bottom: -40px;
  width: 520px;
  height: 340px;
  border-radius: 10px;
  overflow: hidden;
  background: #0e0f12;
  box-shadow: 0 30px 80px rgba(20, 15, 50, 0.15);
  border: 1px solid var(--line);
}
.signin-form {
  background: #fff;
  border-left: 1px solid var(--line);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.signin-form h3 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin: 0;
}
.signin-form .lede {
  font-size: 13px;
  color: var(--mute);
  margin-top: 4px;
  margin-bottom: 28px;
}
.signin-form #sign-in > * { max-width: 100%; }

/* ─── Factory placeholder (purely decorative) ────────────────── */
.factory {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.factory::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 40%, #3c3f4a 0%, transparent 50%),
    radial-gradient(ellipse at 70% 65%, #2a2d36 0%, transparent 55%),
    linear-gradient(180deg, #1c1e25 0%, #0e0f12 100%);
}
.factory::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background-image: repeating-linear-gradient(
    0deg, transparent 0, transparent 2px, #fff 2px, #fff 3px);
}

/* ─── Config error ───────────────────────────────────────────── */
#config-error {
  max-width: 640px;
  margin: 48px auto;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
#config-error code {
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink-soft);
}

/* ─── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  z-index: 1000;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Shared view (view-only recipient) ─────────────────────── */
#shared-view {
  height: 100vh;
  background: var(--paper);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.shared-topbar {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.shared-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--mute);
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 999px;
}
.shared-pane {
  padding: 28px 24px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#shared-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.shared-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.shared-overlay-toggle {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  margin-bottom: 16px;
  align-self: flex-start;
}
.shared-overlay-toggle label {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.shared-overlay-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.shared-overlay-toggle label:has(input:checked) {
  background: var(--ink);
  color: var(--paper);
}
.shared-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  flex: 1;
  min-height: 0;
}
.shared-grid .viewer-stage {
  height: 100%;
  min-height: 320px;
}
@media (max-width: 820px) {
  .shared-grid { grid-template-columns: 1fr; }
}
.shared-pane h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin: 0;
}
.shared-pane h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--mute);
  font-weight: 600;
  margin: 28px 0 10px;
}
.shared-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--mute);
}
.shared-meta .sep { opacity: 0.5; }
.shared-error {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bad-soft);
  border: 1px solid #e9c6c3;
  color: var(--bad);
  font-size: 13px;
}

[hidden] { display: none !important; }
