:root {
  --bg: #f3efe8; --panel: #fbf9f6; --ink: #1d1b19; --muted: #7a736b; --line: #e4ded5; --soft: #efe9e0;
  --brass: #a6844c; --brass-d: #8a6c3b; --serif: 'Prata', Georgia, serif; --sans: 'Jost', system-ui, sans-serif;
  --top: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 400 15px/1.5 var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }

/* top bar */
.topbar { height: var(--top); display: flex; align-items: center; gap: 18px; padding: 0 28px; background: #1d1b19; color: #f3efe8; }
.brand { display: flex; align-items: baseline; gap: 10px; color: inherit; text-decoration: none; }
.brand-name { font: 400 20px var(--serif); letter-spacing: .32em; }
.brand-sub { font-size: 11px; letter-spacing: .28em; text-transform: uppercase; opacity: .7; }
.topline { margin-left: auto; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; opacity: .75; }
.pill { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; border: 1px solid #ffffff40; border-radius: 99px; padding: 3px 11px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; height: calc(100svh - var(--top)); }
html.embed .topbar { display: none; }
html.embed .layout { height: 100svh; }
html.embed .colophon { display: none; }

/* stage */
.stage { position: relative; background: radial-gradient(120% 90% at 50% 20%, #fbf8f3 0, #ece6dc 70%, #e2dacd 100%); overflow: hidden; }
#mv { width: 100%; height: 100%; --poster-color: transparent; outline: none; }
#mv [slot="progress-bar"] { display: none; }
.powered { position: absolute; z-index: 5; top: 18px; left: 18px; display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px 9px 13px; border-radius: 99px;
  background: #1d1b19e6; color: #f3efe8; text-decoration: none; font-size: 13px; letter-spacing: .02em; backdrop-filter: blur(8px); box-shadow: 0 8px 24px #0000002e; transition: transform .2s, background .2s; }
.powered:hover { transform: translateY(-1px); background: #1d1b19; }
.powered strong { font-weight: 600; }
.powered-dot { width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(135deg, #e7c98d, var(--brass)); box-shadow: 0 0 0 3px #a6844c40; }
.powered svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; opacity: .75; }

.loader { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: #f3efe8; transition: opacity .6s; z-index: 4; color: var(--muted); }
.loader.done { opacity: 0; pointer-events: none; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brass); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stage-tools { position: absolute; z-index: 5; right: 18px; bottom: 18px; display: flex; gap: 8px; }
.tool { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 99px; padding: 11px 18px; background: #fffffff0; box-shadow: 0 6px 20px #0000001f; font-size: 14px; font-weight: 500; }
.tool.icon { padding: 11px; }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.tool:hover { background: #fff; }
.stage-hint { position: absolute; left: 20px; bottom: 16px; margin: 0; font-size: 12px; color: #6e675f; letter-spacing: .02em; pointer-events: none; }

.sel-tag { border: 0; background: none; padding: 0; transform: translateY(-50%); pointer-events: none; }
.sel-tag span { display: block; white-space: nowrap; background: var(--ink); color: #f6f2eb; font-size: 12px; letter-spacing: .04em; padding: 6px 12px; border-radius: 99px; box-shadow: 0 6px 16px #0003; position: relative; }
.sel-tag span::after { content: ''; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 8px; background: var(--ink); transform: translateX(-50%) rotate(45deg); }

/* panel */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
.panel-scroll { flex: 1; overflow-y: auto; padding: 30px 30px 20px; }
.eyebrow { margin: 0 0 6px; font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--brass-d); }
h1 { font: 400 30px/1.15 var(--serif); margin: 0 0 10px; }
.lead { margin: 0 0 22px; color: var(--muted); }
.block { padding: 20px 0; border-top: 1px solid var(--line); }
.block > header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 12px; }
.block h2 { margin: 0; font: 500 13px var(--sans); letter-spacing: .16em; text-transform: uppercase; }
.block > header span { font-size: 13px; color: var(--muted); text-align: right; }

/* run strip */
.run { display: flex; gap: 3px; height: 74px; }
.mod { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px; padding: 6px 2px 5px; border: 1px solid var(--line); background: #fff; border-radius: 6px; transition: border-color .15s, box-shadow .15s, background .15s; overflow: hidden; }
.mod b { font-weight: 500; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mod small { font-size: 11px; color: var(--muted); }
.mod:hover { border-color: #cfc6b8; }
.mod[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: #fdfbf7; }
.mod-tall { background: #f6f2ec; }
.mod i, .mini { display: flex; flex-direction: column; gap: 2px; width: 22px; height: 26px; margin-bottom: auto; margin-top: 2px; }
.mod i span, .mini span { flex: 1; border: 1.3px solid #9a9187; border-radius: 2px; }
.mod i .tl, .mini .tl { flex: 1; }
.mod i .sk, .mini .sk { border-top-width: 4px; }
.mod i .rg, .mini .rg { border-color: #6d6760; background: repeating-linear-gradient(90deg, transparent 0 4px, #6d676033 4px 5px); }
.mod i .ov, .mini .ov { background: linear-gradient(#0000 30%, #6d676055 30% 70%, #0000 70%); }
.mod i .fr, .mini .fr { background: linear-gradient(#0000 72%, #9a918755 72% 76%, #0000 76%); }
.meter { height: 3px; background: var(--soft); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.meter div { height: 100%; background: var(--brass); transition: width .3s; }
.meter-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

.editor { margin-top: 16px; padding: 16px; background: #f6f2ec; border-radius: 10px; }
.ed-kind { margin: 0; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--brass-d); }
.editor h3 { margin: 2px 0 2px; font: 400 20px var(--serif); }
.editor .muted { margin: 0; font-size: 14px; }
.label { margin: 14px 0 7px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button, .seg button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; font-size: 14px; }
.chips button[aria-pressed="true"], .seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.ed-actions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.ghost { border: 1px solid #d6cec2; background: transparent; border-radius: 99px; padding: 7px 14px; font-size: 13.5px; }
.ghost:hover:not(:disabled) { border-color: var(--ink); }
.ghost:disabled { opacity: .4; cursor: default; }
.ghost.danger { margin-left: auto; color: #8b3b2f; border-color: #e3c9c2; }

.add { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.add button { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 9px 10px; text-align: left; }
.add button:hover { border-color: var(--ink); }
.add .mini { width: 16px; height: 22px; margin: 0; flex: none; }
.add b { display: block; font-weight: 500; font-size: 14px; }
.add small { display: block; font-size: 12px; color: var(--muted); }

.seg { display: flex; gap: 6px; margin-bottom: 14px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 7px 0; cursor: pointer; font-size: 14.5px; }
.toggle input { position: absolute; opacity: 0; }
.toggle .track { width: 38px; height: 22px; border-radius: 99px; background: #d9d2c7; position: relative; transition: background .2s; flex: none; }
.toggle .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0003; transition: transform .2s; }
.toggle input:checked + .track { background: var(--ink); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:disabled ~ * { opacity: .45; }
.toggle input:focus-visible + .track { outline: 2px solid var(--brass); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 0; background-size: cover; box-shadow: inset 0 0 0 1px #0000001a; position: relative; transition: transform .15s; }
.sw:hover { transform: scale(1.06); }
.sw[aria-checked="true"]::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 1.5px solid var(--ink); }
.sw-none { background: #fff; }
.sw-none::before { content: ''; position: absolute; left: 50%; top: 8px; bottom: 8px; width: 1.5px; background: #b9b0a4; transform: rotate(45deg); }

.table-wrap { overflow-x: auto; }
.bom { width: 100%; border-collapse: collapse; font-size: 13px; }
.bom th { text-align: left; font-weight: 500; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 0 8px 8px 0; border-bottom: 1px solid var(--line); }
.bom td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--soft); vertical-align: top; }
.bom td:first-child { color: var(--brass-d); font-weight: 500; }
.colophon { font-size: 12px; color: var(--muted); margin: 18px 0 0; }
.colophon a { color: inherit; }

.summary { padding: 16px 30px 18px; border-top: 1px solid var(--line); background: #fff; display: grid; gap: 12px; }
.sum-line { margin: 0; font-weight: 500; }
.sum-meta { margin: 0; font-size: 13px; color: var(--muted); }
.sum-actions { display: flex; gap: 8px; }
.sum-actions .primary { margin-left: auto; }
.primary { border: 0; background: var(--ink); color: #fff; border-radius: 99px; padding: 11px 22px; font-size: 14.5px; font-weight: 500; letter-spacing: .02em; transition: background .2s; }
.primary:hover { background: #3a352f; }

/* dialogs */
.modal { border: 0; border-radius: 16px; padding: 30px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 30px 80px #0000004d; color: var(--ink); }
.modal::backdrop { background: #1d1b1966; backdrop-filter: blur(3px); }
.modal h2 { font: 400 24px/1.2 var(--serif); margin: 0 0 10px; }
.modal .close { position: absolute; top: 12px; right: 12px; margin: 0; }
.modal .close button { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); }
.modal .primary { margin-top: 16px; }
.field { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: 13px var(--sans); background: #faf8f5; color: var(--ink); resize: none; }
.field.code { font: 12px/1.5 ui-monospace, Consolas, monospace; }
.qr { width: 200px; margin: 16px auto 0; }
.qr svg { width: 100%; height: auto; display: block; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 99px; font-size: 14px; transition: all .3s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  :root { --top: 52px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .brand-sub, .topline { display: none; }
  .pill { margin-left: auto; }
  .layout { display: flex; flex-direction: column; height: auto; }
  .stage { position: sticky; top: 0; z-index: 3; height: 46svh; flex: none; }
  .panel { border-left: 0; }
  .panel-scroll { overflow: visible; padding: 22px 18px 12px; }
  h1 { font-size: 25px; }
  .summary { position: sticky; bottom: 0; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); z-index: 4; }
  .sum-meta { display: none; }
  .powered { top: 10px; left: 10px; padding: 7px 12px 7px 10px; font-size: 12px; }
  .stage-hint { display: none; }
  .stage-tools { right: 10px; bottom: 10px; }
  .tool { padding: 9px 14px; font-size: 13px; }
  .run { height: 66px; }
  .mod b { font-size: 10px; }
  .mod small { font-size: 10px; }
  .toast { bottom: 96px; }
  html.embed .layout { height: auto; }
}
