/* Create (portal/static/studio.js): the library, then the editor: the picture and what is selected side by side, the
   timeline under them. The picture and the timeline sit on dark charcoal, as in any video editor, in light and dark.
   Everything is under .sc, so the shell's form styles (portal.css) are undone here only where the editor needs it. */
.sc .grow { flex: 1; }
.sc .small { font-size: 0.875rem; }
.sc .btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; }
.sc .btn.ghost { border-color: transparent; }
.sc .btn.ghost:hover { border-color: var(--line); }
.sc label.btn { display: inline-flex; margin: 0; font-size: 1rem; }
.sc .pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.sc .pill.warn { color: var(--warn, #8A5A12); border-color: color-mix(in srgb, var(--warn, #8A5A12) 40%, var(--line)); }
.sc .pill.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.sc .error-text { color: var(--danger); }

/* the library */
.sc-section { margin-bottom: 18px; }
.sc .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.sc-rowhead { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.sc-rowhead h2 { margin: 0; }
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 14px; }
.sc-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); text-align: left; padding: 0; font: inherit; color: inherit; }
button.sc-card { cursor: pointer; } button.sc-card:hover { border-color: var(--text); }
.sc-thumb { position: relative; display: block; aspect-ratio: 9 / 16; max-height: 300px; width: 100%; border: 0; padding: 0; background: #1F201C; cursor: pointer; overflow: hidden; }
.sc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sc-len { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sc-cbody { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; }
.sc-cbody b { font-size: 0.9375rem; overflow-wrap: anywhere; }
.sc-cbody .pill { align-self: flex-start; }
.sc-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sc-empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); grid-column: 1 / -1; margin: 0; }
.sc-fold > summary { cursor: pointer; list-style: none; }
.sc-fold > summary::-webkit-details-marker { display: none; }
.sc-fold > summary::before { content: "▸ "; color: var(--muted); }
.sc-fold[open] > summary::before { content: "▾ "; }
.sc-fold > .sc-upload { margin-top: 12px; }
.sc-bin { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.sc-src { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); text-align: left; font: inherit; color: inherit; min-width: 0; }
button.sc-src { cursor: pointer; } button.sc-src:hover { border-color: var(--text); } button.sc-src:disabled { cursor: default; opacity: 0.7; }
.sc-src.on { border-color: var(--bronze, var(--accent)); box-shadow: 0 0 0 2px var(--bronze, var(--accent)); }
.sc-srcpic { position: relative; flex: none; width: 54px; height: 72px; border-radius: 5px; overflow: hidden; background: #1F201C; }
.sc-srcpic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sc-srcpic .sc-len { right: 2px; bottom: 2px; font-size: 10.5px; padding: 0 4px; }
.sc-srcb { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.sc-srcb b { font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-src > .btn { flex: none; }
.sc-bar { display: block; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 80px; }
.sc-bar i { display: block; height: 100%; background: var(--bronze, var(--accent)); transition: width 0.3s; }
.sc-audio { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sc-audio li { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; min-height: 50px; }
.sc-audio li.muted { display: block; border-style: dashed; }
.sc-audio li > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the editor */
.sc-ed { display: flex; flex-direction: column; gap: 12px; }
.sc-top { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.sc .sc-name { font: 400 1.25rem/1.2 var(--serif, Georgia, serif); border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; min-height: 0; min-width: 160px; width: min(360px, 60vw); background: transparent; }
.sc .sc-name:hover, .sc .sc-name:focus { border-color: var(--line); background: var(--card); }
.sc-state { display: flex; align-items: center; gap: 10px; min-height: 20px; flex-wrap: wrap; }
.sc-state:empty { display: none; }
.sc-state .sc-bar { width: 200px; }
.sc-main { display: grid; grid-template-columns: minmax(240px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.sc-stage { display: flex; flex-direction: column; gap: 10px; align-items: center; background: #1F201C; border-radius: 12px; padding: 14px; position: sticky; top: 12px; }
.sc-canvas { display: block; width: min(100%, 372px, max(214px, calc((100vh - 470px) * 0.5625))); height: auto; aspect-ratio: 9 / 16; border-radius: 6px; background: #000; touch-action: none; }
.sc-transport { display: flex; align-items: center; gap: 8px; color: #ECE8DF; }
.sc-transport .btn:not(.primary), .sc-tlbar .btn { background: #2D2E29; border-color: #3C3D35; color: #ECE8DF; }
.sc-transport .btn:not(.primary):hover, .sc-tlbar .btn:hover { background: #393A33; border-color: #55564C; }
.sc-transport .btn.primary { background: #ECE8DF; color: #1F201C; border-color: #ECE8DF; }
.sc-time { font-variant-numeric: tabular-nums; font-size: 13px; color: #CFCAC0; min-width: 112px; }
.sc-inspect { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sc-ihead { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.sc-ihead h3 { margin: 0; font-size: 1.0625rem; overflow-wrap: anywhere; }
.sc-big { font-size: 1.625rem; font-weight: 600; font-variant-numeric: tabular-nums; margin: 0; }
.sc-inspect > p { margin: 0; }
.sc-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 4px 12px; align-items: center; }
.sc-row > .muted { grid-column: 2; }
.sc .sc-rowl { display: block; margin: 0; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.sc-row textarea, .sc-row select, .sc-row input[type="number"] { min-height: 38px; padding: 6px 8px; background: var(--card); }
.sc-row input[type="number"] { width: 90px; }
.sc-row input[type="checkbox"] { justify-self: start; }
.sc-row textarea { min-height: 70px; font-size: 1rem; }
.sc-times { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sc-to { color: var(--muted); font-size: 0.8125rem; }
.sc-range { display: flex; align-items: center; gap: 10px; }
.sc input[type="range"] { flex: 1; min-width: 100px; min-height: 0; padding: 0; border: 0; background: none; accent-color: var(--bronze, var(--accent)); }
.sc-range output { font-size: 0.8125rem; color: var(--muted); min-width: 58px; font-variant-numeric: tabular-nums; }
.sc-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-sw { width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.25); cursor: pointer; padding: 0; }
.sc-sw.on { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--bronze, var(--accent)); }
.sc-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; justify-self: start; }
.sc-seg button { font: inherit; font-size: 0.8125rem; padding: 6px 10px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; }
.sc-seg button:last-child { border-right: 0; }
.sc-seg button.on { background: var(--accent); color: var(--accent-ink); }
.sc-styles { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-style { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 0.9375rem; cursor: pointer; line-height: 1.2; }
.sc-style:hover { outline: 2px solid var(--bronze, var(--accent)); outline-offset: 1px; }
.sc-about summary { cursor: pointer; font-weight: 600; font-size: 0.875rem; }
.sc-about p { margin: 6px 0 0; }

/* the timeline */
.sc-tl { background: #1F201C; border-radius: 12px; padding: 10px 12px 12px; color: #ECE8DF; }
.sc-tlbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.sc .sc-zoom { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 0.8125rem; font-weight: 400; color: #A8A397; }
.sc .sc-zoom input { width: 110px; flex: none; }
.sc-tlscroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
.sc-tlinner { position: relative; min-width: 100%; }
.sc-ruler { position: relative; height: 24px; border-bottom: 1px solid #3C3D35; cursor: pointer; touch-action: none; user-select: none; }
.sc-tick { position: absolute; top: 4px; font-size: 11px; color: #A8A397; transform: translateX(-50%); font-variant-numeric: tabular-nums; pointer-events: none; }
.sc-tick:first-child { transform: none; }
.sc-tick::after { content: ""; position: absolute; left: 50%; top: 16px; width: 1px; height: 5px; background: #55564C; }
.sc-tick:first-child::after { left: 0; }
.sc-covermark { position: absolute; bottom: 0; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 7px solid #C2AA80; transform: translateX(-5px); pointer-events: none; }
.sc-track { position: relative; height: 58px; margin-top: 6px; border-radius: 6px; background: #2A2B26; }
.sc-track::before { content: attr(data-name); position: sticky; left: 6px; top: 2px; z-index: 0; font-size: 10.5px; color: #8C877B; text-transform: uppercase; letter-spacing: 0.06em; pointer-events: none; }
.sc-track.lanes { height: auto; min-height: 38px; }
.sc-track.thin { height: 30px; }
.sc-blk { position: absolute; top: 4px; bottom: 4px; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 5px; padding: 0 8px; color: #fff; font: inherit; font-size: 12px; text-align: left; overflow: hidden; cursor: pointer; background: #3C3D35; touch-action: none; z-index: 1; min-height: 0; }
.sc-blk.item { background-color: #33342E; }
.sc-blkpic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.sc-blk.item::before { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.7)); }
.sc-blk.layer { height: 24px; bottom: auto; background: #6E5F43; border-color: #C2AA80; }
.sc-blk.layer.sticker { background: #5B5A50; border-color: #D8D1C5; }
.sc-blk.sound { background: #3D5566; border-color: #8FB0C4; padding: 0 5px; }
.sc-blk.music { background: #57465E; border-color: #B79BC0; }
.sc-blk.on { outline: 2px solid #fff; outline-offset: 0; z-index: 2; }
.sc-blkl { position: relative; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 22px; pointer-events: none; }
.sc-blk.item .sc-blkl { position: absolute; z-index: 2; left: 8px; right: 8px; bottom: 3px; line-height: 1.2; text-shadow: 0 1px 2px #000; }
.sc-h { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; background: rgba(255, 255, 255, 0.85); z-index: 3; touch-action: none; }
.sc-hl { left: 0; border-radius: 4px 0 0 4px; }
.sc-hr { right: 0; border-radius: 0 4px 4px 0; }
.sc-trans { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; background: #C2AA80; transform: rotate(45deg); border-radius: 2px; z-index: 2; pointer-events: none; box-shadow: 0 0 0 2px #2A2B26; }
.sc-track .btn { position: absolute; top: 2px; min-height: 26px; padding: 2px 10px; background: transparent; border-color: #3C3D35; color: #A8A397; }
.sc-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #E8836E; pointer-events: none; z-index: 4; }
.sc-head::before { content: ""; position: absolute; top: 0; left: -5px; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid #E8836E; }

/* the pickers (a dialog on the page, outside the view) */
.sc-dlg { width: min(94vw, 760px); max-height: 88vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); }
.sc-dlg.wide { width: min(96vw, 1040px); }
.sc-dlg::backdrop { background: rgba(20, 20, 16, 0.55); }
.sc-dlghead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.sc-dlghead h2 { margin: 0; font-size: 1.25rem; }
.sc-dlgbody { padding: 14px 18px 18px; }
.sc-dlgtop { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sc-dlgtop .muted { flex: 1; min-width: 200px; }
.sc-dlgfoot { display: flex; justify-content: flex-end; margin-top: 14px; position: sticky; bottom: -18px; background: var(--card); padding: 10px 0; }
.sc-bin.pick { max-height: 52vh; overflow: auto; padding: 2px; }
.sc-grid.pick { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.sc-stickers { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.sc-sticker { width: 150px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #FAF8F3; color: #292A25; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; font: inherit; }
.sc-sticker.on-dark { background: #292A25; color: #F2EFE8; }
.sc-sticker:hover { border-color: var(--bronze, var(--accent)); box-shadow: 0 0 0 2px var(--bronze, var(--accent)); }
.sc-sticker img { height: 64px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.sc-result { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 18px; align-items: start; }
.sc-result video { display: block; width: 100%; max-height: 70vh; aspect-ratio: 9 / 16; object-fit: contain; background: #000; border-radius: 8px; }
.sc-resultb { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.sc-resultb p { margin: 0; }

@media (max-width: 900px) {
  .sc-main { grid-template-columns: 1fr; }
  .sc-stage { position: static; }
  .sc-canvas { width: min(100%, max(214px, calc(62vh * 0.5625))); }
  .sc-row { grid-template-columns: 1fr; }
  .sc-row > .muted { grid-column: 1; }
}
@media (max-width: 640px) {
  .sc .card { padding: 14px; }
  .sc-result { grid-template-columns: 1fr; }
  .sc-audio li { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .sc-audio li > .muted:nth-child(3) { display: none; }
  .sc-bin { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .sc-bar i { transition: none; } }
