/* The editor (js/editor.js, screen 12): header, then tool rail | player + timeline | the chosen tool. */
/* its own layout: no sidebar, a slim bar on top (body.ed-on, set by openEditor) */
body.ed-on .app{grid-template-columns:minmax(0,1fr)}
body.ed-on .side{display:none}
body.ed-on .main{padding:12px clamp(12px,1.6vw,24px) 16px}
.ed-bar{display:flex;align-items:center;gap:10px;margin-bottom:12px;padding:8px 10px 8px 8px;border:1px solid var(--line);border-radius:16px;background:var(--glass)}
.ed-bar .ed-back{flex:none}
.ed-h1{margin:0;font-size:1.05rem;font-weight:700;letter-spacing:-.01em;white-space:nowrap}
.ed-state{font-size:.84rem;color:var(--muted);white-space:nowrap}
.ed-state.warn{color:var(--ink);font-weight:600}
.ed-state.busy::before{content:"";display:inline-block;width:8px;height:8px;margin-right:7px;border-radius:50%;background:var(--primary);animation:ed-pulse 1.2s ease-in-out infinite}
@keyframes ed-pulse{50%{opacity:.3}}
@media (prefers-reduced-motion:reduce){ .ed-state.busy::before{animation:none} }
/* Undo / Redo in the bar: every tool's changes not saved yet */
.ed-hist{display:flex;gap:6px;margin-left:4px}
.ed-hist .ghost{gap:6px;padding-left:10px;padding-right:12px}
.ed-hist .ghost .ms{font-size:18px}
/* Save / Discard, pinned to the bottom of the tool panel while something isn't saved */
.ed-savebar{position:sticky;bottom:-16px;z-index:5;display:flex;align-items:center;gap:10px;margin:auto -16px -16px;padding:12px 14px;
  border-top:1px solid var(--line);background:var(--panel);border-radius:0 0 16px 16px;box-shadow:0 -10px 24px rgba(0,0,0,.18)}
.ed-savebar[hidden]{display:none}
.ed-save-n{flex:1;min-width:0;font-size:.8rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ed-savebar #edCancel{color:var(--muted);font-size:.86rem}
.ed-savebar .primary{gap:6px}
.ed-savebar .primary .ms{font-size:18px}
.ed-bar-sp{flex:1}
.ed-bar .ghost,.ed-bar .primary{gap:8px;white-space:nowrap}
.ed-bar .primary .ms{font-size:19px}
/* the Short's name in Details */
.ed-meta{display:flex;flex-direction:column;gap:3px;margin-top:10px;min-width:0}
.ed-name{font-size:.95rem;line-height:1.3;overflow-wrap:anywhere}
.ed-sub{display:flex;gap:10px;font-size:.8rem;color:var(--muted);min-width:0}
.ed-len{font:600 .76rem/1.3 var(--mono);flex:none}
.ed-from{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* Finish */
dialog#edFin{width:min(460px,calc(100vw - 32px));border-radius:20px;padding:24px}
dialog#edFin::backdrop{background:rgba(8,10,18,.62)}
#edFin h2{margin:0 0 4px;font-size:1.2rem}
#edFin .lede{font-size:.88rem;margin:0 0 12px}
.ed-fin-wait{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:12px;background:var(--raised);font-size:.86rem}
.ed-fin-wait[hidden]{display:none}
.ed-fin-wait .spin{width:16px;height:16px;flex:none;border-radius:50%;border:2px solid var(--line-2);border-top-color:var(--primary);animation:ed-spin .8s linear infinite}
@keyframes ed-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){ .ed-fin-wait .spin{animation:none} }
#edFin .cl-sched-acts{flex-wrap:wrap;align-items:center}
#edFinStay{margin-right:auto;color:var(--muted)}
.ed-note{margin-bottom:14px;padding:12px 14px;border-radius:12px;background:var(--cap-soft);color:var(--ink);font-size:.9rem;font-weight:600}
.ed-note[hidden],.ed-grid[hidden],.ed-small[hidden]{display:none}
.ed-grid{--rail:220px;--panel:320px;position:relative;display:grid;grid-template-columns:var(--rail) minmax(0,1fr) var(--panel);gap:16px;align-items:start}
/* the tools' edge (js/editor.js edRailApply): drag to resize; far left = the tools above the player (.rail-top) */
.ed-grip{position:absolute;top:0;bottom:0;left:calc(var(--rail) + 2px);width:12px;z-index:3;display:flex;justify-content:center;cursor:col-resize;touch-action:none}
.ed-grip::before{content:"";align-self:center;width:4px;height:44px;border-radius:4px;background:var(--line-2);transition:height .15s,background .15s}
.ed-grip:hover::before,.ed-grip.drag::before,.ed-grip:focus-visible::before{height:80px;background:var(--primary)}
.ed-grip:focus-visible{outline:none}
.ed-grid.rail-top{grid-template-columns:minmax(0,1fr) var(--panel)}
.ed-grip.ed-grip-r,.ed-grid.rail-top .ed-grip.ed-grip-r{left:auto;right:calc(var(--panel) + 2px)}
.ed-grid.rail-top .ed-grip{left:-14px}
.ed-rail.slim small{display:none}
.ed-rail-dock{display:none!important}
.ed-grid.rail-top .ed-rail-dock{display:flex!important;margin-left:auto;color:var(--muted)}
.ed-rail,.ed-panel,.ed-tl{border-radius:16px;border:1px solid var(--line);background:var(--glass)}
/* tool rail */
.ed-rail{display:flex;flex-direction:column;gap:2px;padding:8px}
.ed-rail hr{border:0;border-top:1px solid var(--line);margin:6px 8px}
.ed-rail button{display:flex;align-items:center;gap:12px;width:100%;padding:9px 10px;border:0;border-radius:11px;background:none;color:var(--ink);font:inherit;text-align:left;cursor:pointer;position:relative}
.ed-rail button>.ms{flex:none;width:36px;height:36px;border-radius:10px;display:grid;place-items:center;font-size:20px;border:1px solid var(--line);background:var(--panel);color:var(--muted)}
.ed-rail button>span:last-child{display:flex;flex-direction:column;gap:1px;min-width:0}
.ed-rail b{font-size:.88rem;font-weight:700}
.ed-rail small{font-size:.74rem;color:var(--muted);line-height:1.3}
.ed-rail button:hover{background:var(--raised)}
.ed-rail button[aria-pressed=true]{background:var(--primary-soft)}
.ed-rail button[aria-pressed=true]::before{content:"";position:absolute;left:-8px;top:8px;bottom:8px;width:3px;border-radius:3px;background:var(--primary)}
.ed-rail button[aria-pressed=true]>.ms{color:var(--primary-text);border-color:transparent;background:var(--panel)}
.ed-rail button:focus-visible{outline:2px solid var(--primary);outline-offset:1px}
/* player */
.ed-stage{display:flex;flex-direction:column;gap:14px;min-width:0}
.ed-media{position:relative;aspect-ratio:16/9;max-height:58vh;border-radius:16px;overflow:hidden;background:#0b0b10}
.ed-blur{position:absolute;inset:-30px;background-size:cover;background-position:center;filter:blur(22px) brightness(.45)}
.ed-media video{position:relative;display:block;width:100%;height:100%;object-fit:contain}
.ed-freeze{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;pointer-events:none;transition:opacity .2s}
.ed-freeze[hidden]{display:none}
.ed-freeze.go{opacity:0}
@media (prefers-reduced-motion:reduce){ .ed-freeze{transition:none} }
/* timeline */
.ed-tl{padding:10px 14px 14px}
.ed-tl-bar{display:flex;align-items:center;gap:6px;margin-bottom:8px}
.ed-tl-bar .iconbtn{width:32px;height:32px}
.ed-tl-bar .iconbtn .ms{font-size:19px}
.ed-time{font:600 .8rem/1 var(--mono);margin-left:6px}
.ed-zoom{margin-left:auto;display:flex;align-items:center;gap:4px;color:var(--muted)}
.ed-zoom .iconbtn{width:32px;height:32px}
.ed-zoom .iconbtn .ms{font-size:19px}
.ed-zoom .ed-fit{min-width:52px;justify-content:center;font:600 .78rem/1 var(--mono)}
.ed-tracks{--lab:96px;position:relative;display:grid;grid-template-columns:var(--lab) minmax(0,1fr);row-gap:8px;align-items:center}
/* The video track: Twick's timeline (its ruler above the parts), the label beside the parts */
.ed-twick{height:112px;min-width:0;overflow:hidden}
.ed-lab-vid{align-self:start;margin-top:52px}
.ed-tl-msg{margin:0;padding:40px 0 0;font-size:.78rem;color:var(--faint)}
.ed-tl-note{font-size:.74rem;color:var(--primary-text);margin-left:8px}
.ed-tl-note[hidden]{display:none}
.ed-lab{display:flex;align-items:center;gap:7px;font-size:.78rem;font-weight:600;color:var(--muted)}
.ed-lab .ms{font-size:17px;color:var(--faint)}
.ed-track{height:34px;border-radius:8px}
.ed-soon{display:flex;align-items:center;padding:0 10px;border:1px dashed var(--line-2);font-size:.74rem;color:var(--faint);overflow:hidden;white-space:nowrap}
/* the chosen tool */
.ed-panel{padding:16px;display:flex;flex-direction:column}
.ed-panel>[hidden]{display:none}
.ed-p-head{display:flex;align-items:center;gap:10px}
.ed-p-head>.ms{font-size:22px;color:var(--primary-text)}
.ed-p-head h2{flex:1;margin:0;font-size:1.05rem}
.ed-p-about{margin:6px 0 14px;font-size:.84rem;color:var(--muted)}
.ed-acts-list{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:1fr 1fr;gap:8px}
.ed-acts-list li{display:flex;flex-direction:column;gap:6px;padding:10px;border-radius:12px;border:1px solid var(--line);background:var(--panel);min-width:0}
.ed-acts-list li>.ms{font-size:20px;color:var(--muted)}
.ed-acts-list li>span{display:flex;flex-direction:column;gap:2px}
.ed-acts-list b{font-size:.84rem}
.ed-acts-list small{font-size:.74rem;color:var(--muted);line-height:1.35}
.ed-sug{margin-top:16px;padding-top:14px;border-top:1px solid var(--line)}
.ed-sug-head{display:flex;align-items:center;gap:8px}
.ed-sug-head b{font-size:.92rem}
.ed-sug p{margin:6px 0 0;font-size:.8rem;color:var(--muted);line-height:1.4}
.ed-small{display:none}
/* the tools in a row above the player: laptops, or chosen by dragging the tools' edge left */
.ed-grid.rail-top .ed-rail{grid-column:1/-1;flex-direction:row;flex-wrap:wrap;gap:4px}
.ed-grid.rail-top .ed-rail hr{display:none}
.ed-grid.rail-top .ed-rail button{width:auto;padding:6px 10px 6px 6px;gap:8px}
.ed-grid.rail-top .ed-rail button>.ms{width:30px;height:30px;font-size:18px}
.ed-grid.rail-top .ed-rail small{display:none}
.ed-grid.rail-top .ed-rail button[aria-pressed=true]::before{display:none}
@media (max-width:1360px){
  .ed-grip:not(.ed-grip-r),.ed-grid.rail-top .ed-rail-dock{display:none!important}
  .ed-grid{grid-template-columns:minmax(0,1fr) var(--panel)}
  .ed-rail{grid-column:1/-1;flex-direction:row;flex-wrap:wrap;gap:4px}
  .ed-rail hr{display:none}
  .ed-rail button{width:auto;padding:6px 10px 6px 6px;gap:8px}
  .ed-rail button>.ms{width:30px;height:30px;font-size:18px}
  .ed-rail small{display:none}
  .ed-rail button[aria-pressed=true]::before{display:none}
}
/* tablets: the panel below the player */
@media (max-width:1023px){
  .ed-grip.ed-grip-r{display:none!important}
  .ed-grid{grid-template-columns:minmax(0,1fr)}
  .ed-acts-list{grid-template-columns:repeat(auto-fill,minmax(180px,1fr))}
}
/* phones: no editor, say so (Quick review on Drafts does the simple editing) */
@media (max-width:700px){
  .ed-rail,.ed-tl,.ed-panel{display:none}
  .ed-media{aspect-ratio:9/12}
  .ed-small{display:flex;gap:10px;align-items:flex-start;margin:0 0 14px;padding:12px 14px;border-radius:12px;background:var(--raised);font-size:.88rem;color:var(--muted)}
  .ed-small .ms{color:var(--faint);flex:none}
  .ed-bar{flex-wrap:wrap;row-gap:6px}
  .ed-bar-sp{flex-basis:100%;order:1}
  .ed-bar #edMore,.ed-bar #edExport,.ed-bar #edFinish,.ed-bar .ed-hist{order:2}
  .ed-bar #edExport,.ed-bar #edFinish{flex:1;justify-content:center}
}
/* laptops and bigger: the editor fills the screen's height; the player takes what the timeline leaves */
@media (min-width:1024px) and (min-height:640px){
  #s12 .work{display:flex;flex-direction:column;height:calc(100vh - 28px)}
  #s12 .ed-grid{flex:1;min-height:0;align-items:stretch;grid-template-rows:minmax(0,1fr)}
  .ed-rail,.ed-panel{overflow-y:auto;min-height:0}
  .ed-stage{min-height:0}
  .ed-media{flex:1;aspect-ratio:auto;max-height:none;min-height:240px}
  .ed-media video{position:absolute;inset:0}
  .ed-tl{flex:none}
}
@media (min-width:1361px) and (min-height:640px){
  #s12 .ed-grid.rail-top{grid-template-rows:auto minmax(0,1fr)}
}
@media (min-width:1024px) and (max-width:1360px) and (min-height:640px){
  #s12 .ed-grid{grid-template-rows:auto minmax(0,1fr)}
  .ed-panel{align-self:start;max-height:100%}
}
#edDetails[hidden],#edPanel[hidden]{display:none}
#edDetails .qr-edit{margin-top:4px}
