/* video-to-3d — site styles. No external fonts or assets. */

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --alt: #f2f2ef;
  --ink: #18191c;
  --muted: #666a73;
  --line: #e2e2dd;
  --line-strong: #cbcbc4;
  --accent: #4553d6;
  --accent-ink: #ffffff;
  --accent-soft: #e9ebfc;
  --ok: #2f8f5b;
  --warn: #b7791f;
  --bad: #c5352b;
  --stage: #e9eaee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(24, 25, 28, .06), 0 8px 24px rgba(24, 25, 28, .06);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101114; --surface: #17181c; --alt: #131417; --ink: #ebebee; --muted: #979ba6;
    --line: #27282e; --line-strong: #383a42; --accent: #8c98ff; --accent-ink: #0c0e22; --accent-soft: #1c1f3a;
    --ok: #5cc48c; --warn: #e0a84a; --bad: #ff7b6e; --stage: #1b1d23;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #101114; --surface: #17181c; --alt: #131417; --ink: #ebebee; --muted: #979ba6;
  --line: #27282e; --line-strong: #383a42; --accent: #8c98ff; --accent-ink: #0c0e22; --accent-soft: #1c1f3a;
  --ok: #5cc48c; --warn: #e0a84a; --bad: #ff7b6e; --stage: #1b1d23;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.fs-lock { overflow: hidden; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
h1, h2 { line-height: 1.15; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
p { margin: 0 0 12px; }
code { font-family: var(--mono); font-size: .875em; background: var(--alt); border: 1px solid var(--line); border-radius: 5px; padding: .08em .36em; white-space: nowrap; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── header ── */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 17px; letter-spacing: -.02em; text-decoration: none; white-space: nowrap; }
.brand img { border-radius: 7px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; min-width: 34px; padding: 0 9px; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.icon-btn:hover { border-color: var(--line-strong); }
.conn { display: inline-flex; align-items: center; gap: 7px; font: 12.5px var(--mono); color: var(--muted); padding: 0 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); display: inline-block; flex: none; }
.conn.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.conn.bad .dot { background: var(--bad); }

/* ── page ── */
main.wrap { padding-top: 36px; padding-bottom: 56px; }
.intro { margin-bottom: 24px; max-width: 46em; }
.intro h1 { font-size: clamp(26px, 3.4vw, 38px); font-weight: 680; letter-spacing: -.03em; margin-bottom: 8px; }
.intro p { color: var(--muted); margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; font-weight: 550; text-decoration: none; cursor: pointer; transition: transform .06s, border-color .15s, background .15s; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.06); }
.btn-small { height: 34px; padding: 0 12px; font-size: 14px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.notice { display: flex; flex-wrap: wrap; gap: 4px 14px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; font-size: 15px; }
.play { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 24px; align-items: start; }
.play-main, .play-out { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; margin: 0 0 6px; }
input[type="text"], input[type="url"], input[type="password"], input[type="number"], select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 12px; }
input::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.status { font-size: 14px; color: var(--muted); }
.status.bad { color: var(--bad); }
.status.ok { color: var(--ok); }
.spin::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 7px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; vertical-align: -1px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* the upload box: a label around a file input, so click, keyboard and drop all work */
.drop { display: grid; place-items: center; gap: 6px; text-align: center; padding: 34px 18px; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop svg { color: var(--accent); }
.drop strong { font-size: 16px; font-weight: 620; }
.drop span { font-size: 14px; color: var(--muted); max-width: 30em; }
.tips { margin: 14px 0 0; padding: 0 0 0 18px; font-size: 14px; color: var(--muted); }
.tips li { margin: 2px 0; }
.actions { margin-top: 16px; min-height: 34px; }

.queue { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.queue:empty { display: none; }
.queue li { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.queue li.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.queue img { width: 52px; height: 52px; object-fit: cover; border-radius: 7px; background: var(--alt); }
.q-name { font-size: 14px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-state { font: 12.5px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-state.bad { color: var(--bad); white-space: normal; }
.q-state.ok { color: var(--ok); }
.q-btns { display: flex; gap: 6px; }
.q-btns button { height: 28px; padding: 0 9px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 12.5px var(--sans); cursor: pointer; }
.q-btns button:hover { border-color: var(--ink); }

/* ── the viewer ── */
.play-out { padding: 14px; }
.stage { position: relative; height: clamp(340px, 52vw, 520px); border-radius: 9px; overflow: hidden; background: var(--stage); }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.stage-msg { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 24px; text-align: center; pointer-events: none; }
.stage-msg p { margin: 0; }
.stage-msg svg { color: var(--line-strong); margin-bottom: 6px; }
.stage-tag { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 4px 10px; border-radius: 999px; font: 12px var(--mono); color: #fff; background: rgba(15, 16, 20, .62); pointer-events: none; white-space: nowrap; }
.stage-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 3; }
.stage-btn { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--surface) 86%, transparent); color: var(--ink); cursor: pointer; }
.stage-btn:hover { border-color: var(--ink); }
.stage-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
#btn-full .ico-exit, #btn-full[aria-pressed="true"] .ico-enter { display: none; }
#btn-full[aria-pressed="true"] .ico-exit { display: block; }

/* expanded: the viewer takes the width of the page, the upload box moves under it */
.play.wide { grid-template-columns: minmax(0, 1fr); }
.play.wide .play-out { order: -1; }
.play.wide .stage { height: clamp(380px, 76vh, 1000px); }

/* full screen: the viewer and its buttons, nothing else (the class also serves browsers without the Fullscreen API) */
.play-out.fs { position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; padding: 10px; display: flex; flex-direction: column; overflow: auto; background: var(--surface); }
.play-out.fs .stage { flex: 1 1 auto; height: auto; min-height: 58vh; }
.play-out.fs #out { flex: none; }
.play-out.fs .meta, .play-out.fs #btn-expand { display: none; }

/* ── working: the mask chase (chase.js) ── */
.stage-busy { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: color-mix(in srgb, var(--stage) 80%, transparent); backdrop-filter: blur(2px); }
.chase { position: absolute; inset: 0 0 88px 0; }
.busy-card { position: absolute; left: 0; right: 0; bottom: 12px; display: grid; justify-items: center; gap: 5px; padding: 0 16px; text-align: center; }
.busy-card p { margin: 0; max-width: 100%; }
.busy-line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.busy-line b { font: 600 20px var(--mono); letter-spacing: -.02em; }
.busy-line b:empty { display: none; }
.busy-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.busy-card .muted { font-size: 13px; min-height: 1.4em; }
.bar { width: min(260px, 70%); height: 4px; border-radius: 4px; background: var(--line-strong); overflow: hidden; }
.bar i { display: block; height: 100%; width: 30%; border-radius: 4px; background: var(--accent); animation: slide 1.6s ease-in-out infinite; }
.bar.known i { animation: none; transition: width .2s; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(360%); } }

.mon { position: absolute; left: 0; top: 0; will-change: transform; }
.mon-shadow { position: absolute; left: 12%; right: 12%; bottom: -4%; height: 14%; border-radius: 50%; background: rgba(0, 0, 0, .2); }
.mon-body { position: absolute; inset: 0; transform-origin: 50% 96%; will-change: transform; }
.mon-body svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mon-hand { transform-box: fill-box; transform-origin: 50% 50%; animation: mon-wave .34s ease-in-out infinite alternate; }
.mon-hand.b { animation-delay: -.17s; }
@keyframes mon-wave { from { transform: translateY(2px); } to { transform: translateY(-5px); } }
.mon-stars { position: absolute; left: 0; right: 0; top: -14%; text-align: center; font-size: 15px; line-height: 1; color: #f5b301; letter-spacing: 3px; opacity: 0; animation: mon-stars .5s linear infinite; }
.mon.dizzy .mon-stars { opacity: 1; }
@keyframes mon-stars { from { transform: translateX(-5px) rotate(-12deg); } 50% { transform: translateX(5px) rotate(12deg); } to { transform: translateX(-5px) rotate(-12deg); } }
.mon-say { position: absolute; left: 50%; bottom: 104%; padding: 2px 9px 3px; border: 1.5px solid #1b1b1f; border-radius: 12px; background: #fff; color: #1b1b1f; font: 700 12.5px/1.3 "Comic Sans MS", "Chalkboard SE", "Comic Neue", "Segoe Print", cursive, var(--sans); white-space: nowrap; opacity: 0; transform: translateX(-50%) scale(.5); transform-origin: 50% 100%; transition: opacity .12s, transform .16s cubic-bezier(.3, 1.6, .5, 1); }
.mon-say::after { content: ""; position: absolute; left: 50%; top: 100%; width: 7px; height: 7px; margin: -4px 0 0 -4px; background: #fff; border-right: 1.5px solid #1b1b1f; border-bottom: 1.5px solid #1b1b1f; transform: rotate(45deg); }
.mon-say.on { opacity: 1; transform: translateX(-50%) scale(1); }

.viewbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.tog { height: 32px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); font: inherit; font-size: 13.5px; cursor: pointer; }
.tog:hover { color: var(--ink); }
.tog[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.viewbar .spacer { flex: 1; }
.view-opt { margin-left: 4px; }
.tog:disabled { opacity: .45; cursor: default; }
.tog:disabled:hover { color: var(--muted); }

/* the editor under the viewer */
.editor { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 10px; }
.ed-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; align-items: start; }
.ed-label { font: 11.5px var(--mono); color: var(--muted); padding-top: 8px; }
.ed-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ed-break { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }
.ed-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.ed-opt input[type="range"] { width: 92px; accent-color: var(--accent); }
.ed-opt input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.ed-opt select { width: auto; padding: 4px 8px; font-size: 13px; }
.editor input[type="color"] { width: 38px; height: 32px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }
.ed-hint { margin: 0; font-size: 13px; color: var(--muted); }
.ed-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.editor > .status { margin: 0; font-size: 13.5px; }
.editor > .status:empty { display: none; }
.stage.selecting canvas, .stage.selecting canvas:active { cursor: crosshair; }
.ed-ring { position: absolute; border: 1.5px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .55); pointer-events: none; }
.ed-box { position: absolute; border: 1px dashed #fff; outline: 1px solid rgba(0, 0, 0, .55); background: rgba(255, 120, 30, .16); pointer-events: none; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin: 12px 0 0; }
.meta:empty { display: none; }
.meta div { background: var(--alt); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.meta dt { font: 11.5px var(--mono); color: var(--muted); }
.meta dd { margin: 0; font: 600 14.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── dialog ── */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 10, 12, .5); backdrop-filter: blur(2px); }
#settings-form { padding: 22px 24px 20px; display: grid; gap: 4px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { font-size: 20px; }
#settings-form .field-label { margin-top: 12px; }
#settings-form p.muted { font-size: 13.5px; margin: 4px 0 0; }
#settings-form input, #settings-form select { font: 14px var(--mono); }
.suggest { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.chip { font: 12.5px var(--mono); color: var(--accent); background: var(--accent-soft); border: 1px solid transparent; border-radius: 999px; padding: 2px 10px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.chip:hover { border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.more { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.more summary { cursor: pointer; font-size: 14px; font-weight: 600; }
#settings-form .check { margin-top: 16px; }
.test-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; min-height: 34px; }
.dlg-foot { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── responsive ── */
@media (max-width: 900px) {
  .play { grid-template-columns: minmax(0, 1fr); }
  #btn-expand { display: none; } /* one column already */
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  main.wrap { padding-top: 24px; }
  .icon-btn-label { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .play-main { padding: 16px; }
  .play-out { padding: 10px; }
  .ed-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .ed-label { padding-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  /* the spinner and the bar stay: they are the sign that work is going on. The chase slows itself down in chase.js */
  * { transition-duration: .01ms !important; }
  .mon-hand, .mon-stars { animation: none; }
}
