/* =============================================================================
   Excel Stitcher: app styles. Built on the UI library's tokens (css/tokens.css,
   css/theme.css): every colour, radius, space and type size comes from there.
   Source hues (--hue) are the only colours not from the theme.
   ========================================================================== */
:root {
  --drop: #3B82F6;                       /* drag-and-drop highlight (library --indicator-active) */
  --drop-soft: color-mix(in srgb, var(--drop) 14%, transparent);
  --panel-w: 320px; --insp-w: 460px; --top-h: 52px; --footer-h: 32px;
}
html, body, #root { height: 100%; }
/* Own the page: a host (e.g. an embedding viewer) may inject plain body/button styles. */
html body, .app { background: var(--bg); color: var(--text-primary); font-family: var(--font-sans); font-size: var(--text-md); line-height: 1.5; letter-spacing: var(--tracking-body); }
:where(.app) :is(button, input, select, textarea) { font-family: inherit; letter-spacing: inherit; color: inherit; }
:where(.app) button { font-size: var(--text-base); line-height: 1.2; }
body { overflow: hidden; }
button { font: inherit; }
.grow { flex: 1; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }
.mono { font-family: var(--font-mono); }
.err { color: var(--danger); }
.warn { color: var(--warning); }
.pad { padding: var(--space-3); }
.eyebrow { font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); color: var(--text-muted); }
.dot { width: 9px; height: 9px; border-radius: 3px; background: var(--hue, var(--text-muted)); flex: none; display: inline-block; }
.ic { flex: none; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-hover); border-top-color: var(--text-primary); animation: eui-spin .8s linear infinite; display: inline-block; }

/* ---------- shared controls ---------- */
.ibtn { display: inline-grid; place-items: center; width: var(--icon-btn); height: var(--icon-btn); border: 1px solid transparent; border-radius: var(--radius-control); background: transparent; color: var(--text-secondary); transition: background var(--duration-fast), color var(--duration-fast); flex: none; }
.ibtn:hover:not(:disabled) { background: var(--accent-subtle); color: var(--text-primary); }
.ibtn:active:not(:disabled) { transform: scale(.94); }
.ibtn:disabled { opacity: .3; cursor: default; }
.eui-btn.danger, .eui-btn.danger-t { color: var(--danger); }
.eui-btn.primary { background: var(--accent); color: var(--on-accent); }
.eui-btn .cnt { font: var(--weight-medium) var(--text-2xs)/1 var(--font-mono); padding: 3px 6px; border-radius: var(--radius-full); background: rgba(var(--bg-rgb), .22); margin-left: 2px; }
.field { display: flex; align-items: center; gap: var(--space-2); height: var(--control-h-md); padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-raised); color: var(--text-muted); transition: border-color var(--duration-base), box-shadow var(--duration-base); }
.field:focus-within { border-color: var(--border-hover); box-shadow: 0 0 0 3px var(--accent-subtle); color: var(--text-primary); }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: var(--text-base); color: var(--text-primary); height: 100%; }
.field input::placeholder { color: var(--text-muted); }
.field input[type=search]::-webkit-search-cancel-button { filter: invert(.5); }
.field-l { display: grid; gap: var(--space-1-5); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); }
.field-l.inl { display: flex; align-items: center; gap: var(--space-2); }
.eui-input.num { width: 90px; }
.chk { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; flex: none; cursor: pointer; }
.edit { border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm); color: var(--text-primary); padding: 3px 6px; margin: 0 -6px; min-width: 0; width: 100%; font-size: inherit; font-weight: inherit; letter-spacing: inherit; text-overflow: ellipsis; }
.edit:hover { border-color: var(--border); }
.edit:focus { outline: none; border-color: var(--border-hover); background: var(--surface-raised); box-shadow: 0 0 0 3px var(--accent-subtle); }
.edit.eui-input { margin: 0; padding: 0 var(--field-px); height: var(--field-h); border-color: var(--border); background: var(--surface-raised); }
.edit.eui-input:hover { border-color: var(--border-hover); }
.link { background: none; border: 0; padding: 0; color: var(--text-primary); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-hover); font-size: var(--text-sm); }
.link:hover { text-decoration-color: var(--text-primary); }
.badge { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); padding: 3px 6px; border-radius: var(--radius-badge); background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); white-space: nowrap; }
.grip { display: inline-grid; place-items: center; width: 18px; height: 24px; color: var(--text-subtle); cursor: grab; touch-action: none; user-select: none; border-radius: var(--radius-xs); flex: none; }
.grip:hover { color: var(--text-primary); background: var(--accent-subtle); }

/* segmented control */
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-control); background: var(--surface-raised); border: 1px solid var(--border); }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: var(--text-sm); font-weight: var(--weight-medium); white-space: nowrap; transition: background var(--duration-fast), color var(--duration-fast); }
.seg button:hover { color: var(--text-primary); }
.seg button.on { background: var(--accent); color: var(--on-accent); }

/* switch */
.switch { position: relative; width: 30px; height: 18px; border-radius: var(--radius-full); border: 1px solid var(--border-hover); background: var(--surface-raised); padding: 0; flex: none; transition: background var(--duration-base) var(--ease-soft); }
.switch i { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-secondary); transition: transform var(--duration-base) var(--ease-soft), background var(--duration-base); }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on i { transform: translateX(12px); background: var(--on-accent); }

/* ---------- top bar ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.top { height: var(--top-h); flex: none; display: flex; align-items: center; gap: var(--space-1-5); padding: 0 var(--space-4); border-bottom: 1px solid var(--border-subtle); background: var(--bg); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: var(--space-2-5); margin-right: var(--space-2); }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-md); background: var(--accent); color: var(--on-accent); }
.brand-t { font-weight: var(--weight-semibold); font-size: var(--text-lg); letter-spacing: var(--tracking-snug); white-space: nowrap; }
.summary { display: flex; align-items: center; gap: var(--space-2); margin-left: var(--space-3); padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-full); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-secondary); }
.summary .sep { color: var(--text-subtle); }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--text-subtle); }
.pip.good { background: var(--success); } .pip.warn { background: var(--warning); }

/* ---------- empty state ---------- */
.hero { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-8); padding: var(--space-8) var(--space-4); }
.drop { width: min(640px, 100%); text-align: center; padding: var(--space-12) var(--space-8); border: 1.5px dashed var(--border-hover); border-radius: var(--radius-3xl); background: rgba(var(--bg-rgb), .85); backdrop-filter: blur(var(--blur-sm)); }
.drop-ic { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto var(--space-5); border-radius: var(--radius-xl); border: 1px solid var(--border); background: var(--surface-raised); color: var(--text-primary); box-shadow: var(--shadow-glow); }
.drop h1 { font-size: var(--text-4xl); line-height: var(--leading-tight); margin-bottom: var(--space-3); }
.lead { color: var(--text-secondary); max-width: 46ch; margin: 0 auto var(--space-6); line-height: var(--leading-normal); }
.drop-btns { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }
.fine { margin-top: var(--space-5); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-muted); }
.note { display: flex; align-items: center; gap: var(--space-2); justify-content: center; margin-top: var(--space-4); font-size: var(--text-sm); color: var(--text-secondary); }
.busy { display: grid; gap: var(--space-3); justify-items: center; padding: var(--space-8); color: var(--text-secondary); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 220px)); gap: var(--space-4); }
.steps li { display: grid; gap: var(--space-1-5); font-size: var(--text-sm); color: var(--text-muted); line-height: var(--leading-snug); }
.steps b { color: var(--text-primary); font-weight: var(--weight-medium); font-size: var(--text-base); }
.steps .n { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-hover); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-secondary); }

/* ---------- workspace ---------- */
.work { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr) 0; transition: grid-template-columns var(--duration-slow) var(--ease-soft); }
.insp-open .work { grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--insp-w); }
.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--border-subtle); background: var(--bg); position: relative; }
.panel-h { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-4) var(--space-2-5); }
.panel-h h2 { font-size: var(--text-lg); margin-top: var(--space-1-5); }
.panel .field.search { margin: 0 var(--space-4); }
.hint { margin: var(--space-2) var(--space-4) var(--space-2-5); font-size: var(--text-xs); color: var(--text-muted); }
.panel-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 var(--space-4) var(--space-6); display: grid; gap: var(--space-3); align-content: start; }

/* source card */
.src { position: relative; display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-3) var(--space-3-5); border: 1px solid var(--border); border-radius: var(--radius-card); background: color-mix(in srgb, var(--hue) 4%, var(--surface)); box-shadow: inset 3px 0 0 var(--hue); transition: opacity var(--duration-base), border-color var(--duration-base); }
.src.dragging { opacity: .4; }
.src.ins-before::before, .src.ins-after::after, .card.ins-before::before, .card.ins-after::after, .collist li.ins-before::before, .collist li.ins-after::after { content: ""; position: absolute; z-index: 5; background: var(--drop); border-radius: 2px; pointer-events: none; }
.src.ins-before::before { left: 0; right: 0; top: -7px; height: 3px; } .src.ins-after::after { left: 0; right: 0; bottom: -7px; height: 3px; }
.src-h { display: flex; align-items: center; gap: var(--space-2); }
.src-h .grip { margin-left: -6px; }
.src-name { font-weight: var(--weight-semibold); font-size: var(--text-md); letter-spacing: var(--tracking-snug); }
.src-meta { display: flex; align-items: center; gap: var(--space-1-5); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-muted); }
.src-mode { display: flex; align-items: center; gap: var(--space-2); width: 100%; text-align: left; padding: var(--space-1-5) var(--space-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: rgba(var(--fg-rgb), .03); color: var(--text-secondary); font-size: var(--text-xs); transition: background var(--duration-fast), border-color var(--duration-fast); }
.src-mode span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-mode b { color: var(--text-primary); font-weight: var(--weight-medium); }
.src-mode:hover { background: var(--accent-subtle); border-color: var(--border-hover); }
.prog { height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--hue, var(--success)); border-radius: 2px; transition: width var(--duration-slow) var(--ease-soft); }
.prog.big { height: 6px; margin: var(--space-3) 0; } .prog.big i { background: var(--accent); }
.prog-t { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text-muted); }
.prog-a { display: inline-flex; gap: var(--space-1-5); }
.chips { list-style: none; margin: var(--space-1) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 28px; max-width: 100%; padding: 0 var(--space-2-5) 0 var(--space-2-5); border: 1px solid var(--border); border-left: 3px solid var(--hue); border-radius: var(--radius-sm); background: var(--surface-raised); font-size: var(--text-sm); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; transition: background var(--duration-fast), border-color var(--duration-fast), opacity var(--duration-fast), transform var(--duration-fast); }
.chip:hover { background: var(--surface-hover); border-color: var(--border-hover); border-left-color: var(--hue); }
.chip:active { cursor: grabbing; }
.chip-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.chip-m { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--text-muted); }
.chip-ok { display: inline-flex; align-items: center; gap: 2px; color: var(--success); font: var(--weight-medium) var(--text-2xs)/1 var(--font-mono); }
.chip.placed { opacity: .62; } .chip.placed:hover { opacity: 1; }
.chip.picked { border-color: var(--text-primary); border-left-color: var(--hue); background: var(--accent-subtle); opacity: 1; box-shadow: 0 0 0 1px var(--text-primary); }
.chip.dragging { opacity: .3; }
.more-toggle { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 2px 0; color: var(--text-secondary); font-size: var(--text-xs); text-align: left; }
.more-toggle .rot { transform: rotate(-90deg); } .more-toggle .ic { transition: transform var(--duration-fast); }
.src-empty { font-size: var(--text-sm); color: var(--text-muted); }
.adder { display: flex; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-4); border: 1.5px dashed var(--border); border-radius: var(--radius-card); background: transparent; color: var(--text-muted); font-size: var(--text-sm); transition: all var(--duration-base); }
.adder:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--accent-subtle); }
.remove-hint { position: absolute; inset: auto var(--space-3) var(--space-3); padding: var(--space-3); text-align: center; border: 1.5px dashed var(--danger); border-radius: var(--radius-card); background: color-mix(in srgb, var(--danger) 12%, var(--bg)); color: var(--danger); font-size: var(--text-sm); pointer-events: none; }
.sources.remove-over { box-shadow: inset 0 0 0 2px var(--danger); }

/* ---------- canvas ---------- */
.canvas { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.toolbar { display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-3) var(--space-4); flex-wrap: wrap; }
.toolbar .field.search { max-width: 360px; min-width: 180px; }
.count { font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-muted); white-space: nowrap; margin-left: auto; }
.selbar { display: flex; align-items: center; gap: var(--space-2); margin: 0 var(--space-4) var(--space-2); padding: var(--space-1-5) var(--space-2) var(--space-1-5) var(--space-4); border: 1px solid var(--border-hover); border-radius: var(--radius-card); background: var(--surface-raised); box-shadow: var(--shadow-subtle); font-size: var(--text-sm); }
.selbar b { font-weight: var(--weight-medium); margin-right: var(--space-2); }
.banner { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-3) var(--space-4) 0; padding: var(--space-2-5) var(--space-3-5); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); font-size: var(--text-base); }
.banner span { flex: 1; }
.canvas-scroll { flex: 1; min-height: 0; overflow: auto; padding: var(--space-1) var(--space-4) 96px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--space-3); align-items: start; }

/* output card */
.card { position: relative; display: grid; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); transition: border-color var(--duration-base), box-shadow var(--duration-base), opacity var(--duration-base); min-width: 0; }
.card:hover { border-color: var(--border-hover); }
.card.selected { border-color: var(--text-secondary); box-shadow: 0 0 0 1px var(--text-secondary); }
.card.active { border-color: var(--drop); box-shadow: 0 0 0 1px var(--drop); }
.card.dragging { opacity: .4; }
.card.ins-before::before { left: -8px; top: 0; bottom: 0; width: 3px; } .card.ins-after::after { right: -8px; top: 0; bottom: 0; width: 3px; }
.card-h { display: flex; align-items: center; gap: var(--space-1-5); padding: var(--space-2) var(--space-2) var(--space-1) var(--space-1-5); min-width: 0; }
.card-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; font-weight: var(--weight-semibold); font-size: var(--text-md); letter-spacing: var(--tracking-snug); }
.card-name .edit { width: auto; flex: 0 1 auto; field-sizing: content; min-width: 40px; max-width: 100%; }
.card-name .ext { color: var(--text-subtle); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); margin-left: 2px; }
.linked { display: inline-grid; place-items: center; color: var(--hue); margin-left: 4px; }
.slots { display: grid; gap: 6px; padding: var(--space-1) var(--space-2-5) var(--space-2-5); }
.card-f { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3-5); border-top: 1px solid var(--border-subtle); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-muted); min-width: 0; }
.status { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-subtle); flex: none; }
.status.good i { background: var(--success); } .status.warn i { background: var(--warning); }
.status.warn { color: var(--text-secondary); }
.adds { margin-left: auto; color: var(--warning); white-space: nowrap; }

/* slot */
.slot { position: relative; display: grid; gap: 4px; padding: 6px var(--space-2) 7px; border: 1px dashed var(--border); border-radius: var(--radius-md); background: transparent; transition: border-color var(--duration-fast), background var(--duration-fast), box-shadow var(--duration-fast); min-width: 0; }
.slot.full { border-style: solid; border-color: color-mix(in srgb, var(--hue) 38%, var(--border)); background: color-mix(in srgb, var(--hue) 6%, var(--surface)); }
.slot-l { display: flex; align-items: center; gap: 6px; font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.slot-b { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-height: 26px; }
.slot-empty { border: 0; background: none; padding: 0; color: var(--text-subtle); font-size: var(--text-sm); gap: 6px; text-align: left; }
.slot-empty:hover { color: var(--text-primary); }
.slot.targetable { border-style: solid; border-color: color-mix(in srgb, var(--hue) 70%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hue) 18%, transparent); animation: eui-pulse-subtle 1.6s ease-in-out infinite; }
.slot.over { border-color: var(--drop); background: var(--drop-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--drop) 28%, transparent); animation: none; }
.slot-cue { position: absolute; right: 8px; top: 50%; translate: 0 -50%; padding: 3px 9px; border-radius: var(--radius-full); background: var(--drop); color: #fff; font-size: var(--text-xs); font-weight: var(--weight-medium); pointer-events: none; }
.slot-split { position: absolute; inset: 0; z-index: 3; display: grid; grid-template-columns: 1fr 1fr; border-radius: var(--radius-md); overflow: hidden; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(2px); }
.slot-split .half { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); background: var(--drop-soft); border-right: 1px dashed var(--drop); }
.slot-split .half.rep { border-right: 0; background: color-mix(in srgb, var(--danger) 10%, transparent); }
.slot-split .half.on { background: var(--drop); color: #fff; } .slot-split .half.rep.on { background: var(--danger); }

/* sheet pill inside a slot */
.pill { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 26px; padding: 0 3px 0 var(--space-2); border-radius: var(--radius-sm); background: var(--surface-raised); border: 1px solid var(--border); font-size: var(--text-sm); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; transition: border-color var(--duration-fast), background var(--duration-fast); }
.pill:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.pill.active { border-color: var(--drop); }
.pill-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-m { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--text-muted); white-space: nowrap; }
.pill-adj { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--warning); white-space: nowrap; }
.pill-x { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--text-subtle); opacity: 0; transition: opacity var(--duration-fast); }
.pill:hover .pill-x, .pill:focus-within .pill-x, .pill:focus .pill-x { opacity: 1; }
.pill-x:hover { color: var(--danger); background: var(--accent-subtle); }
.slot-add { display: grid; place-items: center; width: 24px; height: 24px; border: 1px dashed var(--border-hover); border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); }
.slot-add:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.mode { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.mode:hover { background: var(--accent-subtle); color: var(--text-primary); }

/* "new output" card */
.card.new { place-items: center; align-content: center; gap: var(--space-1-5); min-height: 150px; padding: var(--space-6); border: 1.5px dashed var(--border); background: transparent; color: var(--text-muted); text-align: center; }
.card.new:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--accent-subtle); }
.new-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-raised); }
.new-t { font-weight: var(--weight-medium); font-size: var(--text-md); color: var(--text-primary); }
.new-s { font-size: var(--text-xs); }
.card.new.targetable { border-color: var(--drop); color: var(--drop); animation: eui-pulse-subtle 1.6s ease-in-out infinite; }
.card.new.over { background: var(--drop-soft); border-style: solid; animation: none; } .card.new.over .new-t { color: var(--drop); }
.empty-q { grid-column: 1 / -1; padding: var(--space-8); text-align: center; color: var(--text-muted); }

.remove-zone { position: absolute; left: 50%; bottom: var(--space-5); translate: -50% 0; display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-6); border: 1.5px dashed var(--danger); border-radius: var(--radius-full); background: color-mix(in srgb, var(--danger) 10%, var(--bg)); color: var(--danger); font-size: var(--text-base); font-weight: var(--weight-medium); z-index: 30; box-shadow: var(--shadow-elevated); }
.remove-zone.over { background: var(--danger); color: #fff; border-style: solid; }

/* ---------- list ("rows") view: same markup, laid out as a table ---------- */
.canvas[data-view=list] .canvas-scroll { --cols: minmax(250px, 300px) repeat(var(--ns), minmax(150px, 1fr)) 128px; }
.canvas[data-view=list] .cards { display: block; min-width: max-content; }
.canvas[data-view=list] .card { grid-template-columns: var(--cols); align-items: stretch; border-radius: 0; border-width: 0 0 1px; background: transparent; }
.canvas[data-view=list] .card:hover { background: var(--accent-subtle); }
.canvas[data-view=list] .card.selected { box-shadow: inset 3px 0 0 var(--text-secondary); }
.canvas[data-view=list] .card.active { box-shadow: inset 3px 0 0 var(--drop); }
.canvas[data-view=list] .slots { display: contents; }
.canvas[data-view=list] .slot { margin: var(--space-1-5) 3px; align-content: center; padding: 3px var(--space-1-5); }
.canvas[data-view=list] .slot-l { display: none; }
.canvas[data-view=list] .card-f { border: 0; justify-content: flex-start; padding-right: var(--space-3); }
.canvas[data-view=list] .adds, .canvas[data-view=list] .card-name .ext { display: none; }
.canvas[data-view=list] .card.ins-before::before { left: 0; right: 0; top: -2px; bottom: auto; width: auto; height: 3px; }
.canvas[data-view=list] .card.ins-after::after { left: 0; right: 0; bottom: -2px; top: auto; width: auto; height: 3px; }
.canvas[data-view=list] .card.new { min-height: 56px; grid-template-columns: auto 1fr; justify-items: start; display: flex; flex-direction: row; justify-content: flex-start; padding: var(--space-3); border-radius: var(--radius-md); margin-top: var(--space-3); }
.canvas[data-view=list] .new-ic { width: 28px; height: 28px; }
.list-head { position: sticky; top: calc(-1 * var(--space-1)); z-index: 6; display: grid; grid-template-columns: var(--cols); min-width: max-content; background: var(--bg); border-bottom: 1px solid var(--border); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.list-head > span { display: flex; align-items: center; gap: 8px; padding: var(--space-2-5) var(--space-3); }
.lh-name { padding-left: 38px !important; }

/* ---------- inspector ---------- */
.inspector { min-width: 0; overflow: hidden; border-left: 1px solid transparent; background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.inspector.open { border-left-color: var(--border-subtle); }
.inspector > * { width: var(--insp-w); max-width: 100vw; flex: none; }
.insp-h { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3-5) var(--space-3-5) var(--space-3); border-bottom: 1px solid var(--border-subtle); }
.m-title { flex: 1; min-width: 0; display: grid; gap: 6px; }
.m-title h2 { font-size: var(--text-lg); }
.m-title p { font-size: var(--text-sm); color: var(--text-muted); font-weight: var(--weight-regular); }
.insp-b { flex: 1; min-height: 0; overflow: auto; padding: var(--space-3-5); display: grid; gap: var(--space-3); align-content: start; }
.insp-row { display: flex; align-items: flex-end; gap: var(--space-3); }
.insp-row .field-l { flex: 1; }
.insp-empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-12) var(--space-6); text-align: center; color: var(--text-muted); }
.tabstrip { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--space-2-5); border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.tab:hover { color: var(--text-primary); border-color: var(--border-hover); }
.tab.on { background: var(--surface-raised); color: var(--text-primary); border-color: var(--hue); }
.src-line { display: flex; align-items: center; gap: 6px; font: var(--weight-regular) var(--text-xs)/1.4 var(--font-mono); color: var(--text-muted); }
.legend { display: flex; gap: var(--space-4); font-size: var(--text-xs); color: var(--text-muted); }
.legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.inj { background: color-mix(in srgb, var(--warning) 45%, transparent); } .sw.ext { background: color-mix(in srgb, var(--info) 45%, transparent); }
.notes { margin: 0; padding-left: var(--space-4); display: grid; gap: 4px; font-size: var(--text-sm); color: var(--text-secondary); }
.notes b { color: var(--text-primary); }
.sheet-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); max-height: calc(100vh - 360px); min-height: 120px; background: var(--surface); }
.sheet { border-collapse: separate; border-spacing: 0; font: var(--weight-regular) var(--text-sm)/1.3 var(--font-mono); font-variant-numeric: tabular-nums; width: max-content; min-width: 100%; }
.sheet td, .sheet th { padding: 4px 10px; border-bottom: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.sheet td.num { text-align: right; } .sheet td.b { font-weight: var(--weight-semibold); }
.sheet .rn { position: sticky; left: 0; z-index: 1; background: var(--surface-raised); color: var(--text-subtle); text-align: right; font-size: var(--text-xs); padding: 4px 8px; }
.sheet thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-raised); color: var(--text-muted); font-weight: var(--weight-regular); text-align: center; }
.sheet thead th.rn { z-index: 3; left: 0; }
.sheet tr.header td:not(.rn) { font-weight: var(--weight-semibold); background: var(--surface-raised); border-bottom: 1px solid var(--border-hover); }
.sheet tr.title td:not(.rn) { color: var(--text-muted); }
.sheet tr.injected td:not(.rn) { background: color-mix(in srgb, var(--warning) 20%, transparent); }
.sheet tr.extra td:not(.rn) { background: color-mix(in srgb, var(--info) 20%, transparent); }

/* ---------- menus ---------- */
.menu { position: fixed; z-index: 350; max-height: min(480px, calc(100vh - 16px)); overflow: auto; padding: var(--space-1-5); border: 1px solid var(--border-hover); border-radius: var(--radius-lg); background: var(--surface-raised); box-shadow: var(--shadow-elevated); animation: eui-fade-in var(--duration-fast) var(--ease-soft); }
.mi { display: flex; align-items: center; gap: var(--space-2-5); width: 100%; min-height: 32px; padding: 0 var(--space-2-5); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-primary); font-size: var(--text-base); text-align: left; }
.mi:hover, .mi:focus-visible { background: var(--accent-subtle); }
.mi.danger { color: var(--danger); } .mi.on { font-weight: var(--weight-medium); }
.mi-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-h { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--text-muted); white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.mi-sp { width: 15px; flex: none; }
.mi-label { padding: var(--space-2) var(--space-2-5) var(--space-1); font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.mi-sep { height: 1px; margin: var(--space-1-5) calc(var(--space-1-5) * -1); background: var(--border-subtle); }
.picker .field { height: 32px; margin: 2px 2px var(--space-1-5); }
.picker-list { max-height: 320px; overflow: auto; }
.settings { display: grid; gap: var(--space-3-5); padding: var(--space-2-5); }
.set { display: grid; gap: var(--space-1-5); } .set-l { font-size: var(--text-sm); color: var(--text-secondary); }
.set .seg { width: 100%; } .set .seg button { flex: 1; justify-content: center; padding: 0 var(--space-2); }
.set-sw { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: var(--text-base); }

/* ---------- modal ---------- */
.scrim { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--space-4); background: var(--overlay); backdrop-filter: blur(3px); animation: eui-fade-in var(--duration-base); }
.modal { display: flex; flex-direction: column; max-height: 92vh; width: 100%; border: 1px solid var(--border-hover); border-radius: var(--radius-overlay); background: var(--surface); box-shadow: var(--shadow-modal); animation: modal-in var(--duration-slow) var(--ease-soft); overflow: hidden; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.m-sm { max-width: 420px; } .m-md { max-width: 540px; } .m-lg { max-width: 720px; } .m-xl { max-width: 1180px; height: min(780px, 92vh); }
.m-head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4-5) var(--space-5) var(--space-3-5); }
.m-head .m-title { gap: 4px; }
.m-head h2 { font-size: var(--text-xl); }
.m-body { flex: 1; min-height: 0; overflow: auto; padding: 0 var(--space-5) var(--space-5); display: grid; gap: var(--space-3-5); align-content: start; }
.m-foot { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-subtle); }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.stats3 > div { display: grid; gap: 4px; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); }
.stats3 b { font-size: var(--text-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); } .stats3 span { font-size: var(--text-xs); color: var(--text-muted); }
.exp-scope { display: flex; }
.exp-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.exp-list li { display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-base); }
.exp-list li:last-child { border-bottom: 0; } .exp-list li > .trunc { flex: 1; }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 8px; height: 8px; border-radius: 2px; background: var(--hue); } .dots i.gap { background: transparent; border: 1px dashed var(--text-subtle); }
.save-row { display: flex; gap: var(--space-2); }
.setups { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); }
.setups li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2-5) var(--space-3); border-bottom: 1px solid var(--border-subtle); }
.setups li:last-child { border-bottom: 0; } .setups li > div { display: grid; gap: 2px; min-width: 0; }
.row-btns { display: flex; gap: var(--space-2); }
.check-l { display: flex; align-items: center; gap: var(--space-2-5); font-size: var(--text-base); }
textarea.mono { font-family: var(--font-mono); font-size: var(--text-sm); }
.ptable-w { overflow: auto; max-height: 240px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.ptable { border-collapse: collapse; font-size: var(--text-sm); width: 100%; } .ptable th, .ptable td { padding: 5px 10px; border-bottom: 1px solid var(--border-subtle); text-align: left; } .ptable .miss { color: var(--danger); }

/* ---------- layout editor ---------- */
.layout-modal .m-body { padding: 0; overflow: hidden; display: block; }
.lay { display: grid; grid-template-columns: minmax(0, 1fr) 330px; height: 100%; border-top: 1px solid var(--border-subtle); }
.lay-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: var(--space-3-5) var(--space-5) var(--space-3); gap: var(--space-2-5); }
.lay-hint { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--drop-soft); font-size: var(--text-sm); color: var(--text-secondary); }
.lay-hint b { color: var(--text-primary); font-weight: var(--weight-medium); }
.grid-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.lgrid { border-collapse: separate; border-spacing: 0; font: var(--weight-regular) var(--text-sm)/1.3 var(--font-mono); font-variant-numeric: tabular-nums; }
.lgrid td, .lgrid th { padding: 4px 10px; border-bottom: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.lgrid td.num { text-align: right; } .lgrid td.b { font-weight: var(--weight-semibold); }
.lgrid thead th { position: sticky; top: 0; z-index: 3; padding: 0; background: var(--surface-raised); }
.lgrid thead th button { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 30px; padding: 0 10px; border: 0; background: transparent; color: var(--text-muted); font: inherit; }
.lgrid thead th button:hover { background: var(--accent-subtle); color: var(--text-primary); }
.lgrid thead th small { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .06em; }
.lgrid th.ch.label button { background: color-mix(in srgb, var(--drop) 22%, var(--surface-raised)); color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--drop); }
.lgrid th.ch.split button { background: color-mix(in srgb, var(--hue, var(--success)) 20%, var(--surface-raised)); color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--success); }
.lgrid td.label { background: color-mix(in srgb, var(--drop) 7%, transparent); }
.lgrid td.split { background: color-mix(in srgb, var(--success) 9%, transparent); }
.lgrid th.off, .lgrid td.off { opacity: .35; }
.lgrid .rn { position: sticky; left: 0; z-index: 2; padding: 0; background: var(--surface-raised); text-align: right; width: 40px; }
.lgrid thead .rn { z-index: 4; }
.lgrid .rn button { width: 100%; height: 100%; padding: 4px 10px; border: 0; background: transparent; color: var(--text-subtle); font: inherit; font-size: var(--text-xs); text-align: right; }
.lgrid .rn button:hover { color: var(--text-primary); background: var(--accent-subtle); }
.lgrid tr.title td:not(.rn) { color: var(--text-muted); }
.lgrid tr.head td:not(.rn) { background: color-mix(in srgb, var(--success) 14%, var(--surface)); font-weight: var(--weight-semibold); }
.lgrid tr.head .rn button { color: var(--success); font-weight: var(--weight-semibold); }
.sheet-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 2px 0; }
.stab { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap; }
.stab small { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); text-transform: uppercase; letter-spacing: .06em; padding: 2px 5px; border-radius: var(--radius-badge); background: rgba(var(--bg-rgb), .25); }
.stab:hover { color: var(--text-primary); border-color: var(--border-hover); }
.stab.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.lay-side { display: flex; flex-direction: column; gap: var(--space-4); min-height: 0; padding: var(--space-3-5) var(--space-4); border-left: 1px solid var(--border-subtle); overflow: auto; background: var(--bg); }
.fgrp { display: grid; gap: var(--space-2); } .fgrp.row2 { grid-template-columns: 1fr auto; align-items: end; } .fgrp.grow-g { flex: 1; min-height: 220px; grid-template-rows: auto minmax(0, 1fr) auto; }
.stepper { display: inline-flex; align-items: center; height: var(--field-h); border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-raised); overflow: hidden; }
.stepper button { width: 32px; height: 100%; border: 0; background: transparent; color: var(--text-secondary); font-size: var(--text-lg); } .stepper button:hover:not(:disabled) { background: var(--accent-subtle); color: var(--text-primary); } .stepper button:disabled { opacity: .3; }
.stepper b { min-width: 24px; text-align: center; font-family: var(--font-mono); font-weight: var(--weight-medium); }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.subtabs button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--space-3); border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--text-muted); font-size: var(--text-base); font-weight: var(--weight-medium); }
.subtabs button.on { color: var(--text-primary); border-bottom-color: var(--text-primary); } .subtabs small { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--text-muted); }
.collist { list-style: none; margin: 0; padding: 0; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.collist li { position: relative; display: flex; align-items: center; gap: var(--space-2); min-height: 36px; padding: 0 var(--space-2) 0 var(--space-1); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-base); }
.collist li:last-child { border-bottom: 0; } .collist li > .trunc { flex: 1; } .collist li.off > .trunc { color: var(--text-muted); text-decoration: line-through; } .collist li.dragging { opacity: .4; }
.collist li.ins-before::before { left: 0; right: 0; top: -1px; height: 2px; } .collist li.ins-after::after { left: 0; right: 0; bottom: -1px; height: 2px; }
.collist.short li { padding-left: var(--space-3); }
.rows-list { display: grid; gap: var(--space-2); grid-template-rows: auto minmax(0, 1fr); min-height: 0; } .rows-list .field { height: 32px; }
.valchips { display: flex; flex-wrap: wrap; gap: 5px; } .vchip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--space-2); border: 1px solid var(--border); border-left: 3px solid var(--hue); border-radius: var(--radius-sm); font-size: var(--text-sm); background: var(--surface-raised); } .vchip small { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--text-muted); }

/* ---------- toasts, drag ghost, file overlay ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(var(--footer-h) + var(--space-4)); translate: -50% 0; z-index: 300; display: grid; gap: var(--space-2); justify-items: center; pointer-events: none; width: max-content; max-width: min(640px, 94vw); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); border: 1px solid var(--border-hover); border-radius: var(--radius-card); background: var(--surface-raised); box-shadow: var(--shadow-elevated); font-size: var(--text-base); animation: toast-in var(--duration-slow) var(--ease-soft); }
.toast.error { border-color: var(--danger); }
.toast button { height: 26px; padding: 0 var(--space-2-5); border: 1px solid var(--border-hover); border-radius: var(--radius-sm); background: transparent; color: var(--text-primary); font-size: var(--text-sm); } .toast button:hover { background: var(--accent-subtle); }
.toast .t-x { border: 0; width: 26px; padding: 0; display: grid; place-items: center; color: var(--text-muted); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 var(--space-3); border: 1px solid var(--hue, var(--border-hover)); border-radius: var(--radius-md); background: var(--surface-raised); box-shadow: var(--shadow-elevated); font-size: var(--text-base); font-weight: var(--weight-medium); max-width: 260px; rotate: -2deg; }
.drag-ghost .g-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--hue, var(--text-muted)); flex: none; } .drag-ghost .g-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drag-ghost .g-n { display: grid; place-items: center; min-width: 18px; height: 18px; border-radius: 9px; background: var(--drop); color: #fff; font-size: var(--text-xs); }
body.is-dragging .toast { pointer-events: none; opacity: .5; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }
.fileover { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(4px); pointer-events: none; }
.fileover > div { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-10) var(--space-16); border: 2px dashed var(--drop); border-radius: var(--radius-3xl); background: var(--surface); color: var(--drop); } .fileover b { font-size: var(--text-xl); color: var(--text-primary); } .fileover span { font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-muted); }
.busy-bar { position: fixed; left: 50%; top: calc(var(--top-h) + 12px); translate: -50% 0; z-index: 250; display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-2) var(--space-4); border: 1px solid var(--border-hover); border-radius: var(--radius-full); background: var(--surface-raised); box-shadow: var(--shadow-elevated); font-size: var(--text-sm); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .insp-open .work { grid-template-columns: var(--panel-w) minmax(0, 1fr) 0; } .inspector.open { position: fixed; top: var(--top-h); right: 0; bottom: var(--footer-h); width: var(--insp-w); z-index: 60; box-shadow: var(--shadow-modal); border-left-color: var(--border-hover); } }
@media (max-width: 980px) { .hide-md { display: none !important; } .steps { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  :root { --panel-w: 100%; --insp-w: 100vw; }
  body { overflow: auto; } .app { height: auto; min-height: 100%; }
  .work { display: block; } .panel { border-right: 0; border-bottom: 1px solid var(--border-subtle); } .panel-scroll { max-height: 46vh; }
  .canvas { min-height: 70vh; } .hide-sm { display: none !important; } .brand-t { display: none; } .top { gap: var(--space-1); } .top .eui-btn { padding: 0 var(--space-3); }
  .lay { grid-template-columns: 1fr; overflow: auto; } .lay-side { border-left: 0; border-top: 1px solid var(--border-subtle); }
  .m-xl { height: 94vh; } .layout-modal .m-body { overflow: auto; }
  .top { padding: 0 var(--space-3); } .drop { padding: var(--space-8) var(--space-4); } .drop h1 { font-size: var(--text-3xl); }
}
@media (prefers-reduced-motion: reduce) { .slot.targetable, .card.new.targetable { animation: none; } }

.set-h { margin-top: var(--space-1); padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.hue-btn { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: var(--radius-sm); background: transparent; padding: 0; }
.hue-btn:hover { background: var(--accent-subtle); } .hue-btn .dot { width: 11px; height: 11px; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); padding: var(--space-2); }
.swatches .sw { height: 28px; border-radius: var(--radius-sm); border: 2px solid transparent; background: var(--hue); }
.swatches .sw.on { border-color: var(--text-primary); } .swatches .sw:hover { transform: scale(1.06); }

/* tab names */
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.tpl { display: grid; gap: var(--space-1-5); align-content: start; }
.tpl .field-l { display: flex; flex-direction: column; gap: 2px; }
.tokens { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.token { height: 24px; padding: 0 var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-badge); background: var(--surface-raised); color: var(--text-secondary); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); }
.token:hover { color: var(--text-primary); border-color: var(--border-hover); background: var(--surface-hover); }
.tn-bar { display: flex; align-items: center; gap: var(--space-2); }
.tn-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.tn-row { display: grid; grid-template-columns: 9px minmax(70px, 150px) minmax(0, 1fr) 44px auto; align-items: center; gap: var(--space-2-5); padding: var(--space-1-5) var(--space-3); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-base); }
.tn-row:last-child { border-bottom: 0; } .tn-row.bad { background: color-mix(in srgb, var(--warning) 6%, transparent); }
.tn-in { height: 30px; font-family: var(--font-mono); font-size: var(--text-sm); }
.tn-c { font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-muted); } .tn-c.full { color: var(--warning); }
.tn-f { display: inline-flex; gap: 4px; min-width: 0; }
.lab-r { display: flex; justify-content: space-between; align-items: center; }
.warnbox { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border)); border-radius: var(--radius-md); background: color-mix(in srgb, var(--warning) 8%, transparent); font-size: var(--text-sm); color: var(--text-secondary); text-align: left; }
.warnbox > .ic { color: var(--warning); margin-top: 2px; } .note.warnbox { justify-content: flex-start; margin-top: 0; }
.tabwarn { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; padding: 2px 6px; border: 0; border-radius: var(--radius-badge); background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); font: var(--weight-regular) var(--text-2xs)/1.2 var(--font-mono); }
.tabwarn:hover { background: color-mix(in srgb, var(--warning) 26%, transparent); }
.tab .warn { margin-left: 2px; }
@media (max-width: 760px) { .tpl-grid { grid-template-columns: 1fr; } .tn-row { grid-template-columns: 9px minmax(0, 1fr) 44px; } .tn-o, .tn-f { display: none; } }

/* resizable / collapsible panels */
.panel { position: relative; }
.resizer { position: absolute; top: 0; bottom: 0; width: 9px; z-index: 30; cursor: col-resize; touch-action: none; }
.resizer.right { right: -5px; } .resizer.left { left: -5px; }
.resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px; background: transparent; transition: background var(--duration-fast), width var(--duration-fast), left var(--duration-fast); }
.resizer:hover::after, .resizer:focus-visible::after, body.resizing .resizer::after { background: var(--drop); width: 3px; left: 3px; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
body.resizing .work { transition: none; }
.inspector { position: relative; } .inspector > .resizer { width: 9px; flex: none; }
.panel-a { display: flex; align-items: center; gap: var(--space-1); }
.panel-h .panel-a .ibtn { width: 28px; height: 28px; }
.rot { transform: rotate(-90deg); } .ibtn .ic { transition: transform var(--duration-fast); }
.folded-t { display: grid; gap: 6px; font-size: var(--text-xs); color: var(--text-muted); }
.src:has(.folded-t) { padding-bottom: var(--space-2-5); }
.sources.rail { align-items: center; gap: var(--space-3); padding: var(--space-3) 0; overflow: hidden; }
.rail-list { display: grid; gap: var(--space-2); width: 100%; padding: 0 var(--space-1-5); overflow: auto; }
.rail-i { display: grid; justify-items: center; gap: 4px; padding: var(--space-2) 2px; border: 1px solid var(--border); border-left: 3px solid var(--hue); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--text-secondary); font-size: var(--text-2xs); min-width: 0; }
.rail-i:hover { background: var(--surface-hover); color: var(--text-primary); }
.rail-i span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--weight-medium); }
.rail-i small { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--text-muted); }
.remove-hint.rail-h { inset: auto 4px 4px; padding: var(--space-2) 2px; font-size: var(--text-2xs); }

.fnwarn { display: inline-grid; place-items: center; color: var(--warning); margin-left: 4px; cursor: help; }
@media (max-width: 760px) { .resizer { display: none; } }

/* mapping grid */
.map-modal .m-body { overflow: hidden; display: flex; flex-direction: column; padding-bottom: 0; }
.map-body { display: flex; flex-direction: column; gap: var(--space-2-5); min-height: 0; flex: 1; padding-bottom: var(--space-4); }
.map-help { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--text-secondary); flex-wrap: wrap; }
.map-help code { font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); padding: 2px 5px; border-radius: var(--radius-badge); background: var(--surface-raised); border: 1px solid var(--border); }
.mg { display: flex; flex-direction: column; min-height: 0; flex: 1; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: auto; background: var(--surface); }
.mg-h, .mg-r { display: grid; grid-template-columns: var(--mg-cols); min-width: 640px; width: 100%; }
.mg-h { position: sticky; top: 0; z-index: 3; background: var(--surface-raised); border-bottom: 1px solid var(--border); }
.mg-h > span { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 8px; padding: var(--space-2) var(--space-3); min-width: 0; font-size: var(--text-sm); }
.mg-h small { grid-column: 1 / -1; font: var(--weight-regular) var(--text-2xs)/1.3 var(--font-mono); color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.mg-h .mg-ho { grid-template-columns: 1fr; }
.mg-rows { display: contents; }
.mg-r { border-bottom: 1px solid var(--border-subtle); align-items: stretch; }
.mg-r:focus-within { background: var(--accent-subtle); }
.mg-n { display: grid; place-items: center; font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-subtle); } .mg-r.new .mg-n { color: var(--success); }
.mg-c { position: relative; display: flex; align-items: center; min-width: 0; border-left: 1px solid var(--border-subtle); }
.mg-c input { width: 100%; height: 38px; padding: 0 30px 0 var(--space-3); border: 0; background: transparent; outline: none; color: var(--text-primary); font-size: var(--text-base); min-width: 0; text-overflow: ellipsis; }
.mg-c.name input { padding-right: var(--space-3); font-weight: var(--weight-medium); }
.mg-c input:focus { box-shadow: inset 0 0 0 2px var(--drop); border-radius: 2px; }
.mg-c.ok { box-shadow: inset 3px 0 0 var(--hue); background: color-mix(in srgb, var(--hue) 5%, transparent); }
.mg-c.bad { background: color-mix(in srgb, var(--danger) 8%, transparent); box-shadow: inset 3px 0 0 var(--danger); }
.mg-s { position: absolute; right: 8px; top: 12px; color: var(--success); display: grid; } .mg-s.warn { color: var(--danger); }
.mg-fix { position: absolute; right: 28px; top: 8px; height: 22px; max-width: 70%; padding: 0 var(--space-2); border: 1px solid var(--border-hover); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--text-primary); font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 2; }
.mg-fix:hover { background: var(--surface-hover); }
.mg-c.bad:not(:focus-within) .mg-fix { display: none; } .mg-c.bad:focus-within .mg-fix, .mg-c.bad:hover .mg-fix { display: block; }
.mg-x { align-self: center; } .mg-r .mg-x { opacity: 0; } .mg-r:hover .mg-x, .mg-r:focus-within .mg-x { opacity: 1; }
.mg-add { display: flex; align-items: center; gap: var(--space-2); width: 100%; height: 38px; padding: 0 var(--space-3); border: 0; background: transparent; color: var(--text-muted); font-size: var(--text-sm); position: sticky; left: 0; }
.mg-add:hover { color: var(--text-primary); background: var(--accent-subtle); }
.map-opts { display: flex; gap: var(--space-5); flex-wrap: wrap; }
.mg-sum { font-size: var(--text-sm); color: var(--text-secondary); } .mg-sum b { color: var(--text-primary); font-weight: var(--weight-medium); }

/* source card action buttons */
.tbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 28px; height: 28px; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--text-secondary); transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast), transform var(--duration-fast); }
.tbtn:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-hover); background: var(--surface-hover); }
.tbtn:active:not(:disabled) { transform: scale(.94); }
.tbtn:disabled { opacity: .35; cursor: default; }
.tbtn.hot { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.tbtn.hot:hover:not(:disabled) { background: var(--accent); opacity: .9; color: var(--on-accent); }
.tbtn.on { color: var(--text-primary); }
.n-badge { font: var(--weight-medium) var(--text-2xs)/1 var(--font-mono); }
.prog-t { align-items: center; }

/* tooltip */
.tooltip { position: fixed; z-index: 500; max-width: 280px; padding: 6px 10px; border: 1px solid var(--border-hover); border-radius: var(--radius-md); background: var(--surface-raised); color: var(--text-primary); box-shadow: var(--shadow-elevated); font-size: var(--text-xs); line-height: 1.4; pointer-events: none; animation: eui-fade-in var(--duration-fast) var(--ease-soft); }

/* source quick-edit */
.sq { display: grid; gap: var(--space-2); padding: var(--space-1); }
.sq-h { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-1-5); font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-muted); }
.sq .field-l { padding: 0 var(--space-1-5); } .sq .swatches { padding: 0 var(--space-1-5); }
.sq-move { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; } .sq-move .mi:last-child { justify-content: flex-end; } .sq-move .mi:disabled { opacity: .35; cursor: default; }
button.slot-l { border: 0; background: transparent; padding: 0; text-align: left; cursor: pointer; justify-self: start; max-width: 100%; border-radius: var(--radius-xs); }
button.slot-l:hover { color: var(--text-primary); text-decoration: underline; text-decoration-color: var(--border-hover); text-underline-offset: 3px; }
.list-head > .lh-src { gap: 4px; padding-right: var(--space-1); }
.lh-edit { flex: 1; min-width: 0; margin: 0 !important; padding: 3px 6px !important; text-transform: uppercase; letter-spacing: .06em; font: var(--weight-regular) var(--text-xs)/1.2 var(--font-mono) !important; color: var(--text-muted) !important; text-overflow: ellipsis; }
.lh-edit:hover { color: var(--text-primary) !important; } .lh-edit:focus { text-transform: none; color: var(--text-primary) !important; }
.lh-src .ibtn { width: 24px; height: 24px; }

.su-name { font-weight: var(--weight-semibold); font-size: var(--text-base); padding: 2px 6px; }
.setups li { gap: var(--space-2-5); }

.mg-s { display: inline-flex; align-items: center; gap: 2px; font: var(--weight-medium) var(--text-2xs)/1 var(--font-mono); }
.map-legend code { margin: 0 1px; }

/* start from a setup */
.setup-pick { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border-subtle); display: grid; gap: var(--space-3); justify-items: center; }
.setup-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; max-width: 560px; }
.setup-chip { display: inline-flex; align-items: center; gap: var(--space-2); height: 36px; max-width: 100%; padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-raised); color: var(--text-primary); font-size: var(--text-base); transition: background var(--duration-fast), border-color var(--duration-fast); }
.setup-chip:hover { background: var(--surface-hover); border-color: var(--border-hover); }
.setup-chip small { font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--text-muted); white-space: nowrap; }
.setup-chip b { font-weight: var(--weight-medium); max-width: 160px; }
.setup-chip.dashed { border-style: dashed; background: transparent; color: var(--text-secondary); }
.pending { margin-top: var(--space-5); text-align: left; padding: var(--space-4); border: 1px solid var(--border-hover); border-radius: var(--radius-card); background: var(--surface-raised); display: grid; gap: var(--space-3); }
.pending-h { display: flex; align-items: center; gap: var(--space-2); }
.pending-l { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pending-l li { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-secondary); padding: 4px 0; }
.pending-l li small { margin-left: auto; font: var(--weight-regular) var(--text-2xs)/1 var(--font-mono); color: var(--text-muted); } .pending-l li.ok { color: var(--text-primary); } .pending-l li.ok .ic { color: var(--success); }
.pending-n { font-size: var(--text-xs); color: var(--text-muted); }

/* footer (same pattern as the other farhan.app tools) */
.app-footer { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 0 var(--space-4); min-height: var(--footer-h); padding: var(--space-1) var(--space-5); border-top: 1px solid var(--border-subtle); background: var(--surface); font-size: var(--text-xs); color: var(--text-muted); position: relative; z-index: 20; }
.app-footer a, .footer-link { display: inline-flex; align-items: center; min-height: 24px; padding: 0; border: 0; background: none; color: var(--text-secondary); font: inherit; text-decoration: none; cursor: pointer; transition: color var(--duration-fast); }
.app-footer a:hover, .footer-link:hover { color: var(--text-primary); }
.footer-sep { width: 1px; height: 12px; background: var(--border); }
.footer-spacer { flex: 1; }
.footer-meta { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10.5px; white-space: nowrap; }
.footer-meta::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.footer-credit a { color: var(--text-primary); font-weight: var(--weight-medium); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.about-steps { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-2); color: var(--text-secondary); } .about-steps b { color: var(--text-primary); }
.priv { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-2-5); color: var(--text-secondary); line-height: var(--leading-snug); } .priv b { color: var(--text-primary); font-weight: var(--weight-medium); }
.keys { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); }
.keys li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-base); } .keys li:last-child { border-bottom: 0; }
.kk { display: inline-flex; gap: 6px; flex: none; }
@media (max-width: 760px) { .app-footer { padding: var(--space-2) var(--space-4); row-gap: var(--space-1); } .footer-spacer { display: none; } }
/* while a dialog is open, toasts move to the bottom-left corner: still clickable (Undo), never covering the dialog's buttons */
.app:has(.scrim) .toasts { left: var(--space-4); translate: none; justify-items: start; max-width: min(340px, calc(100vw - 32px)); }
