:root {
  --bg: #f7efe9; --card: #fffaf6; --ink: #2a1f1c; --muted: #8a7570;
  --accent: #b5636b; --accent-ink: #fff; --line: #ecdcd3; --shadow: 0 6px 24px rgba(90, 50, 40, .10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1514; --card: #251d1b; --ink: #f3e7e2; --muted: #b19d97; --line: #3a2e2b;
    --accent: #d27d86; --shadow: 0 6px 24px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, select, input { font: inherit; color: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; max-width: 980px; margin: 0 auto; }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand-name { font-weight: 650; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 12px; }

main { max-width: 980px; margin: 0 auto; padding: 0 16px 40px; display: grid; gap: 18px; }
@media (min-width: 860px) {
  main { grid-template-columns: 1.3fr 1fr; align-items: start; }
  .stage-wrap { grid-row: span 2; position: sticky; top: 12px; }
}

.stage { position: relative; border-radius: 22px; overflow: hidden; background: #000; box-shadow: var(--shadow); aspect-ratio: 4 / 3; }
.stage canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage video { display: none; }
.status { position: absolute; inset: auto 12px 12px 12px; background: rgba(0, 0, 0, .6); color: #fff; padding: 8px 12px; border-radius: 12px; font-size: 13px; }
.compare { position: absolute; top: 10px; right: 10px; border: 0; border-radius: 999px; padding: 6px 12px;
  background: rgba(255, 255, 255, .85); color: #2a1f1c; font-size: 13px; user-select: none; -webkit-user-select: none; touch-action: none; }

.source { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pill { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.pill.active { border-color: var(--accent); color: var(--accent); }
.pill.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ghost { border: 1px solid var(--line); background: transparent; padding: 7px 12px; border-radius: 999px; cursor: pointer; }
.danger { color: #c0392b; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; font-size: 13px; }

h2 { font-size: 16px; margin: 0 0 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.card { border: 1.5px solid var(--line); background: var(--card); border-radius: 16px; padding: 8px; cursor: pointer; text-align: left; position: relative; }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.card canvas { width: 100%; aspect-ratio: 2 / 1; border-radius: 10px; display: block; }
.card .n { font-weight: 600; margin-top: 6px; font-size: 14px; }
.card .m { color: var(--muted); font-size: 12px; }
.card .own { position: absolute; top: 6px; left: 6px; font-size: 10px; background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 6px; }
.card.add { display: grid; place-items: center; color: var(--muted); border-style: dashed; min-height: 110px; }

.info { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.info h3 { margin: 0 0 4px; }
.info .d { color: var(--muted); margin-bottom: 10px; }
.spec { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin-bottom: 12px; }
.spec dt { color: var(--muted); }
.spec dd { margin: 0; }
.mapbar { display: flex; align-items: flex-end; gap: 3px; height: 46px; margin: 4px 0 12px; }
.mapbar span { flex: 1; background: var(--accent); opacity: .75; border-radius: 4px 4px 0 0; position: relative; }
.mapbar span i { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font-size: 10px; font-style: normal; color: var(--muted); }
.info .actions { display: flex; gap: 8px; flex-wrap: wrap; }

dialog { border: 0; border-radius: 20px; padding: 0; background: var(--card); color: var(--ink); width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(30, 15, 10, .45); }
.ed { padding: 18px; display: grid; gap: 10px; }
.ed h3 { margin: 0; }
.ed label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.ed input:not([type=range]), .ed select { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 10px; color: var(--ink); }
.ed input[type=range] { accent-color: var(--accent); }
.ed b { color: var(--ink); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.ed-io { display: flex; gap: 16px; justify-content: center; }
