:root {
  --violet: #9b3df5; --magenta: #c84fb4; --coral: #ea6a5a; --gold: #ffd75e;
  --grad: linear-gradient(100deg, #9b3df5 0%, #c84fb4 52%, #ea6a5a 100%);
  --bg: #0b0618; --bg2: #110a23; --panel: #170e2e; --panel2: #1f1439; --line: rgba(232,222,255,.12); --line2: rgba(232,222,255,.22);
  --text: #f7f3fc; --body: #d2cadf; --muted: #a79fb8;
  --fd: "Lexend", "Segoe UI", system-ui, sans-serif; --fs: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; --fa: "Patrick Hand", cursive;
  --r: 14px; --top: 62px; --side: 228px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.5 var(--fs); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
svg { stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid #d8b4ff; outline-offset: 2px; }
#app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); grid-template-rows: var(--top) minmax(0, 1fr); height: 100vh; height: 100dvh;
  background: radial-gradient(1200px 600px at 85% -10%, rgba(155,61,245,.16), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(234,106,90,.10), transparent 60%), var(--bg); }

/* ---------- top bar ---------- */
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px; border-bottom: 1px solid var(--line); background: rgba(11,6,24,.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); min-width: 0; }
.brand { display: flex; flex: none; }
.brand img { height: 30px; width: auto; display: block; }
.product { display: flex; flex-direction: column; line-height: 1.05; padding-left: 14px; border-left: 1px solid var(--line2); flex: none; }
.product-name { font: 800 19px var(--fd); letter-spacing: -.02em; }
.product-name b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; }
.product-sub { font: 500 11px var(--fd); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.proj { display: flex; align-items: center; gap: 6px; margin-left: 10px; min-width: 0; flex: 1 1 auto; max-width: 340px; }
.proj select { min-width: 0; flex: 1; height: 38px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cdbdf0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 16px; appearance: none; -webkit-appearance: none; font-weight: 700; text-overflow: ellipsis; }
.tb-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.save-state { font-size: 12px; color: var(--muted); min-width: 48px; text-align: center; }
.save-state.warn { color: var(--coral); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); font: 600 13.5px var(--fd); white-space: nowrap; transition: background .15s, border-color .15s, transform .15s; text-decoration: none; }
.btn:hover:not(:disabled) { background: #2a1c4b; border-color: rgba(232,222,255,.35); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; flex: none; }
/* gradient buttons: no border at all, background painted to the border box, so no edge slivers */
.btn-grad { border: 0; background: var(--grad) border-box; background-clip: border-box; color: #fff; padding: 0 16px; box-shadow: 0 6px 18px rgba(200,79,180,.28); }
.btn-grad:hover:not(:disabled) { background: var(--grad) border-box; filter: brightness(1.08); border: 0; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 12.5px; }
.btn.danger { color: #ffb4a9; border-color: rgba(234,106,90,.45); }
.btn.done { border-color: rgba(60,207,145,.5); color: #9ff0c8; }
.btn kbd { font: 600 10px var(--fs); padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.08); color: var(--muted); }
.ibtn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); padding: 0; }
.ibtn:hover:not(:disabled) { background: #2a1c4b; }
.ibtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.ibtn svg circle[r="1.8"] { fill: currentColor; stroke: none; }
.ibtn.sm { width: 30px; height: 30px; border-radius: 8px; }
.ibtn.sm svg { width: 14px; height: 14px; }

/* ---------- side nav ---------- */
.sidenav { border-right: 1px solid var(--line); padding: 14px 10px; overflow-y: auto; display: flex; flex-direction: column; background: rgba(13,8,28,.6); }
.ngrp { margin-bottom: 12px; }
.nlbl { font: 700 10.5px var(--fd); letter-spacing: .12em; text-transform: uppercase; color: #7f7697; padding: 4px 10px 6px; }
.nitem { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none; color: var(--body); font: 500 14px var(--fd); text-align: left; position: relative; }
.nitem svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; }
.nitem:hover { background: rgba(255,255,255,.05); color: #fff; }
.nitem.on { background: linear-gradient(100deg, rgba(155,61,245,.28), rgba(200,79,180,.14)); color: #fff; }
.nitem.on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--grad); }
.nfoot { margin-top: auto; padding-top: 10px; }
.free { font-size: 11.5px; color: var(--muted); margin: 10px 6px 0; }

/* ---------- CTA ---------- */
.cta { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 16px; text-decoration: none; color: var(--text); background: linear-gradient(120deg, rgba(58,26,96,.95), rgba(70,26,52,.95)); border: 1px solid rgba(200,79,180,.45); margin-top: 18px; transition: transform .18s, border-color .2s; }
.cta:hover { transform: translateY(-2px); border-color: rgba(234,106,90,.8); }
.cta-k { font: 400 18px var(--fa); color: #ffd6f1; }
.cta-v { font: 700 14.5px var(--fd); }
.cta--side { margin-top: 0; padding: 12px; } .cta--side .cta-k { font-size: 16px; } .cta--side .cta-v { font-size: 12.5px; }

/* ---------- main ---------- */
.main { overflow-y: auto; overflow-x: hidden; padding: 22px 26px 40px; min-width: 0; outline: none; }
.main.v-canvas, .main.v-flow, .main.v-map { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 16px; }
.vhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.vtitle { min-width: 0; flex: 1 1 340px; }
.vtitle h1 { margin: 0; font: 800 26px var(--fd); letter-spacing: -.02em; }
.vtitle p { margin: 4px 0 0; color: var(--muted); max-width: 760px; }
.vact { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: linear-gradient(180deg, rgba(31,20,57,.9), rgba(23,14,46,.9)); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; min-width: 0; }
.card h2 { margin: 0 0 10px; font: 700 16px var(--fd); }
h2.big { font: 800 22px var(--fd); margin: 0; letter-spacing: -.01em; }
.mt { margin-top: 18px !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 16px; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.fgrid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.fld > span, .lbl { font: 600 12px var(--fd); color: var(--muted); letter-spacing: .02em; }
.fld em { font-style: normal; color: #cdbdf0; font-weight: 500; margin-left: 6px; }
.fld input, .fld textarea, .fld select, .inp, .rel select, .rel input { width: 100%; min-width: 0; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(9,5,20,.6); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.fld textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
.fld input:focus, .fld textarea:focus, .fld select:focus, .inp:focus, .rel select:focus, .rel input:focus { outline: none; border-color: #b67bff; box-shadow: 0 0 0 3px rgba(155,61,245,.22); }
.fld select, .rel select { appearance: none; -webkit-appearance: none; padding-right: 30px; background: rgba(9,5,20,.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cdbdf0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 15px; }
select option { background: #1b1133; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(31,20,57,.7); text-align: left; min-width: 0; }
.stat:hover { border-color: var(--line2); }
.stat b { font: 800 22px var(--fd); }
.stat span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gen-out { padding: 14px; border-radius: 12px; background: rgba(9,5,20,.5); border: 1px dashed var(--line2); margin-bottom: 12px; min-height: 120px; }
.gen-ll { font: 400 20px/1.3 var(--fa); color: #fff; margin: 0 0 8px; }
.gen-out .muted { margin: 0; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); font: 500 13px var(--fd); color: var(--body); }
.chip:hover { border-color: rgba(232,222,255,.4); color: #fff; }
.chip.on { background: rgba(155,61,245,.28); border-color: #b67bff; color: #fff; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.hint { margin: -2px 0 12px; font-size: 13px; color: #d9c7f5; background: rgba(155,61,245,.1); border-radius: 10px; padding: 8px 12px; }
.ing { display: flex; flex-direction: column; gap: 8px; }
.ing-i { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 2px 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: rgba(9,5,20,.4); border: 1px solid var(--line); }
.ing-i .muted { grid-column: 2; font-size: 12.5px; }
.ing-i .ibtn { grid-row: 1 / 3; grid-column: 3; }
.tag { font: 700 10.5px var(--fd); letter-spacing: .06em; text-transform: uppercase; color: #e5c7ff; background: rgba(155,61,245,.2); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.empty { color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--line2); border-radius: 10px; font-size: 13.5px; }

/* ---------- split list/detail ---------- */
.split { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; align-items: start; }
.list { padding: 8px; max-height: calc(100vh - 190px); overflow-y: auto; position: sticky; top: 0; }
.lgrp { font: 700 10.5px var(--fd); letter-spacing: .12em; text-transform: uppercase; color: #7f7697; padding: 10px 10px 4px; }
.litem { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 10px; background: none; }
.litem b { font: 600 13.5px var(--fd); grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.litem span:not(.av) { font-size: 11.5px; color: var(--muted); grid-column: 1 / -1; }
.litem:has(.av) b, .litem:has(.av) span:not(.av) { grid-column: 2; }
.litem .av { grid-row: 1 / 3; }
.litem:hover { background: rgba(255,255,255,.05); }
.litem.on { background: rgba(155,61,245,.22); }
.av { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font: 800 14px var(--fd); color: #fff; flex: none; }
.dhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.dhead .row-btns { margin: 0; }
.detail p { color: var(--body); }
.strip { position: relative; height: 26px; border-radius: 8px; background: rgba(255,255,255,.05); overflow: hidden; margin-top: 14px; }
.strip i { position: absolute; top: 0; bottom: 0; border-right: 2px solid #170e2e; opacity: .9; }
.strip-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 4px 0 14px; }
.beatlist { list-style: none; margin: 0; padding: 0; }
.beatlist li { display: grid; grid-template-columns: 72px 12px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
.beatlist b { font: 700 14.5px var(--fd); }
.beatlist p { margin: 2px 0 0; font-size: 13.5px; }
.bpos { font: 800 15px var(--fd); color: #e7d6ff; display: flex; flex-direction: column; }
.bpos em { font: 500 11.5px var(--fs); font-style: normal; color: var(--muted); }
.bdot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; display: inline-block; flex: none; }

/* ---------- situations ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.tab { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line2); background: transparent; font: 600 13px var(--fd); color: var(--body); }
.tab.on { background: var(--grad) border-box; border-color: transparent; color: #fff; }
.inp.search { max-width: 380px; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.scard { display: flex; flex-direction: column; padding: 14px; border-radius: 12px; background: rgba(31,20,57,.75); border: 1px solid var(--line); min-width: 0; }
.scard.flash { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,215,94,.25); }
.scard-h { display: flex; align-items: center; gap: 10px; }
.scard h3 { margin: 0; font: 700 15px var(--fd); }
.scard p { margin: 8px 0 12px; font-size: 13.5px; color: var(--body); flex: 1; }
.scard .btn { align-self: flex-start; }
.num { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; border-radius: 8px; background: rgba(155,61,245,.25); font: 800 13px var(--fd); color: #e5c7ff; flex: none; }

/* ---------- characters ---------- */
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sw { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; padding: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.sw.on { border-color: #fff; }
.relgrid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.rels { display: flex; flex-direction: column; gap: 8px; }
.rel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr) minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: 6px; align-items: center; }
.rel select, .rel input { padding: 7px 9px; font-size: 13px; }
.rel select { padding-right: 26px; }
.webwrap { background: rgba(9,5,20,.45); border-radius: 12px; border: 1px solid var(--line); }
.web { width: 100%; height: auto; display: block; }

/* ---------- world / start-end ---------- */
.wlist { display: flex; flex-direction: column; gap: 12px; }
.wcard { position: relative; padding: 14px 14px 2px; border-radius: 12px; background: rgba(9,5,20,.4); border: 1px solid var(--line); }
.wcard .fld:first-child { padding-right: 38px; }
.wdel { position: absolute; top: 12px; right: 12px; }
.se-open { border-top: 3px solid #3ccf91; } .se-end { border-top: 3px solid var(--coral); }
.mirror-row { display: grid; grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr); gap: 10px; align-items: stretch; margin-bottom: 14px; }
.mbox { padding: 14px; border-radius: 12px; background: rgba(9,5,20,.5); border: 1px solid var(--line); }
.mbox span { font: 700 11px var(--fd); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.mbox p { margin: 6px 0 0; font: 400 18px/1.35 var(--fa); }
.marrow { display: flex; align-items: center; justify-content: center; }
.marrow svg { width: 48px; fill: none; stroke: #c84fb4; stroke-width: 2; }

/* ---------- beat board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.bcol { background: rgba(23,14,46,.8); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 200px; transition: border-color .15s, background .15s; }
.bcol.over { border-color: #b67bff; background: rgba(155,61,245,.12); }
.bcol-h { display: flex; align-items: center; gap: 8px; font: 800 14px var(--fd); padding: 4px 4px 10px; }
.bcol-h .bdot { margin: 0; }
.bcol-h em { margin-left: auto; font: 600 12px var(--fs); font-style: normal; color: var(--muted); }
.bcol-b { display: flex; flex-direction: column; gap: 8px; }
.icard { padding: 11px 12px 11px 15px; border-radius: 10px; background: #fbf6ee; color: #2a2135; cursor: grab; position: relative; box-shadow: 0 3px 10px rgba(0,0,0,.25); border-left: 5px solid var(--c); transition: transform .12s, box-shadow .12s; }
.icard:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.icard.drag { opacity: .45; }
.icard-t { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.icard-t b { font: 700 14px var(--fd); }
.icard-t span { font: 600 11px var(--fs); color: #7d6f8f; white-space: nowrap; }
.icard p { margin: 5px 0 0; font: 400 16px/1.25 var(--fa); color: #3a3046; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.addcard { border: 1px dashed var(--line2); background: none; border-radius: 10px; padding: 9px; color: var(--muted); font: 600 13px var(--fd); }
.addcard:hover { color: #fff; border-color: rgba(232,222,255,.4); }

/* ---------- toolbar / stage ---------- */
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px; border-radius: 12px; background: rgba(23,14,46,.85); border: 1px solid var(--line); margin-bottom: 10px; }
.toolbar.flat { padding: 0; background: none; border: 0; margin: 0; }
.tsep { width: 1px; height: 24px; background: var(--line2); margin: 0 4px; }
.grow { flex: 1; }
.zlbl { font: 600 12px var(--fd); color: var(--muted); min-width: 44px; text-align: center; }
.chk { display: inline-flex; align-items: center; gap: 6px; font: 500 13px var(--fd); color: var(--body); cursor: pointer; padding: 0 6px; }
.chk input { accent-color: #9b3df5; width: 16px; height: 16px; }
.seg { display: inline-flex; border-radius: 10px; border: 1px solid var(--line2); overflow: hidden; }
.seg button { border: 0; background: none; padding: 7px 12px; font: 600 12.5px var(--fd); color: var(--body); }
.seg button.on { background: rgba(155,61,245,.35); color: #fff; }
.stage { position: relative; flex: 1; min-height: 420px; border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; background: #0e0820; background-image: radial-gradient(rgba(232,222,255,.09) 1px, transparent 1px); background-size: 24px 24px; }
.gsvg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.gsvg.panning { cursor: grabbing; }
.gn, .mn { cursor: move; } .mn { cursor: pointer; }
.gl { cursor: pointer; }
.handle { fill: #ffd75e; stroke: #0e0820; stroke-width: 2; cursor: crosshair; opacity: 0; transition: opacity .15s; }
.gn:hover .handle, .gsvg .gn:focus .handle { opacity: 1; }
@media (hover: none) { .handle { opacity: .9; } }
.rsz { stroke: rgba(255,255,255,.45); stroke-width: 1.5; fill: none; cursor: nwse-resize; pointer-events: stroke; stroke-linecap: round; }
.stage-hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); background: rgba(11,6,24,.75); padding: 5px 10px; border-radius: 8px; pointer-events: none; max-width: calc(100% - 24px); }
.gwrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); background: #120a26; }
.gantt { display: block; user-select: none; -webkit-user-select: none; touch-action: none; }
.gbar, .gms { cursor: grab; } .glabel { cursor: pointer; } .glabel:hover rect { fill: #2a1c4b; }
.grow-bg { cursor: copy; }
.gstat { font: 600 12.5px var(--fd); color: var(--gold); }
.chartwrap { overflow-x: auto; border-radius: 12px; }
.chart { display: block; user-select: none; -webkit-user-select: none; touch-action: none; }
.apt { cursor: ns-resize; }
.arctable { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.arow { display: grid; grid-template-columns: 32px 120px auto minmax(0, 1fr) 20px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(9,5,20,.4); font-size: 13.5px; }
.arow .tag { justify-self: start; }

/* ---------- outline ---------- */
.outline { max-width: 900px; }
.outline h3 { font: 700 17px var(--fd); margin: 22px 0 8px; color: #e9d7ff; }
.outline h4 { font: 700 15px var(--fd); margin: 14px 0 4px; }
.outline p { margin: 3px 0; color: var(--body); }
.oli { padding: 5px 0 5px 14px; border-left: 2px solid rgba(155,61,245,.5); margin: 4px 0; color: var(--body); }
.oli2 { padding: 2px 0 2px 30px; color: var(--muted); font-size: 13.5px; }

/* ---------- menu / modal / toast ---------- */
.menu-pop { position: fixed; z-index: 60; min-width: 220px; padding: 6px; border-radius: 12px; background: #1d1236; border: 1px solid var(--line2); box-shadow: 0 18px 50px rgba(0,0,0,.5); }
.menu-pop button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px; font: 500 13.5px var(--fd); }
.menu-pop button:hover { background: rgba(155,61,245,.22); }
.menu-pop button.danger { color: #ffb4a9; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.modal-wrap { position: fixed; inset: 0; z-index: 70; background: rgba(5,2,12,.66); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-wrap[hidden], .menu-pop[hidden] { display: none; }
.modal { position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; border-radius: 18px; background: linear-gradient(180deg, #221641, #180f30); border: 1px solid var(--line2); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal h2 { margin: 0 40px 16px 0; font: 700 18px var(--fd); }
.modal-x { position: absolute; top: 14px; right: 14px; }
.mrow { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.mrow .danger { margin-right: auto; }
.inp { margin-bottom: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 12px; background: #2a1c4b; border: 1px solid var(--line2); font: 600 13.5px var(--fd); transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
#printArea { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .fgrid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  :root { --top: 56px; }
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--top) auto minmax(0, 1fr); }
  .sidenav { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); gap: 2px; scrollbar-width: none; }
  .sidenav::-webkit-scrollbar { display: none; }
  .ngrp { display: flex; margin: 0; gap: 2px; } .nlbl, .nfoot { display: none; }
  .nitem { flex: none; width: auto; padding: 8px 11px; font-size: 13px; white-space: nowrap; }
  .nitem.on::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 3px; }
  .main { padding: 16px 14px 32px; }
  .grid2, .split, .relgrid { grid-template-columns: minmax(0, 1fr); }
  .list { position: static; max-height: 260px; }
  .product-sub { display: none; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand img { height: 22px; }
  .product { padding-left: 8px; } .product-name { font-size: 16px; }
  .proj { margin-left: 0; max-width: none; }
  .proj select { height: 34px; font-size: 13px; padding-left: 9px; }
  #btnProjMenu, #btnUndo, #btnRedo { width: 34px; height: 34px; }
  .save-state { display: none; }
  .tb-actions { gap: 5px; }
  #btnRedo { display: none; }
  #btnExport { min-height: 34px; padding: 0 10px; font-size: 12.5px; }
  .vtitle h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } .stat { padding: 10px; } .stat b { font-size: 18px; }
  .fgrid, .fgrid3 { grid-template-columns: minmax(0, 1fr); }
  .rel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .rel input { grid-column: 1 / 2; } 
  .mirror-row { grid-template-columns: minmax(0, 1fr); } .marrow svg { transform: rotate(90deg); width: 30px; }
  .board { grid-auto-columns: minmax(230px, 84%); }
  .arow { grid-template-columns: 32px minmax(0, 1fr) auto; } .arow > span:nth-child(n+4) { grid-column: 2 / -1; } .arow .arrow { display: none; }
  .stage { min-height: 380px; }
  .stage-hint { display: none; }
  .beatlist li { grid-template-columns: 58px 12px minmax(0, 1fr); gap: 8px; }
  .card { padding: 14px; }
}
@media (max-width: 600px) {
  .product { display: none; }
  .proj select { min-width: 90px; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar > * { flex: none; }
  .toolbar .grow { display: none; }
  .toolbar.flat { flex-wrap: wrap; }
}


/* ---------- v2: dashboard ---------- */
.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 0; }
.examples span { font: 700 10.5px var(--fd); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-right: 2px; }
.examples i { font-style: normal; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: rgba(234,106,90,.14); color: #ffd3cc; }
.mb { margin-bottom: 12px; }
.hero-card { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: center; background: radial-gradient(600px 260px at 0% 0%, rgba(155,61,245,.28), transparent 70%), linear-gradient(180deg, rgba(31,20,57,.95), rgba(23,14,46,.95)); padding: 22px; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.card .hero-title { margin: 10px 0 6px; font: 800 32px/1.1 var(--fd); letter-spacing: -.02em; overflow-wrap: anywhere; }
.hero-ll { margin: 0 0 14px; font: 400 19px/1.35 var(--fa); color: #f1e6ff; }
.hero-strip { min-width: 0; }
.hero-strip .strip { margin-top: 0; height: 30px; }
.spark { width: 100%; height: 60px; display: block; margin-top: 6px; background: rgba(9,5,20,.35); border-radius: 8px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.dash-grid > .card { margin-bottom: 16px; }
.health { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 18px; align-items: start; }
.ringwrap { display: flex; flex-direction: column; align-items: center; gap: 4px; font: 700 13px var(--fd); color: var(--body); }
.ring { width: 120px; height: 120px; }
.hlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hlist li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 8px 7px 10px; border-radius: 10px; background: rgba(9,5,20,.4); font-size: 13.5px; }
.hlist li i { width: 10px; height: 10px; border-radius: 50%; }
.h-high i { background: #ea6a5a; } .h-mid i { background: #f2b84b; } .h-low i { background: #6f7bf7; } .h-ok i { background: #3ccf91; }
.hlist li.muted { display: block; background: none; padding: 2px 10px; }
.prog { display: flex; flex-direction: column; gap: 8px; }
.prow { display: grid; grid-template-columns: 130px minmax(0, 1fr) 44px; gap: 10px; align-items: center; border: 0; background: none; padding: 4px 0; text-align: left; font: 600 13px var(--fd); color: var(--body); }
.prow b, .qbar { display: block; height: 8px; border-radius: 8px; background: rgba(255,255,255,.08); overflow: hidden; }
.prow b i, .qbar i { display: block; height: 100%; background: var(--grad); border-radius: 8px; }
.prow em { font-style: normal; color: var(--muted); text-align: right; font-size: 12px; }
.prow:hover { color: #fff; }
.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.castc { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(9,5,20,.4); text-align: left; min-width: 0; }
.castc:hover { border-color: var(--line2); }
.castc b { font: 700 14px var(--fd); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.castc .qbar { width: 100%; height: 5px; margin-top: 4px; }
.av.lg { width: 42px; height: 42px; font-size: 18px; margin-bottom: 4px; }
.spark-card { padding: 14px; border-radius: 12px; background: rgba(9,5,20,.45); border: 1px dashed var(--line2); }
.spark-card h3 { margin: 10px 0 6px; font: 700 17px var(--fd); }
.spark-card p { margin: 0 0 12px; color: var(--body); font-size: 14px; }
.spark-card .row-btns { margin: 0; }
.libcounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.lc { display: flex; flex-direction: column; align-items: flex-start; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(155,61,245,.08); text-align: left; }
.lc:hover { border-color: #b67bff; }
.lc b { font: 800 22px var(--fd); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lc span { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(9,5,20,.35); text-align: left; }
.tile b { font: 700 14px var(--fd); } .tile span { font-size: 12px; color: var(--muted); }
.tile:hover { border-color: var(--line2); background: rgba(155,61,245,.1); }

/* ---------- v2: library ---------- */
.tab em { font-style: normal; font-size: 11px; opacity: .8; margin-left: 3px; }
.libbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.searchwrap { position: relative; max-width: 560px; }
.searchwrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; pointer-events: none; }
.searchwrap .inp.search { max-width: none; width: 100%; margin: 0; padding-left: 38px; height: 42px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.fsel { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fsel span { font: 600 11px var(--fd); color: var(--muted); }
.fsel select { height: 34px; max-width: 190px; padding: 0 28px 0 10px; border-radius: 9px; border: 1px solid var(--line2); appearance: none; -webkit-appearance: none; background: rgba(9,5,20,.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cdbdf0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 7px center / 14px; font-size: 13px; text-overflow: ellipsis; }
.libmeta { font: 600 12.5px var(--fd); color: var(--muted); margin: 4px 0 10px; }
.scard-h { justify-content: space-between; align-items: flex-start; }
.star { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: none; padding: 0; margin: -4px -6px 0 0; }
.star svg { width: 19px; height: 19px; fill: none; stroke: #8f86a6; stroke-width: 1.8; }
.star:hover svg { stroke: #ffd75e; }
.star.on svg { fill: #ffd75e; stroke: #ffd75e; }
.stags { display: flex; flex-wrap: wrap; gap: 5px; margin: -4px 0 12px; }
.stags span { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(255,255,255,.06); color: #cdbfe6; }
.sbtns { display: flex; gap: 6px; flex-wrap: wrap; }
.more { display: flex; justify-content: center; margin: 16px 0 70px; }
.combtray { display: none; }
.combtray.on { display: flex; position: sticky; bottom: 10px; z-index: 5; margin-top: 12px; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; background: rgba(29,18,54,.97); border: 1px solid #b67bff; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.ct-l { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; font: 600 13px var(--fd); }
.ct-l b { margin-right: 4px; }
.ct-l .chip { max-width: 100%; }
.ct-l .chip button { border: 0; background: none; color: #fff; font-size: 16px; line-height: 1; padding: 0 0 0 4px; }
.ct-r { display: flex; gap: 6px; }

/* ---------- v2: scenes ---------- */
.stats.s4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat b.pos { color: #6be3ab; } .stat b.neg { color: #ff9d8f; }
.rhythm { display: flex; flex-wrap: wrap; gap: 4px; }
.rb { width: 30px; height: 30px; border-radius: 7px; border: 0; padding: 0; font: 700 11px var(--fd); color: #fff; }
.rb.pos { background: #2fa877; } .rb.neg { background: #c9584a; } .rb.flat { background: #4b4560; }
.scenes { display: flex; flex-direction: column; gap: 8px; }
.scene { border-radius: 12px; border: 1px solid var(--line); background: rgba(31,20,57,.75); overflow: hidden; }
.scene.open { border-color: #b67bff; }
.scene-h { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 10px 12px; border: 0; background: none; text-align: left; }
.snum { width: 30px; height: 30px; border-radius: 8px; background: rgba(155,61,245,.25); display: inline-flex; align-items: center; justify-content: center; font: 800 13px var(--fd); }
.sh-main { display: flex; flex-direction: column; min-width: 0; }
.sh-main b { font: 700 14.5px var(--fd); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-main span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shift { font: 700 12px var(--fd); padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.shift.pos { background: rgba(60,207,145,.18); color: #8ff0c4; } .shift.neg { background: rgba(234,106,90,.18); color: #ffb4a9; } .shift.flat { background: rgba(255,255,255,.07); color: var(--muted); }
.scene-b { padding: 4px 14px 14px; border-top: 1px solid var(--line); padding-top: 14px; }

/* ---------- v2: theme tracker ---------- */
.threads { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.thread { display: flex; gap: 6px; align-items: center; }
.thread input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line2); background: rgba(9,5,20,.6); }
.tgrid-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
.tgrid { border-collapse: collapse; width: 100%; font-size: 13px; }
.tgrid th, .tgrid td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.tgrid th { font: 700 11px var(--fd); color: var(--muted); }
.tgrid th span { display: block; width: 8px; height: 8px; border-radius: 50%; margin: 0 auto 3px; }
.tg-name { text-align: left !important; min-width: 190px; padding-left: 12px !important; position: sticky; left: 0; background: #1b1133; z-index: 1; }
td.tg-name .tag { display: inline-block; margin-right: 8px; background: rgba(255,255,255,.06); }
.tcell { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); padding: 0; }
.tcell.on { background: var(--c); border-color: var(--c); box-shadow: 0 0 10px color-mix(in srgb, var(--c) 50%, transparent); }
.tg-n { font: 800 13px var(--fd); } .tg-n.warn { color: #ffb4a9; }
.beatkey { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.beatkey b { color: #e7d6ff; }

/* ---------- v2: questionnaire ---------- */
.qprog { display: flex; align-items: center; gap: 10px; }
.qbar.wide { width: 160px; }
.qgroups { display: flex; flex-direction: column; gap: 6px; }
.qg { border-radius: 10px; border: 1px solid var(--line); background: rgba(9,5,20,.35); }
.qg-h { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; text-align: left; font: 600 14px var(--fd); }
.qg-h .muted { margin-left: auto; }
.qg-h svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .15s; }
.qg.open .qg-h svg { transform: rotate(180deg); }
.qg-b { padding: 4px 12px 2px; }

@media (max-width: 900px) { .hero-card, .dash-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  .hero-title { font-size: 25px; } .hero-ll { font-size: 17px; }
  .health { grid-template-columns: minmax(0, 1fr); } .ringwrap { flex-direction: row; gap: 12px; } .ring { width: 84px; height: 84px; }
  .prow { grid-template-columns: 100px minmax(0, 1fr) 38px; }
  .stats.s4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fsel { flex: 1 1 calc(50% - 8px); } .fsel select { max-width: none; width: 100%; }
  .scene-h { grid-template-columns: 30px minmax(0, 1fr); } .scene-h .shift { grid-column: 2; justify-self: start; }
  .ct-r { width: 100%; } .ct-r .btn { flex: 1; }
  .tg-name { min-width: 130px; }
  .qbar.wide { width: 90px; }
}

/* ---------- print ---------- */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  #app, .toast, .modal-wrap, .menu-pop { display: none !important; }
  #printArea { display: block; color: #1b1426; font: 11.5pt/1.5 "DM Sans", Arial, sans-serif; }
  .print-doc h1 { font: 800 24pt Lexend, Arial; margin: 0 0 8pt; }
  .print-doc h2 { font: 700 14pt Lexend, Arial; margin: 16pt 0 6pt; color: #6a1fc2; border-bottom: 1px solid #ddd; padding-bottom: 3pt; }
  .print-doc h3 { font: 700 12pt Lexend, Arial; margin: 10pt 0 3pt; }
  .print-doc p { margin: 2pt 0; } .pi { margin: 3pt 0 3pt 10pt; } .pi2 { margin: 1pt 0 1pt 26pt; color: #555; }
  .print-brand { font: 600 9pt Lexend, Arial; color: #9b3df5; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8pt; }
}
@media (max-width: 600px) { .toolbar:not(.flat) { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); padding-right: 28px; } }
