/* Rex home-card workbench. Colours follow rexnow.tv (site.css): silver paper, ink, iris accent,
   ink pill for the primary action. Device screens follow the appearance like the App, and the
   template iframes inherit it, so their prefers-color-scheme matches the screen behind them. */
:root {
  color-scheme: light;
  --bg: #f5f7fa; --surface: #ffffff; --surface-2: #fafbfc; --sunk: #eef1f6; --field: #eef1f6;
  --bar: rgba(245, 247, 250, .96); --bar-line: #dde1e8;
  --line: #e4e8ee; --line-2: #d2d8e4;
  --ink: #17191e; --ink-2: #626772; --ink-3: #8a909c;
  --hover: rgba(23, 25, 30, .045); --fill: rgba(23, 25, 30, .06);
  --accent: #68628e; --accent-soft: rgba(104, 98, 142, .1); --accent-ink: #68628e;
  --primary: #17191e; --primary-hover: #434652; --primary-ink: #ffffff;
  --green: #34c759; --green-ink: #248a3d; --green-soft: rgba(52, 199, 89, .14);
  --orange: #ff9f0a; --orange-soft: rgba(255, 159, 10, .14);
  --red: #ff3b30; --red-soft: rgba(255, 59, 48, .1);
  --board: #eceef2;
  --panel: #f7f8fa; --panel-line: #e3e6ec;
  --raise: inset 0 1px 0 rgba(255, 255, 255, .9), 0 0 0 .5px rgba(48, 62, 87, .12), 0 6px 16px -4px rgba(51, 63, 103, .14);
  --key: rgba(255, 255, 255, .75); --contact: rgba(30, 38, 62, .4);
  --screen: #ffffff; --screen-glow: #f2f4f8; --screen-ink: #111318; --screen-dim: #8a909c;
  --screen-ghost: rgba(17, 19, 24, .06); --screen-ghost-2: rgba(17, 19, 24, .04); --screen-grid: rgba(17, 19, 24, .06);
  --screen-edge: rgba(0, 0, 0, .1);
  --shadow: 0 0 0 1px #fff inset, 0 10px 24px rgba(60, 69, 99, .08), 0 0 0 .5px rgba(48, 62, 87, .08);
  --pop: 0 22px 60px rgba(51, 63, 103, .16), 0 0 0 .5px rgba(48, 62, 87, .12);
  --ease: cubic-bezier(.25, .1, .25, 1);
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  --c-plain: #24292f; --c-kw: #cf222e; --c-str: #0a3069; --c-num: #0550ae; --c-com: #8b949e;
  --c-tag: #116329; --c-attr: #8250df; --c-fn: #6639ba; --c-prop: #0550ae;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111216; --surface: #17191e; --surface-2: #1c1f25; --sunk: #0d0e11; --field: #22252c;
    --bar: rgba(17, 18, 22, .92); --bar-line: rgba(255, 255, 255, .08);
    --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .15);
    --ink: #f5f7fa; --ink-2: #a4a9b4; --ink-3: #747a87;
    --hover: rgba(255, 255, 255, .06); --fill: rgba(255, 255, 255, .08);
    --accent: #a29cc9; --accent-soft: rgba(162, 156, 201, .16); --accent-ink: #b9b4dc;
    --primary: #f5f7fa; --primary-hover: #dde1e8; --primary-ink: #17191e;
    --green: #30d158; --green-ink: #30d158; --green-soft: rgba(48, 209, 88, .16);
    --orange: #ff9f0a; --orange-soft: rgba(255, 159, 10, .16);
    --red: #ff453a; --red-soft: rgba(255, 69, 58, .16);
    --board: #0b0c0f;
    --panel: #131418; --panel-line: rgba(255, 255, 255, .07);
    --raise: inset 0 1px 0 rgba(255, 255, 255, .06), 0 0 0 .5px rgba(255, 255, 255, .1), 0 6px 16px -4px rgba(0, 0, 0, .5);
    --key: rgba(160, 170, 210, .075); --contact: rgba(0, 0, 0, .75);
    --screen: #0b1018; --screen-glow: #202c3e; --screen-ink: #f1f3f8; --screen-dim: #9aa3b5;
    --screen-ghost: rgba(255, 255, 255, .09); --screen-ghost-2: rgba(255, 255, 255, .045); --screen-grid: rgba(255, 255, 255, .07);
    --screen-edge: rgba(255, 255, 255, .12);
    --shadow: 0 0 0 .5px var(--line-2), 0 10px 24px rgba(0, 0, 0, .4);
    --pop: 0 22px 60px rgba(0, 0, 0, .55), 0 0 0 .5px var(--line-2);
    --c-plain: #e6edf3; --c-kw: #ff7b72; --c-str: #a5d6ff; --c-num: #79c0ff; --c-com: #6e7681;
    --c-tag: #7ee787; --c-attr: #d2a8ff; --c-fn: #d2a8ff; --c-prop: #79c0ff;
  }
  :root:not([data-theme="light"]) .brand img { filter: invert(1); }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111216; --surface: #17191e; --surface-2: #1c1f25; --sunk: #0d0e11; --field: #22252c;
  --bar: rgba(17, 18, 22, .92); --bar-line: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .15);
  --ink: #f5f7fa; --ink-2: #a4a9b4; --ink-3: #747a87;
  --hover: rgba(255, 255, 255, .06); --fill: rgba(255, 255, 255, .08);
  --accent: #a29cc9; --accent-soft: rgba(162, 156, 201, .16); --accent-ink: #b9b4dc;
  --primary: #f5f7fa; --primary-hover: #dde1e8; --primary-ink: #17191e;
  --green: #30d158; --green-ink: #30d158; --green-soft: rgba(48, 209, 88, .16);
  --orange: #ff9f0a; --orange-soft: rgba(255, 159, 10, .16);
  --red: #ff453a; --red-soft: rgba(255, 69, 58, .16);
  --board: #0b0c0f;
  --panel: #131418; --panel-line: rgba(255, 255, 255, .07);
  --raise: inset 0 1px 0 rgba(255, 255, 255, .06), 0 0 0 .5px rgba(255, 255, 255, .1), 0 6px 16px -4px rgba(0, 0, 0, .5);
  --key: rgba(160, 170, 210, .075); --contact: rgba(0, 0, 0, .75);
  --screen: #0b1018; --screen-glow: #202c3e; --screen-ink: #f1f3f8; --screen-dim: #9aa3b5;
  --screen-ghost: rgba(255, 255, 255, .09); --screen-ghost-2: rgba(255, 255, 255, .045); --screen-grid: rgba(255, 255, 255, .07);
  --screen-edge: rgba(255, 255, 255, .12);
  --shadow: 0 0 0 .5px var(--line-2), 0 10px 24px rgba(0, 0, 0, .4);
  --pop: 0 22px 60px rgba(0, 0, 0, .55), 0 0 0 .5px var(--line-2);
  --c-plain: #e6edf3; --c-kw: #ff7b72; --c-str: #a5d6ff; --c-num: #79c0ff; --c-com: #6e7681;
  --c-tag: #7ee787; --c-attr: #d2a8ff; --c-fn: #d2a8ff; --c-prop: #79c0ff;
}
:root[data-theme="dark"] .brand img { filter: invert(1); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 13px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:is(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, .mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* MARK: shell */
.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: 48px minmax(0, 1fr); overflow: hidden; }
.bar { position: relative; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--bar-line); background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); min-width: 0; }
.brand { display: flex; align-items: center; padding: 6px; border-radius: 999px; color: var(--ink); text-decoration: none; flex: none; }
.brand:hover { background: var(--hover); }
.brand img { width: 18px; height: 18px; display: block; }
.brand b { margin-left: 6px; font-size: 17px; font-weight: 750; letter-spacing: -.06em; line-height: 1; }
.brand:has(b) { padding-right: 10px; }
.slash { color: var(--line-2); font-size: 18px; font-weight: 300; margin: 0 -3px; flex: none; }
.crumb { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: none; font-weight: 600; white-space: nowrap; min-width: 0; }
.crumb-name { overflow: hidden; text-overflow: ellipsis; }
/* The card name keeps its width; the declaration chip gives way first. */
.bar > .crumb { flex: 0 0 auto; max-width: 280px; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--fill); color: var(--ink-2); font: 500 11.5px/1 var(--mono); white-space: nowrap; min-width: 0; max-width: 300px; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.chip.soft { background: none; box-shadow: none; padding: 0 6px; color: var(--ink-3); }
button.chip.soft:hover { color: var(--ink-2); }
button.chip:hover { color: var(--ink); background: var(--hover); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; padding: 0 14px; border-radius: 999px; border: 0; background: none; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--ink); transition: background .2s var(--ease), color .2s var(--ease), box-shadow .3s var(--ease), transform .12s var(--ease); flex: none; }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn.icon { width: 32px; padding: 0; }
.btn.ghost { color: var(--ink-2); }
.btn.ghost:hover, .btn.ghost[aria-pressed="true"] { background: var(--fill); color: var(--ink); }
.btn.line { background: var(--fill); }
.btn.line:hover { background: color-mix(in srgb, var(--fill) 100%, var(--line-2)); }
.btn.primary { color: var(--primary-ink); background: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.wide { display: flex; width: 100%; height: 44px; margin-top: 20px; font-size: 15px; }
.vsep { width: 1px; height: 20px; background: var(--line-2); margin: 0 2px; flex: none; }
.link-button { border: 0; background: none; padding: 0; color: var(--accent-ink); font-size: 12.5px; }
.link-button:hover { text-decoration: underline; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--fill); flex: none; }
.seg button { height: 26px; padding: 0 13px; border: 0; border-radius: 999px; background: none; color: var(--ink-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; transition: background .2s var(--ease), color .2s var(--ease); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 6px rgba(0, 0, 0, .08), 0 0 0 .5px var(--line); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-3); }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.warn { background: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.dot.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot.idle { background: none; box-shadow: inset 0 0 0 1.5px var(--ink-3); }

.health { display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; flex: none; }
.health:hover, .health[aria-expanded="true"] { background: var(--hover); }
.meter { width: 56px; height: 5px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.meter i { display: block; width: 0; height: 100%; border-radius: 3px; background: var(--green); transition: width .3s; }
.meter i.over { background: var(--red); }
.health b { font: 600 12px var(--mono); color: var(--ink); margin-right: -5px; }
.health .meter, .health b, .health .health-limit { display: none; }

/* MARK: work area */
.work { --side: 264px; position: relative; background: var(--board); display: grid; grid-template-columns: var(--side) minmax(0, 1fr) 0; min-height: 0; transition: grid-template-columns .28s cubic-bezier(.2, .8, .3, 1); }
.work.open { grid-template-columns: var(--side) minmax(0, 1fr) min(560px, 44vw); }
.work.side-off { --side: 0px; }

/* MARK: sidebar */
.side { display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 0; overflow: auto; padding: 10px 8px 24px; border-right: 1px solid var(--panel-line); background: var(--panel); overscroll-behavior: contain; }
.work.side-off .side { visibility: hidden; }
.side-open { flex: none; margin: 2px 4px 10px; }
.side-sec { padding-bottom: 8px; }
.side-sec + .side-sec { border-top: 1px solid var(--panel-line); padding-top: 8px; }
.side-sec[hidden] + .side-sec { border-top: 0; padding-top: 0; }
.side-h { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; }
.side-h h4 { flex: 1; margin: 0; font-size: 12px; font-weight: 600; color: var(--ink); }
.side-sub { font-size: 11px; color: var(--ink-3); }
.side-account { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 11px; color: var(--ink-3); }
.side-account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-account button { border: 0; background: none; padding: 0; color: var(--accent-ink); font-size: 11px; }
.side-note { margin: 2px 8px 8px; color: var(--ink-3); font-size: 12px; line-height: 1.6; }
.side-note .link-button { font-size: 12px; }
.side-list { display: flex; flex-direction: column; gap: 2px; }
.item { position: relative; }
.item-main { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 12px; width: 100%; padding: 6px; border: 0; border-radius: 12px; background: none; text-align: left; }
.item-main { transition: background-color .15s var(--ease), box-shadow .15s var(--ease); }
.item-main:hover { background: var(--hover); }
.item-main[aria-current="true"] { background: var(--surface); box-shadow: var(--raise); }
.item-th { position: relative; display: grid; place-items: center; width: 84px; height: 54px; border-radius: 10px; overflow: hidden; background: var(--screen); background-image: radial-gradient(ellipse at 36% 0, var(--screen-glow), transparent 70%); box-shadow: inset 0 0 0 .5px var(--screen-edge), 0 0 0 .5px rgba(0, 0, 0, .25), 0 4px 10px -2px rgba(34, 38, 51, .28); }
.item-main[aria-current="true"] .item-th { box-shadow: 0 0 0 1.5px var(--accent), 0 4px 10px -2px rgba(34, 38, 51, .28); }
.item-th iframe { pointer-events: none; }
.item-th:has(.th-shot) { background: none; box-shadow: none; border-radius: 0; }
.item-main[aria-current="true"] .item-th:has(.th-shot) { box-shadow: none; }
.th-shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.th-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .th-light { display: none; }
  :root:not([data-theme="light"]) .th-dark { display: block; }
}
:root[data-theme="dark"] .th-light { display: none; }
:root[data-theme="dark"] .th-dark { display: block; }
.th-wait { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .18); border-top-color: rgba(255, 255, 255, .55); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.item-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-right: 22px; }
.item-text b { font-size: 13px; font-weight: 550; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-text small { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-text small.mono { font: 10.5px var(--mono); }
.item-text .st.public { color: var(--green-ink); }
.item-text .st.pending { color: var(--orange); }
.item-text .st.rejected { color: var(--red); }
.item-more { position: absolute; right: 4px; top: 50%; display: grid; place-items: center; width: 26px; height: 26px; margin-top: -13px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--ink-3); opacity: 0; }
.item-more svg { width: 14px; height: 14px; fill: currentColor; }
.item:hover .item-more, .item-more:focus-visible, .item-main[aria-current="true"] + .item-more { opacity: 1; }
.item-more:hover { background: var(--fill); color: var(--ink); }
.pop.menu { width: 188px; padding: 6px; }
.pop.menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none; text-align: left; font-size: 13px; color: var(--ink); }
.pop.menu button:hover, .pop.menu button:focus-visible { background: var(--hover); outline: 0; }
.pop.menu button.danger { color: var(--red); }
.stage { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; min-width: 0; background: radial-gradient(ellipse 60% 55% at 50% 52%, var(--key), transparent 78%); }
.tools { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tools .lbl { color: var(--ink-3); font-size: 12px; flex: none; }
.tools-hint { display: flex; align-items: center; gap: 10px; margin-left: 6px; color: var(--ink-3); font-size: 12px; white-space: nowrap; flex: none; }
.crumb { cursor: default; }
.board { position: relative; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 30px 28px; padding: 34px 28px 28px; min-height: 0; overflow: auto; }
.board-message { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; color: var(--ink-3); text-align: center; }
/* Devices get their size from the sample data and the first card. Until both are in, they lay out
   and load invisibly behind the message, so no half-sized frames show. */
.board:has(> .board-message) > :not(.board-message) { visibility: hidden; }
.board-empty > div { max-width: 340px; }
.empty-title { margin: 0; font-size: 17px; font-weight: 600; color: var(--ink); }
.empty-note { margin: 8px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-3); }
.empty-actions { display: flex; justify-content: center; gap: 10px; margin: 18px 0 8px; }
@media (hover: none) and (pointer: coarse) { .empty-drop { display: none; } }
/* The data switches have nothing to act on until a card is in. */
.stage:has(#board-empty) > .tools, body:has(#board-empty) #health { visibility: hidden; }
.br { flex-basis: 100%; height: 0; }

/* MARK: device (preview-engine.js) */
.device { position: relative; flex: none; }
.device-surface { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.device-screen { position: absolute; overflow: hidden; background: var(--screen); background-image: radial-gradient(ellipse at 36% 0, var(--screen-glow), transparent 65%);
  /* Cover the antialiased aperture underneath the mockup, outside the scroll area. */
  box-shadow: 0 0 0 6px var(--screen); }
.device-page { position: relative; height: 100%; overflow: auto; overscroll-behavior: contain; scrollbar-width: none; }
.device-page::-webkit-scrollbar { display: none; }
.device-art { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(21, 21, 30, .14)) drop-shadow(0 22px 30px rgba(41, 51, 68, .2)); }
.device-heading { position: absolute; left: var(--row-left); top: var(--title-top); color: var(--screen-ink); font-size: var(--title-size); font-weight: 650; line-height: 1.2; white-space: nowrap; }
.device-grid { position: absolute; pointer-events: none; border-radius: 10px; background: repeating-linear-gradient(to right, var(--screen-grid) 0 var(--grid-unit), transparent var(--grid-unit) var(--grid-step)); }
.device-strip { position: absolute; }
.device-ghost { position: absolute; overflow: hidden; pointer-events: none; -webkit-mask: linear-gradient(#000 30%, transparent); mask: linear-gradient(#000 30%, transparent); }
.device-ghost i { display: block; width: calc(var(--ghost-tile) * 1.1); height: var(--ghost-title); margin-bottom: calc(var(--ghost-title) * .9); border-radius: 999px; background: var(--screen-ghost); }
.device-ghost div { display: flex; gap: var(--ghost-gap); margin-bottom: var(--ghost-section); }
.device-ghost b { flex: none; width: var(--ghost-tile); aspect-ratio: 2 / 3; border-radius: calc(var(--ghost-tile) * .09); background: linear-gradient(var(--screen-ghost), var(--screen-ghost-2)); }
.device-strip iframe { display: block; position: absolute; left: 0; top: 0; border: 0; opacity: 0; transition: opacity .2s; }
.device-strip iframe.ready { opacity: 1; }
/* A shared Home backdrop makes the four author examples comparable. */
.device .device-screen.has-example-backdrop {
  background: linear-gradient(color-mix(in srgb, var(--screen) 72%, transparent), color-mix(in srgb, var(--screen) 72%, transparent)),
    url("media/backdrop-1.jpg") center / cover;
}
.device-strip iframe[data-material] {
  background-color: color-mix(in srgb, var(--screen) 55%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: inset 0 0 0 1px var(--screen-edge);
}
.device-strip iframe[data-material="clear-glass"] {
  background-color: color-mix(in srgb, var(--screen) 16%, transparent);
  -webkit-backdrop-filter: blur(4px) saturate(1.12);
  backdrop-filter: blur(4px) saturate(1.12);
}
.device-strip.is-rail { display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; padding-bottom: 12px; scrollbar-width: thin; scrollbar-color: #8b90a4 transparent; }
.device-strip.is-rail iframe { position: relative; flex: none; scroll-snap-align: start; }
.device-boot { position: absolute; inset: 0; display: grid; place-items: center; padding: 10%; color: var(--screen-dim); font-size: 12px; line-height: 1.5; text-align: center; pointer-events: none; }
.device-nav { position: absolute; left: 50%; bottom: 9%; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 1px; max-width: 86%; padding: 7px 14px; border-radius: 11px; background: rgba(20, 20, 28, .86); color: #fff; font-size: 12px; white-space: nowrap; transform: translateX(-50%); backdrop-filter: blur(10px); box-shadow: 0 6px 20px rgba(0, 0, 0, .35); cursor: pointer; animation: rise .2s ease; }
.device-nav span { font-size: 10.5px; color: #b9b4ff; }
.device-nav strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.device.is-bare .device-screen { background: none; box-shadow: none; }
/* Mac: a Rex window with the macOS frame, traffic lights in the content's title area. */
.device.is-window .device-screen { box-shadow: none; }
.device-window { position: absolute; inset: 0; border-radius: 16px; pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--screen-edge), 0 0 0 1px rgba(0, 0, 0, .35), 0 28px 80px -12px rgba(0, 0, 0, .45); }
.device-window i { position: absolute; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .2); }
.device-window i:nth-child(1) { left: 20px; }
.device-window i:nth-child(2) { left: 40px; background: #febc2e; }
.device-window i:nth-child(3) { left: 60px; background: #28c840; }

/* MARK: board figures */
.dev { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: zoom-in; min-width: 0; }
.dev .device { isolation: isolate; transition: transform .25s cubic-bezier(.3, .7, .4, 1); }
.dev .device::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: -3.5%; height: 7%; z-index: -1; border-radius: 50%; background: radial-gradient(closest-side, var(--contact), transparent); filter: blur(5px); transition: transform .25s cubic-bezier(.3, .7, .4, 1), opacity .25s; }
.board:not(.focus) .dev:hover .device::after { transform: translateY(3px) scaleX(.96); opacity: .75; }
.board:not(.focus) .dev:hover .device { transform: translateY(-4px); }
.dev figcaption { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.dev-cap { display: flex; align-items: center; gap: 8px; height: 24px; padding: 0 8px; border: 0; border-radius: 7px; background: none; color: inherit; font-size: 12px; }
.dev-cap:hover { background: var(--hover); }
.dev-cap b { color: var(--ink); font-weight: 550; }
.dev-cap .dot { width: 6px; height: 6px; }
.dev-size { color: var(--ink-3); font-size: 11px; }
.board:not(.focus) .dev:not(:hover) :is(.dev-size, .dev-status) { display: none; }
.board:not(.focus) .dev:not(:hover) .dev-cap .dot:is(.ok, .idle) { display: none; }
.dev.is-paired .dev-status { color: var(--accent-ink); font-weight: 550; }
.board.focus { align-content: center; gap: 12px 8px; padding-right: 296px; }
.board.focus .dev { order: 1; gap: 4px; padding: 6px 8px 4px; border-radius: 10px; cursor: pointer; }
.board.focus .dev:hover { background: var(--hover); }
.board.focus .dev.is-focused { order: 0; flex-basis: 100%; gap: 10px; padding: 0 0 6px; background: none; cursor: default; }
.board.focus .dev:not(.is-focused) iframe { pointer-events: none; }
.board.focus .dev:not(.is-focused) :is(.dev-status, .dev-size, .dot, .device-nav, .device-boot) { display: none; }
.board.focus .dev:not(.is-focused) .dev-cap { height: 18px; padding: 0; font-size: 11px; pointer-events: none; }
.board.focus .dev:not(.is-focused) .dev-cap b { font-weight: 500; color: var(--ink-2); }

.inspect { position: absolute; right: 18px; top: 58px; width: 262px; max-height: calc(100% - 76px); padding: 14px; overflow: auto; border-radius: 18px; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(16px); box-shadow: var(--shadow); font-size: 12px; }
.inspect h5 { margin: 0 0 8px; font-size: 11px; color: var(--ink-3); font-weight: 600; }
.inspect dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.inspect dt { color: var(--ink-3); }
.inspect dd { margin: 0; font-family: var(--mono); font-size: 11.5px; text-align: right; overflow-wrap: anywhere; }
.inspect .ev { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.inspect ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.inspect li { display: grid; gap: 1px; line-height: 1.45; color: var(--ink-2); overflow-wrap: anywhere; }
.inspect li code { font-size: 11px; color: var(--accent-ink); }
.inspect li.err span { color: var(--red); }
.inspect li.empty { color: var(--ink-3); }
.inspect-switches { display: grid; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-2); }
.inspect-switches label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.inspect-switches input { accent-color: var(--accent); margin: 0; }
.raw { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.raw summary { cursor: pointer; color: var(--ink-2); font-weight: 550; }
.raw .seg { margin: 10px 0 8px; }
.raw .seg button { height: 22px; padding: 0 8px; font: 500 11px var(--mono); }
.raw pre { margin: 0; max-height: 300px; overflow: auto; padding: 10px; border-radius: 8px; background: var(--sunk); font: 10.5px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* MARK: drawer */
.drawer { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--surface); border-left: 1px solid var(--panel-line); }
.drawer-head { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); font-weight: 600; flex: none; min-width: 0; }
.drawer-head .dim { color: var(--ink-3); font-weight: 400; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12px; flex: none; min-width: 0; }
.editor-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.drawer-foot .mono { flex: none; font-size: 11px; }
.pane { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.code-host { position: relative; flex: 1; min-height: 0; display: flex; background: var(--surface-2); }
.rx-code { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; }
.rx-code > textarea, .rx-code-hl { margin: 0; border: 0; padding: 14px 18px; font: 12px/19px var(--mono); tab-size: 2; white-space: pre; font-variant-ligatures: none; }
.rx-code > textarea { position: relative; z-index: 1; flex: 1; resize: none; background: transparent; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--accent); overflow: auto; outline: 0; }
.rx-code > textarea::selection { background: var(--accent-soft); }
.rx-code-hl { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: var(--c-plain); }
.rx-code-hl .c-kw { color: var(--c-kw); } .rx-code-hl .c-str { color: var(--c-str); } .rx-code-hl .c-num { color: var(--c-num); }
.rx-code-hl .c-com { color: var(--c-com); font-style: italic; } .rx-code-hl .c-tag { color: var(--c-tag); } .rx-code-hl .c-attr { color: var(--c-attr); }
.rx-code-hl .c-fn { color: var(--c-fn); } .rx-code-hl .c-prop { color: var(--c-prop); }

.dp-search { display: flex; align-items: center; gap: 8px; margin: 12px 14px 4px; padding: 0 12px; height: 34px; border-radius: 12px; background: var(--field); color: var(--ink-3); flex: none; }
.dp-search svg { width: 14px; height: 14px; flex: none; }
.dp-search input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; font-size: 13px; color: var(--ink); }
.dp-results { flex: 1; overflow: auto; padding: 6px 8px 32px; }
.dp-item { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 13px; }
.dp-item:hover { background: var(--hover); }
.dp-item b { font-weight: 550; }
.dp-item span { display: block; margin-top: 2px; color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.dp-none { margin: 10px; color: var(--ink-3); font-size: 12px; }
.dp-body { flex: 1; overflow: auto; padding: 4px 18px 40px; scroll-padding-top: 12px; }
.doc-toc { margin: 8px 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.doc-toc h6 { margin: 8px 0 6px; font-size: 11px; color: var(--ink-3); font-weight: 600; }
.doc-toc .toc ul { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 14px; }
.doc-toc li { margin: 0; break-inside: avoid; }
.doc-toc a { display: inline-block; padding: 3px 0; color: var(--ink-2); text-decoration: none; font-size: 12.5px; }
.doc-toc a:hover { color: var(--accent-ink); }
.doc-download { margin-top: 8px; color: var(--ink-3) !important; font-size: 12px !important; }

.md { font-size: 13.5px; line-height: 1.8; color: var(--ink-2); overflow-wrap: anywhere; }
.md h2 { margin: 30px 0 12px; font-size: 19px; letter-spacing: -.015em; color: var(--ink); line-height: 1.35; scroll-margin-top: 12px; }
.md h2:first-child { margin-top: 6px; }
.md h3, .md h4 { margin: 22px 0 8px; font-size: 14.5px; color: var(--ink); scroll-margin-top: 12px; }
.md p { margin: 0 0 12px; }
.md a { color: var(--accent-ink); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md strong, .md b { color: var(--ink); }
.md code { padding: 1px 5px; border-radius: 5px; background: var(--fill); color: var(--ink); font-size: .88em; }
.md pre { position: relative; margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: auto; font: 11.5px/1.7 var(--mono); color: var(--c-plain); }
.md pre code { padding: 0; background: none; font-size: inherit; color: inherit; }
.code-copy { position: absolute; top: 6px; right: 6px; height: 24px; padding: 0 8px; border: 0; border-radius: 6px; background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); color: var(--ink-2); font: 500 11px var(--sans); opacity: 0; transition: opacity .15s; }
.md pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 20px; }
.md li { margin: 3px 0; }
.md .table-scroll { overflow: auto; margin: 0 0 14px; }
.md table { width: 100%; min-width: 420px; border-collapse: collapse; font-size: 12.5px; }
.md th, .md td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { color: var(--ink-3); font-weight: 600; font-size: 11.5px; }
.md blockquote { margin: 0 0 12px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; color: var(--ink); }

/* MARK: overlays */
.drop-overlay { position: fixed; inset: 10px; z-index: 70; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 2px dashed var(--accent); border-radius: 18px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(4px); color: var(--accent-ink); pointer-events: none; }
.drop-overlay.active { display: flex; }
.drop-overlay strong { font-size: 22px; letter-spacing: -.02em; }
.drop-overlay span { color: var(--ink-2); }
body:has(.drop-overlay.active) iframe { pointer-events: none; }
.pop { position: fixed; z-index: 40; width: min(360px, calc(100vw - 16px)); max-height: calc(100vh - 80px); overflow: auto; padding: 6px; border-radius: 18px; background: var(--surface); box-shadow: var(--pop); }
.pop h4 { margin: 6px 8px 8px; font-size: 11px; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.check { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 12px; background: none; text-align: left; }
.check:hover { background: var(--hover); }
.check .v { color: var(--ink-3); font: 11.5px var(--mono); white-space: nowrap; text-align: right; }
.check .v i { display: block; font: 500 11px var(--sans); font-style: normal; color: var(--accent-ink); opacity: 0; }
.check:hover .v i, .check:focus-visible .v i { opacity: 1; }
.check small { display: block; color: var(--ink-3); font-size: 11.5px; line-height: 1.5; overflow-wrap: anywhere; }
.pop-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 8px 6px 4px; border-top: 1px solid var(--line); }
.pop-foot span { flex: 1; color: var(--ink-3); font-size: 11.5px; line-height: 1.5; }
.pop-foot .btn { height: 28px; font-size: 12px; }
.toast { position: fixed; left: 50%; top: 64px; z-index: 80; max-width: calc(100vw - 32px); padding: 9px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 12.5px; box-shadow: var(--pop); transform: translateX(-50%); animation: rise .2s ease; pointer-events: none; }
.toast:empty { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(var(--rise-x, 0), 8px) scale(.985); } }
.toast, .device-nav { --rise-x: -50%; }

/* MARK: sheets */
/* Dialogs take focus themselves (autofocus), so opening one by touch rings no button. */
.sheet-dialog:focus { outline: none; }
.sheet-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: 24px; background: var(--surface); color: var(--ink); box-shadow: var(--pop); overflow: auto; }
.sheet-dialog[open] { animation: rise .22s cubic-bezier(.2, .8, .3, 1); }
.sheet-dialog::backdrop { background: rgba(10, 10, 14, .38); backdrop-filter: blur(2px); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 18px 12px 2px 24px; }
.sheet-head h3 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.03em; flex: 1; }
.sheet-body { padding: 8px 22px 22px; }
.sheet-body > p, .share-lead { margin: 0 0 12px; color: var(--ink-2); line-height: 1.65; }
.sheet-dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.input-label { display: block; margin: 16px 0 6px; color: var(--ink-2); font-size: 12px; font-weight: 550; }
.text-input { display: block; width: 100%; min-width: 0; height: 44px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--field); color: var(--ink); font-size: 15px; outline: 0; transition: box-shadow .2s var(--ease); }
.text-input:focus { box-shadow: 0 0 0 2px var(--accent); }
.text-input::placeholder { color: var(--ink-3); }
.micro-note { margin: 12px 0 0; color: var(--ink-3); font-size: 12px; line-height: 1.7; }
.sheet-warn { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--orange-soft); color: var(--ink); font-size: 12.5px; line-height: 1.6; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 12px; }
.steps li { position: relative; padding-left: 34px; color: var(--ink-2); line-height: 1.6; counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 11.5px; font-weight: 650; }
.steps b { display: block; color: var(--ink); }
.steps code { padding: 1px 5px; border-radius: 5px; background: var(--fill); font-size: 11.5px; }
.phone-pair { display: flex; gap: 18px; align-items: flex-start; }
.phone-pair > img { width: 148px; height: 148px; flex: none; border-radius: 10px; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.phone-pair > div { min-width: 0; }
.phone-pair p { margin: 0 0 10px; color: var(--ink-2); line-height: 1.6; }
.phone-pair .btn.primary { margin: 0 10px 10px 0; }

/* Upload to Rex (template-share.js). */
.share-form .input-label:first-child, .share-form .share-bound + .input-label { margin-top: 4px; }
.share-id-input { display: flex; align-items: center; height: 44px; padding: 0 16px; border-radius: 12px; background: var(--field); font-size: 15px; }
.share-id-input:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.share-id-input span { color: var(--ink-3); white-space: nowrap; }
.share-id-input input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; outline: 0; }
.share-id-input input::placeholder { color: var(--ink-3); }
.share-id-hint { margin: 6px 0 0; color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.share-id-hint.ok { color: var(--green-ink); }
.share-id-hint.error { color: var(--red); }
.share-code-input { height: 52px; font: 600 22px/1 var(--mono); letter-spacing: .4em; text-align: center; }
.share-links { display: flex; gap: 18px; margin-top: 14px; }
.share-links button, .share-account button, #share-unbind { border: 0; background: none; padding: 0; color: var(--accent-ink); font-size: 12px; }
.share-links button:disabled { color: var(--ink-3); }
.share-account { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-3); }
.share-bound { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center; margin-bottom: 14px; padding: 14px 16px; border-radius: 18px; background: var(--accent-soft); font-size: 12px; color: var(--ink-2); }
.share-bound > div { grid-column: 1 / -1; display: flex; gap: 8px; align-items: baseline; }
.share-bound strong { color: var(--ink); font-weight: 600; }
.share-bound small { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.share-bound label { display: flex; gap: 6px; align-items: center; color: var(--ink); }
.share-bound input { accent-color: var(--accent); }
.share-bound #share-unbind { grid-column: 2; grid-row: 2; justify-self: end; }
.share-bound-review { grid-column: 1 / -1; margin: 2px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
.share-bound-review.public { color: var(--green-ink); }
.share-bound-review.rejected { color: var(--red); }
.share-bound-review button { margin-left: 6px; border: 0; background: none; padding: 0; color: var(--accent-ink); font-size: 12px; }
.share-note { height: auto; min-height: 76px; padding-top: 10px; padding-bottom: 10px; resize: vertical; font: inherit; line-height: 1.55; }
.share-bound code { font: 12px var(--mono); letter-spacing: .04em; }
.share-state { align-self: start; max-width: 220px; padding: 3px 10px; border-radius: 999px; overflow: hidden; background: var(--fill); color: var(--ink-2); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.share-state.public { background: var(--green-soft); color: var(--green-ink); }
.share-state.pending { background: var(--orange-soft); color: var(--orange); }
.share-state.rejected { background: var(--red-soft); color: var(--red); }
.share-kicker { margin: 0 0 14px; color: var(--green-ink); font-size: 13px; font-weight: 600; }
.share-id { display: flex; align-items: baseline; gap: 12px; padding: 20px; border-radius: 18px; background: var(--accent-soft); }
.share-id span { font-size: 12px; color: var(--ink-2); }
.share-id strong { font: 650 28px/1 var(--mono); letter-spacing: .08em; color: var(--ink); }
.share-id button { margin-left: auto; border: 0; background: none; color: var(--accent-ink); font-size: 12px; }
.share-link { display: flex; align-items: center; gap: 12px; margin: 12px 0 16px; }
.share-link a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent-ink); font-size: 13px; }
.share-status { margin: 14px 0 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.6; }
.share-status:empty { display: none; }
.share-status.error { color: var(--red); }
.noscript-note { position: fixed; inset: auto 0 24px; text-align: center; color: var(--ink-2); }

/* MARK: narrow windows */
@media (max-width: 1240px) {
  .tools-hint-text { display: none; }
  .bar .btn.ghost .label { display: none; }
  .bar .btn.ghost { width: 32px; padding: 0; }
}
@media (max-width: 960px) {
  .work, .work.open, .work.side-off { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: 48px; left: 0; bottom: 0; z-index: 31; width: min(300px, 86vw); transform: none; transition: transform .26s cubic-bezier(.2, .8, .3, 1), visibility .26s; box-shadow: var(--pop); }
  .work.side-off .side { transform: translateX(-100%); }
  .drawer { position: fixed; top: 48px; right: 0; bottom: 0; z-index: 30; width: min(100vw, 560px); transform: translateX(100%); transition: transform .26s cubic-bezier(.2, .8, .3, 1); box-shadow: var(--pop); }
  .work.open .drawer { transform: none; }
  .board.focus { padding-right: 28px; padding-bottom: 300px; }
  .inspect { top: auto; bottom: 14px; left: 16px; right: 16px; width: auto; max-height: 270px; }
  .health-limit, .meter, .bar .chip { display: none; }
}
@media (max-width: 720px) {
  .bar { gap: 4px; padding-left: 8px; }
  .slash, .vsep, #health-label, #health-kb, .bar .btn.line .label, .bar a.btn, #open-docs { display: none; }
  .crumb { padding: 0 6px; }
  .bar .btn.line { width: 32px; padding: 0; }
  .bar .btn.primary .label { font-size: 12px; }
  .tools { padding: 12px 12px 0; gap: 8px; }
  .board { padding: 14px 16px 24px; align-content: flex-start; }
  .board:not(.focus) { flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-items: center; }
  .phone-pair { flex-direction: column; align-items: center; text-align: center; }
  /* Phones keep only what they can act on: no card name, no file download; the tool row scrolls. */
  .bar > .crumb, #open-export { display: none; }
  .tools .lbl { display: none; }
}
/* Already on a phone: previewing on "your phone" has nothing to connect. */
@media (max-width: 720px) and (hover: none) and (pointer: coarse) {
  #connect-phone { display: none; }
}

/* Login methods reuse the workbench's buttons and typography. */
.share-login-methods { display: grid; gap: 10px; margin-top: 20px; }
.share-login-methods .btn.wide { margin-top: 0; }
.share-qr { display: flex; align-items: center; gap: 20px; padding: 16px; border-radius: 16px; background: var(--fill); }
.share-qr[hidden] { display: none; }
.share-qr-image { position: relative; flex: none; width: 160px; height: 160px; display: grid; place-items: center; border-radius: 12px; background: #fff; }
.share-qr-image img { display: block; width: 100%; height: 100%; border-radius: 12px; transition: opacity .2s var(--ease), filter .2s var(--ease); }
.share-qr-image img[hidden] { display: none; }
.share-qr.expired .share-qr-image img { opacity: .12; filter: blur(2px); }
.share-qr-image .btn { position: absolute; }
.share-qr-image .btn[hidden] { display: none; }
.share-qr-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.share-qr-text .micro-note { margin-top: 6px; }
#share-step-login .micro-note a { color: var(--accent-ink); }
@media (max-width: 480px) { .share-qr { flex-direction: column; text-align: center; } }
