/* Page layout of the control page:
     header ─────────────────────────────────────────────
     preview (+ mapping editor) │ tabs: Layers · Outputs · …
     live code                  │
   Change the grid here to rearrange; tab order comes from config.panels. */
body.control { height: 100vh; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
header.top {
  display: flex; gap: .6em; align-items: center; padding: .25em .6em;
  border-bottom: 1px solid var(--line); background: var(--panel); min-height: calc(var(--row-h) + 8px);
}
header.top .title { font-weight: 700; letter-spacing: .05em; }

main.split { display: grid; grid-template-columns: minmax(0, var(--left-w, 1.2fr)) 5px minmax(340px, 1fr); min-height: 0; }
/* the divider between preview and panels: a hairline, drag to resize, double-click = back */
.splitter { cursor: col-resize; position: relative; background: transparent; }
.splitter::after { content: ""; position: absolute; top: 0; bottom: 0; left: 2px; width: 1px; background: var(--line); transition: background .15s, width .15s, left .15s; }
.splitter:hover::after, .splitter.drag::after { background: var(--accent); width: 3px; left: 1px; }
.left  { display: flex; flex-direction: column; gap: var(--gap); padding: var(--gap) var(--gap) 0; min-height: 0; overflow: auto; scrollbar-color: transparent transparent; }
.left:hover { scrollbar-color: var(--line) transparent; }        /* the scrollbar only shows when you need it */
.left > :last-child { margin-bottom: var(--gap); }
.right { display: flex; flex-direction: column; min-height: 0; background: transparent; }
.right > .tabs { flex: 1; }

.preview-wrap { background: var(--preview-bg); border-radius: var(--radius); display: flex; flex-direction: column; border: 1px solid var(--line); }
.preview-bar { display: flex; gap: .4em; padding: .3em; align-items: center; flex-wrap: wrap; background: var(--panel); border-bottom: 1px solid var(--line); }
.preview-area { position: relative; display: flex; justify-content: center; align-items: center; padding: .3em; }
.stage { position: relative; width: 100%; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

@media (max-width: 900px) {
  body.control { height: auto; overflow: auto; }
  main.split { grid-template-columns: 1fr; }
  .splitter { display: none; }
  .right { border-left: 0; }
}

/* Phone controller: big touch targets. */
body.phone { padding: var(--gap); display: flex; flex-direction: column; gap: var(--gap); --row-h: 34px; }
body.phone .param { grid-template-columns: 5.5em 1fr; }
body.phone input.val { width: 3.2em; }

/* Launcher: one column of collapsible sections, status chips in each header. */
body.launcher { min-height: 100vh; }
main.lstack { max-width: 1100px; margin: 0 auto; padding: calc(var(--gap) * 2); display: flex; flex-direction: column; gap: var(--gap); }
details.sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
details.sec[open] { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
details.sec > summary {
  display: flex; align-items: center; gap: .7em; padding: .55em .9em; cursor: pointer; list-style: none; user-select: none;
}
details.sec > summary::before { content: "›"; color: var(--text-dim); font-size: 1.2em; transition: transform .15s; width: .6em; }
details.sec[open] > summary::before { transform: rotate(90deg); }
details.sec > summary:hover { background: var(--panel-2); }
.sec-icon { width: 1.6em; height: 1.6em; display: grid; place-items: center; border-radius: var(--radius); background: var(--panel-2); color: var(--accent); font-weight: 700; }
.sec-title { font-weight: 600; font-size: 1.05em; }
.sec-status { margin-left: auto; display: flex; gap: .35em; flex-wrap: wrap; justify-content: flex-end; }
.sec-body { padding: .2em 1em 1em 3.2em; display: flex; flex-direction: column; gap: .6em; }
.chip2 { font-size: .8em; padding: .15em .6em; border-radius: var(--radius); background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--line); white-space: nowrap; }
.chip2.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.chip2.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
a.big { display: flex; flex-direction: column; gap: .15em; padding: .6em .8em; border: 1px solid var(--line); border-radius: var(--radius);
        background: var(--panel-2); color: var(--text); text-decoration: none; }
a.big:hover { border-color: var(--accent); }
a.big b { font-size: 1.05em; }
body.launcher a { color: var(--accent); }
@media (max-width: 700px) { .sec-body { padding-left: 1em; } }

/* ── app bar: brand · section tabs · status/actions ── */
header.appbar { gap: 1em; padding: 0 .8em; min-height: 46px; border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: .6em; padding-right: .6em; border-right: 1px solid var(--line); min-height: 46px; }
.brand .logo { height: 31px; width: auto; aspect-ratio: 56 / 31; flex: none; display: block; object-fit: contain; }
.brand .title { font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; }
.brand .subtitle { font-size: .78rem; color: var(--text-dim); letter-spacing: .04em; text-transform: uppercase; }
nav.sections { display: flex; align-self: stretch; }
nav.sections .sectab {
  height: auto; border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 0 1.1em;
  color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: .82rem;
}
nav.sections .sectab:hover { color: var(--text); background: var(--panel); }
nav.sections .sectab.on { color: var(--text); border-bottom-color: var(--accent); }
.right > .section-box { flex: 1; min-height: 0; }
.right > .section-box[hidden] { display: none; }
.right .tab-body.solo { overflow: auto; }
.right .tab-bar { background: var(--panel); }

/* ── launcher dashboard ── */
main.ldash { max-width: 1400px; margin: 0 auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.lstatus { display: flex; gap: .35em; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 10px; }
.tile { position: relative; height: auto; min-height: 92px; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .9em;
        padding: 14px 16px; text-align: left; background: var(--panel); border: 1px solid var(--line); white-space: normal; }
.tile:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.tile .ticon { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); border: 1px solid var(--line); }
.tile .ttext { display: flex; flex-direction: column; gap: .2em; min-width: 0; }
.tile .ttext b { font-size: 1.15rem; letter-spacing: .01em; }
.tile .ttext span { color: var(--text-dim); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; }
.tile .tcount { position: absolute; top: 8px; right: 10px; font: 600 .78rem var(--mono); color: var(--accent); }
.tile.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.tile.primary .ticon { background: color-mix(in srgb, var(--bg) 15%, transparent); color: var(--bg); border-color: transparent; }
.tile.primary .ttext span, .tile.primary .tcount { color: color-mix(in srgb, var(--bg) 75%, transparent); }
.tile.primary:hover { filter: brightness(1.08); }
.tile .tqr { position: absolute; right: 10px; bottom: 10px; padding: 3px; }
.tile .tqr svg { width: 58px; height: 58px; }
.lcols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 12px; align-items: start; }
.lmain, .lside { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lpanel { background: var(--panel); border: 1px solid var(--line); }
.lpanel > header { display: flex; align-items: center; gap: .6em; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.lpanel > header h3 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); font-weight: 700; }
.lpanel .pchips { display: flex; gap: .3em; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.lpanel .lbody { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.llist { display: flex; flex-direction: column; }
.lrow { display: flex; align-items: center; gap: .5em; padding: 5px 0; border-bottom: 1px solid var(--line); min-height: 28px; }
.lrow:last-child { border-bottom: 0; }
.lform { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.caps { display: flex; gap: .3em; flex-wrap: wrap; }
.chip2 { border-radius: 0; }
@media (max-width: 1000px) { .tiles { grid-template-columns: 1fr 1fr; } .lcols { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .tiles { grid-template-columns: 1fr; } .tile .tqr { display: none; } }

footer.credit { display: flex; align-items: center; justify-content: center; gap: .6em; padding: 18px 0 8px; color: var(--text-dim); font-size: .85rem; }
footer.credit img { height: 62px; width: auto; aspect-ratio: 56 / 31; flex: none; }
body.phone .xypad { position: relative; height: 220px; background: var(--panel-2); border: 1px solid var(--line); touch-action: none;
                    background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 25% 25%; }
body.phone .xypad .hint { position: absolute; left: 6px; bottom: 4px; }
body.phone .xydot { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 12px var(--accent); }
.setup-log { margin: 4px 0 0; padding: 6px; background: var(--bg); border: 1px solid var(--line); font: .78rem var(--mono); white-space: pre-wrap; max-height: 9em; overflow: auto; }
footer.credit a { color: var(--text); }
