:root {
  --gold: #FFD54A; --gold2: #c9a227; --navy: #0b1630; --bg: #030509;
  --fs: 52px; --col: 900px; --ready: 18vh;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: #fff; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}
body.playing { cursor: none; }

#bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 12px; background: rgba(11, 22, 48, .94); border-bottom: 1px solid rgba(255, 213, 74, .25);
  transition: opacity .35s, transform .35s; font-size: 14px;
}
body.hidebar #bar { opacity: 0; transform: translateY(-100%); pointer-events: none; }
#bar button, #bar select, #bar .btn {
  background: #13244d; color: #fff; border: 1px solid rgba(255, 213, 74, .35); border-radius: 8px;
  padding: 6px 10px; font-size: 14px; cursor: pointer; text-decoration: none; font-family: inherit; line-height: 1.2;
}
#bar button:hover, #bar .btn:hover { border-color: var(--gold); }
#bar button.on { background: var(--gold); color: #111; font-weight: 700; }
#bar .grp { display: flex; gap: 4px; align-items: center; padding: 0 6px; border-right: 1px solid rgba(255, 255, 255, .12); }
#bar .lab { color: #9fb0d6; font-size: 12px; margin-right: 2px; }
#bar .lab.sp { margin-left: 6px; }
#bar .val { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
#bar .title { color: #dfe6f7; font-weight: 600; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: 6px; }
#play { min-width: 96px; font-weight: 700; }
#rec { color: #ff6b6b !important; }
#rec.on { background: #e53935 !important; color: #fff !important; }
#saveBtn { background: var(--gold) !important; color: #111 !important; font-weight: 700; }
#clock { margin-left: auto; font-variant-numeric: tabular-nums; color: #dfe6f7; }

#stage { position: absolute; inset: 0; overflow-y: scroll; scrollbar-width: none; }
#stage::-webkit-scrollbar { display: none; }
#col {
  width: min(var(--col), 92vw); margin: 0 auto; padding: calc(var(--ready) + 10px) 0 85vh;
  font-size: var(--fs); line-height: 1.36; font-weight: 600; letter-spacing: .005em;
}
body.mirror #col { transform: scaleX(-1); }
.loading { font-size: .5em; color: #8ea0c9; }
.part { font-size: .46em; letter-spacing: .18em; color: var(--gold); font-weight: 800; margin: 1.6em 0 .2em; border-top: 1px solid rgba(255, 213, 74, .35); padding-top: .7em; }
.part small { display: block; letter-spacing: .04em; color: #8ea0c9; font-weight: 500; font-size: .62em; margin-top: .35em; }
.cue { font-size: .38em; line-height: 1.3; color: #7f93c2; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin: .9em 0 .25em; }
.cue::before { content: "▸ "; color: var(--gold2); }
.ln { margin: 0 0 .5em; color: rgba(255, 255, 255, .88); transition: color .25s, opacity .25s; cursor: pointer; }
.ln.long { margin-bottom: 1.15em; }
.ln.past { opacity: .28; }
.ln.cur { color: #fff; opacity: 1; }
.em, .gold { color: var(--gold); }
.cue-c { color: #7f93c2; }
.pz { display: inline-block; width: .09em; height: .62em; min-width: 3px; min-height: 12px; background: rgba(255, 213, 74, .55); margin: 0 .22em; vertical-align: -.04em; border-radius: 2px; }
.pz2 { display: inline-block; width: .32em; height: .7em; min-width: 10px; min-height: 13px; margin: 0 .2em; vertical-align: -.06em; border-left: max(.09em, 3px) solid var(--gold); border-right: max(.09em, 3px) solid var(--gold); }
.hint { display: block; font-size: .4em; color: #8ea0c9; font-weight: 500; margin-top: .2em; font-style: italic; }
.endp { font-size: .4em; color: #8ea0c9; text-align: center; margin: 1.2em 0 2em; letter-spacing: .08em; text-transform: uppercase; }

#readline { position: fixed; left: 0; right: 0; top: var(--ready); height: 0; z-index: 5; pointer-events: none; }
#readline::before, #readline::after { content: ""; position: absolute; top: -12px; border: 12px solid transparent; }
#readline::before { left: calc(50% - min(var(--col), 92vw) / 2 - 34px); border-left: 16px solid var(--gold); }
#readline::after { right: calc(50% - min(var(--col), 92vw) / 2 - 34px); border-right: 16px solid var(--gold); }
#shadeTop { position: fixed; left: 0; right: 0; top: 0; height: calc(var(--ready) - var(--fs) * .78); background: linear-gradient(var(--bg) 30%, rgba(3, 5, 9, .5)); z-index: 4; pointer-events: none; }
#prog { position: fixed; left: 0; bottom: 0; height: 4px; background: var(--gold); width: 0; z-index: 6; }

#count { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; z-index: 30; background: rgba(3, 5, 9, .78); font-size: 180px; font-weight: 800; color: var(--gold); }
#count small { font-size: 26px; color: #cfd8ee; font-weight: 600; margin-top: 10px; letter-spacing: .06em; }
#recdot { position: fixed; top: 58px; right: 16px; z-index: 25; display: none; align-items: center; gap: 8px; background: rgba(0, 0, 0, .6); padding: 6px 12px; border-radius: 20px; font-weight: 700; font-size: 15px; }
#recdot i { width: 12px; height: 12px; border-radius: 50%; background: #e53935; animation: bl 1s infinite; }
@keyframes bl { 50% { opacity: .25; } }
#meterMini { width: 80px; height: 6px; background: #222; border-radius: 3px; overflow: hidden; }
#meterMini b, #meter b { display: block; height: 100%; width: 0; background: #4caf50; }

.panel { position: fixed; z-index: 40; top: 60px; right: 14px; width: 420px; max-width: calc(100vw - 28px); max-height: calc(100vh - 80px); overflow: auto; background: var(--navy); border: 1px solid rgba(255, 213, 74, .4); border-radius: 14px; padding: 16px 18px; display: none; font-size: 14px; line-height: 1.45; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.panel.open { display: block; }
.panel h3 { margin: .2em 0 .6em; color: var(--gold); font-size: 16px; letter-spacing: .06em; }
.panel h3.mt { margin-top: 16px; }
.panel label { display: block; color: #9fb0d6; font-size: 12px; margin: 10px 0 4px; }
.panel label.chk { color: #dfe6f7; font-size: 13px; }
.panel select { width: 100%; background: #13244d; color: #fff; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; padding: 6px; }
.panel video { width: 100%; border-radius: 10px; background: #000; margin-top: 10px; transform: scaleX(-1); }
#meter { height: 10px; background: #222; border-radius: 5px; overflow: hidden; margin-top: 6px; }
.panel .x { float: right; cursor: pointer; color: #9fb0d6; font-size: 18px; }
.panel ol, .panel ul { padding-left: 18px; margin: .3em 0; }
.panel li { margin: .25em 0; }
.panel .pz { height: 12px; } .panel .pz2 { height: 13px; }
kbd { background: #13244d; border: 1px solid rgba(255, 255, 255, .25); border-radius: 5px; padding: 1px 6px; font-size: 12px; font-family: inherit; }
#takes a { color: var(--gold); }
#takes div { padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
#takes .take-h, #takes .take-act { padding: 0; border: 0; }
#takes .take-act { display: flex; gap: 6px; margin-top: 6px; }
#takes .ok { color: #7bd88f; font-weight: 700; }
#takes .wait { color: #dfe6f7; font-weight: 700; }
#takes button, .later {
  background: #13244d; color: #fff; border: 1px solid rgba(255, 213, 74, .35); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; cursor: pointer; font-family: inherit;
}
#takes button.keep { background: var(--gold); color: #111; border-color: var(--gold); font-weight: 700; }
#takes button.del { color: #ff8a80; border-color: rgba(229, 57, 53, .7); }
#takes button.del.armed { background: #e53935; color: #fff; }
#takes button.send { margin: 8px 0 6px; }

/* take review after Stop */
.review { position: fixed; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(3, 5, 9, .88); }
.review[hidden] { display: none; }
.rv-box { width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--navy); border: 1px solid rgba(255, 213, 74, .4); border-radius: 16px; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.rv-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.rv-head b { color: var(--gold); font-size: 18px; letter-spacing: .06em; }
.rv-head span { color: #9fb0d6; font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
#rvVideo { display: block; width: 100%; max-height: 52vh; background: #000; border-radius: 10px; }
.rv-q { margin: 14px 0 10px; font-size: 17px; font-weight: 600; }
.rv-act { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rv-act button { padding: 14px 10px; font-size: 17px; font-weight: 700; border-radius: 12px; cursor: pointer; font-family: inherit; }
.rv-act .keep { background: var(--gold); color: #111; border: 0; }
.rv-act .del { background: transparent; color: #ff8a80; border: 1px solid #e53935; }
.rv-act .del.armed { background: #e53935; color: #fff; }
.rv-act kbd { margin-left: 6px; opacity: .75; color: inherit; background: rgba(0, 0, 0, .18); }
.rv-foot { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 12px; }
.rv-foot .later { white-space: nowrap; }
#camfloat { position: fixed; right: 16px; bottom: 16px; width: 240px; border-radius: 12px; z-index: 8; display: none; transform: scaleX(-1); border: 2px solid rgba(255, 213, 74, .5); }
.note { color: #8ea0c9; font-size: 12px; }
#camInfo { margin-top: 6px; }
.err { color: #ff8a80; font-size: 22px; padding: 40px 0; line-height: 1.5; }
.err a { color: var(--gold); }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #13244d; color: #fff; border: 1px solid var(--gold); padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 60; font-size: 15px; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Camera controls and mobile-safe inline recording. */
.camera-actions { display:flex; flex-wrap:wrap; gap:6px; margin:12px 0; }
.camera-actions button, #cameraPlay, .camera-action { display:inline-block; background:#13244d; color:#fff; border:1px solid rgba(255,213,74,.4); border-radius:8px; padding:10px 12px; font:inherit; text-decoration:none; cursor:pointer; min-height:44px; }
#cameraRetry { background:var(--gold); color:#111; font-weight:700; }
button:disabled { opacity:.5; cursor:default; }
.camera-help { margin-top:10px; padding:12px; border:1px solid rgba(255,213,74,.4); border-radius:10px; background:rgba(255,213,74,.05); }
.camera-help[hidden] { display:none; }
.camera-help p { margin:0 0 10px; font-size:13px; line-height:1.5; }
.camera-help .note { margin:10px 0 0; }
#camInfo.camera-error { color:#ffb2a8; font-size:14px; line-height:1.5; }
.panel .x { background:transparent; border:0; min-width:40px; min-height:40px; padding:4px; font:inherit; font-size:20px; }
.panel video { min-height:120px; max-height:40vh; object-fit:contain; }
body.rear-camera #camPrev, body.rear-camera #camfloat { transform:none; }
#mobileControls { display:none; }
body.mobile-camera .panel #camPrev {
  display:block; width:auto; height:min(42dvh,560px); min-height:0; max-width:100%; max-height:max(64px,calc(100dvh - 280px));
  aspect-ratio:9 / 16; object-fit:cover; margin-left:auto; margin-right:auto;
}
body.mobile-camera #camfloat {
  width:auto; height:min(24dvh,213px); max-width:120px; max-height:none; aspect-ratio:9 / 16; object-fit:cover;
}
@media (max-width:767px), (max-width:1000px) and (max-height:600px) {
  #bar { flex-wrap:nowrap; overflow-x:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; padding:6px 8px; scrollbar-width:none; }
  #bar::-webkit-scrollbar { display:none; }
  #bar .grp, #clock { flex:0 0 auto; }
  #bar .title { display:none; }
  #bar button, #bar .btn { min-height:44px; display:inline-flex; align-items:center; }
  #col { font-size:min(var(--fs),36px); padding-top:calc(max(var(--ready),80px) + 10px); padding-bottom:calc(85vh + 80px); }
  #readline { top:max(var(--ready),80px); }
  #shadeTop { height:calc(max(var(--ready),80px) - min(var(--fs),36px) * .78); }
  #readline::before { left:0; border-left-width:12px; }
  #readline::after { right:0; border-right-width:12px; }
  #mobileControls { position:fixed; z-index:45; bottom:0; left:0; right:0; display:flex; justify-content:center; gap:8px; padding:10px 12px calc(10px + env(safe-area-inset-bottom,0px)); border-top:1px solid rgba(255,213,74,.3); background:rgba(11,22,48,.97); }
  #mobileControls button { flex:1; max-width:180px; min-height:46px; font:700 15px/1.2 inherit; font-family:inherit; background:#13244d; border:1px solid rgba(255,213,74,.4); border-radius:9px; color:#fff; touch-action:manipulation; }
  #mobileRec { color:#ff8a80!important; }
  #mobileRec.on { background:#c62828; color:#fff!important; }
  #mobileStop:not(:disabled) { background:var(--gold); color:#111; }
  .panel { top:62px; left:8px; right:8px; width:auto; max-width:none; max-height:calc(100vh - 148px); max-height:calc(100dvh - 148px - env(safe-area-inset-bottom,0px)); padding:12px; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
  .panel .x { min-width:44px; min-height:44px; }
  .panel select { min-height:44px; font-size:16px; }
  .panel video { max-height:30dvh; }
  #takes button, .later { min-height:44px; }
  #takes .take-act { flex-wrap:wrap; }
  #camfloat { width:120px; right:8px; bottom:calc(84px + env(safe-area-inset-bottom,0px)); }
  #recdot { top:66px; right:8px; font-size:12px; padding:6px 9px; }
  #meterMini { width:45px; }
  #count { font-size:110px; }
  #count small { max-width:85vw; text-align:center; font-size:18px; }
  .review { padding:8px; }
  .rv-box { padding:12px; max-height:calc(100vh - 16px); max-height:calc(100dvh - 16px); }
  .rv-head { flex-wrap:wrap; }
  .rv-act { gap:8px; }
  .rv-act button { font-size:15px; min-height:48px; }
  .rv-act kbd, .rv-foot kbd { display:none; }
  .rv-foot { flex-direction:column; align-items:stretch; }
  #rvVideo { max-height:45dvh; }
  #toast { max-width:90vw; width:max-content; bottom:calc(88px + env(safe-area-inset-bottom,0px)); font-size:13px; }
}
@media (prefers-reduced-motion:reduce) { #bar, #toast, .ln { transition:none; } #recdot i { animation:none; } }
