/* Composer dock, references, overlays, theater mode, small screens. */

/* ------------------------------------------------------------ composer dock */
/* The dock reserves the composer's resting height (--dock-rest, kept by app.js) and no more. A long prompt opens the
   composer upward over the stage, so writing never resizes the picture. */
.dock { grid-column: 2; grid-row: 3; position: relative; z-index: 3; height: calc(var(--dock-rest, 134px) + 26px); }
.composer {
  position: absolute; left: 12px; right: 12px; bottom: 20px; margin: 0 auto;
  max-width: 1040px; min-width: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border-radius: var(--r-2); background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(28px) saturate(1.2); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9);
}
/* An open composer covers the transport, so the transport steps back instead of peeking around it. */
.transport { transition: opacity var(--t-hand) ease; }
@media (min-width: 821px) { body.composing .transport { opacity: 0; pointer-events: none; } }
/* House lights at half while a take plays: the room recedes, the transport stays. The composer's contents are dimmed,
   not the dock, because an ancestor with opacity below 1 switches the composer's backdrop blur off. */
.top, .rail, .composer > * { transition: opacity var(--t-light) var(--ease-light); }
body.playing.dim-dock :is(.top, .rail, .composer > *) { opacity: .55; }
body.playing.dim-dock :is(.top, .rail):is(:hover, :focus-within),
body.playing.dim-dock .dock:is(:hover, :focus-within) .composer > * { opacity: 1; transition-duration: var(--t-hand); }
.shelf { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.chip {
  position: relative; display: flex; align-items: center; height: 48px; padding: 0 2px 0 6px; flex: none;
  border-radius: var(--r-1); background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08);
}
.chip.unsupported { border: 1px dashed var(--warn); }
.chip .who { display: flex; align-items: center; gap: 8px; min-height: 44px; padding-right: 6px; font: var(--fs-2) var(--mono); color: var(--hi); }
.chip .thumb { position: relative; width: 50px; height: 34px; border-radius: var(--r-1); overflow: hidden; background: rgba(255, 255, 255, .06); display: grid; place-items: center; flex: none; }
.chip .thumb img, .chip .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.chip .thumb canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
.chip button.thumb { cursor: pointer; margin-right: 8px; }
.chip .thumb .ic { position: absolute; width: 14px; height: 14px; color: var(--hi); filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .9)); fill: currentColor; stroke: none; opacity: 0; transition: opacity var(--t-hand); }
.chip .thumb:hover .ic, .chip .thumb.on .ic { opacity: 1; }
.chip .role { min-height: 44px; padding: 0 6px; font-size: var(--fs-2); color: var(--mut); white-space: nowrap; text-decoration: underline dotted rgba(255, 255, 255, .3); text-underline-offset: 4px; }
.chip .role:hover { color: var(--hi); }
.chip .x, .chip .pull, .chip .crop-btn { display: grid; place-items: center; width: 30px; height: 44px; color: var(--dim); transition: color var(--t-hand); }
.chip .x:hover, .chip .pull:hover, .chip .crop-btn:hover { color: var(--hi); }
.chip .x .ic { width: 14px; height: 14px; }
.chip .pull .ic, .chip .crop-btn .ic { width: 15px; height: 15px; }
.chip.ratio-mismatch { border-color: rgba(240, 179, 106, .48); }
.chip.ratio-mismatch .crop-btn { color: var(--accent); }
.chip .peek {
  position: absolute; left: 0; bottom: calc(100% + 10px); z-index: 12; width: 260px; border-radius: var(--r-1); overflow: hidden;
  background: #050506; box-shadow: 0 0 0 1px var(--line), 0 24px 60px -12px rgba(0, 0, 0, .9);
  opacity: 0; transform: translateY(6px) scale(.98); transform-origin: 20% 100%; pointer-events: none; transition: opacity var(--t-hand), transform var(--t-panel) var(--ease);
}
.chip .peek img, .chip .peek video, .chip .peek canvas { width: 100%; display: block; max-height: 300px; object-fit: contain; background: #050506; }
.chip:hover .peek, .chip:focus-within .peek { opacity: 1; transform: none; }
.ref-tools { position: absolute; top: 0; right: 0; display: flex; gap: 2px; }
.ref-tools .round { width: 40px; height: 40px; }
.add { cursor: pointer; }
.add input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.add:has(input:focus-visible) { outline: 2px solid var(--hi); outline-offset: 2px; }

.guard { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--r-1); border: 1px dashed var(--warn); color: #e9d3b4; font-size: var(--fs-3); }
.guard span { flex: 1; text-wrap: pretty; }
.guard button { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(240, 179, 106, .5); color: var(--hi); white-space: nowrap; }

.reuse-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px 6px 11px; border-radius: var(--r-1);
  background: rgba(255, 255, 255, .035); border: 1px solid var(--line);
  font-size: var(--fs-2); color: var(--ink);
}
.reuse-src {
  font-size: var(--fs-1); letter-spacing: .06em; color: var(--mut); white-space: nowrap;
}
.reuse-seg {
  display: inline-flex; align-items: center; padding: 2px; gap: 2px;
  border-radius: 999px; background: rgba(0, 0, 0, .34); border: 1px solid var(--line);
}
.reuse-opt {
  min-height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: var(--fs-2); color: var(--mut); white-space: nowrap;
  transition: background var(--t-hand), color var(--t-hand);
}
.reuse-opt:hover { color: var(--hi); }
.reuse-opt.on { background: var(--hi); color: #0a0a0b; font-weight: 500; }
.reuse-opt.on.is-enh { background: rgba(240, 179, 106, .22); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(240, 179, 106, .45); }
.reuse-hint {
  flex: 1; min-width: 140px; font-size: var(--fs-2); color: var(--mut);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reuse-hint.is-warn { color: var(--accent); }
.reuse-act {
  min-height: 26px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); font-size: var(--fs-2); color: var(--mut); white-space: nowrap;
  transition: border-color var(--t-hand), color var(--t-hand), background var(--t-hand);
}
.reuse-act:hover { border-color: var(--line-2); color: var(--hi); background: rgba(255, 255, 255, .05); }
.reuse-act.on { border-color: var(--line-2); color: var(--hi); background: rgba(255, 255, 255, .08); }
.reuse-x {
  margin-left: auto; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  color: var(--dim); flex: none; transition: color var(--t-hand), background var(--t-hand);
}
.reuse-x:hover { color: var(--hi); background: rgba(255, 255, 255, .08); }
.reuse-x .ic { width: 13px; height: 13px; }

/* At rest the prompt is two lines; with focus it opens to a third of the viewport. Its rest height is fixed
   (min = max) so the dock height above can be derived from it. */
.write { position: relative; min-width: 0; }
.prompt {
  display: block; width: 100%; min-height: calc(2lh + 6px); max-height: calc(2lh + 6px); padding: 4px 52px 2px 4px; resize: none; border: 0; outline: none; background: none;
  font: 400 var(--fs-4)/1.6 var(--sans); letter-spacing: -.005em; color: var(--hi); field-sizing: content; overflow-y: hidden;
  transition: max-height var(--t-panel) var(--ease);
}
.prompt:focus { max-height: 34dvh; overflow-y: auto; }
/* A long prompt at rest: the first line stands, the second trails off before the meter that says how much more there is. */
.prompt.is-clipped:not(:focus) {
  -webkit-mask-image: linear-gradient(#000, #000), linear-gradient(90deg, #000 calc(100% - 310px), transparent calc(100% - 230px));
  mask-image: linear-gradient(#000, #000), linear-gradient(90deg, #000 calc(100% - 310px), transparent calc(100% - 230px));
  -webkit-mask-size: 100% calc(1lh + 4px), 100% 100%; mask-size: 100% calc(1lh + 4px), 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.prompt::placeholder { color: var(--dim); }
.prompt-meter { position: absolute; right: 52px; bottom: 4px; font-size: var(--fs-1); letter-spacing: .06em; color: var(--mut); pointer-events: none; }
.prompt:focus ~ .prompt-meter { display: none; }
.strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill select {
  appearance: none; -webkit-appearance: none; background: none; border: 0; outline: none; cursor: pointer;
  font: var(--fs-2) var(--mono); font-feature-settings: "zero" 1, "tnum" 1; letter-spacing: .04em; color: var(--ink); padding: 0 14px 0 0; max-width: 210px; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 5px) 55%, 100% 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.pill select option { background: #1c1c1f; color: var(--ink); }
.len-pill { gap: 6px; padding-right: 11px; }
.pill.len-pill > .len-val { font: var(--fs-2) var(--mono); font-feature-settings: "zero" 1, "tnum" 1; letter-spacing: .04em; color: var(--ink); min-width: 3.1ch; text-align: center; }
.len-caret { font-size: 10px; color: var(--dim); line-height: 1; }
.pill[aria-pressed] b { font: var(--fs-3) var(--mono); font-weight: 400; color: var(--ink); }
.route { font: var(--fs-1) var(--mono); letter-spacing: .12em; color: var(--mut); padding: 0 4px; white-space: nowrap; }
.grow { flex: 1; }
.go .kbd { font: var(--fs-1) var(--mono); color: rgba(10, 10, 11, .55); letter-spacing: .08em; }
.go {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 0 22px 0 26px; border-radius: 999px; background: var(--hi); color: #0a0a0b; font-weight: 500; font-size: var(--fs-4);
  transition: transform var(--t-hand), filter var(--t-hand), opacity var(--t-hand);
}
.go:hover { filter: brightness(1.08); }
.go:active { transform: scale(.98); }
.go:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* popovers (fine-tune, keys) */
.pop {
  position: fixed; inset: auto; margin: 0; z-index: 30; width: min(360px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 16px; border-radius: var(--r-2);
  background: #151517; color: var(--ink); border: 1px solid var(--line); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .95);
}
.pop::backdrop { background: transparent; }
.pop.pop-sec { width: 64px; min-width: 0; padding: 6px 4px; border-radius: 18px; overflow: hidden; }
.sec-wheel-wrap { position: relative; height: 170px; }
.sec-wheel-band {
  position: absolute; left: 3px; right: 3px; top: 50%; height: 34px; transform: translateY(-50%);
  border-radius: 999px; pointer-events: none;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .14);
}
.sec-wheel {
  height: 100%; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain;
  scrollbar-width: none; padding: 68px 0; outline: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, .55) 24%, #000 40%, #000 60%, rgba(0, 0, 0, .55) 76%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, .55) 24%, #000 40%, #000 60%, rgba(0, 0, 0, .55) 76%, transparent 100%);
}
.sec-wheel::-webkit-scrollbar { display: none; }
.sec-opt {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 34px;
  scroll-snap-align: center; border-radius: 999px; white-space: nowrap;
  font: var(--fs-2) var(--mono); font-feature-settings: "zero" 1, "tnum" 1; letter-spacing: .04em;
  color: var(--mut); opacity: .52; transform: scale(.92);
  transition: color var(--t-hand), opacity var(--t-hand), transform var(--t-hand);
}
.sec-opt:hover { opacity: .85; color: var(--ink); }
.sec-opt.is-selected { color: var(--hi); opacity: 1; font-weight: 500; transform: scale(1.04); }
.pop h3 { margin: 0 0 14px; font: 500 var(--fs-1) var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mut); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-2); color: var(--mut); }
.field.full { grid-column: 1 / -1; }
.field input, .field textarea {
  min-height: 44px; padding: 0 12px; border-radius: var(--r-1); border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .04);
  font: var(--fs-3) var(--mono); color: var(--hi); outline: none; width: 100%;
}
.field textarea { padding: 10px 12px; font: var(--fs-3)/1.5 var(--sans); resize: vertical; min-height: 64px; }
.field input:focus, .field textarea:focus { border-color: rgba(255, 255, 255, .4); }
.field .row { display: flex; gap: 6px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: var(--fs-3); color: var(--mut); margin: 0; }
.keys dt { font: var(--fs-2) var(--mono); color: var(--hi); }
.keys dd { margin: 0; }

/* ------------------------------------------------------------ library sheet */
.sheet {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: rgba(10, 10, 11, .97);
  animation: rise var(--t-panel) var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.sheet-head { display: flex; flex-direction: column; gap: 14px; padding: 22px 40px 16px; flex: none; }
.sheet-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; }
.sheet-title-row { display: flex; align-items: center; gap: 18px; min-width: 0; }
.sheet-head h1 { margin: 0; font: italic 400 clamp(28px, 3.2vw, 42px)/1 var(--serif); letter-spacing: -.01em; color: var(--hi); flex: none; }
.lib-tabs { display: flex; align-items: center; gap: 6px; flex: none; }
.lib-tabs .tab-count { font: var(--fs-1) var(--mono); opacity: .75; }
.sheet-tools {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  min-height: 44px; overflow-x: auto; scrollbar-width: none;
}
.sheet-tools::-webkit-scrollbar { display: none; }
.sheet-tool-group { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; flex: none; }
.lib-tree-pill select { width: 210px; max-width: 210px; }
.search { display: flex; align-items: center; gap: 10px; min-height: 44px; width: 260px; flex: none; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .1); color: var(--mut); }
.search:focus-within { border-color: rgba(255, 255, 255, .4); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--hi); }
.search input::placeholder { color: var(--dim); }
.pill.on { color: #0a0a0b; background: var(--hi); border-color: var(--hi); }
.grid { flex: 1; overflow: auto; scrollbar-gutter: stable; padding: 18px 40px 56px; -webkit-mask-image: linear-gradient(transparent, #000 18px); mask-image: linear-gradient(transparent, #000 18px); display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 32px 24px; align-content: start; }
.card { display: flex; flex-direction: column; gap: 10px; text-align: left; color: var(--ink); content-visibility: auto; contain-intrinsic-size: 280px 250px; }
.card-eval { cursor: pointer; }
.card-eval:focus-visible { outline: 2px solid var(--hi); outline-offset: 4px; border-radius: var(--r-1); }
.card .shot { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-1); overflow: hidden; background: #050506; box-shadow: 0 0 0 1px rgba(255, 255, 255, .07); }
.card .shot img, .card .shot video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.card .shot .bg { object-fit: cover; filter: blur(22px) brightness(.55); transform: scale(1.3); }
.card .shot .bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--hi); width: 0; }
.card .shot .tag { position: absolute; left: 10px; top: 9px; font: var(--fs-1) var(--mono); letter-spacing: .14em; color: var(--hi); text-shadow: 0 1px 6px rgba(0, 0, 0, .9); }
.card .shot .tag-r { left: auto; right: 10px; color: var(--mut); }
.card p { margin: 0; font: 400 var(--fs-5)/1.3 var(--serif); text-wrap: pretty; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-synthesis-style: none; }
/* Chinese is never slanted, uses thin cinema serif weight and airy tracking; Instrument Serif sets Latin inside it. */
.card p:lang(zh) { font-style: normal; font-weight: 300; letter-spacing: .045em; line-height: 1.52; font-size: 16px; }
body.theater .caption:lang(zh) { font-style: normal; font-weight: 300; letter-spacing: .055em; line-height: 1.48; }
/* Shown when a prompt looks structured but could not be read as a caption: the fallback is visible, not silent. */
.raw-tag { margin-right: 8px; padding: 1px 5px; border-radius: var(--r-1); border: 1px solid var(--line-2); font: var(--fs-1) var(--mono); letter-spacing: .1em; color: var(--mut); vertical-align: 2px; }
.card .eval-sub { font: var(--fs-1)/1.35 var(--sans); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--mut); font: var(--fs-1) var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.card .foot span:last-child { display: flex; gap: 8px; }
.card .foot .ic { width: 16px; height: 16px; }
.card-eval-acts { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-reuse {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 11px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .12);
  font: var(--fs-2) var(--mono); color: var(--ink); transition: background var(--t-hand), border-color var(--t-hand), color var(--t-hand);
}
.card-reuse:hover { background: var(--hi); border-color: var(--hi); color: #0a0a0b; }
.card-reuse .ic { width: 13px; height: 13px; }
.card-open-hint { font: var(--fs-1) var(--mono); color: var(--dim); }
.none { grid-column: 1 / -1; padding: 60px 0; text-align: center; color: var(--mut); }

/* eval split preview inside Library */
.eval-stage {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 108px minmax(0, 1fr);
  gap: 16px; padding: 4px 40px 24px 20px; overflow: hidden;
}
.eval-rail {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 0; isolation: isolate; contain: layout paint style; transform: translateZ(0);
}
#evalRail {
  display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0;
  padding: 6px 6px 14px; overflow: auto; scrollbar-width: none;
  transform: translateZ(0); backface-visibility: hidden;
}
#evalRail::-webkit-scrollbar { display: none; }
.eval-main {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 420px);
  gap: 24px; min-width: 0; min-height: 0; align-items: stretch;
}
.eval-player-col {
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
  min-width: 0; min-height: 0;
}
.eval-frame {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-frame); overflow: hidden; background: #050506;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 30px 90px -25px rgba(0, 0, 0, .9);
}
.eval-frame video { width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; }
.eval-frame-acts {
  position: absolute; right: 10px; top: 10px; z-index: 4; display: flex; gap: 4px; opacity: .82; transition: opacity var(--t-hand);
}
.eval-frame:hover .eval-frame-acts, .eval-frame-acts:focus-within { opacity: 1; }
.eval-frame-acts .round { color: var(--hi); background: rgba(10, 10, 11, .52); backdrop-filter: blur(12px); width: 38px; height: 38px; }
.eval-frame-acts .round:hover { background: rgba(40, 40, 42, .82); }
.eval-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mut); padding: 24px; text-align: center; }
.eval-bar {
  display: flex; align-items: center; gap: 8px; height: 44px; flex: none;
}
.eval-bar .tc { font-size: var(--fs-2); font-feature-settings: "zero" 1, "tnum" 1; color: var(--hi); min-width: 66px; }
.eval-bar .tc.end { color: var(--mut); text-align: right; }
.eval-scrub {
  flex: 1; min-width: 0; accent-color: var(--hi); cursor: pointer; height: 4px;
}
.eval-keys-hint { font-size: var(--fs-1); color: var(--dim); white-space: nowrap; margin-left: 4px; }
.eval-info {
  display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto;
  padding: 18px 20px; border-radius: var(--r-2); background: rgba(18, 18, 20, .86); border: 1px solid var(--line);
}
/* Prevent flex shrink from collapsing scroll children (e.g. blockquote) when dl overflows. */
.eval-info > * { flex-shrink: 0; }
.eval-info-head { display: flex; flex-direction: column; gap: 10px; }
.eval-info-title-wrap { display: flex; flex-direction: column; gap: 4px; }
.eval-idx { font-size: var(--fs-1); letter-spacing: .12em; color: var(--mut); text-transform: uppercase; }
.eval-info h3 { margin: 0; font: 400 var(--fs-5)/1.3 var(--sans); color: var(--hi); overflow-wrap: anywhere; }
.eval-reuse-go { min-height: 40px; padding: 0 16px; font-size: var(--fs-3); gap: 8px; width: 100%; }
.eval-reuse-go .ic { width: 15px; height: 15px; }
.eval-info blockquote {
  margin: 0; padding: 10px 12px; border-radius: var(--r-1); background: rgba(255, 255, 255, .03); border: 1px solid var(--line);
  font: var(--fs-3)/1.5 var(--sans); color: var(--ink); overflow-wrap: anywhere; max-height: 180px; overflow: auto;
}
.eval-info dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: var(--fs-3); }
.eval-info dt { color: var(--dim); white-space: nowrap; }
.eval-info dd { margin: 0; font-family: var(--mono); font-size: var(--fs-2); color: var(--ink); overflow-wrap: anywhere; }

/* ------------------------------------------------------------ details drawer */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 35; width: min(400px, 100vw); padding: 20px 22px 24px; overflow: auto;
  background: #121214; border-left: 1px solid var(--line); box-shadow: -40px 0 100px -30px rgba(0, 0, 0, .9); animation: slide var(--t-panel) var(--ease) both;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.drawer h3 { margin: 0; font: 500 var(--fs-1) var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mut); }
.drawer blockquote { margin: 0; }
.d-sec {
  margin-bottom: 16px; padding: 12px 13px; border-radius: var(--r-1);
  background: rgba(255, 255, 255, .025); border: 1px solid var(--line);
}
.d-sec-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.d-sec-label {
  font-size: var(--fs-1); letter-spacing: .12em; text-transform: uppercase; color: var(--dim);
}
.d-sec-badge {
  padding: 2px 6px; border-radius: 999px; border: 1px solid rgba(240, 179, 106, .34);
  background: rgba(240, 179, 106, .1); color: var(--accent);
  font-size: 10px; letter-spacing: .06em; white-space: nowrap; max-width: 190px; overflow: hidden; text-overflow: ellipsis;
}
.d-mini-btn {
  margin-left: auto; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line);
  font: var(--fs-1) var(--mono); color: var(--mut); transition: color var(--t-hand), border-color var(--t-hand);
}
.d-mini-btn:hover { color: var(--hi); border-color: var(--line-2); }
.d-origin-text {
  margin: 0; font: 400 var(--fs-4)/1.6 var(--sans); color: var(--hi);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.d-neg-text {
  margin: 0; max-height: 150px; overflow: auto;
  font: var(--fs-2)/1.5 var(--mono); color: var(--mut);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.d-enhancing-note {
  margin: 0; font: var(--fs-3)/1.5 var(--sans); color: var(--accent); opacity: .9;
}
.enhance-opt { padding-top: 4px; }
/* The slate: a caption read as overview and shots in cinema serif, with raw text one click away. */
.slate-overview { margin: 0; font: 400 16px/1.6 var(--serif); color: var(--ink); text-wrap: pretty; overflow-wrap: anywhere; }
.slate-overview:lang(zh) { font-weight: 300; font-size: 14.5px; letter-spacing: .04em; line-height: 1.68; }
.slate-shots { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.slate-shots li { display: grid; grid-template-columns: auto 1fr; gap: 12px; font: 400 15px/1.55 var(--serif); color: var(--mut); overflow-wrap: anywhere; }
.slate-shots li > span:last-child:lang(zh) { font-weight: 300; font-size: 13.5px; letter-spacing: .035em; line-height: 1.64; }
.slate-shots .tc { font: var(--fs-1)/1.9 var(--mono); font-feature-settings: "zero" 1, "tnum" 1; letter-spacing: .04em; color: var(--dim); white-space: nowrap; }
.slate-raw-toggle { margin-top: 12px; padding: 3px 8px; border-radius: var(--r-1); border: 1px solid var(--line); font: var(--fs-1) var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--mut); transition: color var(--t-hand), border-color var(--t-hand); }
.slate-raw-toggle:hover, .slate-raw-toggle[aria-expanded="true"] { color: var(--hi); border-color: var(--line-2); }
.slate-raw { margin: 10px 0 0; padding: 10px 12px; max-height: 260px; overflow: auto; border-radius: var(--r-1); background: rgba(255, 255, 255, .03); border: 1px solid var(--line); font: var(--fs-2)/1.5 var(--mono); color: var(--mut); white-space: pre-wrap; overflow-wrap: anywhere; }
.eval-info .slate-overview { font-size: var(--fs-3); }
.drawer dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; margin: 0 0 20px; font-size: var(--fs-3); }
.drawer dt { color: var(--dim); }
.drawer dd { margin: 0; font-family: var(--mono); font-size: var(--fs-2); color: var(--ink); overflow-wrap: anywhere; }
.drawer .acts { display: flex; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; top: 68px; z-index: 80; transform: translate(-50%, -8px); padding: 10px 16px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 10px;
  background: #1c1c1f; border: 1px solid var(--line); color: var(--hi); font-size: var(--fs-3); opacity: 0; pointer-events: none; transition: opacity var(--t-panel), transform var(--t-panel) var(--ease); max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.has-action { pointer-events: auto; }
.toast-act {
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line-2);
  color: var(--hi); font: var(--fs-2) var(--sans); font-weight: 500; white-space: nowrap;
  transition: background var(--t-hand), color var(--t-hand);
}
.toast-act:hover { background: var(--hi); color: #0a0a0b; }

/* ------------------------------------------------------------ theater: lights down */
body.theater .top, body.theater .dock, body.theater .rail { display: none; }
body.theater { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
/* Lights down means down: the surround is black masking, so letterbox bars never glow. */
body.theater { background: #000; }
body.theater #ambient { --glow-live: 0; }
body.theater::before { opacity: 0; }
body.theater .room { grid-column: 1; grid-row: 1; padding: 0; }
body.theater .stage-col { justify-content: center; gap: 0; position: relative; }
body.theater .frame { width: min(100cqw, calc(100cqh * var(--ar))); border-radius: 0; box-shadow: none; }
body.theater .frame-actions { display: none; }
body.theater .t-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 18px 26px 60px; background: linear-gradient(180deg, rgba(5, 5, 6, .7), rgba(5, 5, 6, 0)); transition: opacity var(--t-panel) ease;
}
body.theater .t-top > div { display: flex; align-items: center; gap: 10px; }
.glass {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; font-size: var(--fs-3); color: var(--ink);
  background: rgba(12, 12, 13, .5); border: 1px solid rgba(255, 255, 255, .14); backdrop-filter: blur(18px); transition: background var(--t-hand), border-color var(--t-hand);
}
.glass:hover { background: rgba(30, 30, 32, .7); border-color: rgba(255, 255, 255, .32); }
.glass.on { background: var(--hi); color: #0a0a0b; border-color: var(--hi); }
body.theater .t-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; flex-direction: column; gap: 10px; padding: 90px 28px 20px;
}
/* The scrim is its own layer so the caption row, the transport and the scrim can leave separately. */
body.theater .t-bottom::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(5, 5, 6, .92), rgba(5, 5, 6, 0)); pointer-events: none; }
body.theater .t-bottom::before, body.theater .t-row, body.theater .transport { transition: opacity var(--t-panel) ease; }
body.theater .t-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
body.theater .caption {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; max-width: 780px;
  font: italic 400 clamp(21px, 2.3vw, 32px)/1.22 var(--serif); color: var(--hi); text-wrap: pretty; text-shadow: 0 2px 24px rgba(0, 0, 0, .75);
  font-synthesis-style: none;
}
body.theater .t-takes { display: flex; gap: 12px; padding: 4px; }
body.theater .t-takes .take { width: 96px; }
body.theater .transport { width: 100%; height: 52px; }
body.theater .transport .play { background: var(--hi); color: #0a0a0b; width: 48px; height: 48px; }
body.theater .t-top, body.theater .t-bottom, body.theater .caption { pointer-events: none; }
body.theater .t-top > div, body.theater .t-takes, body.theater .transport { pointer-events: auto; }
/* Quiet theater: the chrome and the cursor leave. The pointer wakes only the edge it travels to (w-top, w-bottom),
   keys wake the transport alone (w-keys), deliberate movement brings the cursor back (w-cursor): see wake() in
   app-views.js. Arriving is quick, leaving is slow. Focus inside either bar always keeps it. */
body.theater.quiet:not(.w-top) .t-top:not(:focus-within) { opacity: 0; transition-duration: var(--t-light); }
body.theater.quiet:not(.w-bottom) .t-bottom:not(:focus-within) .t-row { opacity: 0; transition-duration: var(--t-light); }
body.theater.quiet:not(.w-bottom):not(.w-keys) .t-bottom:not(:focus-within) .transport,
body.theater.quiet:not(.w-bottom):not(.w-keys) .t-bottom:not(:focus-within)::before { opacity: 0; transition-duration: var(--t-light); }
body.theater.quiet.w-keys:not(.w-bottom) .t-bottom:not(:focus-within)::before { opacity: .55; }
body.theater.quiet:not(.w-cursor) { cursor: none; }
/* Comparing is looking at the lower third: the caption stands down, the wipe and its tags stay. */
body.theater .frame.comparing ~ .t-bottom .caption { visibility: hidden; }
body:not(.theater) .t-bottom { display: contents; }
body:not(.theater) .t-row { display: none; }
::view-transition-group(stage) { animation-duration: .5s; animation-timing-function: cubic-bezier(.2, .7, .1, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .35s; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 820px) {
  body { overflow-x: clip; overflow-y: auto; height: auto; min-height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; }
  .top { grid-column: 1; grid-row: 1; padding: 8px 10px 8px 12px; gap: 6px; }
  .brand { gap: 8px; min-width: 0; flex: 0 1 auto; }
  .brand-logo { height: 20px; }
  .top nav { gap: 2px; min-width: 0; flex-shrink: 1; }
  .navbtn { padding: 0 8px; gap: 5px; white-space: nowrap; }
  .badge { padding: 0 6px; }
  .badge span { display: none; }
  .room { grid-column: 1; grid-row: 2; padding: 0 16px; }
  .rail { grid-column: 1; grid-row: 3; flex-direction: row; padding: 6px 16px 0; }
  .rail-label { display: none; }   /* the tab already names the reel; the row is for takes */
  #rail { flex-direction: row; padding: 6px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
  .stage-col { container-type: inline-size; }
  .frame, .transport { width: min(100%, calc(62dvh * var(--ar))); min-width: 0; }
  .transport .tc.end { display: none; }
  .dock { grid-column: 1; grid-row: 4; height: auto; padding: 10px 0 0; position: sticky; bottom: 0; }
  .composer { position: static; max-width: none; border-radius: var(--r-2) var(--r-2) 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); background: rgba(20, 20, 22, .94); }
  .shelf { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
  .go .kbd, .chip .peek { display: none; }
  .go { flex: 1 1 100%; min-height: 52px; }
  .sheet-head { padding: 16px 16px 12px; gap: 10px; }
  .sheet-title-row { gap: 10px; }
  .search { width: 180px; }
  .grid { padding: 18px 16px 40px; }
  .eval-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); padding: 4px 16px 16px; gap: 10px; }
  .eval-rail { flex-direction: row; }
  #evalRail { flex-direction: row; padding: 6px; }
  .eval-main { grid-template-columns: minmax(0, 1fr); overflow: auto; }
  .eval-frame { min-height: 240px; }
  .eval-keys-hint { display: none; }
  body.theater { height: 100dvh; overflow: hidden; }
  body.theater .stage-col { container-type: size; }
  body.theater .frame { width: min(100cqw, calc(100cqh * var(--ar))); }
  body.theater .t-takes { display: none; }
  .glass span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .frame .grain { animation: none; }
}

/* ------------------------------------------------------------ studio live extensions */
.badge.live i { background: var(--mut); }
.badge.offline i { background: #e06157; }
.frame > img.still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #050506; z-index: 2; }
.audio-stage {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 24px; background: radial-gradient(80% 80% at 50% 45%, rgba(255, 255, 255, .05), rgba(5, 5, 6, .92));
}
.audio-stage .mono { font-size: var(--fs-1); letter-spacing: .16em; color: var(--mut); }
.audio-stage audio { width: min(460px, 86%); }

.enhance-stream {
  margin: 0; padding: 8px 10px; border-radius: var(--r-1); background: rgba(0, 0, 0, .45); border: 1px solid var(--line);
  font: var(--fs-2)/1.45 var(--mono); color: var(--mut); max-height: 92px; overflow: auto; white-space: pre-wrap;
}

.pop-wide { width: min(420px, calc(100vw - 24px)); }
.pop-select {
  min-height: 44px; padding: 0 12px; border-radius: var(--r-1); border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .04); font: var(--fs-3) var(--mono); color: var(--hi); outline: none; width: 100%;
}
.pop-select option { background: #1c1c1f; color: var(--ink); }
.budget-foot {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 10px; font: var(--fs-1) var(--mono); color: var(--mut);
}
.budget-foot.blocked { color: #f08a80; }

.pop-samples { width: min(440px, calc(100vw - 24px)); }
.samples-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 240px; overflow: auto; }
.sample-card {
  display: flex; flex-direction: column; gap: 5px; padding: 5px; border-radius: var(--r-1); text-align: left;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line); transition: border-color var(--t-hand);
}
.sample-card:hover { border-color: var(--line-2); }
.sample-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-1); display: block; }
.sample-card span { font-size: var(--fs-1); color: var(--mut); padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lib-more-wrap { display: flex; justify-content: center; padding: 0 40px 36px; }

.op-dialog {
  width: min(400px, calc(100vw - 28px)); padding: 22px; border-radius: var(--r-2);
  background: #151517; color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 32px 90px -20px rgba(0, 0, 0, .95);
}
.op-dialog::backdrop { background: rgba(5, 5, 6, .84); backdrop-filter: blur(18px); }
.op-mark { display: block; height: 30px; width: auto; margin: 0 0 18px; user-select: none; -webkit-user-drag: none; }
.op-dialog h3 { margin: 0 0 8px; font: italic 400 30px/1.1 var(--serif); color: var(--hi); }
.op-sub { margin: 0 0 16px; font-size: var(--fs-3); color: var(--mut); }
.op-dialog input {
  width: 100%; min-height: 44px; padding: 0 14px; border-radius: var(--r-1);
  border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .04);
  color: var(--hi); font-size: var(--fs-4); outline: none; margin-bottom: 16px;
}
.op-dialog input:focus { border-color: var(--line-2); }
.op-acts { display: flex; justify-content: flex-end; gap: 8px; }

.model-tag { font: var(--fs-2) var(--mono); font-feature-settings: "zero" 1, "tnum" 1; letter-spacing: .04em; color: var(--ink); cursor: pointer; gap: 6px; }
.model-tag:hover { border-color: rgba(255, 255, 255, .18); color: var(--hi); }
.model-tag.can-switch { border-color: rgba(255, 255, 255, .14); }
.model-tag.can-switch.has-newer { border-color: var(--line-2); }
.model-new-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hi); display: inline-block; flex: none; }
.model-caret { font-size: var(--fs-1); color: var(--mut); line-height: 1; margin-left: -2px; }
.pop-model { width: min(360px, calc(100vw - 24px)); }
.model-summary { font-size: var(--fs-2); color: var(--mut); margin-bottom: 10px; line-height: 1.45; }
.model-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.model-latest-btn {
  min-height: 30px; padding: 0 10px; font-size: var(--fs-2); white-space: nowrap;
  border-color: var(--line-2); color: var(--hi);
}
.model-latest-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .08); }
.model-latest-btn:disabled { opacity: .45; cursor: wait; }
.model-follow-toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-2); color: var(--ink);
  cursor: pointer; user-select: none;
}
.model-follow-toggle input { accent-color: var(--hi); cursor: pointer; }
.model-list {
  display: flex; flex-direction: column; gap: 4px; max-height: 230px; overflow-y: auto;
  padding-right: 2px;
}
.model-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 34px; padding: 6px 10px; border-radius: var(--r-1);
  border: 1px solid rgba(255, 255, 255, .07); background: rgba(255, 255, 255, .02);
  color: var(--ink); text-align: left; font: var(--fs-3) var(--mono);
  transition: background var(--t-hand), border-color var(--t-hand), color var(--t-hand);
}
.model-item:hover:not(:disabled) { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .16); color: var(--hi); }
.model-item.is-active { border-color: var(--line-2); background: rgba(255, 255, 255, .07); color: var(--hi); }
.model-item:disabled { opacity: .5; cursor: wait; }
.model-item-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.model-item-right { display: flex; align-items: center; gap: 6px; font-size: var(--fs-1); color: var(--dim); flex: none; }
.model-pill-latest {
  font: var(--fs-1) var(--mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 5px; border-radius: var(--r-1); color: var(--mut); background: rgba(255, 255, 255, .08);
}
.model-check { color: var(--hi); font-size: var(--fs-2); }
.auto-tag {
  font: var(--fs-1) var(--mono); font-style: normal; letter-spacing: .08em; text-transform: uppercase;
  color: var(--mut); margin-left: -2px;
}
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.pop-head h3 { margin: 0; }
.neg-clear { font: var(--fs-2) var(--mono); color: var(--mut); padding: 4px 8px; border-radius: var(--r-1); }
.neg-clear:hover { color: var(--hi); background: rgba(255, 255, 255, .06); }
.neg-model-note { margin: 6px 0 0; font-size: var(--fs-1); color: var(--dim); }

.op-err { margin: -8px 0 12px; font-size: var(--fs-3); color: #f08a80; }
.transport.is-disabled > :not(#btnTheater) { opacity: .35; pointer-events: none; }
.rail-more {
  width: 76px; min-height: 30px; flex: none; border-radius: var(--r-1);
  border: 1px dashed rgba(255, 255, 255, .14); font: var(--fs-1) var(--mono); letter-spacing: .08em;
  color: var(--mut); text-transform: uppercase; transition: border-color var(--t-hand), color var(--t-hand);
}
.rail-more:hover { border-color: var(--line-2); color: var(--hi); }
.rail-more:disabled { opacity: .45; cursor: wait; }

/* ------------------------------------------------------------ context menu & star/archive UI */
.ctx-menu {
  position: fixed; left: 0; top: 0; z-index: 75; min-width: 176px; padding: 6px;
  border-radius: var(--r-2); background: rgba(22, 22, 25, .96); backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, .13); box-shadow: 0 24px 64px -12px rgba(0, 0, 0, .95);
  display: flex; flex-direction: column; gap: 2px;
  animation: ctxPop var(--t-hand) var(--ease) both;
}
@keyframes ctxPop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.ctx-head {
  padding: 5px 10px 6px; font-size: var(--fs-1); letter-spacing: .12em; color: var(--dim);
  text-transform: uppercase; user-select: none;
}
.ctx-item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 0 10px;
  border-radius: var(--r-1); font-size: var(--fs-3); color: var(--ink); text-align: left;
  transition: background var(--t-hand), color var(--t-hand);
}
.ctx-item .ic { width: 15px; height: 15px; color: var(--mut); transition: color var(--t-hand), fill var(--t-hand); }
.ctx-item:hover:not(:disabled) { background: rgba(255, 255, 255, .08); color: var(--hi); }
.ctx-item:hover:not(:disabled) .ic { color: var(--hi); }
.ctx-item.is-starred { color: var(--hi); }
.ctx-item.is-starred .ic { color: var(--hi); fill: var(--hi); }
.ctx-item:disabled { opacity: .4; cursor: not-allowed; }
.ctx-sep { margin: 4px 6px; border: 0; border-top: 1px solid var(--line); }

.pill-star .ic, .pill-arch .ic { width: 14px; height: 14px; }
.pill-star .tab-count, .pill-arch .tab-count { font: var(--fs-1) var(--mono); font-style: normal; opacity: .78; }
.pill-star.on .ic { fill: currentColor; }
.pill-star.on > span:first-child, .pill-star.on span { color: #0a0a0b; }
.pill-arch.on > span:first-child, .pill-arch.on span { color: #0a0a0b; }

.card-take { cursor: pointer; }
.card-take:focus-visible { outline: 2px solid var(--hi); outline-offset: 4px; border-radius: var(--r-1); }
.card-quick-acts {
  position: absolute; right: 7px; top: 7px; z-index: 4; display: flex; gap: 4px;
  opacity: 0; transition: opacity var(--t-hand);
}
.card:hover .card-quick-acts, .card:focus-within .card-quick-acts, .card-quick-acts.has-star { opacity: 1; }
.card-qbtn {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(10, 10, 11, .68); border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(10px); color: var(--hi); transition: background var(--t-hand), border-color var(--t-hand), color var(--t-hand);
}
.card-qbtn .ic { width: 14px; height: 14px; }
.card-qbtn:hover { background: rgba(34, 34, 38, .92); border-color: var(--line-2); }
.card-qbtn.is-starred { color: var(--hi); border-color: var(--line-2); }
.card-qbtn.is-starred .ic { fill: var(--hi); stroke: var(--hi); }
.card-quick-acts.has-star:not(:hover) .card-qbtn:not(.is-starred) { opacity: 0; }
.card:hover .card-quick-acts .card-qbtn, .card:focus-within .card-quick-acts .card-qbtn { opacity: 1; }
.card .shot .tag-arch { left: auto; right: 10px; top: auto; bottom: 9px; color: var(--mut); }
.drawer .acts .pill .ic { width: 15px; height: 15px; }

/* ------------------------------------------------------------ aspect-locked frame cropper */
.crop-dialog {
  width: min(820px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  padding: 0;
  border-radius: var(--r-2);
  background: #141416;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 36px 100px -20px rgba(0, 0, 0, .96);
  overflow: hidden;
}
.crop-dialog::backdrop { background: rgba(5, 5, 6, .86); backdrop-filter: blur(18px); }
.crop-dialog:focus { outline: none; }
.crop-shell {
  display: flex; flex-direction: column; max-height: calc(100dvh - 26px);
}
.crop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); flex: none;
}
.crop-head-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.crop-head h3 {
  margin: 0; font: 400 17px/1.25 var(--serif); letter-spacing: .02em; color: var(--hi);
}
.crop-badge {
  padding: 3px 9px; border-radius: 999px;
  background: rgba(240, 179, 106, .12); border: 1px solid rgba(240, 179, 106, .36);
  color: var(--accent); font-size: var(--fs-1); letter-spacing: .05em; white-space: nowrap;
}
.crop-queue {
  padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line); color: var(--mut); font-size: var(--fs-1);
}
.crop-close { width: 34px; height: 34px; }
.crop-stage {
  position: relative; flex: 1 1 auto; min-height: 260px; height: min(56dvh, 480px);
  display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(85% 85% at 50% 50%, #111114, #060607);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.crop-canvas-wrap {
  position: relative; flex: none; line-height: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .1);
}
.crop-img {
  display: block; width: 100%; height: 100%;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.crop-box {
  position: absolute; cursor: grab; touch-action: none;
  border: 1.5px solid rgba(242, 239, 232, .94);
  box-shadow: 0 0 0 9999px rgba(5, 5, 6, .74), inset 0 0 0 1px rgba(0, 0, 0, .35);
}
.crop-box:focus { outline: none; }
.crop-box:focus-visible { outline: 1.5px solid rgba(240, 179, 106, .8); outline-offset: 3px; border-radius: 0; }
.crop-box.is-dragging { cursor: grabbing; border-color: #fff; }
.crop-grid { position: absolute; inset: 0; pointer-events: none; opacity: .24; transition: opacity var(--t-hand); }
.crop-box.is-dragging .crop-grid { opacity: .48; }
.crop-grid i { position: absolute; background: rgba(242, 239, 232, .85); }
.crop-grid i:nth-child(1) { left: 33.333%; top: 0; bottom: 0; width: 1px; }
.crop-grid i:nth-child(2) { left: 66.666%; top: 0; bottom: 0; width: 1px; }
.crop-grid i:nth-child(3) { top: 33.333%; left: 0; right: 0; height: 1px; }
.crop-grid i:nth-child(4) { top: 66.666%; left: 0; right: 0; height: 1px; }
.crop-h { position: absolute; z-index: 3; touch-action: none; }
.crop-h-nw, .crop-h-ne, .crop-h-sw, .crop-h-se { width: 26px; height: 26px; }
.crop-h-nw { left: -13px; top: -13px; cursor: nwse-resize; }
.crop-h-ne { right: -13px; top: -13px; cursor: nesw-resize; }
.crop-h-sw { left: -13px; bottom: -13px; cursor: nesw-resize; }
.crop-h-se { right: -13px; bottom: -13px; cursor: nwse-resize; }
.crop-h-nw::after, .crop-h-ne::after, .crop-h-sw::after, .crop-h-se::after {
  content: ''; position: absolute; width: 14px; height: 14px; border-color: var(--hi); border-style: solid; border-width: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .85));
}
.crop-h-nw::after { left: 11px; top: 11px; border-top-width: 2.5px; border-left-width: 2.5px; }
.crop-h-ne::after { right: 11px; top: 11px; border-top-width: 2.5px; border-right-width: 2.5px; }
.crop-h-sw::after { left: 11px; bottom: 11px; border-bottom-width: 2.5px; border-left-width: 2.5px; }
.crop-h-se::after { right: 11px; bottom: 11px; border-bottom-width: 2.5px; border-right-width: 2.5px; }
.crop-h-n, .crop-h-s { left: 18px; right: 18px; height: 16px; cursor: ns-resize; }
.crop-h-n { top: -8px; }
.crop-h-s { bottom: -8px; }
.crop-h-w, .crop-h-e { top: 18px; bottom: 18px; width: 16px; cursor: ew-resize; }
.crop-h-w { left: -8px; }
.crop-h-e { right: -8px; }
.crop-h-n::after, .crop-h-s::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 2.5px;
  transform: translate(-50%, -50%); border-radius: 99px; background: rgba(242, 239, 232, .85);
}
.crop-h-w::after, .crop-h-e::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 2.5px; height: 22px;
  transform: translate(-50%, -50%); border-radius: 99px; background: rgba(242, 239, 232, .85);
}
.crop-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 9px 20px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .02);
  font-size: var(--fs-1); color: var(--mut); flex: none;
}
.crop-tip { color: var(--dim); }
.crop-tip.is-warn { color: var(--accent); }
.crop-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px 16px; border-top: 1px solid var(--line); flex: none;
}
.crop-foot-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crop-role-label { font-size: var(--fs-2); color: var(--mut); }
.crop-role-seg {
  display: inline-flex; align-items: center; padding: 2px; gap: 2px;
  border-radius: 999px; background: rgba(0, 0, 0, .38); border: 1px solid var(--line);
}
.crop-role-opt {
  min-height: 28px; padding: 0 11px; border-radius: 999px;
  font-size: var(--fs-2); color: var(--mut); white-space: nowrap;
  transition: background var(--t-hand), color var(--t-hand);
}
.crop-role-opt:hover { color: var(--hi); }
.crop-role-opt.on { background: var(--hi); color: #0a0a0b; font-weight: 500; }
.crop-reset {
  min-height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line);
  font-size: var(--fs-2); color: var(--mut); transition: color var(--t-hand), border-color var(--t-hand);
}
.crop-reset:hover { color: var(--hi); border-color: var(--line-2); }
.crop-acts { display: flex; align-items: center; gap: 8px; }
.crop-acts .pill { min-height: 38px; padding: 0 16px; }
.crop-confirm { min-height: 38px; padding: 0 18px; font-size: var(--fs-3); }

@media (max-width: 820px) {
  .rail-filters { width: auto; }
  .rail-fbtn { padding: 0 7px; }
  .card-quick-acts { opacity: 1; }
  .crop-dialog { width: calc(100vw - 16px); }
  .crop-stage { height: min(46dvh, 360px); min-height: 210px; }
  .crop-head, .crop-meta, .crop-foot { padding-left: 14px; padding-right: 14px; }
  .crop-acts { width: 100%; justify-content: flex-end; }
  .crop-confirm { flex: 1; }
}

/* ------------------------------------------------------------ community showcase */
.frame-actions .round.is-published,
#dPublish.is-published { color: var(--accent); border-color: rgba(240, 179, 106, .36); }
#tmPublish.is-published { color: var(--accent); }

.card-comm { cursor: pointer; }
.card-comm:focus-visible { outline: 2px solid var(--hi); outline-offset: 4px; border-radius: var(--r-1); }
.comm-tag-code {
  padding: 2px 7px; border-radius: 999px; background: rgba(10, 10, 11, .72);
  border: 1px solid rgba(255, 255, 255, .14); backdrop-filter: blur(8px);
  letter-spacing: .04em !important; text-transform: none !important;
}
.comm-card-sub {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: var(--fs-1); color: var(--dim);
}
.comm-card-sub span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comm-card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.comm-tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  font-size: var(--fs-1); color: var(--mut); white-space: nowrap;
}
.comm-card-bar {
  display: flex; align-items: center; gap: 6px; padding-top: 2px;
}
.comm-mini {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 9px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .025);
  font-size: var(--fs-1); color: var(--mut);
  transition: color var(--t-hand), border-color var(--t-hand), background var(--t-hand);
}
.comm-mini .ic { width: 14px; height: 14px; }
.comm-mini:hover { color: var(--hi); border-color: var(--line-2); background: rgba(255, 255, 255, .06); }
.comm-mini.is-like.on { color: var(--accent); border-color: rgba(240, 179, 106, .42); background: rgba(240, 179, 106, .1); }
.comm-mini.is-like.on .ic { fill: currentColor; }
.comm-mini.is-bm.on { color: var(--hi); border-color: var(--line-2); background: rgba(255, 255, 255, .1); }
.comm-mini.is-bm.on .ic { fill: currentColor; }
.comm-mini.is-link { margin-left: auto; padding: 0 8px; }

/* community case screening room */
.comm-detail {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.comm-detail-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 40px 12px; border-bottom: 1px solid var(--line); flex: none;
}
.comm-detail-nav { display: flex; align-items: center; gap: 10px; min-width: 0; }
.comm-back { gap: 6px; padding-left: 10px; }
.comm-back .ic { width: 16px; height: 16px; }
.comm-code-chip {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px;
  border-radius: 999px; border: 1px solid rgba(240, 179, 106, .35);
  background: rgba(240, 179, 106, .09); color: var(--accent);
  font-size: var(--fs-1); letter-spacing: .04em;
  transition: background var(--t-hand), border-color var(--t-hand);
}
.comm-code-chip:hover { background: rgba(240, 179, 106, .18); border-color: rgba(240, 179, 106, .6); }
.comm-detail-owner { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.comm-danger { color: #f08a80; border-color: rgba(240, 138, 128, .28); }
.comm-danger:hover { border-color: rgba(240, 138, 128, .65); background: rgba(240, 138, 128, .1); color: #ffaea6; }

.comm-detail-body {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 430px);
  gap: 24px; padding: 18px 40px 24px; overflow: hidden;
}
.comm-stage-col {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; overflow: auto;
  padding-right: 4px;
}
.comm-stage-col > * { flex-shrink: 0; }
.comm-frame { flex: none; aspect-ratio: 16 / 9; max-height: min(56vh, 520px); width: 100%; }
.comm-bar { height: 40px; }
.comm-meta-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 18px; border-radius: var(--r-2);
  background: rgba(18, 18, 20, .86); border: 1px solid var(--line);
}
.comm-meta-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.comm-meta-titles { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.comm-meta-titles h2 {
  margin: 0; font: 400 20px/1.35 var(--serif); color: var(--hi); overflow-wrap: anywhere;
}
.comm-meta-titles h2:lang(zh) { font-weight: 300; letter-spacing: .04em; font-size: 18px; }
.comm-meta-sub { font-size: var(--fs-1); color: var(--mut); letter-spacing: .04em; }
.comm-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.comm-note {
  margin: 0; padding: 10px 12px; border-radius: var(--r-1);
  background: rgba(255, 255, 255, .025); border: 1px solid var(--line);
  font-size: var(--fs-3); line-height: 1.6; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere;
}
.comm-engage-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comm-act-btn { gap: 6px; min-height: 38px; padding: 0 13px; }
.comm-act-btn .ic { width: 15px; height: 15px; }
.comm-act-btn.on-like { color: var(--accent); border-color: rgba(240, 179, 106, .48); background: rgba(240, 179, 106, .12); }
.comm-act-btn.on-like .ic { fill: currentColor; }
.comm-act-btn.on-bm { color: var(--hi); border-color: var(--line-2); background: rgba(255, 255, 255, .1); }
.comm-act-btn.on-bm .ic { fill: currentColor; }
.comm-reuse-btn { margin-left: auto; min-height: 38px; padding: 0 16px; gap: 7px; font-size: var(--fs-3); }
.comm-reuse-btn .ic { width: 15px; height: 15px; }

.comm-specs { border-top: 1px solid var(--line); padding-top: 10px; }
.comm-specs summary {
  cursor: pointer; font-size: var(--fs-1); letter-spacing: .1em; text-transform: uppercase; color: var(--mut);
  list-style: none; display: flex; align-items: center; gap: 6px; user-select: none;
}
.comm-specs summary::-webkit-details-marker { display: none; }
.comm-specs summary::before { content: '▸'; font-size: 11px; transition: transform var(--t-hand); }
.comm-specs[open] summary::before { transform: rotate(90deg); }
.comm-specs summary:hover { color: var(--hi); }
.comm-specs-body { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.comm-specs-body .d-sec { margin-bottom: 0; }
.comm-dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; font-size: var(--fs-2); }
.comm-dl dt { color: var(--dim); white-space: nowrap; }
.comm-dl dd { margin: 0; font-family: var(--mono); color: var(--ink); overflow-wrap: anywhere; }

/* comments rail */
.comm-comments-col {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  border-radius: var(--r-2); background: rgba(18, 18, 20, .86); border: 1px solid var(--line);
}
.comm-comments-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--line); flex: none;
}
.comm-comments-title { display: flex; align-items: center; gap: 8px; }
.comm-comments-title h3 { margin: 0; font-size: var(--fs-3); font-weight: 500; color: var(--hi); }
.comm-comments-rule { font-size: 10px; color: var(--dim); letter-spacing: .04em; }
.comm-comment-list {
  flex: 1; min-height: 0; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px;
}
.comm-comment-empty {
  margin: auto 0; padding: 28px 8px; text-align: center; font-size: var(--fs-2); line-height: 1.65; color: var(--dim);
}
.comm-cmt {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px; border-radius: var(--r-1);
  background: rgba(255, 255, 255, .025); border: 1px solid var(--line);
}
.comm-cmt-head { display: flex; align-items: center; gap: 7px; font-size: var(--fs-1); }
.comm-cmt-author { color: var(--hi); font-weight: 500; }
.comm-author-badge {
  padding: 1px 6px; border-radius: 999px; border: 1px solid rgba(240, 179, 106, .35);
  background: rgba(240, 179, 106, .1); color: var(--accent); font-size: 10px;
}
.comm-cmt-time { color: var(--dim); }
.comm-cmt-del {
  margin-left: auto; font-size: var(--fs-1); color: var(--dim);
  transition: color var(--t-hand);
}
.comm-cmt-del:hover { color: #f08a80; }
.comm-cmt-body {
  margin: 0; font-size: var(--fs-3); line-height: 1.6; color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.case-ref-chip {
  display: inline-flex; align-items: center; vertical-align: baseline;
  margin: 0 2px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid rgba(240, 179, 106, .42); background: rgba(240, 179, 106, .12);
  color: var(--accent); font-size: var(--fs-1); line-height: 1.45; letter-spacing: .03em;
  transition: background var(--t-hand), border-color var(--t-hand), color var(--t-hand);
}
.case-ref-chip:hover:not(:disabled) {
  background: var(--accent); border-color: var(--accent); color: #0a0a0b;
}
.case-ref-chip.is-missing {
  border-color: var(--line); background: rgba(255, 255, 255, .03);
  color: var(--dim); text-decoration: line-through; cursor: not-allowed;
}
.case-ref-chip.is-preview { pointer-events: none; }

.comm-comment-form {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px 14px; border-top: 1px solid var(--line); background: rgba(12, 12, 14, .75); flex: none;
}
.comm-ref-preview {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  font-size: var(--fs-1); color: var(--mut);
}
.comm-comment-form textarea {
  width: 100%; resize: vertical; min-height: 70px; max-height: 160px;
  padding: 9px 11px; border-radius: var(--r-1);
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .03);
  font-size: var(--fs-3); line-height: 1.5; color: var(--hi); outline: none;
  transition: border-color var(--t-hand);
}
.comm-comment-form textarea:focus { border-color: rgba(255, 255, 255, .36); }
.comm-comment-form textarea::placeholder { color: var(--dim); }
.comm-comment-err { margin: 0; font-size: var(--fs-1); color: #f08a80; }
.comm-comment-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.comm-char-count { font-size: var(--fs-1); color: var(--dim); }
.comm-char-count.over { color: #f08a80; }
.comm-send-btn { min-height: 36px; padding: 0 16px; font-size: var(--fs-2); }

/* publish dialog */
.pub-dialog {
  width: min(500px, calc(100vw - 24px)); padding: 0; border-radius: var(--r-2);
  border: 1px solid var(--line); background: #141416; color: var(--ink);
  box-shadow: 0 32px 100px rgba(0, 0, 0, .86);
}
.pub-dialog::backdrop { background: rgba(5, 5, 6, .76); backdrop-filter: blur(8px); }
.pub-dialog form { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px 22px; }
.pub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pub-head-left { display: flex; align-items: center; gap: 10px; }
.pub-head h3 { margin: 0; font-size: var(--fs-4); font-weight: 500; color: var(--hi); }
.pub-preview {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--r-1); background: rgba(255, 255, 255, .03); border: 1px solid var(--line);
}
.pub-thumb { width: 88px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; background: #050506; flex: none; }
.pub-preview-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.pub-preview-meta span { font-size: var(--fs-1); color: var(--mut); }
.pub-preview-meta p {
  margin: 0; font-size: var(--fs-2); color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pub-field { display: flex; flex-direction: column; gap: 6px; }
.pub-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pub-field label { font-size: var(--fs-2); color: var(--hi); }
.pub-opt { color: var(--dim); font-weight: 400; margin-left: 4px; }
.pub-count { font-size: var(--fs-1); color: var(--dim); }
.pub-field input, .pub-field textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--r-1);
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .035);
  font-size: var(--fs-3); color: var(--hi); outline: none;
  transition: border-color var(--t-hand);
}
.pub-field input:focus, .pub-field textarea:focus { border-color: rgba(255, 255, 255, .38); }
.pub-field input::placeholder, .pub-field textarea::placeholder { color: var(--dim); }
.pub-field textarea { resize: vertical; min-height: 76px; max-height: 180px; line-height: 1.5; }
.pub-quick-tags { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.pub-qtag {
  min-height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025); font-size: var(--fs-1); color: var(--mut);
  transition: background var(--t-hand), color var(--t-hand), border-color var(--t-hand);
}
.pub-qtag:hover { color: var(--hi); border-color: var(--line-2); }
.pub-qtag.on { color: #0a0a0b; background: var(--hi); border-color: var(--hi); }
.pub-err { margin: 0; font-size: var(--fs-2); color: #f08a80; }
.pub-notice { margin: 0; font-size: var(--fs-1); line-height: 1.55; color: var(--dim); }
.pub-acts { display: flex; align-items: center; gap: 8px; padding-top: 2px; }
.pub-acts .pill, .pub-acts .go { min-height: 38px; padding: 0 16px; font-size: var(--fs-3); }

@media (max-width: 960px) {
  .comm-detail-bar { padding: 12px 16px; }
  .comm-detail-body { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 20px; overflow: auto; }
  .comm-stage-col { overflow: visible; padding-right: 0; }
  .comm-comments-col { min-height: 360px; overflow: visible; }
  .comm-comment-list { max-height: 340px; }
}
