:root {
  --ink: #1c1b18;
  --ink-soft: #5d5a52;
  --cream: #e9e2ce;
  --cream-soft: #f4f0e4;
  --gold: #897858;
  --gold-deep: #6f6146;
  --line: #d9d0b8;
  --stage: #161512;
  --rec: #b3261e;
  --good: #3d6b3a;
  --display: "Playfair Display", Georgia, serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #fff; color: var(--ink); font: 16px/1.5 var(--body); -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 500; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); }
h1 em, h2 em { color: var(--gold); font-style: italic; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: 0 0 .8em; }
.muted { color: var(--ink-soft); font-size: .92rem; }
.err { color: var(--rec); }
.good { color: var(--good); }
.bad { color: #f1b0ab; }

.brand { font-family: var(--display); letter-spacing: .28em; font-size: .9rem; font-weight: 600; }
.brand span { font-style: italic; letter-spacing: .02em; color: var(--gold); font-weight: 500; margin-left: .25em; }
.brand.big { font-size: 1.1rem; text-align: center; margin-bottom: 1.4rem; }

.card { background: var(--cream); border-radius: 14px; padding: 1.2rem; }
label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .8rem; }
input, select {
  display: block; width: 100%; margin-top: .3rem; padding: .7rem .8rem; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); font-size: 1rem;
}
select { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23897858' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right .8rem center; padding-right: 2rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--gold); color: #fff; border: 0; border-radius: 999px; padding: .75rem 1.4rem;
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--gold-deep); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.wide { width: 100%; padding: 1rem; font-size: 1.05rem; }
.chip {
  display: inline-block; border: 1px solid var(--gold); color: var(--gold-deep); background: transparent;
  border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.chip.ghost { border-color: var(--line); color: var(--ink-soft); }
.link { background: none; border: 0; color: var(--gold-deep); cursor: pointer; padding: 0; font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: calc(1rem + var(--safe-b)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 12px; font-size: .9rem; max-width: min(92vw, 520px);
}
.toast.err { background: var(--rec); color: #fff; }

/* ---- Login & dashboard ---- */
.login { max-width: 400px; margin: 12vh auto; padding: 0 1.2rem; }
.dash { max-width: 820px; margin: 0 auto; padding: calc(1rem + var(--safe-t)) 1.2rem 4rem; }
.dash-head { display: flex; justify-content: space-between; align-items: center; padding: .5rem 0 2rem; }
.intro p { color: var(--ink-soft); max-width: 36em; }
.new { display: grid; grid-template-columns: 2fr 1fr auto; gap: .8rem; align-items: end; margin: 1.6rem 0 2.2rem; }
.new label { margin: 0; }
@media (max-width: 640px) { .new { grid-template-columns: 1fr; } }
.usage { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; font-size: .9rem; margin: -1rem 0 1.4rem; }
.usage-bar { flex: 1; min-width: 120px; height: 6px; background: var(--cream); border-radius: 6px; overflow: hidden; }
.usage-bar i { display: block; height: 100%; background: var(--gold); }
.session { margin-bottom: 1.2rem; background: var(--cream-soft); border: 1px solid var(--cream); }
.session-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.links { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .6rem 0 1rem; }
.links code { background: #fff; border-radius: 8px; padding: .25rem .5rem; font-size: .8rem; word-break: break-all; }
.take { border-top: 1px solid var(--line); padding: .9rem 0; }
.take-head { display: flex; gap: .8rem; align-items: baseline; margin-bottom: .5rem; }
.files { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 640px) { .files { grid-template-columns: 1fr; } }
.file { background: #fff; border-radius: 10px; padding: .7rem .8rem; display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; }
.file b { width: 100%; font-weight: 600; }
.file .muted { width: 100%; font-size: .82rem; }
.file.missing { opacity: .6; }
.sync { font-size: .88rem; margin: .6rem 0 0; }
.session-foot { text-align: right; margin-top: .4rem; }

/* ---- Green room ---- */
.green { max-width: 460px; margin: 0 auto; padding: calc(1rem + var(--safe-t)) 1.1rem calc(2rem + var(--safe-b)); }
.green .brand { margin-bottom: 1.4rem; }
.preview-wrap {
  position: relative; margin: 1rem auto .5rem; width: min(100%, 300px); aspect-ratio: 9 / 16;
  border-radius: 18px; overflow: hidden; background: var(--stage);
}
.preview-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mirror { transform: scaleX(-1); }
/* The wide (16:9 side-by-side) edit uses a centred 8:9 slice of a portrait frame. */
.frame-guide {
  position: absolute; left: 0; right: 0; top: 50%; height: calc(100% * 0.633); transform: translateY(-50%);
  box-shadow: 0 0 0 999px rgba(22, 21, 18, .42); border-top: 1px dashed rgba(233, 226, 206, .8); border-bottom: 1px dashed rgba(233, 226, 206, .8);
  pointer-events: none;
}
.frame-guide span {
  position: absolute; top: -1.7rem; left: 50%; transform: translateX(-50%); color: var(--cream);
  font-size: .72rem; letter-spacing: .08em; white-space: nowrap;
}
.meter { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--cream); transform-origin: left; transform: scaleX(0); transition: transform .08s linear; }
.settings-line { text-align: center; font-size: .8rem; margin-bottom: 1rem; }
.checks { margin-bottom: 1rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.row > span { font-size: .95rem; flex-shrink: 0; }
.row select { width: auto; max-width: 62%; margin: 0; }
.seg { display: inline-flex; background: #fff; border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: .35rem 1rem; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--gold); color: #fff; }
.hint { font-size: .82rem; color: var(--ink-soft); margin: -.2rem 0 .9rem; }
.tips summary { cursor: pointer; color: var(--gold-deep); font-size: .92rem; }
.tips ul { padding-left: 1.1rem; margin: .5rem 0 0; font-size: .9rem; }

/* ---- Live studio ---- */
.page-room { background: var(--stage); }
.studio { height: 100dvh; display: flex; flex-direction: column; background: var(--stage); color: #fff; }
.stage { position: relative; flex: 1; overflow: hidden; }
#remote { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--stage); }
.waiting { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: .8rem; padding: 2rem; color: var(--cream); }
.waiting[hidden] { display: none; }
.waiting p { font-family: var(--display); font-style: italic; font-size: 1.3rem; }
.self {
  position: absolute; right: 12px; bottom: 12px; width: 28%; max-width: 150px; aspect-ratio: 9 / 16;
  border-radius: 12px; overflow: hidden; border: 1px solid rgba(233,226,206,.5); background: #000;
}
.self video { width: 100%; height: 100%; object-fit: cover; }
.topbar { position: absolute; top: calc(10px + var(--safe-t)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.rec-pill { display: inline-flex; align-items: center; gap: .5rem; background: rgba(0,0,0,.55); border-radius: 999px; padding: .3rem .8rem; font-variant-numeric: tabular-nums; }
.rec-pill[hidden] { display: none; }
.rec-pill i { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.conn { font-size: .78rem; background: rgba(0,0,0,.45); padding: .25rem .65rem; border-radius: 999px; color: var(--cream); }
.statusbar { padding: .5rem 1rem 0; font-size: .78rem; color: var(--cream); min-height: 2.2rem; }
.statusbar b { color: #fff; font-weight: 600; margin-right: .3rem; }
.controls { display: flex; align-items: center; justify-content: space-around; gap: 1rem; padding: .8rem 1rem calc(.9rem + var(--safe-b)); }
.round { width: 64px; height: 64px; border-radius: 50%; border: 1px solid rgba(233,226,206,.4); background: rgba(255,255,255,.06); color: #fff; font-size: .78rem; cursor: pointer; }
.round.on { background: var(--cream); color: var(--ink); }
.recbtn { width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--cream); background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
.recbtn span { width: 64px; height: 64px; border-radius: 50%; background: var(--rec); display: grid; place-items: center; color: #fff; font-size: .8rem; font-weight: 600; transition: border-radius .25s ease, transform .25s ease; }
.recbtn.on span { border-radius: 14px; transform: scale(.72); }
.guest-note { max-width: 46%; text-align: center; font-size: .85rem; color: var(--cream); font-family: var(--display); font-style: italic; }

@media (min-width: 900px) {
  .stage { display: grid; place-items: center; }
  #remote { width: auto; height: 100%; aspect-ratio: 9 / 16; border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.tap-play { position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; z-index: 5;
  background: var(--cream); color: var(--ink); border: 0; border-radius: 999px; padding: .7rem 1.2rem; font-weight: 600; cursor: pointer; }
