:root {
  --bg: #131316;
  --panel: #1b1b20;
  --panel2: #23232a;
  --line: #2e2e37;
  --text: #e9e9ee;
  --muted: #9a9aa6;
  --accent: #7c6cff;
  --danger: #ff5d6c;
  --radius: 8px;
}
* { box-sizing: border-box; }
/* Slim scrollbars like Safari's: a thin rounded thumb, no track, no arrows (Chrome/Edge/Windows would draw the wide grey default) */
::-webkit-scrollbar { width: 11px; height: 11px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border: 3px solid transparent; border-radius: 8px; background-clip: padding-box; min-height: 36px; min-width: 36px; }
::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { background: rgba(255,255,255,.4); border-width: 2px; background-clip: padding-box; }
::-webkit-scrollbar-button { display: none; }
@supports not selector(::-webkit-scrollbar) { * { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.28) transparent; } }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Helvetica Neue", sans-serif; }
body { display: flex; flex-direction: column; }
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #444452; background: #2a2a33; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.small { padding: 4px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
select, input[type=text], textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%;
}
textarea { resize: vertical; min-height: 54px; }
input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
/* Color field + hex code (built around every input[type=color] in app.js) */
.colorfield { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 2px; width: fit-content;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; }
.colorfield:focus-within { border-color: var(--accent); }
.colorfield input[type=color] { width: 26px; height: 22px; border: 0; border-radius: 4px; }
.colorfield input.hex { width: 8ch; padding: 2px 0; border: 0; background: none; outline: none; color: var(--text);
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.colorfield input.hex.invalid { color: var(--danger); }
.colorfield .pick { display: flex; align-items: center; padding: 3px; border: 0; background: none; color: var(--muted); border-radius: 4px; }
.colorfield .pick:hover { color: var(--text); background: rgba(255,255,255,.08); }
/* Two color fields side by side (text element: Color + Accent color) */
.colorpair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.colorpair .colorfield { max-width: 100%; }
.colorpair .colorfield input.hex { width: 7ch; min-width: 0; }
/* Eyedropper active */
body.picking, body.picking * { cursor: crosshair !important; }
.pick-tip { position: fixed; z-index: 1000; pointer-events: none; display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px;
  background: #2d2d36; border: 1px solid #444; border-radius: 6px; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.pick-tip i { width: 18px; height: 18px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
.hidden { display: none !important; }

/* Wraps onto a second line in a narrow window or with long translations */
.topbar {
  min-height: 54px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: var(--panel); flex: none;
}
.brand { font-weight: 800; font-size: 17px; line-height: 1.4; letter-spacing: .3px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand .chev { color: var(--muted); height: .6em; width: auto; margin-right: .4em; vertical-align: .08em; }
.brand.here .chev { visibility: hidden; }
a.brand:hover .chev { color: var(--text); }
.topbar > * { flex-shrink: 0; }
.group { display: flex; align-items: center; gap: 6px; }
.group select { width: auto; max-width: 220px; }
.lbl { color: var(--muted); font-size: 12px; white-space: nowrap; }
.spacer { flex: 1; }
/* Export + language stay together and right-aligned, even after a wrap */
.group.end { margin-left: auto; gap: 8px; }
/* AI agent connected over MCP (js/bridge.js); the dot pulses while it works */
.agent-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-size: 12px; white-space: nowrap; cursor: default; }
.agent-pill i { width: 7px; height: 7px; border-radius: 50%; background: #3ecf8e; }
.agent-pill.busy { color: var(--text); border-color: var(--accent); }
.agent-pill.busy i { background: var(--accent); animation: agent-pulse 1s ease-in-out infinite; }
@keyframes agent-pulse { 50% { opacity: .3; } }
/* Screen language: one button (active language, the number of languages), the languages listed in its menu */
.topbar #langBtn b { text-transform: uppercase; font-size: 12px; }
.topbar #langBtn small { min-width: 18px; padding: 1px 5px; border-radius: 999px; background: var(--line); color: var(--muted); font-size: 11px; text-align: center; }
.topbar #langBtn small:empty { display: none; }
.langlist { display: flex; flex-direction: column; gap: 2px; max-height: min(50vh, 420px); overflow-y: auto; }
.langlist .langrow { display: flex; align-items: center; gap: 8px; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; }
.langlist .langrow:hover { background: var(--panel2); }
.langrow .ck { width: 12px; color: var(--accent); visibility: hidden; }
.langrow.active .ck { visibility: visible; }
.langrow b { min-width: 62px; font-size: 11px; text-transform: uppercase; }
.langrow.active b { color: var(--accent); }
.langrow .name { flex: 1; color: var(--muted); }
.langrow .x { margin-left: 10px; padding: 0 5px; border-radius: 4px; color: var(--muted); opacity: .5; }
.langrow:hover .x { opacity: 1; }
.langrow .x:hover { color: var(--danger); background: var(--line); }
/* UI language: globe + dropdown */
.uilang { display: flex; align-items: center; gap: 5px; padding-left: 4px; color: var(--muted); cursor: pointer; }
.uilang svg { flex: none; }
/* Own arrow instead of the browser default → same, predictable width in Safari and Chrome */
.uilang select {
  width: auto;
  background: var(--panel2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239a9aa6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 10px 6px;
}
.uilang select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.layout { display: grid; grid-template-columns: 290px 1fr 310px; grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; overflow: hidden; }
.panel { background: var(--panel); overflow-y: auto; min-height: 0; overscroll-behavior: contain; padding-bottom: 30px; }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }
.panel section { padding: 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.panel h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.panel h3 small { text-transform: none; letter-spacing: 0; color: var(--accent); font-weight: 600; margin-left: 4px; }
.panel label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.panel label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
/* Settings of the element selected in the preview (phone/text …): brighter labels, no extra color (the accent stays for controls) */
.panel label.elem-on { color: var(--text); }
.panel .row { display: flex; gap: 10px; align-items: flex-end; }
.panel .row > * { flex: 1; }
/* Swap colors: small icon on the label line at the end of the first column → takes no width from the color fields */
.panel .row:has(> .swapbtn) { position: relative; }
.panel .row > .swapbtn { position: absolute; top: -1px; right: calc(50% + 5px); display: flex; align-items: center; justify-content: center;
  width: 20px; height: 16px; padding: 0; border: 0; background: none; color: var(--muted); }
.panel .row > .swapbtn:hover { color: var(--text); }
.val { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.panel label > .val { position: absolute; right: 0; }
.panel label { position: relative; }
.help { margin: 0; color: var(--muted); font-size: 11px; }
.panel .indent { margin-left: 24px; } /* Sub-option of a checkbox above it */
.panel .indent .seg { align-self: flex-start; } /* Frame only as wide as the buttons */
.langTag { color: var(--accent); text-transform: uppercase; font-weight: 700; }
/* "Auto" next to the headline size */
.panel label .autobtn { margin-left: 6px; padding: 0 6px; height: 16px; border-radius: 4px; font-size: 10.5px; line-height: 14px; color: var(--muted); vertical-align: 1px; }
.panel label .autobtn:hover { color: var(--accent); }
.panel label.tf > .autobtn.tfauto { margin: 0; padding: 0 3px; height: 14px; font-size: 9.5px; line-height: 12px; opacity: .55; flex: none; }
.panel label.tf:hover > .autobtn.tfauto { opacity: 1; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
#colorRow { display: flex; flex-direction: column; gap: 12px; }
.bgbox, .stack { display: flex; flex-direction: column; gap: 10px; }
.topbar .more { padding: 0 9px; font-size: 16px; line-height: 1; letter-spacing: 1px; }
/* All controls in the top bar share one height */
.topbar { --ctl-h: 30px; }
.topbar select, .topbar button { height: var(--ctl-h); }
.topbar button { padding-top: 0; padding-bottom: 0; }
.topbar select { -webkit-appearance: none; appearance: none; padding: 0 24px 0 8px; cursor: pointer;
  background: var(--panel2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239a9aa6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 10px 6px; }
.topbar select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.topbar .dd { display: flex; align-items: center; gap: 8px; max-width: 260px; }
.topbar .dd span { overflow: hidden; text-overflow: ellipsis; }
.topbar .dd svg { flex: none; color: var(--muted); }
/* Menus (project, platforms) */
.popover.menu { width: auto; min-width: 230px; padding: 6px; gap: 2px; }
.menu > button { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; }
.menu > button:hover { background: var(--panel2); }
.menu hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu-note { max-width: 260px; padding: 6px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; line-height: 1.45; }
.platforms { display: flex; flex-direction: column; }
.platforms label { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.platforms label:hover { background: var(--panel2); }
.platforms label:has(input:disabled) { cursor: default; }
.platforms small { margin-left: auto; padding-left: 16px; color: var(--muted); font-size: 11px; }
.editfor { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; }
.seg { flex-wrap: wrap; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 4px 10px; font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: #fff; }
.seg-full { width: 100%; }
/* Own iPhone Duo frame: the two PNGs to choose (✓ once chosen) */
.duopick { display: flex; flex-wrap: wrap; gap: 6px; }
.duopick button.done { border-color: var(--accent); color: var(--accent); }
.seg-full button { flex: 1; padding: 6px 8px; }
/* Scope of a section: per platform (accent) or for all (neutral) */
.panel .scope { display: none; }
body.multi-phone .panel .scope { display: inline-block; }
.panel .scope { margin-left: 6px; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 600;
  letter-spacing: .2px; text-transform: none; vertical-align: 1px; border: 1px solid var(--line); color: var(--muted); }
.panel .scope-slot { border-color: transparent; background: color-mix(in srgb, var(--accent) 20%, transparent); color: color-mix(in srgb, var(--accent) 60%, #fff); }
.slotbox { display: flex; flex-direction: column; gap: 10px; }
body.multi-phone .slotbox { padding-left: 10px; border-left: 2px solid var(--accent); }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.swatch.active { border-color: #fff; }
.gradients .swatch { width: 38px; height: 26px; border-radius: 6px; }
/* Subheading within a section (e.g. presets / custom) */
.subhead { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .3px; }
.subhead::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.checklist { display: flex; flex-direction: column; gap: 6px; }
.checklist label { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.checklist small { color: var(--muted); }

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stagebar { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden; }
/* Narrow windows: the bar scrolls sideways instead of squeezing or cutting off its buttons */
.stagebar > * { flex-shrink: 0; white-space: nowrap; }
.stagebar input[type=range] { width: 140px; }
/* Undo / Redo, with a divider before the zoom */
.histbtns { display: flex; gap: 4px; padding-right: 10px; margin-right: 2px; border-right: 1px solid var(--line); }
.histbtns .icon { display: flex; align-items: center; justify-content: center; width: 30px; height: 28px; padding: 0; }
.histbtns .icon:disabled { opacity: .35; }
.popover.histmenu { width: 290px; }
.histlist { display: flex; flex-direction: column; gap: 2px; max-height: min(420px, 60vh); overflow-y: auto; }
.histlist button { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; flex-shrink: 0;
  text-align: left; border: 0; background: none; padding: 6px 10px 6px 26px; border-radius: 6px; }
.histlist button:hover { background: var(--panel2); }
.histlist button small { color: var(--muted); font-size: 11px; }
.histlist .future { opacity: .5; }
.histlist .now { background: var(--panel2); cursor: default; }
.histlist .now::before { content: ''; position: absolute; left: 10px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--accent); }
.strip { flex: 1; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 26px; padding: 18px 24px 24px; align-items: flex-start; }
/* One row per active platform, stacked */
.lane { display: flex; flex-direction: column; gap: 10px; }
.lane-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .3px; padding-left: 8px; border-left: 2px solid transparent; }
.lh-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Normal view: half a preview of free room on every side (--slack, --slackY from buildStrip) to move the rows like on a canvas.
   On the rows, not as padding of the preview: that would be its minimum height and squeeze the toolbar, dock and tip bar */
.strip.free > .lane { padding: 0 var(--slack, 0px); }
.strip.free > .lane:first-child { padding-top: var(--slackY, 0px); }
.strip.free > .lane:last-child { padding-bottom: var(--slackY, 0px); }
/* Toolbar, dock of left-out rows and tip bar keep their height, the preview takes what is left */
.stage > :not(.strip) { flex: none; }
body.multi-phone .lane.active .lane-head { border-left-color: var(--accent); }
.lane-head small { font-weight: 400; margin-left: 6px; opacity: .8; }
.lane-head em { font-style: normal; font-weight: 400; margin-left: 8px; color: var(--accent); }
.lane.active .lane-head { color: var(--text); }
.lane-cards { display: flex; gap: 22px; align-items: flex-start; }
.strip.dragover { background: rgba(124,108,255,.08); }
.card { flex: none; display: flex; flex-direction: column; gap: 8px; align-items: center; position: relative; }
/* Minus at the top right: delete the screen immediately */
/* Inside the card's width: the cards are only as far apart as in the store (see drawAll) */
.card-del { position: absolute; top: -11px; right: -2px; z-index: 2; width: 22px; height: 22px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--danger); border: 2px solid var(--bg); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
/* Minus as a bar instead of a text character → exactly centered, independent of the font */
.card-del::before { content: ''; width: 10px; height: 2px; border-radius: 1px; background: #fff; }
.card-del:hover { background: #ff3b4d; border-color: var(--bg); transform: scale(1.1); }
/* Hidden in this language: the card stays (greyed out, not exported); the eye replaces the minus */
.card-hide { position: absolute; top: -11px; right: -2px; z-index: 2; width: 22px; height: 22px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: var(--panel2); border: 2px solid var(--bg); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.card-hide:hover { background: var(--accent); transform: scale(1.1); }
.card.langoff canvas { opacity: .3; filter: grayscale(1); }
.card.langoff .card-hide { background: var(--accent); }
.card .offtag { position: absolute; top: 40%; left: 50%; transform: translateX(-50%); z-index: 1; max-width: 90%; padding: 4px 10px;
  border-radius: 12px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; text-align: center; pointer-events: none; }
.strip.panning, .strip.panning * { cursor: grabbing !important; user-select: none; }
.strip.panready, .strip.panready .card canvas { cursor: grab; }
.card canvas { display: block; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.4); cursor: pointer; outline: 2px solid transparent; outline-offset: 2px; touch-action: none; }
.card.selected canvas { outline-color: var(--accent); }
/* The same screen in the other row */
.card.paired canvas { outline-color: rgba(124,108,255,.35); }
.card.dragover canvas { outline-color: #fff; outline-style: dashed; }
.card .num { color: var(--muted); font-size: 12px; }
/* 3D screen (only in rows that show 3D) */
/* Top left on the card: "3D" and, for the selected phone, the hint for rotating in 3D (clickable) */
.cardtags { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 2; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 4px; pointer-events: none; }
.badge3d, .hint3d { padding: 1px 6px; border-radius: 5px; font-size: 10px; font-weight: 700; letter-spacing: .4px; line-height: 16px;
  color: #fff; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.hint3d { white-space: normal; max-width: 100%; border: 0; height: auto; text-align: center; letter-spacing: 0; font-weight: 600; cursor: pointer; pointer-events: auto;
  box-shadow: 0 0 0 1px rgba(255,255,255,.35); animation: hint3d-in .5s ease-out; }
.hint3d:hover { background: rgba(0,0,0,.65); }
.hint3d.on { background: var(--accent); box-shadow: none; }
/* Tip bar below the preview; as a pointer to the span switch it is clickable and highlighted */
.tipbar { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: left; }
.tiptext { flex: 1; min-width: 0; }
.tipcoffee { flex: none; width: 26px; height: 22px; margin: -4px 0; padding: 0; border-color: transparent; background: none; font-size: 14px; line-height: 1; opacity: .7; cursor: pointer; }
.tipcoffee:hover { opacity: 1; background: var(--panel2); }
.tipbar.link { cursor: pointer; }
.tipbar.link:hover { color: var(--text); }
/* Settings the hint points to: briefly highlighted */
.flash { animation: flash 1.4s ease-out; border-radius: 6px; }
@keyframes flash { 0%, 40% { background: rgba(124,108,255,.28); box-shadow: 0 0 0 4px rgba(124,108,255,.28); } }
@keyframes hint3d-in { from { transform: translateY(-4px); opacity: 0; } }
/* Same size as the screens (drawAll sets it when zooming) */
.card.add button { width: 120px; height: 120px; font-size: 32px; border-style: dashed; border-radius: 10px; color: var(--muted); }

.drop {
  border: 1.5px dashed #3d3d48; border-radius: var(--radius); padding: 10px; display: flex; gap: 10px; align-items: center;
  background: var(--panel2); cursor: pointer; min-height: 90px;
}
.drop.small { min-height: 60px; }
.watchpick { display: flex; flex-direction: column; gap: 6px; }
.watchpick .lbl { color: var(--muted); font-size: 11px; }
.watchpick .thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.watchpick button { padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: none; cursor: pointer; line-height: 0; }
.watchpick button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.watchpick img { width: 36px; height: 44px; object-fit: cover; border-radius: 6px; background: #000; }
.drop.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.drop img, .drop canvas { width: 46px; height: 92px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.drop.small img, .drop.small canvas { width: 30px; height: 60px; }
.drop .info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.drop .info b { font-size: 12px; }
.drop .info span { color: var(--muted); font-size: 11px; }
.drop .info .btns { display: flex; gap: 6px; margin-top: 2px; }

.actions { display: grid !important; grid-template-columns: 1fr 1fr; }
.actions.hidden { display: none !important; }
/* Wrap long translations instead of cutting them off */
.actions button { white-space: normal; min-width: 0; }

.dialog { width: 380px; max-width: calc(100vw - 32px); padding: 18px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.dialog[open] { display: flex; flex-direction: column; gap: 12px; }
.dialog::backdrop { background: rgba(0,0,0,.55); }
.dialog h2 { margin: 0; font-size: 16px; }
.dialog .checklist label { padding: 4px 0; }
.dialog .field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
/* Thank-you after an export: centered, one big button, the way out stays easy to find */
.supportdlg { width: 400px; align-items: center; text-align: center; padding: 28px 24px 20px; }
.supportdlg p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.support-cup { font-size: 46px; line-height: 1; }
.btn-link.primary { display: block; width: 100%; padding: 12px 16px; border-radius: 8px; background: var(--accent); border: 1px solid var(--accent);
  color: #fff; font-weight: 600; font-size: 15px; text-decoration: none; margin-top: 4px; }
.btn-link.primary:hover { filter: brightness(1.08); }
.support-later { display: flex; justify-content: center; }
.supportdlg > button.primary { width: 100%; padding: 12px 16px; }
.support-later { flex-direction: column; align-items: center; gap: 2px; }
.support-later a { color: var(--muted); padding: 6px 10px; text-decoration: none; }
.support-later a:hover { color: var(--text); }
.support-later button { background: none; border-color: transparent; color: var(--muted); }
.support-later button:hover { color: var(--text); background: none; }
/* Store check in the export dialog: errors red, advice amber, all fine green; a click leads to the screen */
#exportDialog { width: 460px; }
.exp-breakdown { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow: auto; font-size: 12px; }
.exp-breakdown:empty { display: none; }
.exp-lang { padding: 6px 8px; border-radius: 8px; background: color-mix(in srgb, var(--text) 5%, transparent); }
.exp-lang-h { display: flex; justify-content: space-between; align-items: center; margin: 0 0 2px; color: var(--muted); cursor: pointer; }
.exp-lang.off ul { opacity: .4; }
.exp-lang.off .exp-lang-h b { color: var(--muted); }
.exp-lang-h b { color: var(--text); margin-right: 4px; }
.exp-lang ul { list-style: none; margin: 0; padding: 0; }
.exp-lang li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.exp-lang li b { font-weight: 500; white-space: nowrap; }
.exp-vid { margin-top: 2px; color: var(--muted); }
.checks { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow: auto; }
.chk { display: flex; gap: 8px; align-items: baseline; width: 100%; margin: 0; padding: 6px 8px; border: 0; border-radius: 8px; text-align: left;
  font-size: 12px; line-height: 1.35; white-space: normal; color: var(--text); background: color-mix(in srgb, #ffb020 12%, transparent); cursor: pointer; }
.chk.err { background: color-mix(in srgb, #ff3b4d 14%, transparent); }
.chk.ok { background: color-mix(in srgb, #34c759 14%, transparent); cursor: default; }
.chk:disabled { cursor: default; opacity: 1; }
.chk b { flex: none; width: 12px; color: #ffb020; }
.chk.err b { color: #ff5a6e; }
.chk.ok b { color: #34c759; }
.chk:not(.ok):not(:disabled):hover { filter: brightness(1.25); }
/* Cloud storage (js/cloud.js): status next to the project name, two-line menu entry, dialog form */
/* Cloud status: only the cloud, its state as a dot at its lower right (green saved, amber unsaved, pulsing while
   saving, red failed); paused or changed elsewhere colors the cloud too, as it waits for a click */
.cloudchip { position: relative; display: flex; align-items: center; justify-content: center; width: var(--ctl-h); padding: 0; border: 0; background: none; color: var(--muted); }
.cloudchip:hover { color: var(--text); background: var(--panel2); }
.cloudchip i { position: absolute; right: 5px; bottom: 7px; width: 7px; height: 7px; border-radius: 50%; background: #3ecf8e; box-shadow: 0 0 0 2px var(--panel); }
.cloudchip:hover i { box-shadow: 0 0 0 2px var(--panel2); }
.cloudchip.unsaved i, .cloudchip.paused i, .cloudchip.conflict i { background: #ffb547; }
.cloudchip.saving i { background: var(--accent); animation: agent-pulse 1s ease-in-out infinite; }
.cloudchip.failed i { background: var(--danger); }
.cloudchip.paused, .cloudchip.conflict { color: #ffb547; }
/* A save is running: no clicks; a thin bar under the cloud shows how much has gone up (--p set by js/cloud.js) */
.cloudchip:disabled { cursor: progress; }
.cloudchip:disabled:hover { color: var(--muted); background: none; }
.cloudchip.saving::after { content: ''; position: absolute; left: 6px; bottom: 3px; height: 2px; width: calc((100% - 12px) * var(--p, 0%) / 100%); border-radius: 1px; background: var(--accent); }
/* No cloud connected yet: a greyed cloud without a dot, its click offers the clouds */
.cloudchip.off { opacity: .45; }
.cloudchip.off:hover { opacity: 1; }
.cloudchip.off i { display: none; }
.menu > .menu-hint { padding: 6px 10px 4px; color: var(--muted); font-size: 11px; }
.menu > .menu-check { display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.menu > .menu-check:hover { background: var(--panel2); }
.menu > .menu-check input { margin: 2px 0 0; }
.menu > .menu-check small { display: block; color: var(--muted); font-size: 11px; }
/* How often auto-save uploads (js/cloud.js), under its checkbox, in line with its text; the hint wraps at the menu's width */
.menu > .menu-choice { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 6px 31px; }
.menu > .menu-choice label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; }
.menu > .menu-choice input { margin: 0; }
.menu > .menu-choice small { width: 0; min-width: 100%; margin-top: 2px; color: var(--muted); font-size: 11px; }
.menu > button.two-line { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.menu > button.two-line small { color: var(--muted); font-size: 11px; }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
/* Project menu: submenus "Save to" / "Open from" (js/cloud.js), the state of a project in a cloud */
.menu > .menu-sub > .sub-trigger { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; }
.menu > .menu-sub > .sub-trigger:hover, .menu > .menu-sub.open > .sub-trigger { background: var(--panel2); }
.sub-trigger svg { flex: none; color: var(--muted); }
.popover.menu.submenu { min-width: 190px; }
.menu > .menu-state { display: flex; align-items: center; gap: 10px; margin: 0 0 2px; padding: 8px 10px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.menu > .menu-state > span > span { display: block; color: var(--text); }
.menu > .menu-state small { display: block; font-size: 11px; }
.menu > .menu-state.unsaved small, .menu > .menu-state.paused small, .menu > .menu-state.conflict small { color: #ffb547; }
.menu > .menu-state.failed small { color: var(--danger); }
.cloudaccount { margin-right: auto; align-self: center; color: var(--muted); font-size: 12px; }
.cloudaccount .textlink { border: 0; background: none; padding: 0; color: var(--accent); font-size: inherit; cursor: pointer; }
.cloudaccount .textlink:hover { text-decoration: underline; }
.cloudlist { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.cloudlist button { display: flex; justify-content: space-between; gap: 12px; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; }
.cloudlist button:hover { background: var(--panel2); }
.cloudlist small, .cloudlist .empty { color: var(--muted); }
.topbar .iconbtn { display: flex; align-items: center; gap: 6px; }
/* Video screen: timeline for trimming (as in editing software) */
.timeline { position: relative; height: 58px; border-radius: 8px; background: #000; user-select: none; -webkit-user-select: none; touch-action: none; cursor: pointer; }
.tl-thumbs { position: absolute; inset: 0; display: flex; border-radius: 8px; overflow: hidden; }
.tl-thumbs canvas { flex: 1; min-width: 0; height: 100%; display: block; }
.tl-shade { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,.62); pointer-events: none; }
#tlShadeL { left: 0; border-radius: 8px 0 0 8px; }
#tlShadeR { right: 0; border-radius: 0 8px 8px 0; }
.tl-range { position: absolute; top: 0; bottom: 0; border: 3px solid var(--accent); border-left-width: 0; border-right-width: 0; cursor: grab; }
.tl-handle { position: absolute; top: -3px; bottom: -3px; width: 12px; background: var(--accent); cursor: ew-resize; display: flex; align-items: center; justify-content: center; }
.tl-handle::after { content: ''; width: 2px; height: 18px; border-radius: 1px; background: rgba(255,255,255,.85); }
.tl-handle[data-h="start"] { left: -12px; border-radius: 6px 0 0 6px; }
.tl-handle[data-h="end"] { right: -12px; border-radius: 0 6px 6px 0; }
.tl-head { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 4px rgba(0,0,0,.6); pointer-events: none; }
#videoPanel .timeline { margin: 0 12px; }
#videoPanel { padding-bottom: 4px; }
/* Length outside the store recommendation */
.help.warn { color: #ffb84d; }
.vctl { display: flex; align-items: center; gap: 8px; }
.vctl .icon { display: flex; align-items: center; justify-content: center; width: 30px; height: 26px; padding: 0; }
.vctl .icon + .icon { margin-left: -4px; }
.vctl input { flex: 1; min-width: 0; }
.popover { position: fixed; z-index: 50; width: 300px; display: flex; flex-direction: column; gap: 8px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.55); }
.langpick .list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; }
.langpick .list label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.langpick .list label:hover { background: var(--panel2); }
.langpick .list label:has(input:disabled) { opacity: .5; cursor: default; }
.langpick .list small { margin-left: auto; color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.langpick .empty { padding: 10px 6px; color: var(--muted); }
.langpick .foot { display: flex; justify-content: space-between; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2d2d36; border: 1px solid #444;
  padding: 12px 18px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 10; max-width: 80vw; font-size: 14px;
}
.toast-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.toast-cancel { padding: 2px 10px; font-size: 12px; }
.toast-bar { margin-top: 8px; height: 6px; min-width: 260px; border-radius: 3px; background: #444; overflow: hidden; }
.toast-bar > i { display: block; height: 100%; background: var(--accent); transition: width .15s linear; }
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: #3ecf8e; }
.panel label.has-reset > .val { right: 36px; }
.panel label > button.resetbtn { position: absolute; right: 0; top: -4px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--muted); font-size: 14px; line-height: 22px; cursor: pointer; }
.panel label > button.resetbtn:hover { color: var(--accent); background: none; }
.panel label > button.resetbtn.off { display: none; } /* value is at its start value */
.panel .val { cursor: text; }
.panel label > input[type=text].valedit { position: absolute; right: 36px; top: -4px; width: 56px; padding: 1px 4px; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.panel label > .val.editing { visibility: hidden; }
.panel label:not(.has-reset) > input[type=text].valedit { right: 0; }
/* Value directly next to the reset button, both on the text line */
.panel label.has-reset > .val { top: 0; right: 20px; line-height: 16px; }
.panel label > button.resetbtn { top: 0; right: 0; width: 18px; height: 16px; line-height: 16px; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.panel label > input[type=text].valedit { right: 20px; top: -3px; }
.panel label:not(.has-reset) > input[type=text].valedit { right: 0; }
/* Side-by-side view: lanes dissolve, heads and cards sit in the strip's grid (columns = platforms, rows = screens) */
/* View switch in the bar above the preview: as tall as the buttons next to it */
.viewseg { flex-wrap: nowrap; }
.viewseg button { padding: 6px 10px; font-size: 13px; font-weight: 500; }
.viewseg button:hover:not(.active) { color: var(--text); }
/* Columns as wide as their screens (fixed by the zoom, --cw per platform), next to each other; first and last column = half a
   preview of free room (--slack), so the screens can be moved sideways like on a canvas (centered when the view opens) */
.strip.side { display: grid; grid-template-columns: var(--slack, 0px) repeat(var(--cols), max-content) var(--slack, 0px); gap: 14px 14px; align-content: start; align-items: start; }
/* Eye after the row heading (three or more rows): quiet until the mouse is on the heading */
.lane-head .eyebtn { display: inline-flex; flex: none; padding: 0; border: 0; background: none; color: var(--muted); opacity: .45; cursor: pointer; transition: opacity .15s; }
.lane-head:hover .eyebtn:not(:disabled) { opacity: .8; }
.lane-head .eyebtn:hover:not(:disabled) { opacity: 1; color: var(--text); }
.lane-head .eyebtn:disabled { opacity: .2; cursor: default; }
/* Dock of the left-out platforms: a narrow last column, one dashed bar each with the name upright (like the reserve bench) */
/* Sticky at the right edge of the preview while moving sideways; covers screens passing beneath it */
.sidedock { display: flex; gap: 6px; align-self: stretch; justify-self: end; position: sticky; right: 0; z-index: 3; padding-left: 10px; background: var(--bg); }
.dockbar { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0; padding: 8px 6px; min-width: 0; border: 0;
  border-left: 2px dashed var(--line); border-radius: 0; background: none; color: var(--muted); cursor: pointer; }
.dockbar span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; white-space: nowrap; }
.dockbar:hover { color: var(--text); border-left-color: var(--muted); }
/* Normal view: the dock is a strip below the preview (above the tip bar), the bars side by side with their names lying */
.rowdock { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 24px 10px; background: var(--bg); border-top: 1px solid var(--line); }
.rowdock .dockbar { flex-direction: row; padding: 6px 10px; border-left: 0; border: 2px dashed var(--line); border-radius: 8px; }
.rowdock .dockbar span { writing-mode: horizontal-tb; transform: none; }
.rowdock .dockbar:hover { border-color: var(--muted); }
.strip.side .lane, .strip.side .lane-cards { display: contents; }
/* First platform hugs the middle from the left, last one from the right. The heading as wide as the screens below it (cut with …,
   the whole text as tooltip), flush with them and without the stripe of the active row */
.strip.side .card[data-col=first], .strip.side .lane[data-col=first] .lane-head { justify-self: end; }
.strip.side .card[data-col=last], .strip.side .lane[data-col=last] .lane-head { justify-self: start; }
.strip.side .card[data-col=mid], .strip.side .lane[data-col=mid] .lane-head { justify-self: center; }
.strip.side .lane-head { width: var(--cw); min-height: 18px; padding-left: 0; border-left: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* min-height: cut off, it would count as 0 px high in its grid row */
/* The feature graphic (twice as wide) does not widen its column: it reaches out toward the free side */
.strip.side .card.feature { width: var(--cw); }
.strip.side .card.feature[data-col=first] { align-items: flex-end; }
.strip.side .card.feature[data-col=last] { align-items: flex-start; }
.card.add button { padding: 0; box-sizing: border-box; min-width: 0; }

/* Variants: the other variants peek out above the shown card (not sideways: the neighbors may be close), ‹ 2/3 › below it switches in place */
.card.stacked canvas { box-shadow: 0 -8px 0 -4px #5c5c6c, 0 6px 24px rgba(0,0,0,.4); }
.card.stacked.deep canvas { box-shadow: 0 -8px 0 -4px #5c5c6c, 0 -16px 0 -8px #3e3e4a, 0 6px 24px rgba(0,0,0,.4); }
/* Number + ‹ 2/3 › scale down with the screen width (--cw, set by the zoom) so they never reach past the screen; everything in em */
.card .num { display: flex; align-items: center; justify-content: center; gap: .67em; max-width: 100%; white-space: nowrap; font-size: clamp(6px, calc(var(--cw, 200px) / 12), 12px); }
.vstack { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--panel2); overflow: hidden; }
.vstack button { height: 1.67em; padding: 0 .58em; line-height: 1.5em; border: 0; border-radius: 0; background: none; font-size: 1.08em; }
.vstack button:hover { background: #2a2a33; }
.vstack .vcount { padding: 0 .25em; font-size: 1em; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Comparison of the variants of one place (replaces the rows until "Done") */
.compare-head { font-size: 15px; font-weight: 600; }
.card.alt canvas { cursor: pointer; }
.card.alt.selected canvas { cursor: default; }
.card.alt .num b { color: var(--accent); font-weight: 600; }
/* Reserve bench right of the row: parked screens, not exported */
.bench-sep { flex: none; align-self: stretch; display: flex; align-items: flex-start; margin-left: 18px; padding-left: 10px; border-left: 2px dashed var(--line); }
.bench-sep span { writing-mode: vertical-rl; transform: rotate(180deg); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; cursor: help; }
.card.bench canvas { cursor: default; opacity: .8; transition: opacity .15s; }
/* Google Play feature graphic: card at the end of the Android row, its own panel on the right while it is selected */
.panel.right:not(.feature-mode) #featurePanel { display: none; }
.panel.right.feature-mode .actions { display: none !important; }
.card.bench:hover canvas { opacity: 1; }
.bench-acts { display: flex; gap: 6px; }
.strip.side .bench-sep { justify-self: stretch; margin: 10px 0 0; padding: 8px 0 0; border-left: 0; border-top: 2px dashed var(--line); }
.strip.side .bench-sep span { writing-mode: horizontal-tb; transform: none; }

/* Own image as background */
.bgimg { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.bgimg > button { flex: none; }
.bgimg .bgthumb { flex: none; width: 54px; height: 34px; border-radius: 6px; border: 1px dashed var(--border, #444); background: #222 center / cover no-repeat; cursor: pointer; }

/* Right panel: header with the screen number and how to grab elements in the preview */
.panelhead { padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--line); background: var(--panel2);
  position: sticky; top: 0; z-index: 3; } /* stays visible while scrolling: which side applies to what */
.panelhead .ptitle { font-size: 14px; font-weight: 700; letter-spacing: .2px; }
.panelhead .help { font-size: 12px; }
.panel .subhead .scope { margin-left: 0; }
.subhead .slotlbl { color: var(--accent); font-weight: 600; }
/* Placed images: list with thumbnail */
.imglist { display: flex; flex-direction: column; gap: 4px; }
.imglist:empty { display: none; }
/* One card per element; the selected one contains its settings (#imgEdit, moved there by js) and can be folded */
.imgcard { border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
.imgcard:hover { border-color: #444452; }
.imgcard.active { border-color: #55556a; background: #26262e; }
.imgcard > .stack { padding: 6px 10px 10px; }
.imgcard.folded > .stack { display: none; }
.imgrow { display: flex; align-items: center; gap: 8px; padding: 4px; cursor: pointer; }
.imgrow .fold { flex: none; width: 22px; height: 22px; padding: 0; border: 0; background: none; }
.imgrow .fold::after { content: ''; display: block; margin: 0 auto; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg); transition: transform .15s; }
.imgrow .fold:hover::after { border-color: var(--text); }
.imgcard.folded .fold::after { transform: rotate(-45deg); }
.imgrow .thumb { flex: none; width: 34px; height: 34px; border-radius: 4px; background: #222 center / contain no-repeat; }
.imgrow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#imgPanel.dragover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* Main categories (device, text, background, additional elements): colored stripe on the outer edge –
   same color on both sides for the same element – and collapsible via the heading */
/* --accent: controls inside a category pick up its color, muted (78 % color, 22 % gray #a0a0a0, mixed in oklab). Plain hex on
   purpose: native checkboxes don't always paint a color-mix() accent until they're clicked */
.panel .cat { --cat: #7c6cff; --accent: #827bec; }
.panel .cat[data-cat="device"] { --cat: #4f9dff; --accent: #659feb; }
.panel .cat[data-cat="text"]   { --cat: #ffb547; --accent: #eab164; }
.panel .cat[data-cat="bg"]     { --cat: #3ecf8e; --accent: #61c592; }
.panel .cat[data-cat="extra"]  { --cat: #ff6fae; --accent: #8c8ca0; }  /* element settings stay neutral, like the selected card */
.panel.left .cat  { box-shadow: inset 3px 0 0 var(--cat); }
.panel.right .cat { box-shadow: inset -3px 0 0 var(--cat); }
.panel .cat > h3 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; cursor: pointer; user-select: none; -webkit-user-select: none; color: var(--text); }
.panel .cat > h3 > span:first-child { color: var(--cat); }
.panel .cat > h3 .scope { margin-left: 0; }
.panel .cat > h3::after { content: ''; margin-left: auto; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg); transition: transform .15s; }
.panel .cat > h3:hover::after { border-color: var(--text); }
.panel .cat.collapsed > h3::after { transform: rotate(-45deg); }
.panel .cat.collapsed > :not(h3) { display: none !important; }
.panel .cat.collapsed { padding-bottom: 14px; }

/* Help: ? next to the zoom, dialog with all explanations */
.helpbtn { width: 26px; height: 26px; padding: 0; border-radius: 50%; font-weight: 700; color: var(--muted); }
.helpbtn:hover { color: var(--text); }
.helpdlg { width: 520px; max-height: calc(100vh - 64px); overflow: hidden; }
.helpdlg .helpbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.helpdlg h3 { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.helpdlg ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; line-height: 1.45; }
/* Value that comes from the general setting (no own value yet) */
.panel .val.inherited { color: var(--muted); }
.colorfield.inherited input.hex { color: var(--muted); }
/* "Further adjustments" at the end of Device/Headline on the right: collapsed box like a subheading with an arrow,
   count of own values and ↺ (sets them back) */
details.override > summary { display: flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; user-select: none; -webkit-user-select: none;
  margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .3px; }
details.override > summary::-webkit-details-marker { display: none; }
details.override > summary::after { content: ''; flex: 1; height: 1px; background: var(--line); }
details.override > summary:hover { color: var(--text); }
details.override > summary .chev { flex: none; transform: rotate(-90deg); transition: transform .15s; }
details.override[open] > summary .chev { transform: none; }
details.override > summary > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
details.override > summary::after { min-width: 8px; }
/* Number of own values: neutral badge (purple stays for controls) */
details.override .ovcount { flex: none; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); font-size: 10px; font-weight: 600; letter-spacing: 0; line-height: 14px; text-align: center; }
details.override .ovcount:empty { display: none; }
details.override .subreset { order: 2; width: 18px; height: 16px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 16px; cursor: pointer; }
details.override .subreset:hover { color: var(--accent); }
details.override > .stack { margin-top: 10px; }
/* Platform row of the selected screen next to the "Device" heading, in the category color */
.cat h3 .slotlbl { color: var(--cat); font-weight: 600; }
.imgrow canvas.thumb { background: none; }
/* Kind of the element below its name; the magnifier as an icon */
.imgrow .nm small { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.imgrow .thumb.ico { display: flex; align-items: center; justify-content: center; background: var(--panel); color: var(--text); }
.imgrow .thumb.ico svg, .elemmenu .ico { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* Images and texts can be dragged to change their order: line where it will land */
.imgrow[draggable="true"] { cursor: grab; }
.imgcard.dragging { opacity: .45; }
.imgcard.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.imgcard.drop-after { box-shadow: 0 2px 0 var(--accent); }
/* Layer anchors in the element list (headline, subheadline, devices, background): one-line rows with a small symbol, as solid
   as the elements' cards; the lifted objects indented above the phone they come out of */
.imgcard.anchor .imgrow { padding: 3px 4px; font-size: 12.5px; }
.imgrow .thumb.mini { width: 34px; height: 22px; display: flex; align-items: center; justify-content: center; background: none; color: var(--muted); }
.imgrow .thumb.mini svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.imgcard.anchor.active .thumb.mini { color: var(--text); }
.imgcard.anchor[data-kind="bg"] { background: none; border-style: dashed; }
.imgcard.anchor[data-kind="bg"] .imgrow { cursor: default; color: var(--muted); }
.imgcard[data-kind^="pop:"] { margin-left: 14px; }
/* Lifted objects are chained to their device: a line from each of them down to the top edge of the device card (it ends there, not inside) */
.imgcard.popchild { position: relative; }
.imgcard.popchild::before { content: ''; position: absolute; left: -8px; top: -4px; bottom: -4px; border-left: 1.5px solid var(--muted); opacity: .6; pointer-events: none; }
.imgcard.popchild.first::before { top: 50%; }
.imgcard.popchild::after { content: ''; position: absolute; left: -8px; width: 8px; top: 50%; border-top: 1.5px solid var(--muted); opacity: .6; pointer-events: none; }
/* Grip in front of every row that can be dragged (the others keep the room, so the rows line up) */
#imgList .imgrow::before { content: ''; flex: none; width: 9px; margin-right: -3px; color: var(--muted); font-size: 12px; line-height: 1; }
#imgList .imgrow[draggable="true"]::before { content: '⠿'; }
#imgList .imgrow[draggable="true"]:hover::before { color: var(--text); }
.layerhelp { margin: -2px 0 6px; }
/* Layers reaching in from a neighboring screen: as tall as the anchors but held back (dashed, no fill, dimmed), the screen
   they come from small on the right */
.imgcard.nbrow { background: none; border-style: dashed; }
.imgcard.nbrow:hover { border-color: #444452; }
.imgcard.nbrow .imgrow { color: var(--muted); }
.imgcard.nbrow .imgrow:hover { color: var(--text); }
.imgcard.nbrow .thumb.mini { opacity: .7; }
.imgrow .from { flex: none; padding-right: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
/* "＋ Add element" and its menu: the kinds as tiles (icon, name, description), below them the presets – smaller, four per row,
   so that they don't outweigh the kinds */
.addbtn { width: 100%; }
.popover.elemmenu { width: 440px; min-width: 0; overflow-y: auto; padding: 10px; gap: 6px; }
.elemmenu .kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; grid-auto-rows: 1fr; }
.elemmenu .kinds > button { display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 10px 10px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.elemmenu .kinds > button:hover { border-color: #55556a; background: #2a2a33; }
.elemmenu .kinds > button .ico { flex: none; width: 22px; height: 22px; color: var(--accent); }
.elemmenu .kinds > button > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; white-space: normal; }
.elemmenu .kinds > button b { font-size: 13px; font-weight: 600; }
.elemmenu .kinds > button small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.elemmenu .kinds > button:disabled { opacity: .5; }
.elemmenu .kinds > button:disabled .ico { color: var(--muted); }
.elemmenu .kinds > button:disabled:hover { border-color: var(--line); background: var(--panel2); }
.elemmenu .subhead { margin: 8px 2px 0; }
/* "＋ Add device": two kinds, a narrower menu; with a second device the tabs Device 1 | Device 2 fill the row beside ✕ */
.popover.elemmenu.dev2menu { width: 360px; }
.dev2row { display: flex; align-items: center; gap: 6px; }
.dev2row .seg { flex: 1; flex-wrap: nowrap; }
.dev2row .seg button { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.elemmenu .presets { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.elemmenu .presets button { min-width: 0; white-space: normal; gap: 3px; padding: 3px 3px 4px; font-size: 10px; color: var(--muted); border-color: transparent; background: none; }
.elemmenu .presets button:hover { color: var(--text); border-color: var(--line); background: var(--panel2); }
.presets .subhead { grid-column: 1 / -1; margin: 6px 0 0; }
.elemmenu .presets .subhead { margin: 8px 4px 2px; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.presets button { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 4px 4px 5px; font-size: 11px; }
.presets canvas { width: 100%; aspect-ratio: 2 / 1; border-radius: 4px; display: block; }
.imgrow .thumb.txt { display: flex; align-items: center; justify-content: center; font: 700 16px Georgia, serif; color: var(--text); background: var(--panel); }
/* Cutout: screenshot with the chosen area (drag to move, corners resize, outside draws a new one) */
.cropbox { display: flex; justify-content: center; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
.cropbox canvas { display: block; max-width: 100%; touch-action: none; cursor: crosshair; }
.cropbox canvas#popCrop { cursor: pointer; }
/* Selection dialog for "Lift out object": tools left, screenshot right */
.popdlg { width: min(1100px, calc(100vw - 32px)); height: min(860px, calc(100vh - 32px)); max-height: none; }
.popdlg-body { flex: 1; min-height: 0; display: flex; gap: 14px; }
.popdlg-tools { flex: none; width: 220px; overflow-y: auto; }
.popdlg-stage { flex: 1; min-width: 0; position: relative; overflow: hidden; border-radius: 8px; border: 1px solid var(--line);
  background: repeating-conic-gradient(#1c1c22 0 25%, #24242b 0 50%) 0 0 / 20px 20px; }
.popdlg-stage canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.seltools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seltools button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; font-size: 11px; }
.seltools button .ico { font-size: 16px; line-height: 1; }
.seltools button.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
/* Rows of buttons (undo / clear, zoom) and the add / remove switch fill the width of the tool column */
.popdlg .row { display: flex; gap: 6px; }
.popdlg .zoomrow > button, .popdlg .row > button { flex: 1; }
#selMode button { flex: 1; padding: 5px 8px; }
@media (max-width: 640px) { .popdlg-body { flex-direction: column; } .popdlg-tools { width: auto; } }
/* Compact fields for position, size and rotation (two per row, three for the 3D angles): name left, value and ↺ right;
   dragging sideways changes the value (cursor), the range input stays hidden */
.tfgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tfgrid.tfgrid3 { grid-template-columns: 1fr 1fr 1fr; }
.panel label.tf { flex-direction: row; align-items: center; gap: 4px; height: 30px; padding: 0 5px 0 9px; min-width: 0;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; cursor: ew-resize; touch-action: none;
  user-select: none; -webkit-user-select: none; }
.panel label.tf:hover, .panel label.tf.scrubbing { border-color: #55556a; }
.panel label.tf > b { font-weight: 600; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel label.tf.elem-on > b { color: var(--text); }
.panel label.tf > input[type=range] { display: none; }
.panel label.tf > .val, .panel label.tf.has-reset > .val { position: static; margin-left: auto; line-height: 16px; white-space: nowrap; }
.panel label.tf > button.resetbtn { position: static; order: 2; flex: none; width: 16px; }
.panel label.tf > input[type=text].valedit { right: 22px; top: 4px; width: 58px; }
.panel label.tf:not(.has-reset) > input[type=text].valedit { right: 5px; }
/* 🔗 linked with the other platform (heading of Text/Background, rows of the element list): chain = linked, broken = separate */
.linkbtn { flex: none; display: flex; align-items: center; justify-content: center; width: 24px; height: 22px; padding: 0;
  border: 0; border-radius: 5px; background: none; color: var(--muted); opacity: .7; }
.linkbtn.on { color: var(--text); opacity: 1; }
.linkbtn:hover { background: rgba(255,255,255,.08); opacity: 1; }
.linkbtn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.panel .cat > h3 .linkbtn { margin-left: auto; }
.panel .cat > h3 .linkbtn:not(.hidden) ~ .linkbtn { margin-left: 2px; }
/* 📱🔗 / 🌐🔗: a small sign of what is linked (phone rows, screen languages) in front of the chain */
.linkbtn.tagged { width: auto; gap: 1px; padding: 0 3px; }
.panel .cat > h3:has(.linkbtn:not(.hidden))::after { margin-left: 6px; }
.linkbtn.blocked { opacity: .35; cursor: help; }
.linkbtn.blocked:hover { background: none; opacity: .5; }
