:root {
  --bg: #f6f6f4; --surface: #ffffff; --line: #e4e4e0; --text: #1d1d1b; --muted: #6b6b66;
  --accent: #ea580c; --accent-ink: #ffffff; --danger: #b91c1c; --ok: #15803d;
  --stage: #2a2a28; --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161615; --surface: #20201e; --line: #34342f; --text: #ededea; --muted: #9b9b94; --stage: #0d0d0c; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1em; margin: 0; }
.ok { color: var(--ok); margin: 0; }
h1 { font-size: 22px; margin: 0; }
h2 { margin: 0 0 12px; font-size: 19px; }

.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 8px; font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.round { width: 40px; height: 40px; border-radius: 50%; justify-content: center; padding: 0; }
.btn[disabled] { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; font-weight: 400; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
label.check { flex-direction: row; align-items: center; font-weight: 400; gap: 8px; }
label.check input { width: auto; }

.brand { font-weight: 800; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: .01em; }
.brand span { color: var(--accent); font-weight: 600; }
.brand.big { font-size: 26px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card p { margin: 0; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
details label { margin-top: 10px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.spacer { flex: 1; }
.who { font-size: 13px; color: var(--muted); }

/* pages */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 18px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; }
.card:hover { border-color: var(--accent); }
.thumb { position: relative; aspect-ratio: 16/9; background: var(--stage); overflow: hidden; }
.thumb iframe { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; }
.thumb.portrait iframe { width: 1080px; height: 1920px; }
.card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.card-body b { font-size: 15px; }
.card-body small { color: var(--muted); }
.card-actions { display: flex; gap: 8px; padding: 0 14px 12px; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 20px; background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); font-weight: 600; }
.empty { text-align: center; padding: 40px 0; }

/* editor */
.editor { display: grid; grid-template-columns: 380px 1fr; height: calc(100vh - 53px); }
.panel { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; }
.panel-head { position: sticky; top: 0; background: var(--surface); padding: 14px 16px 10px; border-bottom: 1px solid var(--line); z-index: 2; display: flex; flex-direction: column; gap: 4px; }
.name-input { font-size: 17px; font-weight: 700; border-color: transparent; padding: 6px 8px; margin-left: -8px; }
.name-input:hover, .name-input:focus { border-color: var(--line); }
.save-state { font-size: 12px; }
.form { padding: 12px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 36px; padding: 2px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; font: inherit; color: inherit; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.img-field { display: flex; gap: 10px; align-items: center; }
.img-field .pv { width: 64px; height: 48px; border-radius: 6px; background: var(--bg) center/contain no-repeat; border: 1px solid var(--line); flex: none; }
.img-field .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.list-item { border: 1px solid var(--line); border-radius: 9px; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.list-item-head { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.list-item-head .spacer { flex: 1; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 3px 6px; border-radius: 5px; font-size: 14px; }
.icon-btn:hover { background: var(--bg); color: var(--text); }

.stage-area { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.stage-tools { display: flex; align-items: center; gap: 10px; padding: 12px 18px; }
.stage-box { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 10px 18px; }
.stage-frame { position: relative; background: var(--stage); box-shadow: 0 8px 30px rgba(0,0,0,.18); border-radius: 4px; overflow: hidden; }
.stage-frame iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; }
.transport { display: flex; align-items: center; gap: 12px; padding: 12px 18px 18px; }
.transport input[type=range] { flex: 1; padding: 0; accent-color: var(--accent); }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 92px; text-align: right; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
#publish-form { display: flex; flex-direction: column; gap: 14px; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.opt { flex-direction: row; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-weight: 400; cursor: pointer; }
.opt input { width: auto; margin-top: 3px; }
.opt small { color: var(--muted); }
.progress { display: flex; flex-direction: column; gap: 6px; }
.progress .bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 860px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: none; }
  .stage-area { order: -1; }
  .stage-box { height: 56vw; }
  .who { display: none; }
}
