/* ============================================================
   flow-clip — player styles
   No clip-specific words live here. Every visible string comes
   from the clip's data file.
   ============================================================ */
:root{
  --bg:#0a0c10; --panel:#12151c; --panel-2:#171b24; --line:#242a36;
  --text:#e8ecf4; --dim:#98a2b6; --faint:#6b7488;
  --accent:#5fb0ff;
  --shadow:0 24px 60px rgba(0,0,0,.6);
  --mono:"SF Mono",Consolas,"DejaVu Sans Mono",monospace;
  --font:"Segoe UI","Noto Sans Thai",system-ui,-apple-system,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--text); font-family:var(--font);
  font-size:15px; line-height:1.6; -webkit-font-smoothing:antialiased;
  min-height:100vh;
}

/* ---------- shell ---------- */
.app{
  display:grid;
  grid-template-columns:268px minmax(0,1fr);
  gap:0; height:100dvh; overflow:hidden;
}

/* ---------- chapter rail ---------- */
.railwrap{
  position:sticky; top:0; height:100vh;
  background:var(--panel); border-right:1px solid var(--line);
}
.rail{
  position:absolute; inset:0; height:100%;
  padding:20px 0 24px;
  /* its own scroller; the bar is drawn over the content and takes
     no width of its own, so nothing reflows when it appears */
  overflow-y:auto; overflow-x:hidden;
  scrollbar-width:none; -ms-overflow-style:none;
}
.rail::-webkit-scrollbar{width:0; height:0}

/* the visible bar: an overlay track pinned to the rail's right edge */
.railscroll{
  position:absolute; top:6px; right:2px; width:5px; bottom:6px;
  pointer-events:none; opacity:0; transition:opacity .25s;
  z-index:5;
}
.railwrap:hover .railscroll, .railwrap:focus-within .railscroll,
.railscroll.live{opacity:1}
.railscroll .thumb{
  position:absolute; left:0; width:5px; border-radius:3px;
  background:rgba(255,255,255,.3);
  transition:background .2s;
}
.railscroll:hover .thumb{background:rgba(255,255,255,.5)}
@media (max-width:767px){ .railscroll{display:none} }

.rail h1{font-size:15px; margin:0 20px 4px; letter-spacing:.2px}
.rail .sub{font-size:12.5px; color:var(--dim); margin:0 20px 18px; line-height:1.5}
.rail .back{
  display:inline-block; margin:0 20px 14px; font-size:12px;
  color:var(--faint); text-decoration:none;
}
.rail .back:hover{color:var(--text)}
.chapters{list-style:none;margin:0;padding:0}
.chapters .ch{
  font-size:11px; letter-spacing:.9px; text-transform:uppercase;
  color:var(--faint); margin:18px 20px 7px; font-weight:600;
}
.bm{
  display:grid; grid-template-columns:30px 1fr; align-items:start; gap:9px;
  width:100%; text-align:left; background:none; border:0; cursor:pointer;
  color:var(--dim); font:inherit; font-size:13.2px; line-height:1.4;
  padding:8px 18px 8px 16px; border-left:2px solid transparent;
  transition:background .16s, color .16s, border-color .16s;
  position:relative; overflow:hidden;
}
.bm:hover{background:var(--panel-2); color:var(--text)}
/* progress fill — how far through this scene we are */
.bm .prog{
  position:absolute; left:0; top:0; bottom:0; width:0;
  background:linear-gradient(90deg,rgba(95,176,255,.16),rgba(95,176,255,.05));
  pointer-events:none; transition:width .5s cubic-bezier(.4,0,.2,1);
}
.bm.seen .prog{width:100%; background:rgba(95,176,255,.05)}
.bm > *{position:relative}
/* dots: one per beat in the scene, only on the scene being played */
.bm .dots{display:none; gap:4px; margin-top:6px}
.bm[aria-current="true"] .dots{display:flex}
.bm .dot{
  width:16px; height:3px; border-radius:2px; background:#2f3746;
  transition:background .25s;
}
.bm .dot.on{background:var(--accent)}
.bm .dot.past{background:rgba(95,176,255,.45)}
.bm .n{
  font-family:var(--mono); font-size:11px; color:var(--faint);
  background:var(--panel-2); border:1px solid var(--line); border-radius:5px;
  text-align:center; padding:2px 0; margin-top:1px;
}
.bm[aria-current="true"]{
  background:#161c28; color:var(--text); border-left-color:var(--accent);
}
.bm[aria-current="true"] .n{
  background:var(--accent); border-color:var(--accent); color:#06121f; font-weight:700;
}
.bm .who{
  display:inline-block; font-size:10.5px; padding:0 5px; border-radius:4px;
  margin-left:6px; vertical-align:1px; font-weight:600;
  background:var(--role-soft,rgba(255,255,255,.08)); color:var(--role,var(--dim));
}

/* ---------- stage ---------- */
/* top stays, middle holds the screen, footer stays */
.stage{
  display:grid; grid-template-rows:auto minmax(0,1fr) auto;
  min-width:0; height:100dvh; overflow:hidden; position:relative;
}
/* the middle never scrolls — the screen shrinks to fit what is left */
.stagebody{min-height:0; overflow:hidden; display:flex; flex-direction:column}
.stagehead{
  padding:14px 24px 14px 30px; display:flex; align-items:flex-start;
  justify-content:space-between; gap:20px; flex-wrap:wrap;
  position:relative; border-bottom:1px solid var(--line);
}
/* a line divides the screen from the foot; the beats and controls
   inside that foot are not divided from each other */
.stagefoot{border-top:1px solid var(--line)}
/* a quiet chevron that sits in the row, not floating over it */
.headtoggle{
  flex:0 0 auto; align-self:center; margin-left:auto;
  background:none; border:0; color:var(--faint);
  width:28px; height:28px; border-radius:50%; padding:0;
  cursor:pointer; display:inline-grid; place-items:center;
  transition:background .15s, color .15s;
}
.headtoggle:hover{background:var(--panel-2); color:var(--text)}
.headtoggle svg{transition:transform .25s ease}
.headtoggle span{
  position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%);
}

/* --- collapsed: header shrinks to one line --- */
body.mini .stagehead{padding:8px 24px 8px 30px}
body.mini .scenario p,
body.mini .scenario .kicker,
body.mini .cast{display:none}
body.mini .scenario h2{
  font-size:14px; font-weight:600; color:var(--dim);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  max-width:calc(100vw - 460px); margin:0;
}
body.mini .headtoggle svg{transform:rotate(180deg)}
body.mini .framewrap{padding-top:10px}
.scenario{max-width:720px}
.scenario .kicker{
  font-size:11px; letter-spacing:1.1px; text-transform:uppercase;
  color:var(--faint); font-weight:600; margin-bottom:5px;
}
.scenario h2{margin:0 0 6px; font-size:19px; font-weight:650; letter-spacing:.1px}
.scenario p{margin:0; color:var(--dim); font-size:13.5px; line-height:1.62}

.cast{display:flex; gap:7px; flex-wrap:wrap; margin-top:2px}
.cast span{
  font-size:11.5px; padding:3px 9px; border-radius:20px;
  border:1px solid var(--line); background:var(--panel); color:var(--dim);
}
.cast span b{font-weight:600; color:var(--role,var(--text))}

/* ---------- frame ---------- */
.framewrap{
  padding:14px 30px; min-width:0; min-height:0; flex:1 1 auto;
  display:flex; justify-content:flex-start; align-items:stretch; gap:0;
}
/* the notes sit left of the screen, divided by one vertical line */
.notes{
  flex:0 0 clamp(210px, 18vw, 270px); min-width:0; min-height:0;
  display:flex; flex-direction:column; gap:12px;
  padding:2px 18px 2px 0; margin-right:18px; align-self:stretch;
  overflow:hidden; position:relative;
}
/* the divider runs the whole height of the region, not just the notes */
.notes::after{
  content:""; position:absolute; top:-15px; bottom:-15px; right:0;
  width:1px; background:var(--line);
}
/* the screen centres itself inside the space left over */
.framewrap > .frame{align-self:center}
.frame{
  position:relative; border-radius:12px; overflow:hidden;
  border:1px solid var(--line); background:#000; box-shadow:var(--shadow);
  /* true aspect ratio of the shots; never cropped */
  aspect-ratio:var(--ratio, 16/9);
  width:var(--framew, 100%); height:auto;
  margin:auto;
}
.frame img{
  position:absolute; inset:0; width:100%; height:100%; object-fit:fill;
  opacity:0; transition:opacity .42s ease;
}
.frame img.on{opacity:1}

.spot{
  position:absolute; pointer-events:none;
  border:2px solid var(--accent); border-radius:8px;
  box-shadow:0 0 0 1px rgba(10,14,22,.85), 0 0 26px rgba(95,176,255,.4);
  opacity:0; transition:opacity .3s ease, left .55s cubic-bezier(.4,0,.2,1),
    top .55s cubic-bezier(.4,0,.2,1), width .55s cubic-bezier(.4,0,.2,1),
    height .55s cubic-bezier(.4,0,.2,1);
}
.spot.on{opacity:1}

.marker{
  position:absolute; pointer-events:none;
  width:22px; height:22px; margin:-11px 0 0 -26px;
  border-radius:50%; background:var(--accent); color:#06121f;
  font-size:12px; font-weight:800; font-family:var(--mono);
  display:grid; place-items:center;
  box-shadow:0 0 0 3px rgba(5,8,14,.9), 0 0 18px rgba(95,176,255,.55);
  opacity:0; transition:opacity .3s ease, left .55s cubic-bezier(.4,0,.2,1),
    top .55s cubic-bezier(.4,0,.2,1);
}
.marker.on{opacity:1}

/* the caption is pinned to the bottom of the notes column, so it
   never sits over the screen */
.capinner{
  flex:0 0 auto; margin-top:auto;
  padding-top:12px; border-top:1px solid var(--line);
  opacity:0; transform:translateY(9px);
  transition:opacity .34s ease, transform .34s ease;
}
.capinner.on{opacity:1; transform:none}
.capwho{
  display:inline-block; font-size:10.5px; font-weight:700; letter-spacing:.7px;
  text-transform:uppercase; padding:2px 8px; border-radius:5px; margin-bottom:7px;
  background:var(--role-soft,rgba(255,255,255,.1)); color:var(--role,var(--text));
}
.captext{font-size:15.5px; line-height:1.5; font-weight:600; color:#fff}
.capsub{font-size:13px; color:var(--dim); margin-top:5px; line-height:1.55}

/* ---------- beats ---------- */
/* one slim row each, not a wall of cards */
.beats{
  flex:1 1 auto; min-height:0;
  display:flex; flex-direction:column; gap:5px; align-items:stretch;
  overflow-y:auto; overflow-x:hidden; padding-right:6px;
  scrollbar-width:thin; scrollbar-color:#2f3746 transparent;
}
.beats::-webkit-scrollbar{width:6px}
.beats::-webkit-scrollbar-thumb{background:#2f3746; border-radius:3px}
.beats::-webkit-scrollbar-track{background:transparent}
.beat{
  flex:0 0 auto; min-width:0;
  background:var(--panel); border:1px solid var(--line); border-radius:7px;
  padding:6px 10px; font-size:12px; line-height:1.4; color:var(--dim);
  cursor:pointer; text-align:left; font-family:inherit;
  display:flex; align-items:flex-start; gap:8px;
  transition:border-color .16s, background .16s;
}
.beat:hover{border-color:#39435a; background:var(--panel-2)}
.beat[aria-current="true"]{border-color:var(--accent); background:#141b27}
.beat b{display:block; color:var(--text); font-weight:600; font-size:12.2px; min-width:0}
.beat[aria-current="true"] b{color:#fff}
.beat .num{
  font-family:var(--mono); font-size:10px; color:var(--faint); margin-top:1px;
  flex:0 0 auto; background:var(--panel-2); border-radius:4px; padding:1px 5px;
}
.beat[aria-current="true"] .num{background:var(--accent); color:#06121f; font-weight:700}

/* ---------- transport ---------- */
.transport{padding:6px 30px 12px; display:flex; flex-direction:column; gap:8px}
.controls{display:flex; align-items:center; gap:10px; flex-wrap:wrap}
.btn{
  background:var(--panel-2); border:1px solid var(--line); color:var(--text);
  border-radius:8px; padding:7px 13px; font:inherit; font-size:13px;
  cursor:pointer; display:inline-flex; align-items:center; gap:7px;
  transition:background .15s, border-color .15s;
}
.btn:hover{background:#1e2430; border-color:#323a4a}
.btn.primary{background:var(--accent); border-color:var(--accent); color:#06121f; font-weight:650}
.btn.primary:hover{background:#7cc0ff}
.btn svg{display:block}
.pos{font-family:var(--mono); font-size:12px; color:var(--dim); margin-left:2px; white-space:nowrap}
.spd{display:flex; gap:0; border:1px solid var(--line); border-radius:8px; overflow:hidden}
.spd button{
  background:var(--panel-2); border:0; color:var(--dim); font:inherit; font-size:12px;
  padding:7px 10px; cursor:pointer; border-right:1px solid var(--line);
}
.spd button:last-child{border-right:0}
.spd button[aria-pressed="true"]{background:var(--accent); color:#06121f; font-weight:700}
.hint{font-size:11.5px; color:var(--faint); margin-left:auto}
kbd{
  font-family:var(--mono); font-size:10.5px; background:var(--panel-2);
  border:1px solid var(--line); border-bottom-width:2px; border-radius:4px;
  padding:1px 5px; color:var(--dim);
}

/* ---------- failure ---------- */
.fatal{
  margin:40px auto; max-width:620px; padding:20px 24px;
  border:1px solid var(--line); border-radius:10px; background:var(--panel);
  color:var(--dim); font-size:13.5px;
}
.fatal code{font-family:var(--mono); color:var(--text)}

@media (max-width:980px){
  .app{grid-template-columns:1fr}
  .railwrap{position:static; height:auto; border-right:0; border-bottom:1px solid var(--line)}
  .rail{position:static; height:auto; overflow:visible}
  .stagehead,.framewrap,.transport{padding-left:18px; padding-right:18px}
  .framewrap{flex-direction:column}
  .notes{
    flex:0 0 auto; border-right:0; border-bottom:1px solid var(--line);
    margin-right:0; margin-bottom:12px; padding:0 0 12px;
    max-height:42vh;
  }
  .notes::after{display:none}
  .capinner{margin-top:12px}
}
