/* iClipSora editor */
body.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.app::before { opacity: .7; }
body.app::before, body.app::after { opacity: .75; }

.app-bar {
  flex: none; display: flex; align-items: center; gap: 12px;
  margin: 10px 10px 0; height: 58px; padding: 0 8px 0 16px; border-radius: 999px; z-index: 5;
}
.app-bar .logo { font-size: 17px; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.plan-pill { height: 34px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-2); background: rgba(255,255,255,0.06); border: 1px solid var(--stroke); }
.plan-pill.paid { color: var(--accent-ink); background: var(--grad); border-color: transparent; }

/* segmented control */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(0,0,0,0.28); border: 1px solid var(--stroke); position: relative; }
.seg button { border: 0; background: transparent; height: 32px; padding: 0 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: color .2s, background .25s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: rgba(255,255,255,0.14); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 2px 8px rgba(0,0,0,0.25); }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.tpl-seg { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tpl-seg::-webkit-scrollbar { display: none; }
.tpl-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }

.app-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 10px; padding: 10px; }

/* panel */
.panel { min-height: 0; display: flex; flex-direction: column; border-radius: 28px; overflow: hidden; }
.panel-head { padding: 14px 14px 10px; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
.panel-body > section { display: grid; gap: 14px; padding: 0; }
.panel-body > section[hidden] { display: none; }
.group { display: grid; gap: 10px; padding: 14px; border-radius: 20px; background: rgba(0,0,0,0.18); border: 1px solid var(--stroke); }
.group h4 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14.5px; }
.toggle-row small { display: block; color: var(--text-3); font-size: 12.5px; }

/* iOS switch */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(120,120,128,0.36); transition: background .25s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,0.25); transition: transform .3s cubic-bezier(.3,.7,.4,1.3); }
.switch input:checked + span { background: linear-gradient(120deg, #4FC7FF, #7D8EFF); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--sky); outline-offset: 2px; }

/* range */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--sky) 0 var(--p, 0%), rgba(255,255,255,0.14) var(--p, 0%)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.14); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--sky); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }

/* messages */
.msgs { display: grid; gap: 8px; }
.msg { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; padding: 10px; border-radius: 18px; background: rgba(255,255,255,0.04); border: 1px solid var(--stroke); transition: border-color .2s, background .2s; }
.msg:focus-within { border-color: rgba(110, 124, 255,0.45); background: rgba(110, 124, 255,0.05); }
.who { height: 30px; min-width: 64px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--stroke); font-size: 12.5px; font-weight: 700; cursor: pointer; background: rgba(255,255,255,0.08); color: var(--text-2); }
.who[data-side="me"] { background: linear-gradient(120deg, rgba(110, 124, 255,0.9), rgba(160, 110, 255,0.9)); color: var(--accent-ink); border-color: transparent; }
.msg-text { resize: none; border: 0; background: transparent; outline: none; padding: 5px 2px; line-height: 1.4; font-size: 15px; min-height: 30px; overflow: hidden; }
.msg-text::placeholder { color: var(--text-3); }
.msg-tools { grid-column: 1 / -1; display: flex; gap: 2px; align-items: center; }
.msg-tools .spacer { flex: 1; }
.ibtn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--text-3); cursor: pointer; transition: color .15s, background .15s; }
.ibtn:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.ibtn.on { color: var(--sky); }
.ibtn.danger:hover { color: var(--danger); }
.ibtn svg { width: 17px; height: 17px; }
.msg-timing { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.msg-timing[hidden] { display: none; }
.msg-timing label { display: grid; gap: 4px; font-size: 12px; color: var(--text-3); }
.msg-timing .input { padding: 7px 10px; font-size: 14px; border-radius: 10px; }
.msg-img { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.msg-img img { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; }
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-row .btn { width: 100%; }

.avatar-pick { display: flex; align-items: center; gap: 12px; }
.avatar-pick .av { width: 56px; height: 56px; border-radius: 50%; background: var(--bg-3) center/cover; border: 1px solid var(--stroke); flex: none; display: grid; place-items: center; font-weight: 700; color: var(--text-2); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); position: relative; }
.swatch[aria-pressed="true"] { border-color: #fff; }
.swatch.locked::after { content: "★"; position: absolute; right: -4px; top: -4px; width: 16px; height: 16px; border-radius: 50%; background: var(--grad); color: var(--accent-ink); font-size: 9px; display: grid; place-items: center; }
.color-input { width: 44px; height: 40px; padding: 0; border: 0; background: none; cursor: pointer; }

/* stage */
.stage { min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; }
.stage-canvas-wrap { flex: 1; min-height: 0; width: 100%; position: relative; }
#preview { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.transport { flex: none; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px; width: min(560px, 100%); }
.transport .time { font: 500 13px/1 var(--mono); color: var(--text-2); min-width: 112px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--grad); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: inset 0 1px 0 rgba(255,255,255,0.5); }
.play svg { width: 18px; height: 18px; }

/* dialogs */
dialog { border: 0; padding: 0; color: var(--text); background: transparent; max-width: calc(100vw - 24px); }
dialog::backdrop { background: rgba(5,6,8,0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.sheet { width: 480px; border-radius: 32px; padding: 24px; display: grid; gap: 18px; background: rgba(36,38,43,0.86); }
.sheet h2 { font-size: 26px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.opt { display: grid; gap: 8px; }
.opt > span { font-size: 13px; color: var(--text-2); font-weight: 500; }
.lock { font-size: 11px; font-weight: 700; margin-left: 6px; padding: 2px 6px; border-radius: 6px; background: var(--grad); color: var(--accent-ink); }
.progress { height: 10px; border-radius: 5px; background: rgba(255,255,255,0.1); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 5px; transition: width .2s; }
.result video { width: 100%; max-height: 46vh; border-radius: 18px; background: #000; }
.wm-note { font-size: 13.5px; color: var(--text-2); }
.wm-note a { color: var(--sky); }

.toast { position: fixed; left: 50%; top: 80px; transform: translate(-50%, -12px); opacity: 0; padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; transition: .3s; z-index: 100; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* responsive */
@media (max-width: 900px) {
  body.app { height: auto; overflow: auto; }
  .app-bar { position: sticky; top: 8px; margin: 8px 8px 0; padding-left: 12px; }
  .app-bar .logo-text { display: none; }
  .app-main { grid-template-columns: 1fr; padding: 8px; }
  .stage { order: -1; height: 64vh; height: 64dvh; }
  .panel { overflow: visible; }
  .panel-body { overflow: visible; }
  .plan-pill { display: none; }
}
@media (max-width: 520px) {
  .app-bar .logo { display: none; }
}

/* template picker */
.tpl-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 14px; border-radius: 999px; border: 1px solid var(--stroke); background: rgba(0,0,0,0.28); font-size: 14.5px; font-weight: 650; cursor: pointer; color: var(--text); white-space: nowrap; }
.tpl-btn:hover { border-color: var(--stroke-hi); }
.tpl-btn .tpl-dot { margin: 0; }
.tpl-btn svg { width: 16px; height: 16px; color: var(--text-2); }
.tpl-sheet { width: 720px; max-height: 86vh; overflow-y: auto; }
.tpl-group h4 { margin: 4px 0 10px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.tpl-group + .tpl-group { margin-top: 18px; }
.tpl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tpl-item { display: grid; gap: 4px; text-align: left; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.04); cursor: pointer; color: var(--text); }
.tpl-item:hover { background: rgba(255,255,255,0.08); border-color: var(--stroke-hi); }
.tpl-item[aria-pressed="true"] { border-color: rgba(110, 124, 255,0.6); background: rgba(110, 124, 255,0.1); }
.tpl-item b { font-size: 14.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; }
.tpl-item span { font-size: 12.5px; color: var(--text-3); line-height: 1.35; }
.form { display: grid; gap: 10px; }
.item-card { display: grid; gap: 8px; padding: 12px; border-radius: 18px; background: rgba(255,255,255,0.04); border: 1px solid var(--stroke); }
.item-card:focus-within { border-color: rgba(110, 124, 255,0.45); }
.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.item-grid .wide { grid-column: 1 / -1; }
.item-grid .field > span { font-size: 12px; }
.item-grid .input, .item-grid .select { padding: 8px 11px; font-size: 14.5px; border-radius: 11px; }
.item-grid .textarea { min-height: 64px; padding: 8px 11px; font-size: 14.5px; border-radius: 11px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: #7D8CFF; }
.img-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.img-pick img { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; }
.img-pick { flex-wrap: wrap; }
.img-pick .btn { flex: none; }
.img-pick .hint { flex-basis: 100%; font-size: 12.5px; color: var(--text-3); }
.msg .author { grid-column: 2; border: 0; background: transparent; outline: none; font-size: 13px; font-weight: 650; color: var(--sky); padding: 0 2px; }
.swatch.add { display: grid; place-items: center; background: rgba(255,255,255,0.06); color: var(--text-2); font-size: 20px; }
@media (max-width: 900px) { .tpl-btn { height: 36px; font-size: 13.5px; } }

/* transport buttons + tooltips */
.tbtn { height: 40px; display: inline-flex; align-items: center; gap: 7px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.06); color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer; flex: none; transition: background .15s, border-color .15s; }
.tbtn:hover { background: rgba(255,255,255,0.12); border-color: var(--stroke-hi); }
.tbtn svg { width: 18px; height: 18px; }
.transport { width: min(680px, 100%); }
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; padding: 7px 11px; border-radius: 10px; font-size: 12.5px; font-weight: 500;
  background: rgba(20,21,24,0.95); color: #fff; border: 1px solid var(--stroke); box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: none; z-index: 20;
}
.sc-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: end; }
.sc-row .input { padding: 8px 10px; font-size: 14px; border-radius: 10px; }
.sc-row .field > span { font-size: 12px; }
@media (max-width: 560px) { .tbtn span { display: none; } .tbtn { width: 40px; padding: 0; justify-content: center; } }

.msg-tools .at { font: 500 11.5px/1 var(--mono); color: var(--text-3); padding: 0 6px; font-variant-numeric: tabular-nums; }
.item-card.is-target { border-color: rgba(110, 124, 255,0.45); background: rgba(110, 124, 255,0.06); }
.row-title { font-size: 12.5px; font-weight: 700; letter-spacing: .02em; color: var(--sky); }
.msg-timing { grid-template-columns: 1fr 1fr; }
.msg-timing select.input { padding: 7px 8px; }

.swatch.live { animation: live-swatch 5s linear infinite; }
.swatch.live::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: #FF453A; box-shadow: 0 0 0 2px var(--bg-2); }
@keyframes live-swatch { to { filter: hue-rotate(360deg); } }

/* projects + account in the app bar */
.proj-btn { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--stroke); background: rgba(0,0,0,0.28); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; position: relative; transition: border-color .2s, background .2s; }
.proj-btn:hover { border-color: var(--stroke-hi); background: rgba(255,255,255,0.06); }
.proj-btn svg { width: 18px; height: 18px; }
.proj-btn[data-sync]::after { content: ""; position: absolute; top: 6px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: #4CD995; }
.proj-btn[data-sync="saving"]::after { background: #FFC457; }
.proj-btn[data-sync="error"]::after { background: #FF6B6B; }
.proj-btn[data-sync="local"]::after { display: none; }
.acct-chip { white-space: nowrap; flex: none; height: 34px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text); border: 1px solid var(--stroke); background: rgba(255,255,255,0.06); }
.acct-chip:hover { border-color: var(--stroke-hi); }
.acct-chip.in { padding: 0; width: 34px; justify-content: center; border: 0; background: none; }
.acct-chip .nav-avatar { width: 32px; height: 32px; font-size: 14px; }
.proj-sheet { width: 520px; max-height: min(80vh, 720px); grid-template-rows: auto auto auto 1fr; }
.proj-sheet #proj-hint a { color: var(--sky); text-decoration: underline; }
.proj-items { display: grid; gap: 6px; overflow-y: auto; align-content: start; min-height: 80px; overscroll-behavior: contain; }
.proj-item { display: flex; align-items: center; gap: 2px; border-radius: 14px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.03); padding: 4px 6px 4px 4px; }
.proj-item.current { border-color: rgba(110,124,255,0.55); background: rgba(110,124,255,0.08); }
.proj-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; border-radius: 10px; }
.proj-open:hover { background: rgba(255,255,255,0.05); }
.proj-meta { display: grid; min-width: 0; }
.proj-meta b { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-meta span { font-size: 12.5px; color: var(--text-3); }
@media (max-width: 640px) { .proj-btn span { display: none; } .proj-btn { padding: 0 11px; height: 36px; flex: none; } .acct-chip { padding: 0 11px; font-size: 13px; } }
@media (max-width: 400px) { #export-btn span { display: none; } #export-btn { padding: 0 12px; } .tpl-btn { padding: 0 10px; } }
