/* Emote Studio — interface styled after the Raven design language:
   pure black, minimal chrome, editorial contrast between a tight geometric
   sans and a serif for prose, tiny wide-tracked uppercase labels, and
   near-square white primary buttons.

   ABC Diatype and Tobias are commercial faces, so we use the same fallback
   stacks the reference site declares. */

:root {
  --bg:            #000000;
  --surface:       #0a0a0a;
  --surface-2:     #0f0f0f;
  --line:          #1a1a1a;
  --line-strong:   #2e2e2e;
  --line-btn:      #474747;
  --text:          #ffffff;
  --text-dim:      #8d8d92;
  --text-faint:    #5c5c61;
  --accent:        #1851ff;
  --danger:        #ff4d4d;
  --ok:            #35d07f;

  --r-btn:   3px;
  --r-input: 8px;
  --r-card:  10px;

  --sans:  'ABC Diatype', system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  --serif: 'Tobias', 'Iowan Old Style', Palatino, Georgia, serif;
  --mono:  ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── type ────────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.eyebrow::before {
  content: '';
  width: 26px;
  height: 1px;
  background: var(--line-strong);
  flex: none;
}

.display {
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 400;
  margin: 0;
}

.prose {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0;
}

/* ── buttons ─────────────────────────────────────────────── */
.rb-btn {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1;
  padding: 11px 16px;
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  background: #ffffff;
  color: #0a0b0d;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .14s ease, border-color .14s ease, opacity .14s ease, transform .06s ease;
}
.rb-btn:hover:not(:disabled)  { background: #e7e7e7; }
.rb-btn:active:not(:disabled) { transform: translateY(1px); }
.rb-btn:disabled { opacity: .32; cursor: not-allowed; }

.rb-btn-sec {
  background: transparent;
  color: var(--text);
  border-color: var(--line-btn);
}
.rb-btn-sec:hover:not(:disabled) { background: #131313; border-color: #6a6a6a; }

.rb-btn-sm { font-size: 11.5px; padding: 8px 12px; }

.rb-icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-btn);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease;
}
.rb-icon-btn:hover:not(:disabled) { background: #131313; border-color: #6a6a6a; }
.rb-icon-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ── surfaces ────────────────────────────────────────────── */
.rb-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

.rb-pill {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  white-space: nowrap;
}
.rb-pill.on  { color: var(--text); border-color: #4a4a4a; }
.rb-pill.err { color: var(--danger); border-color: #4a2020; }

/* ── inputs ──────────────────────────────────────────────── */
.rb-input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .14s ease, background .14s ease;
}
.rb-input:focus { border-color: #3a3a3a; background: #121212; }
.rb-input::placeholder { color: var(--text-faint); }
select.rb-input { cursor: pointer; }

.rb-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
  display: block;
}
.rb-check { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ── gate ────────────────────────────────────────────────── */
#gate {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--bg);
  overflow: hidden;
}
/* soft atmospheric wash behind the panel */
#gate::before {
  content: '';
  position: absolute;
  width: 900px; height: 620px;
  top: -14%; left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center,
              rgba(52,66,120,.30) 0%, rgba(24,81,255,.10) 38%, transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}
.gate-card {
  position: relative;
  width: 100%; max-width: 430px;
  padding: 0;
  background: transparent;
  border: none;
  text-align: left;
}
.gate-logo {
  width: 30px; height: 30px; border-radius: 6px;
  background: #fff; color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; letter-spacing: -0.03em;
  margin-bottom: 26px;
}
.gate-shake { animation: gshake .32s; }
@keyframes gshake {
  0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)}
  40%{transform:translateX(6px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)}
}

/* ── app chrome: floating pill bar ───────────────────────── */
.rb-topbar {
  position: sticky; top: 0; z-index: 20;
  margin: 12px 12px 0;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px 9px 14px;
  background: rgba(10,10,10,.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.rb-logo {
  width: 26px; height: 26px; border-radius: 5px;
  background: #fff; color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; letter-spacing: -0.03em;
}
.rb-panel-title {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 13px 14px 9px;
}

/* ── dropzone ────────────────────────────────────────────── */
.rb-drop {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-input);
  margin: 0 14px 12px;
  padding: 8px;
  transition: border-color .15s ease, background .15s ease;
}
.rb-drop.hot { border-color: var(--accent); background: rgba(24,81,255,.06); }

/* ── viewport ────────────────────────────────────────────── */
#viewport {
  background: #060606;
  border-radius: var(--r-input);
  overflow: hidden;
  position: relative;
}
#viewport canvas { display: block; width: 100%; height: 100%; }

/* ── progress ────────────────────────────────────────────── */
.rb-progress { height: 2px; background: var(--line); border-radius: 999px; overflow: hidden; }
.rb-progress-bar {
  height: 100%; width: 0%;
  background: #ffffff;
  transition: width .18s ease;
}

/* ── timeline ────────────────────────────────────────────── */
.rb-scrub {
  -webkit-appearance: none; appearance: none;
  height: 2px; border-radius: 999px;
  background: var(--line-strong);
  outline: none; cursor: pointer;
}
.rb-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: none; cursor: pointer;
}
.rb-scrub::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: none; cursor: pointer;
}
.rb-scrub:disabled { opacity: .35; cursor: not-allowed; }

/* ── code ────────────────────────────────────────────────── */
.rb-code {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  white-space: pre;
  overflow: auto;
  padding: 12px 14px;
  margin: 0;
  background: #060606;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
}

/* ── toast ───────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(70px);
  background: #fff; color: #0a0b0d;
  font-size: 12.5px; font-weight: 500;
  padding: 11px 18px; border-radius: var(--r-btn);
  opacity: 0; transition: all .24s cubic-bezier(.2,.9,.3,1);
  pointer-events: none; z-index: 60;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── scrollbars ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1f1f1f; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #2c2c2c; }

/* ── layout ──────────────────────────────────────────────── */
.min-h-dvh { min-height: 100dvh; }
#studio { display: flex; flex-direction: column; height: 100dvh; }

.wrap {
  flex: 1; min-height: 0;
  display: grid; gap: 12px; padding: 12px;
  grid-template-columns: 1fr;
  overflow-y: auto;
}
.col-left, .col-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.col-mid { display: flex; flex-direction: column; min-width: 0; min-height: 420px; }

@media (min-width: 900px) {
  .wrap { grid-template-columns: 296px minmax(0, 1fr); overflow: hidden; }
  .col-left  { overflow-y: auto; }
  .col-right { grid-column: 1 / -1; }
}
@media (min-width: 1240px) {
  .wrap { grid-template-columns: 296px minmax(0, 1fr) 296px; }
  .col-right { grid-column: auto; overflow: hidden; }
}

.view-btn.on { background: #fff; color: #0a0b0d; border-color: transparent; }

/* ── side-by-side stage: source video and rig, one timeline ── */
.stage {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
}
@media (min-width: 760px) {
  .stage { grid-template-columns: 1fr 1fr; }
}
.stage-pane {
  position: relative;
  min-height: 240px;
  background: #060606;
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.stage-pane > video {
  max-width: 100%; max-height: 100%;
  width: auto; height: 100%;
  display: block; background: #000;
}
.stage-pane > #viewport { position: absolute; inset: 0; border-radius: 0; }
.pane-tag {
  position: absolute; left: 9px; top: 8px; z-index: 3;
  font-family: var(--mono); font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--text-faint);
  background: rgba(0,0,0,.6); padding: 3px 7px; border-radius: 3px;
  pointer-events: none;
}
#vp-msg {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 20px;
  font-family: var(--serif); font-size: 13px; color: var(--text-faint);
  pointer-events: none;
}

/* ══ Mobile ═══════════════════════════════════════════════════
   Phones get natural document scrolling rather than the desktop's nested
   panes, larger touch targets, and 16px inputs so iOS does not zoom on
   focus. Safe-area insets keep content clear of notches and home bars. */

@media (max-width: 899px) {

  /* let the page scroll instead of trapping scroll inside columns */
  #studio { height: auto; min-height: 100dvh; }
  .wrap {
    overflow: visible;
    padding: 10px calc(10px + env(safe-area-inset-right))
             calc(18px + env(safe-area-inset-bottom))
             calc(10px + env(safe-area-inset-left));
    gap: 10px;
  }
  .col-left, .col-right { overflow: visible; }
  .col-mid { min-height: 0; }

  .rb-topbar {
    margin: calc(8px + env(safe-area-inset-top)) 10px 0;
    padding: 10px 10px 10px 13px;
    border-radius: 11px;
  }
  /* the strapline is the first thing to go when space is tight */
  .rb-topbar .eyebrow { display: none; }

  /* comfortable, thumb-sized controls */
  .rb-btn { padding: 14px 18px; font-size: 14px; min-height: 46px; }
  .rb-btn-sm { padding: 10px 14px; font-size: 13px; min-height: 38px; }
  .rb-icon-btn { width: 44px; height: 44px; }
  .rb-check { width: 20px; height: 20px; }

  /* 16px minimum stops iOS Safari zooming the page on focus */
  .rb-input { font-size: 16px; padding: 12px 13px; }

  /* stacked panes: keep both visible without eating the screen */
  .stage { padding: 10px; gap: 10px; }
  .stage-pane { min-height: 190px; }
  .stage-pane > video { height: auto; max-height: 300px; width: 100%; object-fit: contain; }

  /* the transport bar wraps: scrubber gets its own full-width row */
  .transport { flex-wrap: wrap; row-gap: 12px; }
  #scrub { order: 10; flex: 1 1 100%; min-width: 0; }
  #lbl-time, #lbl-frame { width: auto; }

  .rb-code { font-size: 10.5px; }
  #viewport canvas { touch-action: none; }   /* orbit drag must not scroll the page */
}

@media (max-width: 899px) {
  /* gate: breathing room and notch clearance */
  #gate {
    padding: calc(28px + env(safe-area-inset-top)) 22px
             calc(28px + env(safe-area-inset-bottom));
    align-items: flex-start;
  }
  .gate-card { max-width: 100%; margin-top: 8vh; }
  .display { font-size: clamp(30px, 9vw, 42px); }
  .prose { font-size: 14.5px; }
}

/* very narrow phones */
@media (max-width: 400px) {
  .wrap { padding-left: 8px; padding-right: 8px; }
  .rb-panel-title { padding: 11px 12px 8px; }
  .stage-pane { min-height: 165px; }
  .view-btn { padding: 9px 10px; font-size: 12px; }
}

/* coarse pointers: no hover states, bigger hit areas on the scrubber */
@media (hover: none) {
  .rb-btn:hover:not(:disabled) { background: #ffffff; }
  .rb-btn-sec:hover:not(:disabled) { background: transparent; border-color: var(--line-btn); }
  .rb-scrub { height: 4px; }
  .rb-scrub::-webkit-slider-thumb { width: 18px; height: 18px; }
  .rb-scrub::-moz-range-thumb { width: 18px; height: 18px; }
}

/* landscape phones are short: reclaim vertical space */
@media (max-width: 899px) and (orientation: landscape) and (max-height: 520px) {
  .stage { grid-template-columns: 1fr 1fr; }
  .stage-pane { min-height: 150px; }
  .gate-card { margin-top: 2vh; }
}

/* ── transport bar ────────────────────────────────────────── */
.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
/* the scrubber must never share a line with the readouts, or its thumb
   overlaps the text at narrow widths */
#scrub { flex: 1 1 auto; min-width: 60px; }
