
  /* ── Reset ── */
  *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

  /* ── AUP Primitives (shared with web-device) — MUST come before themes ── */

/* === Derived Token Defaults === */
:root {
  --card-bg: var(--color-surface, #f8fafc);
  --card-border: 1px solid var(--color-border, #e2e8f0);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --backdrop: none;
  --transition: 0.2s ease;
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --hover: rgba(0,0,0,0.04);
  --color-accent-bg: color-mix(in srgb, var(--color-accent, #6366f1) 10%, transparent);
  --font-heading: var(--font-body, system-ui, -apple-system, sans-serif);
  --heading-weight: 700;
  --heading-spacing: normal;
  --heading-transform: none;
  --heading-gradient: var(--color-accent, #6366f1);
  --glow: none;
  --color-assistant: var(--color-accent, #6366f1);
  --color-error: #ef4444;
  --color-success: #22c55e;
  --accent-fg: #fff;
  --msg-font-size: var(--type-body, 0.95rem);
  --hover-bg: rgba(0,0,0,0.04);
  --error-bg: rgba(220,38,38,0.1);
  --muted: var(--color-dim, #64748b);
}

/* ── AUP Primitives ── */
.aup-view { display: flex; flex-direction: column; gap: var(--space-block, 12px); }
.aup-view[data-layout="row"] { flex-direction: row; }
.aup-view[data-layout="row"] > .aup-view:not([data-width]) { flex: 1; min-width: 0; }
.aup-view[data-layout="grid"] { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--grid-min-width, 200px), 1fr)); gap: 12px; }
.aup-view[data-layout="grid"] > * { min-width: 0; }
.aup-view[data-layout="stack"] { display: grid; width: 100%; height: 100%; }
.aup-view[data-layout="stack"] > * { grid-area: 1 / 1; }
.aup-view[data-layout="stack"] > *:first-child { z-index: 0; }
.aup-view[data-layout="stack"] > *:nth-child(2) { z-index: 1; }
.aup-view[data-layout="stack"] > *:nth-child(n+3) { z-index: 2; }

.aup-view[data-layout="overlay-grid"] { --overlay-pad: 5vw; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto 1fr auto auto auto; grid-template-areas: "top-start top-center top-end" "mid-start mid-center mid-end" "lower-start lower-center lower-end" "ticker ticker ticker" "bottom-start bottom-center bottom-end"; width: 100%; height: 100%; padding: var(--overlay-pad); pointer-events: none; gap: 8px; }
.aup-view[data-layout="overlay-grid"] > * { pointer-events: auto; }
.aup-view[data-layout="overlay-grid"] > .aup-text,
.aup-view[data-layout="overlay-grid"] > .aup-action,
.aup-view[data-layout="overlay-grid"] > .aup-time { width: fit-content; height: fit-content; }
.aup-view[data-layout="overlay-grid"] > .aup-map { min-width: 240px; max-width: 320px; aspect-ratio: 1; }
.aup-view[data-layout="overlay-grid"] > .aup-table,
.aup-view[data-layout="overlay-grid"] > .aup-chart,
.aup-view[data-layout="overlay-grid"] > .aup-finance-chart,
.aup-view[data-layout="overlay-grid"] > .aup-calendar { min-width: 240px; max-width: 320px; }
.aup-view[data-layout="overlay-grid"] > .aup-media { width: fit-content; height: fit-content; }
.aup-view[data-layout="overlay-grid"] > .aup-media img { max-height: 48px; object-fit: contain; width: auto; }
.aup-view[data-layout="overlay-grid"] > [data-region="top-start"]     { grid-area: top-start; align-self: start; justify-self: start; }
.aup-view[data-layout="overlay-grid"] > [data-region="top-center"]    { grid-area: top-center; align-self: start; justify-self: center; }
.aup-view[data-layout="overlay-grid"] > [data-region="top-end"]       { grid-area: top-end; align-self: start; justify-self: end; }
.aup-view[data-layout="overlay-grid"] > [data-region="mid-start"]     { grid-area: mid-start; align-self: center; justify-self: start; }
.aup-view[data-layout="overlay-grid"] > [data-region="mid-center"]    { grid-area: mid-center; align-self: center; justify-self: center; }
.aup-view[data-layout="overlay-grid"] > [data-region="mid-end"]       { grid-area: mid-end; align-self: center; justify-self: end; }
.aup-view[data-layout="overlay-grid"] > [data-region="lower-start"]   { grid-area: lower-start; align-self: end; justify-self: start; }
.aup-view[data-layout="overlay-grid"] > [data-region="lower-center"]  { grid-area: lower-center; align-self: end; justify-self: center; }
.aup-view[data-layout="overlay-grid"] > [data-region="lower-end"]     { grid-area: lower-end; align-self: end; justify-self: end; }
.aup-view[data-layout="overlay-grid"] > [data-region="ticker"]        { grid-area: ticker; justify-self: stretch; margin-left: calc(-1 * var(--overlay-pad)); margin-right: calc(-1 * var(--overlay-pad)); }
.aup-view[data-layout="overlay-grid"] > [data-region="bottom-start"]  { grid-area: bottom-start; align-self: end; justify-self: start; }
.aup-view[data-layout="overlay-grid"] > [data-region="bottom-center"] { grid-area: bottom-center; align-self: end; justify-self: center; }
.aup-view[data-layout="overlay-grid"] > [data-region="bottom-end"]    { grid-area: bottom-end; align-self: end; justify-self: end; }
.aup-view[data-mode="card"] { background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); padding: var(--space-block, 16px); box-shadow: var(--shadow-card); backdrop-filter: var(--backdrop); -webkit-backdrop-filter: var(--backdrop); transition: box-shadow var(--transition), transform var(--transition), background var(--transition); position: relative; overflow: hidden; }
.aup-view[data-mode="card"]::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--heading-gradient, linear-gradient(90deg, var(--color-accent), var(--color-accent-secondary, var(--color-accent)))); opacity: 0; transition: opacity var(--transition); }
.aup-view[data-mode="card"]:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover, var(--shadow-card)); }
.aup-view[data-mode="card"]:hover::before { opacity: 1; }
:is([data-tone="bold"], [data-tone="mono"]) .aup-view[data-mode="card"]::before { display: none; }
.aup-view[data-mode="panel"] { background: var(--card-bg); border-radius: var(--radius-sm); padding: 10px 16px; backdrop-filter: var(--backdrop); -webkit-backdrop-filter: var(--backdrop); }
/* Header panel: first panel child acts as sticky header */
.aup-view[data-mode="panel"]:first-child { position: sticky; top: 0; z-index: 20; border-radius: 0; padding: 10px max(16px, calc((100% - 1200px) / 2 + 40px)); background: color-mix(in srgb, var(--color-surface, #f8fafc) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--color-border, #e2e8f0); }
.aup-view[data-mode="panel"]:first-child .aup-action { flex-shrink: 0; }
/* Adjacent panels (e.g. nav bar) inherit centered padding */
.aup-view[data-mode="panel"]:first-child + .aup-view[data-mode="panel"] { border-radius: 0; padding: 10px max(16px, calc((100% - 1200px) / 2 + 40px)); border-bottom: 1px solid var(--color-border, #e2e8f0); }
.aup-view[data-mode="panel"]:first-child + .aup-view[data-mode="panel"] .aup-action { flex-shrink: 0; }

.aup-view[data-mode="pane"] { flex: 1; min-width: 0; overflow-y: auto; border-radius: var(--radius-md); padding: 16px; background: var(--card-bg); backdrop-filter: var(--backdrop); -webkit-backdrop-filter: var(--backdrop); }
.aup-view[data-mode="pane"] > .aup-text[data-level="2"]:first-child { background: var(--color-surface); margin: -16px -16px 12px; padding: 10px 16px; border-bottom: 1px solid var(--color-border); border-radius: var(--radius-md) var(--radius-md) 0 0; position: sticky; top: -16px; z-index: 1; }
.aup-view[data-mode="divider"] { height: 1px; background: var(--color-border); flex: none; padding: 0; gap: 0; border-radius: 0; }

/* ── Shell Layout: Desktop App Chrome ── */
.aup-view[data-mode="shell"] {
  display: grid;
  grid-template-areas:
    "menubar"
    "toolbar"
    "body"
    "statusbar"
    "dock";
  grid-template-rows: auto auto 1fr auto auto;
  width: 100%; height: 100vh; overflow: hidden; gap: 0;
  background: var(--color-bg);
  font-family: "SF Mono", "Consolas", "JetBrains Mono", "Fira Code", monospace;
  font-size: 13px;
}
.aup-view[data-mode="shell"] > [data-role="menubar"]   { grid-area: menubar; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 32px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); font-size: 0.8rem; flex-shrink: 0; overflow: hidden; }
.aup-view[data-mode="shell"] > [data-role="menubar"] * { margin: 0; font-size: inherit; }
.aup-view[data-mode="shell"] > [data-role="statusbar"] * { margin: 0; font-size: inherit; }
.aup-view[data-mode="shell"] > [data-role="toolbar"]   { grid-area: toolbar; display: flex; align-items: center; gap: 8px; padding: 4px 12px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.aup-view[data-mode="shell"] > [data-role="body"]      { grid-area: body; display: flex; overflow: hidden; min-height: 0; }
.aup-view[data-mode="shell"] > [data-role="statusbar"] { grid-area: statusbar; display: flex; align-items: center; gap: 12px; padding: 0 12px; height: 24px; background: var(--color-surface); border-top: 1px solid var(--color-border); font-size: 0.75rem; color: var(--color-dim); flex-shrink: 0; }
.aup-view[data-mode="shell"] > [data-role="dock"]      { grid-area: dock; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 4px 12px; background: var(--color-surface); border-top: 1px solid var(--color-border); flex-shrink: 0; }
/* Shell body children */
[data-role="sidebar"]   { width: 220px; overflow-y: auto; flex-shrink: 0; border-right: 1px solid var(--color-border); background: var(--color-surface); padding: 8px 0; }
[data-role="sidebar"] > .aup-view > .aup-text:first-child { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-dim); padding: 8px 12px 4px; }
[data-role="sidebar"] .aup-action { display: block; width: 100%; text-align: left; padding: 4px 12px; font-size: 0.8rem; border-radius: 0; background: none; border: none; color: var(--color-text); cursor: pointer; }
[data-role="sidebar"] .aup-action:hover { background: var(--hover); }
[data-role="sidebar"] .aup-action[data-variant="primary"] { background: var(--color-accent); color: var(--accent-fg, #fff); border-radius: var(--radius-sm); margin: 1px 8px; width: calc(100% - 16px); }
[data-role="content"]   { flex: 1; overflow-y: auto; min-width: 0; padding: 16px; }
[data-role="content"] > .aup-text[data-level="2"] { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-dim); margin-bottom: 12px; }
[data-role="content"] > .aup-view[data-layout="row"] { padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: 2px; }
[data-role="content"] > .aup-view[data-layout="row"]:hover { background: var(--hover); }
[data-role="content"] > .aup-view[data-layout="row"] > .aup-text:first-child { min-width: 120px; font-weight: 500; font-size: 0.85rem; }
[data-role="content"] > .aup-view[data-layout="row"] > .aup-text:last-child { margin-left: auto; font-weight: 600; }
[data-role="inspector"] { width: 280px; overflow-y: auto; flex-shrink: 0; border-left: 1px solid var(--color-border); background: var(--color-surface); padding: 8px; }
[data-role="inspector"] > .aup-text[data-level="3"] { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-dim); padding: 8px 4px 4px; margin-bottom: 0; }
[data-role="inspector"] > .aup-text[data-variant="dim"] { font-size: 0.8rem; padding: 4px; }
/* Collapsible panels */
[data-collapsed="true"] > .aup-view-body { display: none; }
[data-collapsed="true"][data-role="sidebar"] { width: auto; min-width: 0; padding: 4px; }
[data-collapsed="true"][data-role="inspector"] { width: auto; min-width: 0; padding: 4px; }
.aup-collapse-toggle { background: none; border: none; cursor: pointer; padding: 4px 8px; color: var(--color-dim); font-size: 0.75rem; border-radius: var(--radius-sm); }
.aup-collapse-toggle:hover { background: var(--hover); color: var(--color-text); }
/* Shell responsive: hide sidebar/inspector/statusbar on small screens */
@media (max-width: 768px) {
  .aup-view[data-mode="shell"] > [data-role="body"] > [data-role="sidebar"]   { display: none; }
  .aup-view[data-mode="shell"] > [data-role="body"] > [data-role="inspector"] { display: none; }
  .aup-view[data-mode="shell"] > [data-role="statusbar"] { display: none; }
}

/* ── Tabs Mode ── */
.aup-view[data-mode="tabs"] { display: flex; flex-direction: column; overflow: hidden; }
.aup-view[data-mode="tabs"] > .aup-tab-bar { display: flex; gap: 0; border-bottom: 1px solid var(--color-border); background: var(--color-surface); padding: 0 8px; flex-shrink: 0; overflow-x: auto; }
.aup-view[data-mode="tabs"] > .aup-tab-bar > .aup-tab { padding: 6px 14px; font-size: 0.8rem; cursor: pointer; border: none; background: none; color: var(--color-dim); border-bottom: 2px solid transparent; white-space: nowrap; transition: color var(--transition), border-color var(--transition); }
.aup-view[data-mode="tabs"] > .aup-tab-bar > .aup-tab:hover { color: var(--color-text); background: var(--hover); }
.aup-view[data-mode="tabs"] > .aup-tab-bar > .aup-tab[data-active="true"] { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.aup-view[data-mode="tabs"] > .aup-tab-panel { flex: 1; overflow-y: auto; padding: 12px 16px; }
.aup-view[data-mode="tabs"] > .aup-tab-panel[data-active="false"] { display: none; }

/* ── Spatial Intent: Layout ── */
.aup-view[data-align="start"] { justify-content: flex-start; }
.aup-view[data-align="center"] { justify-content: center; }
.aup-view[data-align="end"] { justify-content: flex-end; }
.aup-view[data-align="between"] { justify-content: space-between; }
.aup-view[data-cross-align="start"] { align-items: flex-start; }
.aup-view[data-cross-align="center"] { align-items: center; }
.aup-view[data-cross-align="end"] { align-items: flex-end; }
.aup-view[data-cross-align="stretch"] { align-items: stretch; }

/* ── Spatial Intent: Gap ── */
.aup-view[data-gap="none"] { gap: 0; }
.aup-view[data-gap="xs"] { gap: calc(var(--space-element, 0.5rem) * 0.5); }
.aup-view[data-gap="sm"] { gap: var(--space-element, 8px); }
.aup-view[data-gap="md"] { gap: var(--space-block, 16px); }
.aup-view[data-gap="lg"] { gap: calc(var(--space-block, 1rem) * 1.5); }
.aup-view[data-gap="xl"] { gap: var(--space-section, 40px); }

/* ── Spatial Intent: Wrap & Overflow ── */
.aup-view[data-wrap="true"] { flex-wrap: wrap; }
.aup-view[data-wrap="true"][style*="--grid-min-width"] {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min-width), 1fr));
}
.aup-view[data-overflow="auto"] { overflow: auto; }
.aup-view[data-overflow="hidden"] { overflow: hidden; }
.aup-view[data-overflow="scroll-x"] { overflow-x: auto; overflow-y: hidden; }
.aup-view[data-overflow="scroll-y"] { overflow-x: hidden; overflow-y: auto; }

/* ── Spatial Intent: Sizing ── */
[data-width="hug"] { width: fit-content; flex: none !important; }
[data-width="fill"] { width: 100%; }
[data-max-width="xs"] { max-width: 320px; }
[data-max-width="sm"] { max-width: 480px; }
[data-max-width="md"] { max-width: 640px; }
[data-max-width="lg"] { max-width: 960px; }
[data-max-width="xl"] { max-width: 1200px; }
[data-max-width="full"] { max-width: 100%; }
[data-height="fill"] { height: 100%; }
.aup-view[data-layout="row"] > .aup-view[data-width="fill"] { flex: 1; min-width: 0; }

.aup-text { color: var(--color-text); font-size: var(--type-body, 0.95rem); line-height: var(--leading-normal, 1.6); }
.aup-text[data-level="1"] { font-family: var(--font-heading); font-size: var(--type-display, 2em); font-weight: var(--heading-weight); color: var(--color-accent); text-shadow: var(--glow); letter-spacing: var(--heading-spacing); text-transform: var(--heading-transform); line-height: var(--leading-tight, 1.15); margin-bottom: 0.3em; }
/* Gradient heading text — themes with --heading-gradient get background-clip */
:not([data-tone="bold"]):not([data-tone="mono"]) .aup-text[data-level="1"] { background: var(--heading-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.aup-text[data-scale="display"] { background: var(--heading-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
:is([data-tone="bold"], [data-tone="mono"]) .aup-text[data-scale="display"] { background: none; -webkit-text-fill-color: unset; }
.aup-text[data-level="2"] { font-family: var(--font-heading); font-size: var(--type-heading, 1.5em); font-weight: var(--heading-weight); color: var(--color-text); letter-spacing: var(--heading-spacing); text-transform: var(--heading-transform); line-height: var(--leading-tight, 1.25); margin-bottom: 0.25em; display: flex; align-items: center; gap: 10px; }
.aup-text[data-level="2"]::before { content: ''; width: 4px; height: 0.9em; border-radius: 2px; background: var(--heading-gradient, var(--color-accent)); flex-shrink: 0; }
:is([data-tone="bold"], [data-tone="mono"]) .aup-text[data-level="2"]::before { border-radius: 0; background: var(--color-accent); }
.aup-text[data-level="3"] { font-family: var(--font-heading); font-size: var(--type-caption, 1.2em); font-weight: var(--heading-weight); color: var(--color-text); letter-spacing: var(--heading-spacing); margin-bottom: 0.2em; }
.aup-text[data-level="4"], .aup-text[data-level="5"], .aup-text[data-level="6"] { font-family: var(--font-heading); font-weight: var(--heading-weight); letter-spacing: var(--heading-spacing); }
.aup-text[data-format="code"] { font-family: var(--font-mono, monospace); background: var(--color-bg); padding: 0; border-radius: var(--radius-sm); border: 1px solid var(--color-border); white-space: pre-wrap; overflow: auto; }
.aup-text[data-format="code"] pre { margin: 0; padding: 12px; overflow: auto; }
.aup-text[data-format="code"] pre code { font-family: var(--font-mono, monospace); font-size: 0.85em; line-height: 1.5; }
.aup-text[data-format="code"] pre code.hljs { background: transparent; padding: 0; }
.aup-text[data-intent="info"] { color: var(--color-assistant); }
.aup-text[data-intent="success"] { color: var(--color-success); }
.aup-text[data-intent="warning"] { color: var(--color-accent); }
.aup-text[data-intent="error"] { color: var(--color-error); }

/* ── Spatial Intent: Typography Scale ── */
.aup-text[data-scale="display"] { font-family: var(--font-display, var(--font-heading)); font-size: 3.5em; font-weight: var(--heading-weight); letter-spacing: -0.03em; line-height: 1.05; }
.aup-text[data-scale="h1"] { font-family: var(--font-heading); font-size: 2.25em; font-weight: var(--heading-weight); letter-spacing: var(--heading-spacing); line-height: 1.15; }
.aup-text[data-scale="h2"] { font-family: var(--font-heading); font-size: 1.65em; font-weight: var(--heading-weight); letter-spacing: var(--heading-spacing); line-height: 1.25; }
.aup-text[data-scale="h3"] { font-family: var(--font-heading); font-size: 1.2em; font-weight: var(--heading-weight); letter-spacing: var(--heading-spacing); }
.aup-text[data-scale="body"] { font-size: 1em; }
.aup-text[data-scale="sm"] { font-size: 0.8em; }
.aup-text[data-scale="caption"] { font-size: 0.85em; color: var(--color-dim); }
.aup-text[data-scale="code"] { font-size: 0.85em; font-family: "JetBrains Mono", "Fira Code", monospace; }

/* ── Badge / Pill ── */
.aup-text[data-mode="badge"] { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 0.78em; font-weight: 600; background: var(--color-surface); border: 1px solid var(--color-border); letter-spacing: 0.02em; }
.aup-text[data-mode="badge"][data-intent="info"] { background: color-mix(in srgb, var(--color-assistant) 20%, var(--color-bg)); border-color: color-mix(in srgb, var(--color-assistant) 40%, transparent); color: var(--color-assistant); box-shadow: 0 0 8px color-mix(in srgb, var(--color-assistant) 10%, transparent); }
.aup-text[data-mode="badge"][data-intent="success"] { background: color-mix(in srgb, var(--color-success) 22%, var(--color-bg)); border-color: color-mix(in srgb, var(--color-success) 40%, transparent); color: var(--color-success); box-shadow: 0 0 8px color-mix(in srgb, var(--color-success) 10%, transparent); }
.aup-text[data-mode="badge"][data-intent="warning"] { background: color-mix(in srgb, var(--color-accent) 22%, var(--color-bg)); border-color: color-mix(in srgb, var(--color-accent) 40%, transparent); color: var(--color-accent); box-shadow: 0 0 8px color-mix(in srgb, var(--color-accent) 10%, transparent); }
.aup-text[data-mode="badge"][data-intent="error"] { background: color-mix(in srgb, var(--color-error) 22%, var(--color-bg)); border-color: color-mix(in srgb, var(--color-error) 40%, transparent); color: var(--color-error); box-shadow: 0 0 8px color-mix(in srgb, var(--color-error) 10%, transparent); }

/* ── Copyable text ── */
.aup-text[data-copyable] { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.aup-copy-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.aup-copy-btn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-dim); cursor: pointer; font-size: 0.7rem; padding: 0; transition: all 0.15s; flex-shrink: 0; }
.aup-copy-btn:hover { border-color: var(--color-accent); color: var(--color-accent); background: var(--hover); }
.aup-copy-btn[data-copied] { border-color: var(--color-success); color: var(--color-success); }

.aup-action { background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); padding: 8px 16px; border-radius: var(--radius-md); cursor: pointer; font-family: var(--font-body); font-size: 0.9rem; transition: all var(--transition) cubic-bezier(0.4, 0, 0.2, 1); white-space: nowrap; }
.aup-action:hover { border-color: var(--color-accent); color: var(--color-accent); background: var(--color-accent-bg); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.aup-action:active { transform: translateY(0); }
.aup-action[data-variant="primary"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg); font-weight: 600; box-shadow: 0 2px 8px color-mix(in srgb, var(--color-accent) 35%, transparent); }
.aup-action[data-variant="primary"]:hover { filter: brightness(1.15); box-shadow: 0 4px 16px color-mix(in srgb, var(--color-accent) 45%, transparent); transform: translateY(-1px); }
.aup-action[data-variant="primary"]:active { transform: translateY(0); filter: brightness(0.95); box-shadow: 0 1px 4px color-mix(in srgb, var(--color-accent) 25%, transparent); }
.aup-action[data-variant="destructive"] { background: color-mix(in srgb, var(--color-error) 12%, transparent); border-color: var(--color-error); color: var(--color-error); }
.aup-action[data-variant="destructive"]:hover { background: var(--color-error); color: var(--color-bg); box-shadow: 0 2px 8px color-mix(in srgb, var(--color-error) 35%, transparent); transform: translateY(-1px); }
.aup-action[data-variant="ghost"] { background: transparent; border-color: transparent; }
.aup-action[data-variant="ghost"]:hover { background: var(--color-surface); border-color: var(--color-border); transform: none; box-shadow: none; }
.aup-action { display: inline-flex; align-items: center; gap: 6px; }
.aup-action .aup-icon-svg { width: 1em; height: 1em; flex-shrink: 0; }
.aup-action[data-size="xs"] { padding: 3px 8px; font-size: 0.78em; }
.aup-action[data-size="sm"] { padding: 5px 12px; font-size: 0.85em; }
.aup-action[data-size="lg"] { padding: 10px 24px; font-size: 1em; }
.aup-action[data-size="xl"] { padding: 12px 32px; font-size: 1.1em; }

/* ── AUP Ticker Primitive ── */
.aup-ticker { overflow: hidden; width: 100%; white-space: nowrap; position: relative; font-family: var(--font-body); color: var(--color-text); padding: 8px 0; min-height: 2em; display: flex; align-items: center; }
.aup-ticker-track { display: inline-flex; align-items: center; will-change: transform; }
.aup-ticker[data-mode="scroll"] .aup-ticker-track { animation: ticker-scroll var(--ticker-duration, 20s) linear infinite; }
.aup-ticker[data-mode="scroll"][data-direction="ltr"] .aup-ticker-track { animation-direction: reverse; }
.aup-ticker[data-paused="true"] .aup-ticker-track { animation-play-state: paused; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.aup-ticker[data-mode="scroll"] .aup-ticker-item,
.aup-ticker[data-mode="static"] .aup-ticker-item { display: inline-flex; align-items: center; flex-shrink: 0; }
.aup-ticker-separator { display: inline-flex; align-items: center; flex-shrink: 0; padding: 0 8px; opacity: 0.5; }
.aup-ticker[data-mode="flip"] .aup-ticker-track { position: relative; width: 100%; min-height: 1.5em; }
.aup-ticker[data-mode="flip"] .aup-ticker-item { position: absolute; inset: 0; display: flex; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.4s ease, transform 0.4s ease; }
.aup-ticker[data-mode="flip"][data-flip-transition="slide-up"] .aup-ticker-item { transform: translateY(100%); }
.aup-ticker[data-mode="flip"][data-flip-transition="slide-up"] .aup-ticker-item.active { transform: translateY(0); }
.aup-ticker[data-mode="flip"][data-flip-transition="slide-left"] .aup-ticker-item { transform: translateX(100%); }
.aup-ticker[data-mode="flip"][data-flip-transition="slide-left"] .aup-ticker-item.active { transform: translateX(0); }
.aup-ticker[data-mode="flip"] .aup-ticker-item.active { opacity: 1; pointer-events: auto; }
.aup-ticker[data-intent="breaking"] { background: rgba(220,38,38,0.85); color: #fff; padding: 6px 12px; }
.aup-ticker[data-intent="warning"] { background: rgba(245,158,11,0.85); color: #000; padding: 6px 12px; }
.aup-ticker[data-intent="success"] { background: rgba(22,163,74,0.85); color: #fff; padding: 6px 12px; }
.aup-ticker[data-intent="info"] { background: rgba(37,99,235,0.85); color: #fff; padding: 6px 12px; }
.aup-view[data-layout="overlay-grid"] > .aup-ticker { width: 100%; }

/* ── Role base — structural defaults (no colors, themes provide visual treatment) ── */
[data-role="live-badge"] { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.8rem; }
[data-role="speaker-bar"] { display: flex; flex-direction: column; gap: 2px; }
[data-role="lower-third"] { display: flex; flex-direction: column; gap: 2px; }
[data-role="alert"] { font-weight: 600; }
[data-role="clock"] { font-variant-numeric: tabular-nums; }
[data-role="score-bug"] { display: inline-flex; align-items: center; font-variant-numeric: tabular-nums; }
[data-role="data-widget"] { display: block; }
[data-role="featured-comment"] { display: block; max-width: 400px; }

.aup-unknown { border: 1px dashed var(--color-dim); padding: 8px; border-radius: var(--radius-sm); color: var(--color-dim); font-size: 0.8em; }

/* ── AUP Time Primitive ── */
.aup-time { font-family: var(--font-body); color: var(--color-text); font-variant-numeric: tabular-nums; }
.aup-time-display { font-size: 1em; }
.aup-time-clock { font-size: 2em; font-weight: 600; letter-spacing: 0.02em; }
.aup-time-timer, .aup-time-countdown { font-size: 1.5em; font-weight: 500; font-family: "Share Tech Mono", "JetBrains Mono", monospace; }
.aup-time-picker input { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); padding: 6px 10px; border-radius: var(--radius-sm); font-family: var(--font-body); outline: none; }
.aup-time-picker input:focus { border-color: var(--color-accent); }

/* ── AUP Time Analog Clock ── */
.aup-time-analog-clock { display: inline-block; }
.aup-time-analog-clock svg { width: 120px; height: 120px; }
.aup-clock-face { fill: var(--card-bg); stroke: var(--color-border); stroke-width: 2; }
.aup-clock-tick { stroke: var(--color-dim); }
.aup-clock-number { fill: var(--color-text); font-size: 20px; font-weight: 600; text-anchor: middle; dominant-baseline: central; font-family: var(--font-body); }
.aup-clock-hand-hour { stroke: var(--color-text); stroke-width: 4; stroke-linecap: round; }
.aup-clock-hand-minute { stroke: var(--color-text); stroke-width: 2.5; stroke-linecap: round; }
.aup-clock-hand-second { stroke: var(--color-accent); stroke-width: 1; }
.aup-clock-center { fill: var(--color-text); }

/* ── AUP Time Calendar ── */
.aup-time-calendar { display: inline-block; width: 120px; text-align: center; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--color-border); background: var(--card-bg); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.aup-calendar-month { background: var(--color-accent); color: #fff; padding: 6px; font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.aup-calendar-day { font-size: 3em; font-weight: 700; padding: 8px 0 4px; color: var(--color-text); line-height: 1; font-family: var(--font-body); }
.aup-calendar-weekday { font-size: 0.8em; color: var(--color-dim); padding: 0 0 10px; }

/* ── AUP Chart Primitive ── */
.aup-chart { position: relative; min-height: 200px; background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); padding: 16px; }
.aup-chart canvas { width: 100% !important; height: 100% !important; }
.aup-chart-loading { color: var(--color-dim); text-align: center; padding: 40px; font-size: 0.9em; }

/* ── AUP Finance Chart (TradingView Lightweight Charts) ── */
.aup-finance-chart { position: relative; min-height: 200px; background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); overflow: hidden; }
.aup-finance-chart-loading { color: var(--color-dim); text-align: center; padding: 40px; font-size: 0.9em; }

/* ── AUP Map Primitive ── */
.aup-map { min-height: 300px; border: var(--card-border); border-radius: var(--radius-lg); overflow: hidden; position: relative; }
.aup-map-loading { color: var(--color-dim); text-align: center; padding: 40px; font-size: 0.9em; }
.aup-map .leaflet-popup-content-wrapper { background: var(--card-bg); color: var(--color-text); border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); border: 1px solid var(--color-border); font-family: var(--font-body); }
.aup-map .leaflet-popup-tip { background: var(--card-bg); }
.aup-map .leaflet-popup-content { margin: 8px 12px; font-size: 0.85em; line-height: 1.5; }
.aup-map .leaflet-control-attribution { font-size: 10px; opacity: 0.6; }
.aup-map .leaflet-control-zoom a { background: var(--card-bg); color: var(--color-text); border-color: var(--color-border); }
.aup-map .leaflet-control-zoom a:hover { background: var(--hover-bg); }

/* ── AUP Calendar Primitive ── */
.aup-calendar { background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); padding: 16px; }
.aup-calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.aup-calendar-header button { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); }
.aup-calendar-header button:hover { border-color: var(--color-accent); color: var(--color-accent); }
.aup-calendar-header .aup-calendar-title { font-weight: 600; font-size: 1.05em; }
.aup-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.aup-calendar-day-header { text-align: center; font-size: 0.75em; font-weight: 600; color: var(--color-dim); padding: 4px; text-transform: uppercase; }
.aup-calendar-day { text-align: center; padding: 6px 4px; border-radius: var(--radius-sm); font-size: 0.85em; cursor: default; position: relative; min-height: 32px; }
.aup-calendar-day.today { background: var(--color-accent-bg); color: var(--color-accent); font-weight: 700; }
.aup-calendar-day.other-month { color: var(--color-dim); opacity: 0.4; }
.aup-calendar-day .aup-calendar-event { display: block; font-size: 0.65em; margin-top: 2px; padding: 1px 3px; border-radius: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aup-calendar-event[data-intent="info"] { background: rgba(96,165,250,0.2); color: #60a5fa; }
.aup-calendar-event[data-intent="success"] { background: rgba(74,222,128,0.2); color: #4ade80; }
.aup-calendar-event[data-intent="warning"] { background: rgba(251,191,36,0.2); color: #fbbf24; }
.aup-calendar-event[data-intent="error"] { background: rgba(248,113,113,0.2); color: #f87171; }

/* ── AUP Moon Phase ── */
.aup-moonphase { display: flex; flex-direction: column; align-items: center; gap: 12px; background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); padding: 24px; }
.aup-moonphase-visual { font-size: 4rem; line-height: 1; filter: drop-shadow(0 0 12px rgba(200,200,255,0.3)); }
.aup-moonphase-name { font-size: 1.1em; font-weight: 600; text-transform: capitalize; }
.aup-moonphase-details { display: flex; gap: 20px; font-size: 0.85em; color: var(--color-dim); }
.aup-moonphase-details span { display: flex; align-items: center; gap: 4px; }
.aup-moonphase-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; width: 100%; margin-top: 8px; }
.aup-moonphase-month-day { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.72em; color: var(--color-dim); padding: 4px 2px; border-radius: var(--radius-sm); }
.aup-moonphase-month-day.today { background: rgba(99,102,241,0.15); color: var(--color-accent); }
.aup-moonphase-month-day .moon-emoji { font-size: 1.3em; }

/* ── XEyes ── */
.aup-xeyes { --xeyes-iris: #2c2c2c; --xeyes-bg: #fff; display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 16px 20px 8px; background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); }
.aup-xeyes-eye { width: 64px; height: 80px; background: var(--xeyes-bg); border-radius: 50% / 55%; border: 2px solid #888; display: flex; align-items: center; justify-content: center; position: relative; box-shadow: inset 0 2px 8px rgba(0,0,0,0.1); transition: border-radius 0.15s; }
.aup-xeyes-pupil { width: 24px; height: 24px; position: relative; transition: transform 0.05s linear; }
.aup-xeyes-iris { width: 24px; height: 24px; background: var(--xeyes-iris); border-radius: 50%; position: absolute; inset: 0; box-shadow: inset -2px -1px 3px rgba(255,255,255,0.3), 0 0 0 3px rgba(80,60,30,0.15); }
.aup-xeyes-iris::after { content: ""; position: absolute; width: 8px; height: 8px; background: #fff; border-radius: 50%; top: 3px; left: 4px; opacity: 0.9; }
.aup-xeyes-blink .aup-xeyes-eye { border-radius: 50% / 10%; height: 8px; overflow: hidden; }
.aup-xeyes-blink .aup-xeyes-pupil { opacity: 0; }
.aup-xeyes-label { width: 100%; text-align: center; font-size: 0.7em; color: var(--color-dim); letter-spacing: 0.5px; padding-top: 2px; font-family: var(--font-mono); }
.aup-xeyes[data-xeyes-size="sm"] .aup-xeyes-eye { width: 40px; height: 52px; }
.aup-xeyes[data-xeyes-size="sm"] .aup-xeyes-pupil, .aup-xeyes[data-xeyes-size="sm"] .aup-xeyes-iris { width: 16px; height: 16px; }
.aup-xeyes[data-xeyes-size="sm"] .aup-xeyes-iris::after { width: 5px; height: 5px; top: 2px; left: 3px; }
.aup-xeyes[data-xeyes-size="lg"] .aup-xeyes-eye { width: 96px; height: 120px; border-width: 3px; }
.aup-xeyes[data-xeyes-size="lg"] .aup-xeyes-pupil, .aup-xeyes[data-xeyes-size="lg"] .aup-xeyes-iris { width: 36px; height: 36px; }
.aup-xeyes[data-xeyes-size="lg"] .aup-xeyes-iris::after { width: 12px; height: 12px; top: 5px; left: 6px; }

/* ── AUP Natal Chart ── */
.aup-natal-chart { position: relative; min-height: 200px; background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); overflow: hidden; padding: 16px; }
.aup-natal-chart-loading { color: var(--color-dim); text-align: center; padding: 40px; font-size: 0.9em; }
.aup-natal-chart svg { display: block; margin: 0 auto; }
.aup-natal-aspects { margin-top: 16px; }
.aup-natal-aspects table { width: 100%; border-collapse: collapse; font-size: 0.82em; }
.aup-natal-aspects th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--color-border); color: var(--color-dim); font-weight: 600; }
.aup-natal-aspects td { padding: 5px 8px; border-bottom: 1px solid var(--color-border); }
.aup-natal-aspects tr:hover { background: rgba(99,102,241,0.06); }
.aup-natal-planets { margin-top: 12px; }
.aup-natal-planets table { width: 100%; border-collapse: collapse; font-size: 0.82em; }
.aup-natal-planets th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--color-border); color: var(--color-dim); font-weight: 600; }
.aup-natal-planets td { padding: 5px 8px; border-bottom: 1px solid var(--color-border); }

/* ── AUP Input ── */
.aup-input { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.aup-input label { color: var(--color-dim); font-size: 0.85em; }
.aup-input input, .aup-input select, .aup-input textarea { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); padding: 8px 12px; border-radius: var(--radius-md); font-family: var(--font-body); font-size: 0.9rem; outline: none; transition: border-color var(--transition); width: 100%; }
.aup-input input:focus, .aup-input select:focus, .aup-input textarea:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 12%, transparent); }
.aup-input .aup-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.aup-input .aup-toggle-track { width: 40px; height: 22px; border-radius: 11px; background: var(--color-border); position: relative; transition: background var(--transition), box-shadow var(--transition); cursor: pointer; }
.aup-input .aup-toggle-track.on { background: var(--color-accent); box-shadow: 0 0 8px color-mix(in srgb, var(--color-accent) 30%, transparent); }
.aup-input .aup-toggle-thumb { width: 18px; height: 18px; border-radius: 50%; background: white; position: absolute; top: 2px; left: 2px; transition: left var(--transition) cubic-bezier(0.4, 0, 0.2, 1), box-shadow var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.aup-input .aup-toggle-track.on .aup-toggle-thumb { left: 20px; }
.aup-input input[type="range"] { accent-color: var(--color-accent); }
.aup-input input[type="checkbox"] { accent-color: var(--color-accent); width: 16px; height: 16px; }
.aup-input .aup-checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.aup-progress { width: 100%; height: 8px; background: var(--color-border); border-radius: 4px; overflow: hidden; }
.aup-progress-fill { height: 100%; background: var(--color-accent); border-radius: 4px; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); background-image: linear-gradient(90deg, transparent 0%, color-mix(in srgb, white 15%, transparent) 50%, transparent 100%); background-size: 200% 100%; }
.aup-progress-fill[data-intent="success"] { background: var(--color-success); }
.aup-progress-fill[data-intent="error"] { background: var(--color-error); }
.aup-progress-fill[data-intent="info"] { background: var(--color-assistant); }
.aup-progress-row { display: flex; align-items: center; gap: 8px; }
.aup-progress-label { font-size: 0.85em; color: var(--color-dim); white-space: nowrap; }

/* ── AUP Command Bar ── */
.aup-command-bar { display: flex; flex-direction: column; height: 100%; min-height: 200px; background: var(--color-bg); }
.aup-cb-history { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.aup-cb-msg { padding: 8px 12px; border-radius: var(--radius-md); max-width: 85%; word-wrap: break-word; font-size: 0.9rem; line-height: 1.5; }
.aup-cb-msg-user { align-self: flex-end; background: var(--color-accent); color: white; border-bottom-right-radius: 2px; }
.aup-cb-msg-assistant, .aup-cb-msg-agent { align-self: flex-start; background: var(--color-surface); color: var(--color-text); border-bottom-left-radius: 2px; }
.aup-cb-msg-error { align-self: flex-start; background: rgba(255,60,60,0.15); color: #f44; border: 1px solid rgba(255,60,60,0.25); font-size: 0.85rem; }
.aup-cb-msg-assistant pre, .aup-cb-msg-agent pre { background: var(--color-bg); border-radius: var(--radius-sm); padding: 8px; overflow-x: auto; margin: 4px 0; font-size: 0.85em; }
.aup-cb-msg-assistant code, .aup-cb-msg-agent code { font-family: var(--font-mono, "JetBrains Mono", monospace); font-size: 0.9em; }
.aup-cb-msg-assistant p:first-child, .aup-cb-msg-agent p:first-child { margin-top: 0; }
.aup-cb-msg-assistant p:last-child, .aup-cb-msg-agent p:last-child { margin-bottom: 0; }
.aup-cb-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--color-border); background: var(--color-surface); }
.aup-cb-model { font-size: 0.75em; color: var(--color-dim); background: var(--color-bg); padding: 2px 8px; border-radius: var(--radius-sm); white-space: nowrap; flex-shrink: 0; }
.aup-cb-input { flex: 1; background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); padding: 8px 12px; border-radius: var(--radius-md); font-family: var(--font-body); font-size: 0.9rem; outline: none; transition: border-color var(--transition); }
.aup-cb-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 12%, transparent); }
.aup-cb-input:disabled { opacity: 0.5; cursor: not-allowed; }
.aup-cb-send { background: var(--color-accent); color: white; border: none; border-radius: var(--radius-md); width: 34px; height: 34px; cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity var(--transition); }
.aup-cb-send:hover { opacity: 0.85; }
.aup-cb-timer { font-variant-numeric: tabular-nums; font-size: 0.85em; color: var(--color-dim); }
.aup-cb-timer::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: aup-dots 1.4s steps(4, end) infinite; }
@keyframes aup-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ── Agent mode variants ── */
.aup-agent-chat { display: flex; flex-direction: column; height: 100%; }
.aup-agent-hud { position: fixed; top: 16px; right: 16px; max-width: 400px; max-height: 60vh; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: 0 8px 32px rgba(0,0,0,0.2); z-index: 1000; overflow: hidden; }
.aup-agent-bar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--color-surface); border-top: 1px solid var(--color-border); padding: 8px 16px; z-index: 1000; }
.aup-agent-bar .aup-cb-history { display: none; }
.aup-agent-bar .aup-cb-bar { padding: 0; border-top: none; }

/* ── AUP Media ── */
.aup-media { display: inline-block; }
.aup-media img { max-width: 100%; height: auto; border-radius: var(--radius-md); object-fit: contain; }
.aup-media .aup-icon { font-size: 1.5em; display: inline-flex; align-items: center; justify-content: center; width: 2em; height: 2em; border-radius: 50%; background: var(--color-surface); }
.aup-media .aup-icon-svg { width: 1.25em; height: 1.25em; flex-shrink: 0; }
.aup-media video { max-width: 100%; border-radius: var(--radius-sm); }
.aup-media .aup-placeholder { width: 100px; height: 100px; background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--color-dim); font-size: 0.8em; }
.aup-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; background: var(--color-accent-bg); color: var(--color-accent); font-weight: 600; flex-shrink: 0; }
.aup-avatar img { width: 100%; height: 100%; object-fit: cover; }
.aup-avatar[data-size="xs"] { width: 24px; height: 24px; font-size: 0.65em; }
.aup-avatar[data-size="sm"] { width: 32px; height: 32px; font-size: 0.75em; }
.aup-avatar[data-size="md"], .aup-avatar:not([data-size]) { width: 40px; height: 40px; font-size: 0.9em; }
.aup-avatar[data-size="lg"] { width: 56px; height: 56px; font-size: 1.1em; }
.aup-avatar[data-size="xl"] { width: 80px; height: 80px; font-size: 1.4em; }

/* ── AUP Overlay ── */
.aup-overlay { display: none; }
.aup-overlay.open { display: contents; }
.aup-overlay-backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 1000; animation: aup-backdrop-in 0.25s ease both; }
.aup-overlay[data-scope="global"] > .aup-overlay-backdrop { position: fixed; }
.aup-overlay-dialog { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 24px; z-index: 1001; min-width: 320px; max-width: 80vw; max-height: 80vh; overflow-y: auto; box-shadow: 0 24px 48px rgba(0,0,0,0.2), 0 8px 16px rgba(0,0,0,0.1); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); animation: aup-dialog-in 0.2s cubic-bezier(0.4, 0, 0.2, 1) both; }
.aup-overlay[data-scope="global"] > .aup-overlay-dialog { position: fixed; }
.aup-overlay-dialog-title { font-family: var(--font-heading); font-weight: var(--heading-weight); color: var(--color-text); margin-bottom: 16px; font-size: 1.2em; letter-spacing: var(--heading-spacing); display: flex; justify-content: space-between; align-items: center; }
.aup-overlay-close { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px 8px; opacity: 0.6; color: inherit; }
.aup-overlay-close:hover { opacity: 1; }
.aup-overlay-popover { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 8px 0; z-index: 9999; min-width: 160px; max-width: 320px; max-height: 400px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.1); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); animation: aup-dialog-in 0.15s cubic-bezier(0.4, 0, 0.2, 1) both; }
.aup-overlay:not(.open) > .aup-overlay-popover { display: none; }
.aup-overlay-popover .aup-action { display: block; width: 100%; text-align: left; padding: 6px 16px; border-radius: 0; border: none; background: none; }
.aup-overlay-popover .aup-action:hover { background: var(--hover); }
.aup-overlay-drawer { position: absolute; top: 0; bottom: 0; background: var(--color-surface); border-left: 1px solid var(--color-border); z-index: 1001; width: 320px; padding: 16px; overflow-y: auto; box-shadow: -8px 0 24px rgba(0,0,0,0.15); }
.aup-overlay[data-scope="global"] > .aup-overlay-drawer { position: fixed; }
.aup-overlay-drawer.right { right: 0; animation: aup-drawer-right 0.3s cubic-bezier(0.4, 0, 0.2, 1) both; }
.aup-overlay-drawer.left { left: 0; border-left: none; border-right: 1px solid var(--color-border); animation: aup-drawer-left 0.3s cubic-bezier(0.4, 0, 0.2, 1) both; box-shadow: 8px 0 24px rgba(0,0,0,0.15); }
.aup-overlay-toast { position: absolute; z-index: 2100; max-width: 400px; min-width: 280px; animation: aup-toast-in 0.35s cubic-bezier(0.4, 0, 0.2, 1) both; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 0; box-shadow: 0 8px 24px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); overflow: hidden; display: flex; flex-direction: column; }
.aup-overlay[data-scope="global"] > .aup-overlay-toast { position: fixed; }
.aup-overlay-toast.exiting { animation: aup-toast-out 0.25s ease forwards; }
/* Position variants */
.aup-overlay-toast[data-position="bottom-right"], .aup-overlay-toast:not([data-position]) { bottom: 80px; right: 20px; }
.aup-overlay-toast[data-position="bottom-left"] { bottom: 80px; left: 20px; }
.aup-overlay-toast[data-position="bottom-center"] { bottom: 80px; left: 50%; transform: translateX(-50%); }
.aup-overlay-toast[data-position="top-right"] { top: 20px; right: 20px; }
.aup-overlay-toast[data-position="top-left"] { top: 20px; left: 20px; }
.aup-overlay-toast[data-position="top-center"] { top: 20px; left: 50%; transform: translateX(-50%); }
/* Intent accent — left border stripe */
.aup-overlay-toast[data-intent="success"] { border-left: 3px solid var(--color-success); }
.aup-overlay-toast[data-intent="error"] { border-left: 3px solid var(--color-error); }
.aup-overlay-toast[data-intent="warning"] { border-left: 3px solid var(--color-accent); }
.aup-overlay-toast[data-intent="info"] { border-left: 3px solid color-mix(in srgb, var(--color-accent) 60%, var(--color-text)); }
/* Body layout */
.aup-toast-body { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; }
.aup-toast-icon { flex-shrink: 0; font-size: 1.3em; line-height: 1; margin-top: 1px; }
.aup-toast-icon img { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; }
.aup-toast-content { flex: 1; min-width: 0; }
.aup-toast-title { font-weight: 600; font-size: 0.9em; color: var(--color-text); margin-bottom: 2px; }
.aup-toast-message { font-size: 0.84em; color: var(--color-dim); line-height: 1.4; }
.aup-toast-close { flex-shrink: 0; background: none; border: none; color: var(--color-dim); cursor: pointer; font-size: 1.1em; padding: 0 2px; line-height: 1; opacity: 0.6; transition: opacity var(--transition); }
.aup-toast-close:hover { opacity: 1; }
/* Timer bar */
.aup-toast-timer { height: 3px; background: color-mix(in srgb, var(--color-accent) 20%, transparent); }
.aup-toast-timer-bar { height: 100%; background: var(--color-accent); transition: width linear; }
.aup-overlay-toast[data-intent="success"] .aup-toast-timer-bar { background: var(--color-success); }
.aup-overlay-toast[data-intent="error"] .aup-toast-timer-bar { background: var(--color-error); }
.aup-overlay-toast[data-intent="warning"] .aup-toast-timer-bar { background: var(--color-accent); }
/* ── Alert / Confirm ── */
.aup-overlay-alert { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 28px 32px; z-index: 1001; min-width: 340px; max-width: 480px; text-align: center; box-shadow: 0 24px 48px rgba(0,0,0,0.25); animation: aup-dialog-in 0.2s cubic-bezier(0.4, 0, 0.2, 1) both; }
.aup-alert-icon { font-size: 2.4em; margin-bottom: 12px; line-height: 1; }
.aup-alert-icon[data-intent="info"] { color: var(--color-accent); }
.aup-alert-icon[data-intent="success"] { color: var(--color-success); }
.aup-alert-icon[data-intent="error"] { color: var(--color-error); }
.aup-alert-icon[data-intent="warning"] { color: #f0a030; }
.aup-alert-title { font-family: var(--font-heading); font-weight: var(--heading-weight); color: var(--color-text); font-size: 1.25em; margin-bottom: 8px; letter-spacing: var(--heading-spacing); }
.aup-alert-message { color: var(--color-dim); font-size: 0.92em; line-height: 1.5; margin-bottom: 20px; }
.aup-alert-actions { display: flex; gap: 8px; justify-content: center; }
.aup-alert-btn { padding: 8px 24px; border-radius: var(--radius-md); font-family: var(--font-body); font-size: 0.9em; font-weight: 600; cursor: pointer; transition: all var(--transition); border: 1px solid var(--color-border); }
.aup-alert-btn.primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg); }
.aup-alert-btn.primary:hover { filter: brightness(1.15); transform: translateY(-1px); }
.aup-alert-btn.secondary { background: transparent; color: var(--color-text); }
.aup-alert-btn.secondary:hover { background: var(--color-accent-bg); border-color: var(--color-accent); }
.aup-alert-btn.danger { background: var(--color-error); border-color: var(--color-error); color: #fff; }
.aup-alert-btn.danger:hover { filter: brightness(1.1); }

/* ── HUD (fullscreen status) ── */
.aup-overlay-hud { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1001; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 32px 48px; background: color-mix(in srgb, var(--color-surface) 90%, transparent); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: 0 16px 48px rgba(0,0,0,0.25); animation: aup-dialog-in 0.25s cubic-bezier(0.4, 0, 0.2, 1) both; }
.aup-hud-spinner { width: 36px; height: 36px; border: 3px solid var(--color-border); border-top-color: var(--color-accent); border-radius: 50%; animation: aup-spin 0.8s linear infinite; }
.aup-hud-icon { font-size: 2em; }
.aup-hud-message { color: var(--color-text); font-size: 0.95em; font-weight: 500; }
.aup-hud-sub { color: var(--color-dim); font-size: 0.82em; }
.aup-hud-progress { width: 160px; height: 4px; background: var(--color-border); border-radius: 2px; overflow: hidden; }
.aup-hud-progress-bar { height: 100%; background: var(--color-accent); border-radius: 2px; transition: width 0.3s ease; }
@keyframes aup-spin { to { transform: rotate(360deg); } }

/* ── Choice / AskUser (Claude Code style) ── */
.aup-overlay-choice { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 0; z-index: 1001; min-width: 420px; max-width: 560px; max-height: 80vh; overflow: hidden; box-shadow: 0 24px 48px rgba(0,0,0,0.25); animation: aup-dialog-in 0.2s cubic-bezier(0.4, 0, 0.2, 1) both; display: flex; flex-direction: column; }
.aup-choice-header { padding: 20px 24px 0; }
.aup-choice-tag { display: inline-block; font-size: 0.7em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-accent); background: var(--color-accent-bg); padding: 3px 10px; border-radius: 999px; margin-bottom: 10px; }
.aup-choice-question { font-family: var(--font-heading); font-weight: var(--heading-weight); color: var(--color-text); font-size: 1.15em; line-height: 1.4; letter-spacing: var(--heading-spacing); margin-bottom: 4px; }
.aup-choice-hint { color: var(--color-dim); font-size: 0.82em; margin-bottom: 0; }
.aup-choice-options { padding: 12px 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.aup-choice-option { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition); background: transparent; text-align: left; font-family: var(--font-body); }
.aup-choice-option:hover { border-color: var(--color-accent); background: var(--color-accent-bg); }
.aup-choice-option.selected { border-color: var(--color-accent); background: var(--color-accent-bg); box-shadow: 0 0 0 1px var(--color-accent); }
.aup-choice-radio { flex-shrink: 0; width: 18px; height: 18px; border: 2px solid var(--color-border); border-radius: 50%; margin-top: 1px; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.aup-choice-check { flex-shrink: 0; width: 18px; height: 18px; border: 2px solid var(--color-border); border-radius: 4px; margin-top: 1px; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.aup-choice-option.selected .aup-choice-radio { border-color: var(--color-accent); }
.aup-choice-option.selected .aup-choice-radio::after { content: ""; width: 8px; height: 8px; background: var(--color-accent); border-radius: 50%; }
.aup-choice-option.selected .aup-choice-check { border-color: var(--color-accent); background: var(--color-accent); }
.aup-choice-option.selected .aup-choice-check::after { content: ""; width: 10px; height: 7px; border-left: 2px solid var(--color-bg); border-bottom: 2px solid var(--color-bg); transform: rotate(-45deg) translate(1px, -1px); }
.aup-choice-label { font-weight: 500; color: var(--color-text); font-size: 0.92em; }
.aup-choice-desc { color: var(--color-dim); font-size: 0.82em; line-height: 1.4; margin-top: 2px; }
.aup-choice-other { display: flex; gap: 8px; padding: 0 12px 16px; }
.aup-choice-other input { flex: 1; background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); padding: 8px 12px; border-radius: var(--radius-md); font-family: var(--font-body); font-size: 0.9em; outline: none; transition: border-color var(--transition); }
.aup-choice-other input:focus { border-color: var(--color-accent); }
.aup-choice-other input::placeholder { color: var(--color-dim); }
.aup-choice-footer { padding: 12px 16px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; background: color-mix(in srgb, var(--color-bg) 50%, var(--color-surface)); }
.aup-choice-stepper { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 24px 4px; }
.aup-choice-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-border); transition: all var(--transition); }
.aup-choice-dot.active { background: var(--color-accent); transform: scale(1.3); }
.aup-choice-dot.done { background: var(--color-accent); opacity: 0.5; }
.aup-choice-step-label { font-size: 0.72em; color: var(--color-dim); margin-left: 8px; }
.aup-choice-step-body { animation: aup-step-in 0.2s ease; }
@keyframes aup-step-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
.aup-choice-footer { align-items: center; }
.aup-choice-footer .spacer { flex: 1; }

@keyframes aup-toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes aup-toast-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-8px) scale(0.97); } }
@keyframes aup-page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes aup-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes aup-dialog-in { from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes aup-drawer-right { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes aup-drawer-left { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes aup-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── AUP Table ── */
.aup-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--msg-font-size); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.aup-table th { text-align: left; padding: 10px 14px; border-bottom: 2px solid var(--color-border); color: var(--color-dim); font-weight: 600; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.06em; background: var(--color-surface); cursor: pointer; user-select: none; transition: color var(--transition), background var(--transition); }
.aup-table th:hover { color: var(--color-accent); background: var(--color-accent-bg); }
.aup-table th[data-align="right"] { text-align: right; }
.aup-table th[data-align="center"] { text-align: center; }
.aup-table td { padding: 10px 14px; border-bottom: 1px solid var(--color-border); color: var(--color-text); transition: background var(--transition); }
.aup-table td[data-align="right"] { text-align: right; }
.aup-table td[data-align="center"] { text-align: center; }
.aup-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--color-surface) 50%, transparent); }
.aup-table tr:hover td { background: var(--color-accent-bg); }
.aup-table tbody tr:last-child td { border-bottom: none; }
.aup-table .aup-table-empty { text-align: center; color: var(--color-dim); padding: 20px; }

/* ── AUP Terminal Component ── */
.aup-terminal { background: var(--color-bg, #0c0c0c); border: none; border-radius: 0; overflow: hidden; }
.aup-terminal .xterm { padding: 4px; }
.aup-terminal .xterm-viewport { overflow-y: auto !important; }
.aup-terminal-placeholder { color: var(--color-dim); text-align: center; padding: 40px; font-size: 0.9em; }

/* ── AUP Editor Subsystem ── */
.aup-editor { display: flex; flex-direction: column; background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); overflow: hidden; }
.aup-editor-toolbar { display: flex; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); flex-wrap: wrap; }
.aup-editor-toolbar button { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); padding: 3px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.78em; transition: all var(--transition); }
.aup-editor-toolbar button:hover { border-color: var(--color-accent); color: var(--color-accent); }
.aup-editor-toolbar .active { background: var(--color-accent-bg); border-color: var(--color-accent); color: var(--color-accent); }
.aup-editor-area { flex: 1; min-height: 200px; position: relative; }
.aup-editor-area textarea { width: 100%; height: 100%; min-height: 200px; background: transparent; color: transparent; caret-color: var(--color-text); border: none; padding: 12px; font-family: "JetBrains Mono", "Fira Code", monospace; font-size: 13px; line-height: 1.6; resize: vertical; outline: none; tab-size: 2; position: relative; z-index: 1; }
.aup-editor-highlight { position: absolute; top: 0; left: 0; right: 0; bottom: 0; padding: 12px; font-family: "JetBrains Mono", "Fira Code", monospace; font-size: 13px; line-height: 1.6; tab-size: 2; white-space: pre-wrap; word-wrap: break-word; overflow: hidden; pointer-events: none; background: var(--color-bg); color: var(--color-text); }
.aup-editor-highlight code { background: transparent !important; padding: 0 !important; font-size: inherit; line-height: inherit; }
.aup-editor-statusbar { display: flex; justify-content: space-between; padding: 4px 10px; font-size: 0.75em; color: var(--color-dim); border-top: 1px solid var(--color-border); background: var(--color-surface); }
.aup-editor-gutter { position: absolute; left: 0; top: 0; bottom: 0; width: 40px; padding: 12px 4px; text-align: right; font-family: "JetBrains Mono", monospace; font-size: 13px; line-height: 1.6; color: var(--color-dim); background: var(--color-surface); border-right: 1px solid var(--color-border); user-select: none; overflow: hidden; white-space: pre; }
.aup-editor-area.has-gutter textarea { padding-left: 48px; }
.aup-editor-area.has-gutter .aup-editor-highlight { padding-left: 48px; }

/* ── AUP Frame (sandboxed iframe page isolation) ── */
.aup-frame { position: relative; width: 100%; min-height: 200px; flex: 1; border-radius: var(--radius-lg); overflow: hidden; background: var(--card-bg); border: var(--card-border); display: flex; flex-direction: column; }
.aup-frame iframe { width: 100%; flex: 1; min-height: 200px; border: none; display: block; }
.aup-frame[data-size-width] iframe { width: auto; }
.aup-frame[data-size-height] { min-height: 0; }
.aup-frame[data-size-height] iframe { min-height: 0; }
.aup-frame-loading { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; background: var(--color-surface); }
.aup-frame-loading-bar { width: 120px; height: 4px; background: var(--color-border); border-radius: 2px; overflow: hidden; position: relative; }
.aup-frame-loading-bar::after { content: ''; position: absolute; left: -40%; width: 40%; height: 100%; background: var(--color-accent); border-radius: 2px; animation: aup-frame-shimmer 1.2s ease-in-out infinite; }
@keyframes aup-frame-shimmer { 0% { left: -40%; } 100% { left: 100%; } }
.aup-frame-error { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 200px; color: var(--color-dim); padding: 24px; text-align: center; }
.aup-frame-error-icon { font-size: 2em; }
.aup-frame-error-msg { font-size: 0.9em; }
.aup-frame-retry { background: var(--color-accent); color: var(--color-bg); border: none; padding: 6px 16px; border-radius: var(--radius-md); cursor: pointer; font-family: var(--font-body); font-size: 0.85em; font-weight: 500; transition: all var(--transition); }
.aup-frame-retry:hover { filter: brightness(1.15); }

/* ── AUP Device (nested AUP rendering surface) ── */
.aup-surface { position: relative; border: 1px solid var(--color-border); border-radius: var(--radius-md); min-height: 60px; }
.aup-surface[data-aup-surface-sizing="fixed"] { overflow: hidden; }
.aup-surface[data-aup-surface-sizing="fixed"] .aup-surface-content { width: 100%; height: 100%; overflow: auto; }
.aup-surface[data-aup-surface-sizing="fit"] .aup-surface-content { width: 100%; }
.aup-surface-status { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); z-index: 1; transition: background 0.3s; }
.aup-surface-status.connected { background: var(--color-success, #22c55e); }
.aup-surface-status.error { background: var(--color-error, #ef4444); }
.aup-surface-fallback { padding: 12px; background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: var(--radius-sm); color: var(--muted); text-align: center; font-size: 0.85em; }
.aup-surface-breadcrumb { display: flex; align-items: center; gap: 2px; padding: 6px 12px; font-size: 12px; color: var(--color-dim); border-bottom: 1px solid var(--color-border); background: var(--color-surface); overflow-x: auto; white-space: nowrap; }
.aup-surface-breadcrumb-sep { opacity: 0.4; margin: 0 2px; }
.aup-surface-breadcrumb-seg { cursor: pointer; color: var(--color-accent); transition: opacity var(--transition); }
.aup-surface-breadcrumb-seg:hover { opacity: 0.8; text-decoration: underline; }
.aup-surface-breadcrumb-cur { color: var(--color-text); font-weight: 500; }

/* ── AUP Device view selector (tabs / dropdown) ── */
.aup-surface-view-selector { display: flex; align-items: center; gap: 0; padding: 0 8px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); font-size: 13px; overflow-x: auto; white-space: nowrap; }
.aup-surface-view-tab { padding: 6px 12px; cursor: pointer; color: var(--color-dim); border-bottom: 2px solid transparent; transition: color 0.2s, border-color 0.2s; user-select: none; }
.aup-surface-view-tab:hover { color: var(--color-text); }
.aup-surface-view-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 500; }
.aup-surface-view-dropdown { padding: 4px 8px; margin: 4px 8px; font-size: 13px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text); cursor: pointer; }
.aup-surface-view-dropdown:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }

/* ── Surface Sidebar Nav ── */
.aup-surface-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.aup-surface-nav { width: 200px; flex-shrink: 0; border-right: 1px solid var(--color-border); background: var(--color-surface); padding: 12px 0; overflow-y: auto; }
.aup-surface-nav-item { display: block; padding: 8px 16px; font-size: 0.85rem; color: var(--color-text); cursor: pointer; transition: background 0.15s, color 0.15s; user-select: none; }
.aup-surface-nav-item:hover { background: var(--hover); }
.aup-surface-nav-item.active { color: var(--color-accent); background: var(--hover); font-weight: 500; }
.aup-surface-main { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; }
.aup-surface-main > .aup-surface-content { flex: 1; padding: 16px 24px; }
@media (max-width: 768px) {
  .aup-surface-nav { display: none; }
}

/* ── AUP src binding: loading skeleton & error banner ── */
.aup-src-loading { display: flex; align-items: center; justify-content: center; padding: 16px; }
.aup-src-loading-bar { width: 120px; height: 4px; background: var(--color-border); border-radius: 2px; overflow: hidden; position: relative; }
.aup-src-loading-bar::after { content: ''; position: absolute; left: -40%; width: 40%; height: 100%; background: var(--color-accent); border-radius: 2px; animation: aup-frame-shimmer 1.2s ease-in-out infinite; }
.aup-src-error { padding: 8px 12px; background: var(--error-bg, rgba(220,38,38,0.1)); color: var(--color-error, #ef4444); font-size: 0.85em; border-radius: var(--radius-sm); margin: 4px 0; }

/* ── AUP Canvas Subsystem ── */
.aup-canvas { background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); overflow: clip; }
.aup-canvas-toolbar { display: flex; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); align-items: center; }
.aup-canvas-toolbar button { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.8em; transition: all var(--transition); }
.aup-canvas-toolbar button:hover { border-color: var(--color-accent); color: var(--color-accent); }
.aup-canvas-toolbar button.active { background: var(--color-accent-bg); border-color: var(--color-accent); color: var(--color-accent); }
.aup-canvas-toolbar .separator { width: 1px; height: 18px; background: var(--color-border); }
.aup-canvas-toolbar input[type="color"] { width: 28px; height: 28px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); cursor: pointer; background: none; padding: 2px; }
.aup-canvas-toolbar input[type="range"] { width: 60px; accent-color: var(--color-accent); }
.aup-canvas-area { position: relative; }
.aup-canvas-area canvas { display: block; cursor: crosshair; }

/* ── Entrance Animations ── */
/* Entrance animations disabled — causes flicker on page transitions */

@keyframes aup-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes aup-slide-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes aup-slide-down { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes aup-slide-left { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes aup-zoom-in { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
@keyframes aup-blur-in { from { opacity: 0; filter: blur(8px); transform: scale(0.97); } to { opacity: 1; filter: blur(0); transform: scale(1); } }
@keyframes aup-scale-card { from { opacity: 0; transform: scale(0.92) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ── Background video ── */
.aup-bg-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; pointer-events: none; }
.aup-view:has(.aup-bg-video) > *:not(.aup-bg-video) { position: relative; z-index: 1; }

/* ── Audio ── */
.aup-media audio { width: 100%; max-width: 400px; }

a.aup-action { text-decoration: none; display: inline-block; }
a.aup-action[data-variant="active"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg); }
/* ── Focus ring ── */
.aup-action:focus-visible, .aup-input input:focus-visible, .aup-input select:focus-visible, .aup-input textarea:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-accent) 15%, transparent); }

/* ══════════════════════════════════════════════════
   AFS List Primitive
   Two dimensions: layout (spatial) × itemStyle (per-item)
   ══════════════════════════════════════════════════ */
.aup-list { display: flex; flex-direction: column; height: 100%; overflow: hidden; font-family: var(--font-body); color: var(--color-text); }

.aup-list-loading { padding: 16px; color: var(--color-dim); font-size: 13px; text-align: center; }
.aup-list-empty { padding: 24px 16px; color: var(--color-dim); font-size: 13px; text-align: center; }
.aup-list-load-more { padding: 12px 16px; text-align: center; color: var(--color-accent); cursor: pointer; font-size: 12px; border-top: 1px solid var(--color-border); }
.aup-list-load-more:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.aup-list-virtual-spacer { flex-shrink: 0; }
.aup-list-virtual-content { flex-shrink: 0; }
.aup-list-template-item { cursor: pointer; }
.aup-list-template-header { flex-shrink: 0; }

/* ── Search ── */
.aup-list-search { padding: 6px 8px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.aup-list-search-input { width: 100%; padding: 5px 10px; font-size: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--color-bg) 80%, var(--color-surface)); color: var(--color-text); outline: none; font-family: var(--font-body); }
.aup-list-search-input:focus { border-color: var(--color-accent); }
.aup-list-search-input::placeholder { color: var(--color-dim); }

/* ── Breadcrumb ── */
.aup-list-breadcrumb { display: flex; align-items: center; gap: 2px; padding: 8px 12px; font-size: 12px; color: var(--color-dim); border-bottom: 1px solid var(--color-border); flex-shrink: 0; overflow-x: auto; white-space: nowrap; }
.aup-list-breadcrumb-sep { opacity: 0.4; margin: 0 2px; }
.aup-list-breadcrumb-seg { cursor: pointer; color: var(--color-accent); transition: opacity var(--transition); }
.aup-list-breadcrumb-seg:hover { opacity: 0.8; text-decoration: underline; }
.aup-list-breadcrumb-cur { color: var(--color-text); font-weight: 500; }

/* ── Body — layout dimension ── */
.aup-list-body { display: flex; flex-direction: column; overflow-y: auto; flex: 1; min-height: 0; }
.aup-list-body:focus { outline: none; }
.aup-list-body:focus-visible { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-accent) 40%, transparent); }

/* Layout: list (default) */
.aup-list[data-layout="list"] .aup-list-body { gap: 1px; }

/* Layout: grid */
.aup-list[data-layout="grid"] .aup-list-body {
  display: grid;
  grid-template-columns: repeat(var(--list-cols, 3), 1fr);
  gap: 12px; padding: 12px;
}
.aup-list[data-layout="grid"][data-auto-fill] .aup-list-body {
  grid-template-columns: repeat(auto-fill, minmax(var(--list-min-width, 200px), 1fr));
}
@media (max-width: 600px) {
  .aup-list[data-layout="grid"]:not([data-auto-fill]) .aup-list-body { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; }
}

/* Layout: masonry — CSS columns */
.aup-list[data-layout="masonry"] .aup-list-body {
  display: block; column-count: var(--list-cols, 3); column-gap: 12px; padding: 12px;
}
.aup-list[data-layout="masonry"] .aup-list-body > * { break-inside: avoid; margin-bottom: 12px; }
.aup-list[data-layout="masonry"] .aup-list-media { aspect-ratio: auto; }
.aup-list[data-layout="masonry"] .aup-list-media-img { width: 100%; height: auto; object-fit: contain; }
@media (max-width: 600px) {
  .aup-list[data-layout="masonry"] .aup-list-body { column-count: 2; }
}

/* Layout: slideshow */
.aup-list[data-layout="slideshow"] .aup-list-body { position: relative; overflow: hidden; }
.aup-list-slideshow-nav { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px; border-top: 1px solid var(--color-border); flex-shrink: 0; }
.aup-list-slide-btn { background: none; border: 1px solid var(--color-border); color: var(--color-text); width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: background var(--transition); }
.aup-list-slide-btn:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.aup-list-slide-counter { font-size: 12px; color: var(--color-dim); min-width: 48px; text-align: center; }

/* ── Item Style: row (default) ── */
.aup-list-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; transition: background var(--transition); border-radius: var(--radius-sm); margin: 0 4px; }
.aup-list-row:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.aup-list-row[data-selected="true"] { background: color-mix(in srgb, var(--color-accent) 15%, transparent); }
.aup-list-row[data-selected="true"] .aup-list-label { color: var(--color-accent); }

/* ── Item Style: card ── */
.aup-list-card { display: flex; flex-direction: column; border: var(--card-border); border-radius: var(--radius-md); background: var(--card-bg); box-shadow: var(--shadow-card); overflow: hidden; cursor: pointer; transition: box-shadow var(--transition), transform var(--transition); }
.aup-list-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.aup-list-card[data-selected="true"] { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.aup-list-card-image { height: 140px; background-size: cover; background-position: center; background-repeat: no-repeat; background-color: color-mix(in srgb, var(--color-surface) 80%, var(--color-border)); }
.aup-list-card-avatar-area { display: flex; align-items: center; justify-content: center; padding: 20px 0 8px; background: color-mix(in srgb, var(--color-surface) 80%, var(--color-border)); }
.aup-list-card-avatar { width: 80px; height: 80px; border-radius: 50%; background-size: cover; background-position: center; background-repeat: no-repeat; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.aup-list-card-icon-area { height: 80px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--color-surface) 80%, var(--color-border)); color: var(--color-dim); }
.aup-list-card-icon-area .aup-icon-svg { width: 32px; height: 32px; }
.aup-list-card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.aup-list-card-title { font-size: 13px; font-weight: 600; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aup-list-card-desc { font-size: 11px; color: var(--color-dim); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ── Item Style: compact ── */
.aup-list-compact { display: flex; align-items: center; gap: 6px; padding: 3px 8px; cursor: pointer; font-size: 12px; transition: background var(--transition); border-radius: var(--radius-sm); }
.aup-list-compact:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.aup-list-compact[data-selected="true"] { background: color-mix(in srgb, var(--color-accent) 15%, transparent); }
.aup-list-compact .aup-list-icon { width: 14px; height: 14px; }
.aup-list-compact .aup-icon-svg { width: 12px; height: 12px; }

/* ── Item Style: media ── */
.aup-list-media { position: relative; border-radius: var(--radius-md); overflow: hidden; cursor: pointer; aspect-ratio: 4/3; }
.aup-list-media:hover .aup-list-media-overlay { opacity: 1; }
.aup-list-media[data-selected="true"] { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.aup-list-media-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aup-list-media-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--color-surface) 70%, var(--color-border)); color: var(--color-dim); }
.aup-list-media-placeholder .aup-icon-svg { width: 40px; height: 40px; }
.aup-list-media-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px 10px; background: linear-gradient(transparent, rgba(0,0,0,0.7)); opacity: 0; transition: opacity var(--transition); }
.aup-list-media-title { font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.aup-list-media-subtitle { font-size: 11px; color: rgba(255,255,255,0.75); margin-top: 2px; }
.aup-list-media-footer { font-size: 10px; color: rgba(255,255,255,0.6); margin-top: 4px; }

/* ── Item Style: hero ── */
.aup-list-hero { position: relative; min-height: 200px; border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; background-size: cover; background-position: center; background-color: color-mix(in srgb, var(--color-surface) 70%, var(--color-border)); display: flex; align-items: flex-end; }
.aup-list-hero:hover { opacity: 0.95; }
.aup-list-hero[data-selected="true"] { outline: 3px solid var(--color-accent); outline-offset: -3px; }
.aup-list-hero-content { width: 100%; padding: 20px 24px; background: linear-gradient(transparent 0%, rgba(0,0,0,0.6) 60%, rgba(0,0,0,0.85)); }
.aup-list-hero-title { font-size: 18px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.aup-list-hero-desc { font-size: 13px; color: rgba(255,255,255,0.8); margin-top: 4px; }
.aup-list-hero-footer { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 6px; }

/* ── Item Style: card footer ── */
.aup-list-card-footer { font-size: 11px; color: var(--color-dim); margin-top: 6px; padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--color-border) 40%, transparent); }

/* ── Shared sub-elements ── */
.aup-list-icon { flex-shrink: 0; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; color: var(--color-dim); }
.aup-list-icon .aup-icon-svg { width: 16px; height: 16px; }
.aup-list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.aup-list-label { font-size: 13px; font-weight: 500; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aup-list-desc { font-size: 11px; color: var(--color-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aup-list-badge { flex-shrink: 0; font-size: 11px; padding: 1px 6px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--color-dim) 15%, transparent); color: var(--color-dim); font-weight: 500; }
.aup-list-chevron { flex-shrink: 0; width: 14px; font-size: 10px; color: var(--color-dim); user-select: none; }

/* ── Grouped children ── */
.aup-list-children { padding-left: 16px; display: none; border-left: 1px solid color-mix(in srgb, var(--color-border) 50%, transparent); margin-left: 6px; }
.aup-list-children[data-expanded="true"] { display: block; }

/* ── Table layout ── */
.aup-list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.aup-list-table th { text-align: left; padding: 6px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-dim); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; background: var(--color-bg); }
.aup-list-table td { padding: 5px 12px; border-bottom: 1px solid color-mix(in srgb, var(--color-border) 40%, transparent); color: var(--color-text); }
.aup-list-table-row { cursor: pointer; transition: background var(--transition); }
.aup-list-table-row:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.aup-list-table-row[data-selected="true"] { background: color-mix(in srgb, var(--color-accent) 15%, transparent); }
.aup-list-table-expand { cursor: pointer; user-select: none; }

/* ── Kind-specific ── */
.aup-list-dir .aup-list-icon { color: var(--color-accent); }
.aup-list-file .aup-list-icon { color: var(--color-dim); }
.aup-list-group { font-weight: 600; }
.aup-list-group .aup-list-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-dim); }
.aup-list-group .aup-list-badge { background: color-mix(in srgb, var(--color-accent) 15%, transparent); color: var(--color-accent); }

/* Task status */
.aup-list-task--ready .aup-list-badge { background: color-mix(in srgb, var(--color-success, #4ec9b0) 15%, transparent); color: var(--color-success, #4ec9b0); }
.aup-list-task--in_progress .aup-list-badge { background: color-mix(in srgb, var(--color-accent) 15%, transparent); color: var(--color-accent); }
.aup-list-task--review .aup-list-badge { background: color-mix(in srgb, var(--color-assistant, #59c2ff) 15%, transparent); color: var(--color-assistant, #59c2ff); }
.aup-list-task--blocked .aup-list-badge { background: color-mix(in srgb, var(--color-error, #ff6b6b) 15%, transparent); color: var(--color-error, #ff6b6b); }
.aup-list-task--done .aup-list-badge { background: color-mix(in srgb, var(--color-dim) 10%, transparent); color: var(--color-dim); }
.aup-list-task--done .aup-list-label { opacity: 0.6; }
.aup-list-task--draft .aup-list-badge { background: color-mix(in srgb, var(--color-dim) 15%, transparent); color: var(--color-dim); }
.aup-list-queue .aup-list-icon { color: var(--color-assistant, #59c2ff); }
.aup-list-daemon .aup-list-icon { color: var(--color-success, #4ec9b0); }


  /* ══════════════════════════════════════════════════
     Design Token System — Style Manager
     Composable Style System — tone × palette × mode
     JS sets data-tone + data-palette + data-mode on <html>
     ══════════════════════════════════════════════════ */

  /* ── Shared layout tokens ── */
  :root {
    --msg-gap: 0.8rem;
    --msg-padding: 0.7rem 1rem;
    --msg-max-width: 75%;
    --input-padding: 0.8rem 1.5rem;
  }

  /* ── Composable Style (4 tones × 5 palettes, from @aigne/afs-aup) ── */
  /* ═══ Tones ═══ */

/* Tone: editorial — Premium serif+sans pairing with elegant spacing */
:root, [data-tone="editorial"] {
  --font-body: "Sora", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
  --font-heading: "DM Serif Display", Georgia, serif;
  --font-display: "DM Serif Display", Georgia, serif;
  --font-mono: "JetBrains Mono", monospace;
  --heading-weight: 400;
  --heading-spacing: -0.02em;
  --heading-transform: none;
  --msg-font-size: 0.88rem;
  --type-display: 3rem;
  --type-heading: 1.75rem;
  --type-body: 1rem;
  --type-caption: 0.875rem;
  --type-small: 0.75rem;
  --leading-tight: 1.2;
  --leading-normal: 1.7;
  --leading-relaxed: 1.9;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 2rem;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.2);
  --shadow-hover: 0 16px 40px rgba(0,0,0,0.35);
  --card-border: 1px solid var(--color-border);
  --card-bg: var(--color-surface);
  --backdrop: blur(20px);
  --transition: 0.3s;
  --glow: none;
  --atmosphere: radial-gradient(ellipse 60% 50% at 50% 0%, color-mix(in srgb, var(--color-accent) 6%, transparent) 0%, transparent 60%);
  --heading-gradient: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-secondary) 100%);
  --space-section: 4rem;
  --space-block: 1.5rem;
  --space-element: 0.75rem;
  --space-page-x: 2rem;
  --content-max: 48rem;
  --container-max: 1200px;
}
[data-tone="editorial"] body { font-weight: 300; line-height: var(--leading-normal); }
[data-tone="editorial"] .aup-action { border-radius: 2rem; }

/* Tone: clean — Neutral sans-serif with standard density */
[data-tone="clean"] {
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: "Inter", -apple-system, sans-serif;
  --font-display: "Inter", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --heading-weight: 600;
  --heading-spacing: -0.01em;
  --heading-transform: none;
  --msg-font-size: 0.88rem;
  --type-display: 2.25rem;
  --type-heading: 1.5rem;
  --type-body: 0.9375rem;
  --type-caption: 0.8125rem;
  --type-small: 0.75rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.1);
  --card-border: 1px solid var(--color-border);
  --card-bg: var(--color-surface);
  --backdrop: none;
  --transition: 0.15s;
  --glow: none;
  --atmosphere: none;
  --heading-gradient: none;
  --space-section: 2.5rem;
  --space-block: 1rem;
  --space-element: 0.5rem;
  --space-page-x: 1.5rem;
  --content-max: 64rem;
  --container-max: 1200px;
}

/* Tone: bold — Heavy sans-serif with hard shadows and zero radius */
[data-tone="bold"] {
  --font-body: "Rubik", "Inter", -apple-system, sans-serif;
  --font-heading: "Outfit", "Inter", sans-serif;
  --font-display: "Outfit", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --heading-weight: 900;
  --heading-spacing: -0.02em;
  --heading-transform: none;
  --msg-font-size: 0.9rem;
  --type-display: 3.5rem;
  --type-heading: 2rem;
  --type-body: 1rem;
  --type-caption: 0.875rem;
  --type-small: 0.75rem;
  --leading-tight: 1.1;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;
  --radius-sm: 0;
  --radius-md: 0;
  --radius-lg: 0;
  --shadow-card: 4px 4px 0 var(--color-text);
  --shadow-hover: 6px 6px 0 var(--color-text);
  --card-border: 3px solid var(--color-text);
  --card-bg: var(--color-surface);
  --backdrop: none;
  --transition: 0s;
  --glow: none;
  --atmosphere: none;
  --heading-gradient: none;
  --space-section: 2rem;
  --space-block: 1rem;
  --space-element: 0.5rem;
  --space-page-x: 1.5rem;
  --content-max: 60rem;
  --container-max: 1200px;
}

/* Tone: mono — Monospace fonts with compact density and accent glow */
[data-tone="mono"] {
  --font-body: "IBM Plex Mono", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", monospace;
  --font-heading: "JetBrains Mono", "Instrument Serif", Georgia, serif;
  --font-display: "JetBrains Mono", monospace;
  --font-mono: "IBM Plex Mono", monospace;
  --heading-weight: 400;
  --heading-spacing: -0.03em;
  --heading-transform: none;
  --msg-font-size: 0.85rem;
  --type-display: 2rem;
  --type-heading: 1.25rem;
  --type-body: 0.875rem;
  --type-caption: 0.8125rem;
  --type-small: 0.6875rem;
  --leading-tight: 1.3;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;
  --radius-sm: 0;
  --radius-md: 0;
  --radius-lg: 0;
  --shadow-card: none;
  --shadow-hover: none;
  --card-border: 1px solid var(--color-border);
  --card-bg: var(--color-surface);
  --backdrop: none;
  --transition: 0s;
  --glow: 0 0 8px color-mix(in srgb, var(--color-accent) 30%, transparent);
  --atmosphere: none;
  --heading-gradient: none;
  --space-section: 1.5rem;
  --space-block: 0.75rem;
  --space-element: 0.375rem;
  --space-page-x: 1rem;
  --content-max: 72rem;
  --container-max: 1400px;
}
[data-tone="mono"] body { line-height: var(--leading-normal); }
[data-tone="mono"] .aup-text[data-scale="code"] { border-left: 3px solid var(--color-accent); border-radius: 0; }
[data-tone="mono"] .aup-text[data-mode="badge"] { font-size: 0.65rem; letter-spacing: 0.2em; text-transform: uppercase; border-radius: 0; }

/* ═══ Palettes ═══ */

/* Palette: neutral — Blue accent — professional and safe */
:root, [data-palette="neutral"][data-mode="dark"] {
  --color-bg: #0a0a0a;
  --color-surface: #161616;
  --color-border: #2a2a2a;
  --color-text: #e8e8e8;
  --color-dim: #a3a3a3;
  --color-accent: #5B9BF0;
  --color-accent-bg: rgba(91,155,240,0.1);
  --color-accent-secondary: #818cf8;
  --color-assistant: #818cf8;
  --color-assistant-bg: rgba(129,140,248,0.08);
  --color-success: #34d399;
  --color-error: #f87171;
}
[data-palette="neutral"][data-mode="light"] {
  --color-bg: #FFFFFF;
  --color-surface: #FAFAFA;
  --color-border: #E8E8E8;
  --color-text: #171717;
  --color-dim: #737373;
  --color-accent: #1E6FD9;
  --color-accent-bg: rgba(30,111,217,0.06);
  --color-accent-secondary: #1a56db;
  --color-assistant: #1a56db;
  --color-assistant-bg: rgba(26,86,219,0.06);
  --color-success: #059669;
  --color-error: #dc2626;
}

/* Palette: warm — Gold/amber accent — sophisticated and luxurious */
[data-palette="warm"][data-mode="dark"] {
  --color-bg: #0a0e14;
  --color-surface: #131820;
  --color-border: #1d2433;
  --color-text: #b3b1ad;
  --color-dim: #626a73;
  --color-accent: #e6b450;
  --color-accent-bg: #2a2000;
  --color-accent-secondary: #59c2ff;
  --color-assistant: #59c2ff;
  --color-assistant-bg: #0d1a2d;
  --color-success: #91b362;
  --color-error: #f07178;
}
[data-palette="warm"][data-mode="light"] {
  --color-bg: #f5f3ef;
  --color-surface: #fefdfb;
  --color-border: #e0dcd4;
  --color-text: #2c2418;
  --color-dim: #8a7e6e;
  --color-accent: #b8860b;
  --color-accent-bg: #fef7e5;
  --color-accent-secondary: #1a6dbd;
  --color-assistant: #1a6dbd;
  --color-assistant-bg: #eaf2fc;
  --color-success: #4d8a30;
  --color-error: #c53030;
}

/* Palette: vivid — Pink accent — bold and energetic */
[data-palette="vivid"][data-mode="dark"] {
  --color-bg: #0a0e1a;
  --color-surface: #111827;
  --color-border: #1e293b;
  --color-text: #e8edf5;
  --color-dim: #8892a8;
  --color-accent: #ff1493;
  --color-accent-bg: rgba(255,20,147,0.1);
  --color-accent-secondary: #0080ff;
  --color-assistant: #0080ff;
  --color-assistant-bg: rgba(0,128,255,0.1);
  --color-success: #34d399;
  --color-error: #f87171;
}
[data-palette="vivid"][data-mode="light"] {
  --color-bg: #f0f4ff;
  --color-surface: #ffffff;
  --color-border: #d0d8e8;
  --color-text: #1a1a2e;
  --color-dim: #6a7088;
  --color-accent: #c81070;
  --color-accent-bg: rgba(200,16,112,0.06);
  --color-accent-secondary: #0060cc;
  --color-assistant: #0060cc;
  --color-assistant-bg: rgba(0,96,204,0.06);
  --color-success: #059669;
  --color-error: #dc2626;
}

/* Palette: natural — Lime accent — fresh and organic */
[data-palette="natural"][data-mode="dark"] {
  --color-bg: #0a0a0f;
  --color-surface: #1a1a25;
  --color-border: rgba(255,255,255,0.06);
  --color-text: #e8e6f0;
  --color-dim: #8b89a0;
  --color-accent: #c4f04d;
  --color-accent-bg: rgba(196,240,77,0.12);
  --color-accent-secondary: #e879f9;
  --color-assistant: #c4f04d;
  --color-assistant-bg: rgba(196,240,77,0.08);
  --color-success: #91b362;
  --color-error: #f07178;
}
[data-palette="natural"][data-mode="light"] {
  --color-bg: #fafaf8;
  --color-surface: #ffffff;
  --color-border: rgba(0,0,0,0.08);
  --color-text: #1a1a1f;
  --color-dim: #6b6b78;
  --color-accent: #2a6e00;
  --color-accent-bg: rgba(42,110,0,0.08);
  --color-accent-secondary: #228B22;
  --color-assistant: #2a6e00;
  --color-assistant-bg: rgba(42,110,0,0.06);
  --color-success: #2a6e00;
  --color-error: #c53030;
}

/* Palette: electric — Cyan accent — futuristic and tech */
[data-palette="electric"][data-mode="dark"] {
  --color-bg: #0B1120;
  --color-surface: #131C2E;
  --color-border: #1E293B;
  --color-text: #E2E8F0;
  --color-dim: #94A3B8;
  --color-accent: #22D3EE;
  --color-accent-bg: rgba(34,211,238,0.1);
  --color-accent-secondary: #818cf8;
  --color-assistant: #818cf8;
  --color-assistant-bg: rgba(129,140,248,0.08);
  --color-success: #34d399;
  --color-error: #f87171;
}
[data-palette="electric"][data-mode="light"] {
  --color-bg: #ffffff;
  --color-surface: #F8FAFC;
  --color-border: #E2E8F0;
  --color-text: #0F172A;
  --color-dim: #475569;
  --color-accent: #06B6D4;
  --color-accent-bg: rgba(6,182,212,0.06);
  --color-accent-secondary: #4F46E5;
  --color-assistant: #4F46E5;
  --color-assistant-bg: rgba(79,70,229,0.06);
  --color-success: #059669;
  --color-error: #dc2626;
}

  /* Per-theme overrides are now in generateAllThemesCSS() */

  /* ── Layout ── */
  html, body { height: 100%; }
  body { font-family: var(--font-body); line-height: 1.6; background: var(--color-bg); color: var(--color-text); display: flex; flex-direction: column; position: relative; }
  body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: -1; opacity: 0.7; background: var(--atmosphere, none); }
  body::after { content: ""; position: fixed; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: -1; opacity: 0.015; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); background-repeat: repeat; background-size: 256px 256px; mix-blend-mode: overlay; }
  [data-tone="bold"] body::after { opacity: 0; }

  /* Background grid texture — subtle structural depth for dark themes */
  html:not([data-mode="light"]):not([data-tone="bold"]) body { background-color: var(--color-bg); background-image: linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px); background-size: auto, 60px 60px, 60px 60px; }



  header { padding: 0.6rem 1.5rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 0.8rem; background: var(--color-surface); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; }
  header h1 { font-family: var(--font-heading); font-size: 1rem; font-weight: 700; color: var(--color-accent); letter-spacing: var(--heading-spacing); }
  header .status { font-size: 0.75rem; color: var(--color-dim); }
  header .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
  header .dot.on { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }
  header .dot.off { background: var(--color-error); }

  #messages { flex: 1; overflow-y: auto; padding: 1rem 1.5rem; display: flex; flex-direction: column; gap: var(--msg-gap); }

  /* ── Message bubbles ── */
  .msg { max-width: var(--msg-max-width); padding: var(--msg-padding); border-radius: var(--radius-lg); font-size: var(--msg-font-size); line-height: 1.6; word-wrap: break-word; overflow-wrap: break-word; position: relative; transition: background var(--transition), color var(--transition); }
  .msg.user { align-self: flex-end; background: var(--color-accent-bg); color: var(--color-accent); border-bottom-right-radius: var(--radius-sm); white-space: pre-wrap; }
  .msg.assistant { align-self: flex-start; background: var(--color-assistant-bg); color: var(--color-assistant); border-bottom-left-radius: var(--radius-sm); }
  .msg.system { align-self: center; color: var(--color-dim); font-size: 0.78rem; }
  .msg.error { align-self: center; background: #2a0000; color: var(--color-error); font-size: 0.78rem; white-space: pre-wrap; }
  .msg.notify { align-self: flex-start; background: #0d2a0d; color: var(--color-success); font-size: 0.82rem; white-space: pre-wrap; border-radius: var(--radius-md); }

  /* ── Copy button ── */
  .msg .copy-btn { position: absolute; top: 6px; right: 6px; background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-dim); width: 26px; height: 26px; border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity var(--transition); font-size: 14px; line-height: 1; padding: 0; }
  .msg:hover .copy-btn { opacity: 1; }
  .msg .copy-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
  .msg .copy-btn.copied { border-color: var(--color-success); color: var(--color-success); }

  /* ── Markdown inside assistant bubbles ── */
  .msg.assistant p { margin: 0.4em 0; }
  .msg.assistant p:first-child { margin-top: 0; }
  .msg.assistant p:last-child { margin-bottom: 0; }
  .msg.assistant h1, .msg.assistant h2, .msg.assistant h3,
  .msg.assistant h4, .msg.assistant h5, .msg.assistant h6 { color: var(--color-text); margin: 0.8em 0 0.3em; font-size: 0.95em; }
  .msg.assistant h1 { font-size: 1.1em; }
  .msg.assistant h2 { font-size: 1.0em; }
  .msg.assistant strong { color: var(--color-text); }
  .msg.assistant em { color: var(--color-dim); }
  .msg.assistant a { color: var(--color-accent); text-decoration: underline; }
  .msg.assistant code { background: var(--color-bg); color: var(--color-accent); padding: 1px 5px; border-radius: var(--radius-sm); font-family: "JetBrains Mono", "Fira Code", monospace; font-size: 0.82em; }
  .msg.assistant pre { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 0.7em 0.9em; margin: 0.5em 0; overflow-x: auto; font-size: 0.82em; line-height: 1.5; }
  .msg.assistant pre code { background: none; padding: 0; color: var(--color-text); font-size: inherit; }
  .msg.assistant pre code.hljs { background: transparent; padding: 0; }
  .msg.assistant ul, .msg.assistant ol { margin: 0.4em 0; padding-left: 1.5em; }
  .msg.assistant li { margin: 0.2em 0; }
  .msg.assistant blockquote { border-left: 3px solid var(--color-border); padding-left: 0.8em; color: var(--color-dim); margin: 0.5em 0; }
  .msg.assistant table { border-collapse: collapse; margin: 0.5em 0; font-size: 0.82em; width: 100%; }
  .msg.assistant th, .msg.assistant td { border: 1px solid var(--color-border); padding: 0.3em 0.6em; text-align: left; }
  .msg.assistant th { background: var(--color-surface); color: var(--color-text); }
  .msg.assistant hr { border: none; border-top: 1px solid var(--color-border); margin: 0.6em 0; }
  .msg.assistant img { max-width: 100%; border-radius: var(--radius-sm); }

  /* ── Component: table ── */
  .component-table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 0.3em 0; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
  .component-table th, .component-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--color-border); }
  .component-table th { background: var(--color-surface); color: var(--color-text); border-bottom: 2px solid var(--color-border); }
  .component-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--color-surface) 50%, transparent); }
  .component-table tbody tr:hover td { background: var(--color-accent-bg); }
  .component-table tbody tr:last-child td { border-bottom: none; }
  .component-image { max-width: 100%; border-radius: var(--radius-md); }

  /* ── Prompt area ── */
  #prompt-area { display: none; padding: 12px 1.5rem; background: var(--color-surface); border-top: 1px solid var(--color-border); }
  #prompt-area .prompt-msg { margin-bottom: 8px; font-weight: bold; color: var(--color-accent); }
  #prompt-area .prompt-options { display: flex; flex-direction: column; gap: 4px; }
  #prompt-area .prompt-options button { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); padding: 6px 12px; border-radius: var(--radius-md); cursor: pointer; text-align: left; font-family: var(--font-body); font-size: var(--msg-font-size); transition: all var(--transition); }
  #prompt-area .prompt-options button:hover { background: var(--color-accent-bg); border-color: var(--color-accent); color: var(--color-accent); }

  /* ── Input bar ── */
  #input-bar { padding: var(--input-padding); border-top: 1px solid var(--color-border); display: flex; gap: 0.5rem; }
  #input-bar textarea { flex: 1; background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); padding: 0.6rem 0.8rem; border-radius: var(--radius-md); font-family: var(--font-body); font-size: var(--msg-font-size); resize: none; outline: none; min-height: 40px; max-height: 120px; transition: border-color var(--transition); }
  #input-bar textarea:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 12%, transparent); }
  #input-bar button { background: var(--color-accent); border: 1px solid var(--color-accent); color: var(--color-bg); padding: 0 1.2rem; border-radius: var(--radius-md); font-family: var(--font-body); font-size: var(--msg-font-size); font-weight: 600; cursor: pointer; transition: all var(--transition); }
  #input-bar button:hover { filter: brightness(1.15); box-shadow: 0 2px 8px color-mix(in srgb, var(--color-accent) 35%, transparent); }
  #input-bar button:disabled { opacity: 0.4; cursor: default; }

  /* ── Page view ── */
  #page-view { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
  #page-view .page-toolbar { padding: 6px 16px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 8px; }
  #page-view .page-toolbar button { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85em; transition: all var(--transition); }
  #page-view .page-toolbar button:hover { border-color: var(--color-accent); color: var(--color-accent); }
  #page-view .page-toolbar span { font-size: 0.85em; color: var(--color-dim); }
  #page-content { flex: 1; padding: 16px; overflow-y: auto; color: var(--color-text); }

  /* ── Layout page grid ── */
  .layout-page { display: grid; grid-template-areas: "header header" "sidebar main" "footer footer"; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr auto; min-height: 100%; gap: 1px; background: var(--color-border); }
  .layout-header { grid-area: header; background: var(--color-surface); padding: 12px 16px; }
  .layout-sidebar { grid-area: sidebar; background: var(--color-bg); padding: 12px 16px; }
  .layout-main { grid-area: main; background: var(--color-bg); padding: 16px; }
  .layout-footer { grid-area: footer; background: var(--color-surface); padding: 8px 16px; font-size: 0.85em; color: var(--color-dim); }

  /* ── Desktop Splash ── */
  @keyframes splash-breathe { 0%, 100% { opacity: 0.18; transform: scale(1); } 50% { opacity: 0.35; transform: scale(1.04); } }
  @keyframes splash-orbit-spin { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }
  @keyframes splash-glyph-breathe { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.5; } }
  @keyframes splash-core-pulse { 0%, 100% { opacity: 0.3; r: 6; } 50% { opacity: 0.6; r: 7; } }
  @keyframes splash-ray-flow { 0%, 100% { opacity: 0.1; } 50% { opacity: 0.3; } }
  #desktop-splash {
    flex: 1; display: flex; align-items: center; justify-content: center;
    background: var(--color-bg);
    position: relative; overflow: hidden;
    transition: opacity 0.6s ease-out;
  }
  #desktop-splash::before {
    content: ""; position: absolute; inset: 0;
    background:
      radial-gradient(ellipse 50% 50% at 50% 50%, color-mix(in srgb, var(--color-accent) 5%, transparent) 0%, transparent 70%);
    pointer-events: none;
    animation: splash-breathe 6s ease-in-out infinite;
  }
  #desktop-splash.hidden { opacity: 0; pointer-events: none; position: absolute; }
  .splash-orbit {
    position: absolute; top: 50%; left: 50%;
    border: 1px solid color-mix(in srgb, var(--color-accent) 8%, transparent);
    border-radius: 50%; pointer-events: none;
  }
  .splash-orbit-1 { width: 240px; height: 240px; animation: splash-orbit-spin 40s linear infinite; }
  .splash-orbit-2 { width: 360px; height: 360px; animation: splash-orbit-spin 60s linear infinite reverse; border-style: dashed; border-color: color-mix(in srgb, var(--color-dim) 6%, transparent); }
  .splash-orbit-3 { width: 500px; height: 500px; animation: splash-orbit-spin 90s linear infinite; border-color: color-mix(in srgb, var(--color-dim) 3%, transparent); }
  .splash-content { text-align: center; user-select: none; position: relative; z-index: 1; }
  .splash-glyph { width: 80px; height: 80px; margin: 0 auto 24px; color: var(--color-dim); }
  .splash-glyph svg { width: 100%; height: 100%; }
  .splash-glyph .glyph-outer { opacity: 0.15; animation: splash-glyph-breathe 5s ease-in-out infinite; }
  .splash-glyph .glyph-inner { opacity: 0.2; animation: splash-glyph-breathe 5s ease-in-out infinite 1.5s; }
  .splash-glyph .glyph-core { opacity: 0.35; animation: splash-core-pulse 4s ease-in-out infinite; }
  .splash-glyph .glyph-ray { opacity: 0.12; animation: splash-ray-flow 4s ease-in-out infinite; }
  .splash-glyph .glyph-ray:nth-child(5) { animation-delay: 0.4s; }
  .splash-glyph .glyph-ray:nth-child(6) { animation-delay: 0.8s; }
  .splash-glyph .glyph-ray:nth-child(7) { animation-delay: 1.2s; }
  .splash-glyph .glyph-ray:nth-child(8) { animation-delay: 1.6s; }
  .splash-glyph .glyph-ray:nth-child(9) { animation-delay: 2.0s; }
  .splash-glyph .glyph-ray:nth-child(10) { animation-delay: 2.4s; }
  .splash-wordmark {
    font-family: var(--font-heading); font-size: 2.4rem; font-weight: 800;
    letter-spacing: 0.15em; color: var(--color-dim); opacity: 0.2;
    text-transform: uppercase;
    animation: splash-breathe 6s ease-in-out infinite 0.5s;
  }
  .splash-sub {
    font-family: var(--font-body); font-size: 0.7rem; font-weight: 400;
    letter-spacing: 0.3em; text-transform: uppercase;
    color: var(--color-dim); opacity: 0.15; margin-top: 4px;
  }
  .splash-status {
    margin-top: 32px; display: flex; align-items: center; justify-content: center; gap: 6px;
    font-family: var(--font-body); font-size: 0.65rem; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--color-dim); opacity: 0.3;
  }

  /* ── Session Badge ── */
  #session-badge {
    position: fixed; bottom: 8px; left: 10px; z-index: 9999;
    display: flex; align-items: center; gap: 5px;
    font-family: var(--font-mono, "JetBrains Mono", "Share Tech Mono", monospace);
    font-size: 0.6rem; letter-spacing: 0.04em;
    color: var(--color-dim); opacity: 0.25;
    user-select: all; pointer-events: auto;
    transition: opacity 0.3s;
  }
  #session-badge:hover { opacity: 0.6; }
  #session-badge:hover #session-dot.connected { background: rgba(80,200,120,0.8); }
  #session-badge:hover #session-dot.disconnected { background: rgba(220,80,80,0.7); }
  #session-badge:hover #session-dot.connecting { background: rgba(200,180,80,0.7); }
  #session-id:empty { display: none; }
  #session-dot {
    width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
    background: rgba(100,100,100,0.4); transition: background 0.3s;
  }
  #session-dot.connected { background: rgba(80,200,120,0.35); }
  #session-dot.disconnected { background: rgba(220,80,80,0.35); }
  #session-dot.connecting { background: rgba(200,180,80,0.35); animation: session-dot-blink 1.2s ease-in-out infinite; }
  @keyframes session-dot-blink { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

  /* ── AUP Display ── */
  #aup-display { display: none; flex: 1; overflow-y: auto; padding: 20px 24px; }
  #aup-display.active { display: flex; flex-direction: column; }
  #aup-display.full-page { padding: 0; overflow: hidden; }
  #aup-display.full-page .aup-toolbar { display: none; }
  #aup-display.full-page #aup-root { max-width: none; padding: 0; margin: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
  #aup-display.full-page #aup-root > .aup-view,
  #aup-display.full-page #aup-root > .aup-surface { flex: 1; max-width: none !important; width: 100% !important; padding: 0 !important; margin: 0 !important; border-radius: 0 !important; background: none !important; border: none !important; box-shadow: none !important; overflow-y: auto; }
  #aup-display.full-page #aup-root > .aup-surface:has(.aup-surface-layout) { overflow: hidden !important; display: flex !important; flex-direction: column; }
  #aup-display.full-page #aup-root > .aup-view[data-layout="overlay-grid"] { padding: var(--overlay-pad) !important; }
  /* Full-page centering: non-panel, non-shell children get max-width + auto margin */
  #aup-display.full-page #aup-root > .aup-view > *:not([data-mode="panel"]):not([data-mode="shell"]):not(.wm-container) { max-width: 1200px; width: 100%; margin-left: auto !important; margin-right: auto !important; padding-left: 40px; padding-right: 40px; box-sizing: border-box; }
  /* Nav bar and footer panels bleed full width but pad their content */
  #aup-display.full-page #aup-root > .aup-view > .aup-view:first-child[data-mode="panel"] { padding-left: max(16px, calc((100% - 1200px) / 2 + 40px)); padding-right: max(16px, calc((100% - 1200px) / 2 + 40px)); }
  #aup-display.full-page #aup-root > .aup-view > .aup-view[data-mode="panel"]:last-child { padding-left: max(16px, calc((100% - 1200px) / 2 + 40px)); padding-right: max(16px, calc((100% - 1200px) / 2 + 40px)); }
  #aup-display.full-page .aup-deck-host { width: 100%; height: 100%; }
  .aup-toolbar { padding: 6px 16px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 8px; }
  .aup-toolbar button { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85em; transition: all var(--transition); }
  .aup-toolbar button:hover { border-color: var(--color-accent); color: var(--color-accent); }
  #aup-root { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; }

  /* ── AUP Runtime: panel breakout from #aup-root max-width container ── */
  #aup-root > .aup-view:first-child[data-mode="panel"] { margin: -20px -24px 20px; padding: 10px 24px; width: calc(100% + 48px); max-width: none; }
  #aup-root > .aup-view[data-mode="panel"]:last-child { border-radius: 0; margin: 20px -24px -20px; padding: 16px 24px; width: calc(100% + 48px); max-width: none; border-top: 1px solid var(--color-border); background: color-mix(in srgb, var(--color-surface) 60%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 0.85em; color: var(--color-dim); }

  /* ── AUP Runtime: Page transition + message animation ── */
  #aup-root.aup-animating { animation: aup-page-in 0.25s ease-out; }
  .msg { animation: aup-msg-in 0.2s ease-out; }

  /* ════════════════════════════════════════════════════════
     WM — Window Manager (compositor layer)
     ════════════════════════════════════════════════════════ */

  /* ── WM Container ── */
  .wm-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    overflow: hidden;
  }
  /* Nested WM (e.g. explorer inside a floating surface): fill parent, no 100vh */
  .wm-surface-content > .wm-container {
    min-height: 0;
    height: 100%;
  }

  /* ── WM Empty placeholder ── */
  .wm-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 200px;
    color: var(--color-dim);
    font-size: 0.9rem;
  }

  /* ── WM Surface ── */
  .wm-surface {
    background: var(--color-surface);
    border: var(--card-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .wm-surface[data-active="true"] {
    box-shadow: 0 0 0 2px var(--color-accent);
  }

  .wm-surface-content {
    flex: 1;
    overflow: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    color: var(--wm-content-text, inherit);
    padding: 10px 12px;
  }
  .wm-surface[data-wm-bleed] .wm-surface-content {
    padding: 0;
  }
  /* Strip standalone chrome from primitives inside WM surfaces —
     the window frame already provides border, radius, and background.
     Targets card-like components (map, chart, table, terminal, editor,
     canvas, calendar, moonphase, xeyes, frame, surface, deck, natal-chart,
     finance-chart, photo-story, list, command-bar). Lightweight inline
     elements (text, view, action, media, input, overlay, ticker, time)
     are excluded — they have no card chrome to strip. */
  .wm-surface-content > .aup-map,
  .wm-surface-content > .aup-chart,
  .wm-surface-content > .aup-finance-chart,
  .wm-surface-content > .aup-table,
  .wm-surface-content > .aup-terminal,
  .wm-surface-content > .aup-editor,
  .wm-surface-content > .aup-canvas,
  .wm-surface-content > .aup-calendar,
  .wm-surface-content > .aup-moonphase,
  .wm-surface-content > .aup-xeyes,
  .wm-surface-content > .aup-frame,
  .wm-surface-content > .aup-surface,
  .wm-surface-content > .aup-deck,
  .wm-surface-content > .aup-natal-chart,
  .wm-surface-content > .aup-photo-story,
  .wm-surface-content > .aup-list,
  .wm-surface-content > .aup-command-bar {
    border: none; border-radius: 0; min-height: 0; flex: 1;
  }

  /* ── Default Decorator: Title Bar ── */
  .wm-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 32px;
    padding: 0 8px;
    background: color-mix(in srgb, var(--color-bg) 90%, var(--color-accent) 10%);
    border-bottom: 1px solid var(--color-border);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
  }
  .wm-titlebar:active { cursor: grabbing; }

  .wm-title-text {
    font-size: var(--wm-font-size, 0.75rem);
    font-weight: 600;
    color: var(--color-text);
    font-family: var(--wm-font-family, inherit);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wm-close-btn {
    background: none;
    border: none;
    color: var(--color-dim);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    line-height: 1;
  }
  .wm-close-btn:hover {
    background: var(--color-error);
    color: #fff;
  }

  /* ── Chrome Actions (app-defined titlebar buttons) ── */
  .wm-chrome-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
    margin-right: 4px;
    align-items: center;
  }
  .wm-chrome-action {
    background: none;
    border: none;
    color: var(--color-dim);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    line-height: 1;
    white-space: nowrap;
    opacity: 0.7;
  }
  .wm-chrome-action:hover {
    background: var(--hover);
    color: var(--color-text);
    opacity: 1;
  }
  /* Centered titlebars (macos/neon/glass): position chrome-actions absolute right */
  [data-wm-style="macos"] .wm-chrome-actions,
  [data-wm-style="neon"] .wm-chrome-actions,
  [data-wm-style="glass"] .wm-chrome-actions {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
  }

  /* ── 8-Direction Resize Zones ── */
  .wm-rz {
    position: absolute;
    z-index: 11;
  }
  /* Edges */
  .wm-rz-n  { top: -3px; left: 6px; right: 6px; height: 6px; cursor: n-resize; }
  .wm-rz-s  { bottom: -3px; left: 6px; right: 6px; height: 6px; cursor: s-resize; }
  .wm-rz-e  { top: 6px; bottom: 6px; right: -3px; width: 6px; cursor: e-resize; }
  .wm-rz-w  { top: 6px; bottom: 6px; left: -3px; width: 6px; cursor: w-resize; }
  /* Corners */
  .wm-rz-nw { top: -3px; left: -3px; width: 10px; height: 10px; cursor: nw-resize; }
  .wm-rz-ne { top: -3px; right: -3px; width: 10px; height: 10px; cursor: ne-resize; }
  .wm-rz-sw { bottom: -3px; left: -3px; width: 10px; height: 10px; cursor: sw-resize; }
  .wm-rz-se { bottom: -3px; right: -3px; width: 10px; height: 10px; cursor: se-resize; }

  /* ── Chromeless Drag Grip (top edge of no-titlebar surfaces) ── */
  .wm-drag-grip {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 14px;
    z-index: 10;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s;
    background: linear-gradient(180deg, rgba(128,128,128,0.25) 0%, transparent 100%);
  }
  .wm-drag-grip:active { cursor: grabbing; }
  .wm-surface:hover .wm-drag-grip { opacity: 1; }
  .wm-drag-grip::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.5);
  }

  /* ═══════════════════════════════════════════════════════════
     WM Chrome Styles — scoped by [data-wm-style] on .wm-container
     All use CSS vars with style-specific defaults.
     ═══════════════════════════════════════════════════════════ */

  /* ── Style: macOS ── */
  [data-wm-style="macos"] .wm-surface {
    border: none;
    border-radius: var(--wm-border-radius, 10px);
    box-shadow: var(--wm-shadow, 0 12px 40px rgba(0,0,0,0.3), 0 0 0 0.5px rgba(255,255,255,0.08));
    background: var(--wm-surface-bg, var(--color-surface));
  }
  [data-wm-style="macos"] .wm-titlebar {
    height: var(--wm-titlebar-height, 38px);
    padding: 0 12px;
    background: var(--wm-titlebar-bg, color-mix(in srgb, var(--color-bg) 85%, var(--color-text) 5%));
    border-bottom: 1px solid rgba(0,0,0,0.15);
    justify-content: center;
    position: relative;
  }
  [data-wm-style="macos"] .wm-title-text {
    font-size: var(--wm-font-size, 0.8rem);
    font-weight: 500;
    color: var(--wm-titlebar-text, var(--color-text));
    font-family: var(--wm-font-family, inherit);
    text-align: center;
  }
  [data-wm-style="macos"] .wm-mac-traffic {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 7px;
    align-items: center;
  }
  [data-wm-style="macos"] .wm-mac-traffic span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    display: block;
    transition: filter 0.15s;
  }
  [data-wm-style="macos"] .wm-mac-traffic span:hover { filter: brightness(1.2); }
  [data-wm-style="macos"] .wm-mac-close { background: #ff5f57; }
  [data-wm-style="macos"] .wm-mac-minimize { background: #ffbd2e; }
  [data-wm-style="macos"] .wm-mac-maximize { background: #28c840; }
  [data-wm-style="macos"] .wm-surface[data-active="true"] {
    box-shadow: var(--wm-shadow, 0 16px 48px rgba(0,0,0,0.35), 0 0 0 0.5px rgba(255,255,255,0.1));
  }

  /* ── Style: Windows ── */
  [data-wm-style="windows"] .wm-surface {
    border: var(--wm-border-color, 1px solid rgba(128,128,128,0.3));
    border-radius: var(--wm-border-radius, 2px);
    box-shadow: var(--wm-shadow, 0 2px 8px rgba(0,0,0,0.15));
    background: var(--wm-surface-bg, var(--color-surface));
  }
  [data-wm-style="windows"] .wm-titlebar {
    height: var(--wm-titlebar-height, 30px);
    padding: 0 4px 0 10px;
    background: var(--wm-titlebar-bg, color-mix(in srgb, var(--color-bg) 90%, var(--color-accent) 10%));
    border-bottom: 1px solid var(--color-border);
  }
  [data-wm-style="windows"] .wm-title-text {
    font-size: var(--wm-font-size, 0.75rem);
    font-weight: 400;
    color: var(--wm-titlebar-text, var(--color-text));
    font-family: var(--wm-font-family, inherit);
    flex: 1;
  }
  [data-wm-style="windows"] .wm-win-btns {
    display: flex;
    margin-left: auto;
    height: 100%;
  }
  [data-wm-style="windows"] .wm-win-btns button {
    background: none;
    border: none;
    color: var(--wm-titlebar-text, var(--color-dim));
    cursor: pointer;
    width: 44px;
    height: 100%;
    font-size: 0.75rem;
    line-height: 1;
    transition: background 0.1s;
  }
  [data-wm-style="windows"] .wm-win-btns button:hover { background: rgba(128,128,128,0.2); }
  [data-wm-style="windows"] .wm-win-close:hover { background: #e81123 !important; color: #fff !important; }

  /* ── Style: X Windows ── */
  [data-wm-style="xwindows"] .wm-surface {
    border: var(--wm-border-color, 2px outset #888);
    border-radius: var(--wm-border-radius, 0);
    box-shadow: none;
    background: var(--wm-surface-bg, var(--color-surface));
  }
  [data-wm-style="xwindows"] .wm-titlebar {
    height: var(--wm-titlebar-height, 24px);
    padding: 0 2px 0 6px;
    background: var(--wm-titlebar-bg, linear-gradient(90deg, #3b5998 0%, #1a3a6a 100%));
    border-bottom: 1px solid #222;
  }
  [data-wm-style="xwindows"] .wm-title-text {
    font-size: var(--wm-font-size, 0.7rem);
    font-weight: 700;
    color: var(--wm-titlebar-text, #fff);
    font-family: var(--wm-font-family, inherit);
    flex: 1;
    letter-spacing: 0.02em;
  }
  [data-wm-style="xwindows"] .wm-x-btns {
    display: flex;
    gap: 2px;
    margin-left: auto;
    align-items: center;
    height: 100%;
  }
  [data-wm-style="xwindows"] .wm-x-btn {
    background: #c0c0c0;
    border: 1px outset #ddd;
    color: #000;
    cursor: pointer;
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    line-height: 16px;
    text-align: center;
    padding: 0;
  }
  [data-wm-style="xwindows"] .wm-x-btn:active { border-style: inset; }
  [data-wm-style="xwindows"] .wm-xwm-grip {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    cursor: se-resize;
    background:
      linear-gradient(135deg, transparent 30%, #888 30%, #888 40%, transparent 40%, transparent 60%, #888 60%, #888 70%, transparent 70%);
    z-index: 12;
  }

  /* ═══════════════════════════════════════════════════════════
     Hollywood OS Presets — CSS-only skins, zero JS overhead.
     Each preset inherits a base style's titlebar structure.
     ═══════════════════════════════════════════════════════════ */

  /* ── Preset: Neon (base: macos) — cyan glow on dark, scanline overlay ── */
  [data-wm-style="neon"] .wm-surface {
    border: 1px solid var(--wm-glow-color, #00ffff);
    border-radius: var(--wm-border-radius, 8px);
    box-shadow: var(--wm-shadow,
      0 0 calc(8px * var(--wm-glow-intensity, 1)) rgba(0, 255, 255, 0.3),
      0 0 calc(24px * var(--wm-glow-intensity, 1)) rgba(0, 255, 255, 0.1),
      inset 0 0 calc(12px * var(--wm-glow-intensity, 1)) rgba(0, 255, 255, 0.05));
    background: var(--wm-surface-bg, rgba(0, 10, 20, 0.95));
  }
  [data-wm-style="neon"] .wm-titlebar {
    height: var(--wm-titlebar-height, 36px);
    padding: 0 12px;
    background: var(--wm-titlebar-bg, linear-gradient(180deg, rgba(0, 255, 255, 0.12) 0%, rgba(0, 20, 30, 0.95) 100%));
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    justify-content: center;
    position: relative;
  }
  [data-wm-style="neon"] .wm-title-text {
    font-size: var(--wm-font-size, 0.8rem);
    font-weight: 600;
    color: var(--wm-titlebar-text, #00ffff);
    font-family: var(--wm-font-family, inherit);
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.6);
    text-align: center;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  [data-wm-style="neon"] .wm-mac-traffic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: flex; gap: 7px; align-items: center; }
  [data-wm-style="neon"] .wm-mac-traffic span { width: 10px; height: 10px; border-radius: 50%; cursor: pointer; display: block; }
  [data-wm-style="neon"] .wm-mac-close { background: #ff0055; box-shadow: 0 0 6px #ff0055; }
  [data-wm-style="neon"] .wm-mac-minimize { background: #ffaa00; box-shadow: 0 0 6px #ffaa00; }
  [data-wm-style="neon"] .wm-mac-maximize { background: #00ff88; box-shadow: 0 0 6px #00ff88; }
  [data-wm-style="neon"] .wm-surface[data-active="true"] {
    box-shadow: var(--wm-shadow,
      0 0 calc(12px * var(--wm-glow-intensity, 1)) rgba(0, 255, 255, 0.5),
      0 0 calc(36px * var(--wm-glow-intensity, 1)) rgba(0, 255, 255, 0.15),
      inset 0 0 calc(16px * var(--wm-glow-intensity, 1)) rgba(0, 255, 255, 0.08));
    border-color: var(--wm-glow-color, #00ffff);
  }

  /* ── Preset: Cyberpunk (base: windows) — angular, high contrast, pink/yellow accents ── */
  [data-wm-style="cyberpunk"] .wm-surface {
    border: var(--wm-border-color, 2px solid #ff2d95);
    border-radius: var(--wm-border-radius, 0);
    box-shadow: var(--wm-shadow, 4px 4px 0 rgba(255, 45, 149, 0.3), -1px -1px 0 rgba(255, 230, 0, 0.2));
    background: var(--wm-surface-bg, rgba(15, 5, 20, 0.97));
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  }
  [data-wm-style="cyberpunk"] .wm-titlebar {
    height: var(--wm-titlebar-height, 32px);
    padding: 0 16px 0 10px;
    background: var(--wm-titlebar-bg, linear-gradient(90deg, #ff2d95 0%, #1a0a20 40%));
    border-bottom: 1px solid rgba(255, 230, 0, 0.3);
  }
  [data-wm-style="cyberpunk"] .wm-title-text {
    font-size: var(--wm-font-size, 0.7rem);
    font-weight: 700;
    color: var(--wm-titlebar-text, #ffe600);
    font-family: var(--wm-font-family, inherit);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    flex: 1;
  }
  [data-wm-style="cyberpunk"] .wm-win-btns { display: flex; margin-left: auto; height: 100%; }
  [data-wm-style="cyberpunk"] .wm-win-btns button {
    background: var(--wm-button-bg, none);
    border: 1px solid rgba(255, 230, 0, 0.3);
    color: var(--wm-titlebar-text, #ffe600);
    cursor: pointer;
    width: 32px;
    height: calc(100% - 4px);
    margin: 2px 1px;
    font-size: 0.65rem;
    line-height: 1;
    transition: background 0.1s, border-color 0.1s;
  }
  [data-wm-style="cyberpunk"] .wm-win-btns button:hover { background: var(--wm-button-hover-bg, rgba(255, 230, 0, 0.15)); border-color: #ffe600; }
  [data-wm-style="cyberpunk"] .wm-win-close:hover { background: #ff2d95 !important; color: #fff !important; }

  /* ── Preset: Hacker (base: minimal) — green on black, terminal aesthetic ── */
  [data-wm-style="hacker"] .wm-surface {
    border: var(--wm-border-color, 1px solid rgba(0, 255, 65, 0.3));
    border-radius: var(--wm-border-radius, 2px);
    box-shadow: var(--wm-shadow, 0 0 8px rgba(0, 255, 65, 0.1));
    background: var(--wm-surface-bg, rgba(0, 8, 0, 0.97));
  }
  [data-wm-style="hacker"] .wm-titlebar {
    height: var(--wm-titlebar-height, 28px);
    padding: 0 8px;
    background: var(--wm-titlebar-bg, rgba(0, 255, 65, 0.08));
    border-bottom: 1px solid rgba(0, 255, 65, 0.2);
  }
  [data-wm-style="hacker"] .wm-title-text {
    font-size: var(--wm-font-size, 0.75rem);
    font-weight: 400;
    color: var(--wm-titlebar-text, #00ff41);
    font-family: var(--wm-font-family, "SF Mono", "Fira Code", "Cascadia Code", monospace);
    letter-spacing: 0.02em;
  }
  [data-wm-style="hacker"] .wm-close-btn {
    color: #00ff41;
    border: none;
    background: none;
    font-family: monospace;
  }
  [data-wm-style="hacker"] .wm-close-btn:hover { color: #ff3333; }
  [data-wm-style="hacker"] .wm-surface[data-active="true"] {
    border-color: rgba(0, 255, 65, 0.5);
    box-shadow: var(--wm-shadow, 0 0 12px rgba(0, 255, 65, 0.15), inset 0 0 30px rgba(0, 255, 65, 0.02));
  }

  /* ── Preset: Glass (base: macos) — frosted blur, semi-transparent ── */
  [data-wm-style="glass"] .wm-surface {
    border: var(--wm-border-color, 1px solid rgba(255, 255, 255, 0.18));
    border-radius: var(--wm-border-radius, 12px);
    box-shadow: var(--wm-shadow, 0 8px 32px rgba(0, 0, 0, 0.25));
    background: var(--wm-surface-bg, rgba(255, 255, 255, 0.08));
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
  }
  [data-wm-style="glass"] .wm-titlebar {
    height: var(--wm-titlebar-height, 38px);
    padding: 0 12px;
    background: var(--wm-titlebar-bg, rgba(255, 255, 255, 0.06));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    justify-content: center;
    position: relative;
  }
  [data-wm-style="glass"] .wm-title-text {
    font-size: var(--wm-font-size, 0.8rem);
    font-weight: 500;
    color: var(--wm-titlebar-text, rgba(255, 255, 255, 0.9));
    font-family: var(--wm-font-family, inherit);
    text-align: center;
  }
  [data-wm-style="glass"] .wm-mac-traffic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: flex; gap: 7px; align-items: center; }
  [data-wm-style="glass"] .wm-mac-traffic span { width: 12px; height: 12px; border-radius: 50%; cursor: pointer; display: block; backdrop-filter: blur(4px); }
  [data-wm-style="glass"] .wm-mac-close { background: rgba(255, 95, 87, 0.7); }
  [data-wm-style="glass"] .wm-mac-minimize { background: rgba(255, 189, 46, 0.7); }
  [data-wm-style="glass"] .wm-mac-maximize { background: rgba(40, 200, 64, 0.7); }
  [data-wm-style="glass"] .wm-mac-traffic span:hover { backdrop-filter: none; }
  [data-wm-style="glass"] .wm-surface[data-active="true"] {
    box-shadow: var(--wm-shadow, 0 12px 40px rgba(0, 0, 0, 0.3));
    border-color: rgba(255, 255, 255, 0.25);
  }

  /* ── Preset: Retro (base: xwindows) — amber CRT, beveled, warm glow ── */
  [data-wm-style="retro"] .wm-surface {
    border: var(--wm-border-color, 2px outset #c8a000);
    border-radius: var(--wm-border-radius, 0);
    box-shadow: var(--wm-shadow, 0 0 12px rgba(200, 160, 0, 0.15), inset 0 0 30px rgba(200, 160, 0, 0.03));
    background: var(--wm-surface-bg, #1a1400);
  }
  [data-wm-style="retro"] .wm-titlebar {
    height: var(--wm-titlebar-height, 24px);
    padding: 0 2px 0 6px;
    background: var(--wm-titlebar-bg, linear-gradient(90deg, #c8a000 0%, #806600 100%));
    border-bottom: 1px solid #4a3800;
  }
  [data-wm-style="retro"] .wm-title-text {
    font-size: var(--wm-font-size, 0.7rem);
    font-weight: 700;
    color: var(--wm-titlebar-text, #1a1400);
    flex: 1;
    letter-spacing: 0.02em;
    font-family: var(--wm-font-family, "SF Mono", "Courier New", monospace);
    text-transform: uppercase;
  }
  [data-wm-style="retro"] .wm-x-btns { display: flex; gap: 2px; margin-left: auto; align-items: center; height: 100%; }
  [data-wm-style="retro"] .wm-x-btn {
    background: var(--wm-button-bg, #c8a000);
    border: 1px outset #e0c030;
    color: #1a1400;
    cursor: pointer;
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    line-height: 16px;
    text-align: center;
    padding: 0;
  }
  [data-wm-style="retro"] .wm-x-btn:active { border-style: inset; }
  [data-wm-style="retro"] .wm-xwm-grip {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 30%, #c8a000 30%, #c8a000 40%, transparent 40%, transparent 60%, #c8a000 60%, #c8a000 70%, transparent 70%);
    z-index: 12;
  }
  [data-wm-style="retro"] .wm-surface[data-active="true"] {
    border-color: #ffe040;
    box-shadow: var(--wm-shadow, 0 0 16px rgba(200, 160, 0, 0.25), inset 0 0 30px rgba(200, 160, 0, 0.05));
  }

  /* ── Inactive window dimming for presets (subtle focus cue) ── */
  [data-wm-style="neon"] .wm-surface:not([data-active="true"]) .wm-titlebar { opacity: 0.7; }
  [data-wm-style="cyberpunk"] .wm-surface:not([data-active="true"]) .wm-titlebar { opacity: 0.6; }
  [data-wm-style="hacker"] .wm-surface:not([data-active="true"]) { border-color: rgba(0, 255, 65, 0.15); }
  [data-wm-style="glass"] .wm-surface:not([data-active="true"]) { opacity: 0.85; }
  [data-wm-style="retro"] .wm-surface:not([data-active="true"]) .wm-titlebar { opacity: 0.65; }
  [data-wm-style="winamp"] .wm-surface:not([data-active="true"]) .wm-titlebar { opacity: 0.6; }
  [data-wm-style="matrix"] .wm-surface:not([data-active="true"]) { border-color: rgba(0, 255, 65, 0.1); }
  [data-wm-style="stealth"] .wm-surface:not([data-active="true"]) { border-color: rgba(255,255,255,0.04); }

  /* ── Content text color defaults for dark presets ──
   * Override --color-text and --color-dim CSS vars so all child elements (headings, text widgets, etc.)
   * inherit legible colors. --wm-content-text allows agent override. */
  [data-wm-style="neon"] .wm-surface-content { --color-text: var(--wm-content-text, #d0e8ff); --color-dim: color-mix(in srgb, var(--color-text) 60%, transparent); color: var(--color-text); }
  [data-wm-style="cyberpunk"] .wm-surface-content { --color-text: var(--wm-content-text, #e0d0ff); --color-dim: color-mix(in srgb, var(--color-text) 60%, transparent); color: var(--color-text); }
  [data-wm-style="hacker"] .wm-surface-content { --color-text: var(--wm-content-text, #b0ffb0); --color-dim: color-mix(in srgb, var(--color-text) 60%, transparent); color: var(--color-text); }
  [data-wm-style="glass"] .wm-surface-content { --color-text: var(--wm-content-text, rgba(255, 255, 255, 0.92)); --color-dim: rgba(255, 255, 255, 0.55); color: var(--color-text); }
  [data-wm-style="retro"] .wm-surface-content { --color-text: var(--wm-content-text, #d4a800); --color-dim: color-mix(in srgb, var(--color-text) 60%, transparent); color: var(--color-text); }
  [data-wm-style="winamp"] .wm-surface-content { --color-text: var(--wm-content-text, #c0c0c0); --color-dim: #808080; color: var(--color-text); }
  [data-wm-style="matrix"] .wm-surface-content { --color-text: var(--wm-content-text, #00ff41); --color-dim: color-mix(in srgb, var(--color-text) 60%, transparent); color: var(--color-text); }

  /* ── Preset: Winamp (base: minimal) — classic media player skin, metal texture, tight layout ── */
  [data-wm-style="winamp"] .wm-surface {
    border: var(--wm-border-color, 1px solid #1a1a1a);
    border-radius: var(--wm-border-radius, 3px);
    box-shadow: var(--wm-shadow, 1px 1px 0 rgba(255,255,255,0.1) inset, -1px -1px 0 rgba(0,0,0,0.4) inset, 2px 2px 6px rgba(0,0,0,0.4));
    background: var(--wm-surface-bg, #2b2b2b);
  }
  [data-wm-style="winamp"] .wm-titlebar {
    height: var(--wm-titlebar-height, 22px);
    padding: 0 4px;
    background: var(--wm-titlebar-bg, linear-gradient(180deg, #4a6a8a 0%, #2a3a4a 40%, #1a2a3a 100%));
    border-bottom: 1px solid #0a0a0a;
  }
  [data-wm-style="winamp"] .wm-title-text {
    font-size: var(--wm-font-size, 0.6rem);
    font-weight: 700;
    color: var(--wm-titlebar-text, #00e000);
    font-family: var(--wm-font-family, "Small Fonts", "Fixedsys", "Courier New", monospace);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.8);
  }
  [data-wm-style="winamp"] .wm-close-btn {
    color: #00e000;
    background: #1a2a1a;
    border: 1px solid #3a4a3a;
    font-size: 0.55rem;
    width: 16px;
    height: 16px;
    line-height: 14px;
    padding: 0;
    border-radius: 1px;
  }
  [data-wm-style="winamp"] .wm-close-btn:hover { background: #3a1a1a; color: #ff4444; border-color: #ff4444; }
  [data-wm-style="winamp"] .wm-surface[data-active="true"] {
    box-shadow: var(--wm-shadow, 1px 1px 0 rgba(255,255,255,0.15) inset, -1px -1px 0 rgba(0,0,0,0.5) inset, 3px 3px 10px rgba(0,0,0,0.5));
  }
  [data-wm-style="winamp"] .wm-surface[data-active="true"] .wm-titlebar {
    background: var(--wm-titlebar-bg, linear-gradient(180deg, #5a8aba 0%, #3a5a7a 40%, #2a4a6a 100%));
  }

  /* ── Preset: Matrix (base: minimal) — falling green code, black void, digital rain aesthetic ── */
  [data-wm-style="matrix"] .wm-surface {
    border: var(--wm-border-color, 1px solid rgba(0, 255, 65, 0.25));
    border-radius: var(--wm-border-radius, 0);
    box-shadow: var(--wm-shadow, 0 0 15px rgba(0, 255, 65, 0.08), 0 0 40px rgba(0, 255, 65, 0.03));
    background: var(--wm-surface-bg, rgba(0, 3, 0, 0.96));
  }
  [data-wm-style="matrix"] .wm-titlebar {
    height: var(--wm-titlebar-height, 26px);
    padding: 0 8px;
    background: var(--wm-titlebar-bg, rgba(0, 255, 65, 0.06));
    border-bottom: 1px solid rgba(0, 255, 65, 0.15);
    position: relative;
    overflow: hidden;
  }
  [data-wm-style="matrix"] .wm-titlebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 2px,
      rgba(0, 255, 65, 0.03) 2px,
      rgba(0, 255, 65, 0.03) 4px
    );
    pointer-events: none;
  }
  [data-wm-style="matrix"] .wm-title-text {
    font-size: var(--wm-font-size, 0.7rem);
    font-weight: 400;
    color: var(--wm-titlebar-text, #00ff41);
    font-family: var(--wm-font-family, "SF Mono", "Fira Code", "Cascadia Code", monospace);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.8), 0 0 20px rgba(0, 255, 65, 0.3);
  }
  [data-wm-style="matrix"] .wm-close-btn {
    color: #00ff41;
    border: none;
    background: none;
    font-family: monospace;
    text-shadow: 0 0 6px rgba(0, 255, 65, 0.6);
  }
  [data-wm-style="matrix"] .wm-close-btn:hover { color: #ff0000; text-shadow: 0 0 8px rgba(255,0,0,0.6); }
  [data-wm-style="matrix"] .wm-surface[data-active="true"] {
    border-color: rgba(0, 255, 65, 0.5);
    box-shadow: var(--wm-shadow,
      0 0 20px rgba(0, 255, 65, 0.15),
      0 0 60px rgba(0, 255, 65, 0.05),
      inset 0 0 40px rgba(0, 255, 65, 0.02));
  }
  /* Scanline overlay on surface content for CRT feel */
  [data-wm-style="matrix"] .wm-surface-content::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 1px,
      rgba(0, 0, 0, 0.08) 1px,
      rgba(0, 0, 0, 0.08) 2px
    );
    pointer-events: none;
    z-index: 999;
  }

  /* ── Preset: Stealth (base: minimal) — Fluxbox/Blackbox vibe ──
   * Inactive windows: titlebar collapses, just a thin accent edge visible.
   * Hover or active: titlebar slides in smoothly. Pure content-first. */
  [data-wm-style="stealth"] .wm-surface {
    border: var(--wm-border-color, 1px solid rgba(255,255,255,0.06));
    border-radius: var(--wm-border-radius, 3px);
    box-shadow: var(--wm-shadow, 0 2px 12px rgba(0,0,0,0.3));
    background: var(--wm-surface-bg, rgba(18, 18, 24, 0.97));
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  [data-wm-style="stealth"] .wm-titlebar {
    height: 0;
    min-height: 0;
    padding: 0 8px;
    overflow: hidden;
    background: var(--wm-titlebar-bg, rgba(255,255,255,0.04));
    border-bottom: none;
    opacity: 0;
    transition: height 0.2s ease, opacity 0.15s ease, border-bottom 0.2s;
  }
  [data-wm-style="stealth"] .wm-title-text {
    font-size: var(--wm-font-size, 0.7rem);
    font-weight: 500;
    color: var(--wm-titlebar-text, rgba(255,255,255,0.7));
    font-family: var(--wm-font-family, inherit);
    white-space: nowrap;
  }
  [data-wm-style="stealth"] .wm-close-btn {
    color: rgba(255,255,255,0.4);
    font-size: 0.7rem;
    padding: 2px 5px;
  }
  [data-wm-style="stealth"] .wm-close-btn:hover { background: var(--color-error); color: #fff; }
  [data-wm-style="stealth"] .wm-chrome-action { color: rgba(255,255,255,0.4); }
  [data-wm-style="stealth"] .wm-chrome-action:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.08); }
  /* Top accent edge — visible hint that chrome exists */
  [data-wm-style="stealth"] .wm-surface::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--wm-accent, rgba(100, 160, 255, 0.4));
    border-radius: 3px 3px 0 0;
    z-index: 10;
    transition: opacity 0.2s;
  }
  /* Hover → reveal chrome */
  [data-wm-style="stealth"] .wm-surface:hover .wm-titlebar {
    height: var(--wm-titlebar-height, 28px);
    opacity: 1;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  [data-wm-style="stealth"] .wm-surface:hover::before { opacity: 0; }
  /* Active → always show chrome */
  [data-wm-style="stealth"] .wm-surface[data-active="true"] .wm-titlebar {
    height: var(--wm-titlebar-height, 28px);
    opacity: 1;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  [data-wm-style="stealth"] .wm-surface[data-active="true"]::before { opacity: 0; }
  [data-wm-style="stealth"] .wm-surface[data-active="true"] {
    border-color: var(--wm-accent, rgba(100, 160, 255, 0.25));
    box-shadow: var(--wm-shadow, 0 4px 20px rgba(0,0,0,0.4));
  }
  /* Content colors for dark bg */
  [data-wm-style="stealth"] .wm-surface-content { --color-text: var(--wm-content-text, rgba(255,255,255,0.88)); --color-dim: rgba(255,255,255,0.4); color: var(--color-text); }

  /* ── Desktop Widget: transparent / non-interactive surfaces ── */
  .wm-surface[data-wm-no-bg] {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
  .wm-surface[data-wm-no-bg] .wm-surface-content {
    overflow: visible;
  }
  .wm-surface[data-wm-no-bg][data-active="true"] {
    box-shadow: none;
  }
  .wm-surface[data-wm-no-interact] {
    pointer-events: none;
  }

  /* ── WM Wallpaper ── */
  .wm-wallpaper {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--color-bg);
  }
  /* Cool wallpaper effects */
  .wm-wallpaper[data-wm-wp-effect="mesh"] {
    background:
      radial-gradient(at 40% 20%, hsla(28,100%,74%,0.3) 0, transparent 50%),
      radial-gradient(at 80% 0%, hsla(189,100%,56%,0.3) 0, transparent 50%),
      radial-gradient(at 0% 50%, hsla(355,85%,63%,0.3) 0, transparent 50%),
      radial-gradient(at 80% 50%, hsla(240,100%,70%,0.2) 0, transparent 50%),
      radial-gradient(at 0% 100%, hsla(22,100%,77%,0.3) 0, transparent 50%),
      var(--color-bg);
  }
  .wm-wallpaper[data-wm-wp-effect="aurora"] {
    background: linear-gradient(135deg, #0c0c1d 0%, #111132 25%, #0a192f 50%, #0c2340 75%, #0c0c1d 100%);
    overflow: hidden;
  }
  .wm-wallpaper[data-wm-wp-effect="aurora"]::before {
    content: '';
    position: absolute;
    inset: -50%;
    background:
      conic-gradient(from 0deg at 50% 50%, transparent 0deg, rgba(0, 255, 128, 0.08) 60deg, transparent 120deg, rgba(0, 128, 255, 0.08) 180deg, transparent 240deg, rgba(128, 0, 255, 0.06) 300deg, transparent 360deg);
    animation: wm-aurora-spin 20s linear infinite;
  }
  @keyframes wm-aurora-spin {
    from { transform: rotate(0deg) scale(1.5); }
    to { transform: rotate(360deg) scale(1.5); }
  }
  .wm-wallpaper[data-wm-wp-effect="gradient"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  .wm-wallpaper[data-wm-wp-effect="dots"] {
    background-image: radial-gradient(circle, var(--color-border) 1px, transparent 1px);
    background-size: 24px 24px;
  }
  .wm-wallpaper[data-wm-wp-effect="noise"] {
    background: var(--color-bg);
  }
  .wm-wallpaper[data-wm-wp-effect="noise"]::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.03;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px;
  }

  /* ── WM Menubar ── */
  /* ── macOS-style Menubar ──
   * Matches macOS Sequoia: SF Pro Text 13px, 25px bar, -0.01em tracking,
   * translucent backdrop, bold app name, right-aligned status area.
   */
  .wm-menubar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 0 6px;
    background: rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
    color: rgba(255, 255, 255, 0.92);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    font-size: 13.5px;
    font-weight: 400;
    letter-spacing: -0.01em;
    font-feature-settings: "kern" 1, "liga" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
  }
  .wm-menubar-left {
    display: flex;
    align-items: center;
    gap: 0;
    height: 100%;
  }
  .wm-menubar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
  }
  /* Every menubar item (text, action, etc) gets consistent padding */
  .wm-menubar .aup-text,
  .wm-menubar .aup-action,
  .wm-menubar .aup-time {
    color: rgba(255, 255, 255, 0.92);
    font-size: 13.5px;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 25px;
    margin: 0;
    padding: 0 9px;
    white-space: nowrap;
    border: none;
    background: transparent;
    border-radius: 3px;
    cursor: default;
  }
  .wm-menubar .aup-action {
    cursor: pointer;
    transition: background 0.1s;
  }
  .wm-menubar .aup-text:hover,
  .wm-menubar .aup-action:hover {
    background: rgba(255, 255, 255, 0.1);
  }
  .wm-menubar .aup-text:active,
  .wm-menubar .aup-action:active,
  .wm-menubar .aup-action[data-active="true"] {
    background: rgba(255, 255, 255, 0.18);
  }
  /* App name (first item on left) — bold like macOS */
  .wm-menubar-left > :first-child .aup-text,
  .wm-menubar-left > :first-child.aup-text,
  .wm-menubar-left > :first-child .aup-action,
  .wm-menubar-left > :first-child.aup-action {
    font-weight: 600;
  }
  /* Right side items (clock, icons) — slightly lighter weight */
  .wm-menubar-right .aup-text,
  .wm-menubar-right .aup-time {
    font-weight: 400;
    padding: 0 5px;
    opacity: 0.9;
  }
  /* Menubar media/icons */
  .wm-menubar .aup-media {
    width: 16px;
    height: 16px;
    border-radius: 0;
    opacity: 0.85;
  }

  /* Offset surfaces when menubar is present */
  .wm-container:has(.wm-menubar) {
    padding-top: 25px;
  }

  /* ── Dock ── */
  /* ── Dock ── */
  .wm-dock {
    position: absolute;
    display: flex;
    gap: 8px;
    padding: 8px;
    background: color-mix(in srgb, var(--color-bg) 90%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    overflow: auto;
    align-items: stretch;
    box-sizing: border-box;
  }
  /* Position variants */
  .wm-dock[data-dock-pos="bottom"] {
    bottom: 0; left: 0; right: 0;
    border-top: 1px solid var(--color-border);
    justify-content: center;
  }
  .wm-dock[data-dock-pos="top"] {
    top: 0; left: 0; right: 0;
    border-bottom: 1px solid var(--color-border);
    justify-content: center;
  }
  .wm-dock[data-dock-pos="left"] {
    top: 0; bottom: 0; left: 0;
    border-right: 1px solid var(--color-border);
    flex-direction: column;
    align-items: stretch;
  }
  .wm-dock[data-dock-pos="right"] {
    top: 0; bottom: 0; right: 0;
    border-left: 1px solid var(--color-border);
    flex-direction: column;
    align-items: stretch;
  }

  /* Resize handle — subtle dots default, visible bar on hover */
  .wm-dock > .wm-dock-handle {
    position: absolute;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background 0.2s, box-shadow 0.2s;
  }
  .wm-dock-handle::after {
    content: "• • •";
    font-size: 8px;
    color: rgba(128,128,128,0.2);
    letter-spacing: 0.5px;
    line-height: 1;
    transition: color 0.2s;
  }
  .wm-dock-handle:hover {
    background: rgba(128,128,128,0.22);
    box-shadow: 0 0 6px rgba(0,0,0,0.08);
    border-radius: 4px;
  }
  .wm-dock-handle:hover::after { color: rgba(60,60,60,0.7); }
  .wm-dock-handle:active { background: rgba(128,128,128,0.25); }
  .wm-dock-handle:active::after { color: var(--color-accent); }
  /* Horizontal docks */
  .wm-dock[data-dock-pos="bottom"] > .wm-dock-handle {
    --_hdl-dir: bottom;
    top: -4px; left: 0; right: 0; height: 12px;
    cursor: ns-resize;
  }
  .wm-dock[data-dock-pos="top"] > .wm-dock-handle {
    --_hdl-dir: top;
    bottom: -4px; left: 0; right: 0; height: 12px;
    cursor: ns-resize;
  }
  /* Vertical docks */
  .wm-dock[data-dock-pos="left"] > .wm-dock-handle {
    --_hdl-dir: right;
    top: 0; bottom: 0; right: -4px; width: 12px;
    cursor: ew-resize;
    writing-mode: vertical-lr;
  }
  .wm-dock[data-dock-pos="left"] > .wm-dock-handle::after { letter-spacing: 0; }
  .wm-dock[data-dock-pos="right"] > .wm-dock-handle {
    --_hdl-dir: left;
    top: 0; bottom: 0; left: -4px; width: 12px;
    cursor: ew-resize;
    writing-mode: vertical-lr;
  }
  .wm-dock[data-dock-pos="right"] > .wm-dock-handle::after { letter-spacing: 0; }

  /* Dock items */
  .wm-dock-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: box-shadow 0.15s ease;
    flex-shrink: 0;
    min-width: 60px;
    min-height: 40px;
  }
  /* Horizontal dock: fixed aspect items */
  .wm-dock[data-dock-pos="bottom"] > .wm-dock-item,
  .wm-dock[data-dock-pos="top"] > .wm-dock-item {
    aspect-ratio: 4/3;
  }
  /* Vertical dock: fill width, fixed aspect */
  .wm-dock[data-dock-pos="left"] > .wm-dock-item,
  .wm-dock[data-dock-pos="right"] > .wm-dock-item {
    width: 100%;
    aspect-ratio: 4/3;
    box-sizing: border-box;
  }
  .wm-dock-item:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    border-color: var(--color-accent);
  }
  /* Live mode: items fill dock slot, interactive */
  .wm-dock[data-dock-mode="live"] > .wm-dock-item {
    cursor: default;
    aspect-ratio: auto;
    flex: 1 1 0;
    min-width: 100px;
    min-height: 60px;
  }

  .wm-dock-viewport {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    pointer-events: none;
    overflow: hidden;
  }
  .wm-dock-item .wm-surface {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
  }
  .wm-dock-item .wm-titlebar {
    display: none !important;
  }
  .wm-dock-item .wm-surface-content {
    overflow: hidden;
  }
  /* Live mode: content is interactive, no pointer block */
  .wm-dock[data-dock-mode="live"] > .wm-dock-item .wm-surface-content {
    overflow: auto;
    pointer-events: auto;
  }

  /* Thumbnail label */
  .wm-dock-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    color: #fff;
    font-size: 0.6rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
  }
  /* Live mode label: top bar with undock control */
  .wm-dock-label-live {
    bottom: auto;
    top: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 3px 8px;
    pointer-events: auto;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    z-index: 2;
  }
  .wm-dock-undock-btn {
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.7;
    padding: 2px 4px;
    border-radius: 3px;
    transition: opacity 0.15s, background 0.15s;
  }
  .wm-dock-undock-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.2);
  }

  /* ── Dock Theming ── */

  /* Material: frosted (default) */
  .wm-dock[data-dock-appearance="frosted"] {
    background: var(--dock-bg, rgba(255,255,255,0.65));
    backdrop-filter: blur(var(--dock-blur, 20px));
    -webkit-backdrop-filter: blur(var(--dock-blur, 20px));
    border-color: var(--dock-border, rgba(255,255,255,0.3));
  }
  /* Material: liquid glass */
  .wm-dock[data-dock-appearance="liquid"] {
    background: var(--dock-bg, rgba(255,255,255,0.35));
    backdrop-filter: blur(var(--dock-blur, 28px)) saturate(1.6);
    -webkit-backdrop-filter: blur(var(--dock-blur, 28px)) saturate(1.6);
    border: 1.5px solid var(--dock-border, rgba(255,255,255,0.5));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(255,255,255,0.15);
  }
  .wm-dock[data-dock-appearance="liquid"]::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 40%, rgba(255,255,255,0.08) 100%);
    pointer-events: none;
  }
  /* Material: brushed metal */
  .wm-dock[data-dock-appearance="metal"] {
    background: var(--dock-bg, linear-gradient(135deg, #c8c8c8 0%, #9a9a9a 25%, #b0b0b0 50%, #8a8a8a 75%, #a0a0a0 100%));
    backdrop-filter: none;
    border: 1px solid var(--dock-border, rgba(0,0,0,0.25));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
  }
  .wm-dock[data-dock-appearance="metal"]::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent, transparent 1px, rgba(255,255,255,0.03) 1px, rgba(255,255,255,0.03) 2px);
    pointer-events: none;
  }
  /* Material: plastic */
  .wm-dock[data-dock-appearance="plastic"] {
    background: var(--dock-bg, linear-gradient(180deg, #eaeaea 0%, #d2d2d2 100%));
    backdrop-filter: none;
    border: 1px solid var(--dock-border, #b0b0b0);
  }
  /* Material: transparent */
  .wm-dock[data-dock-appearance="transparent"] {
    background: var(--dock-bg, transparent);
    backdrop-filter: none;
    border: none;
    box-shadow: none !important;
  }
  /* Tint overlay */
  .wm-dock[data-dock-tint]::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--dock-tint, transparent);
    opacity: var(--dock-opacity, 0.15);
    pointer-events: none;
    border-radius: inherit;
    z-index: 0;
  }
  .wm-dock[data-dock-tint] > *:not(.wm-dock-handle) { position: relative; z-index: 1; }

  /* Layout: edge (default — no extra rules needed) */
  /* Layout: floating */
  .wm-dock[data-dock-layout="floating"] {
    border-radius: var(--dock-radius, 12px);
    border: 1px solid var(--dock-border, rgba(255,255,255,0.3));
  }
  .wm-dock[data-dock-layout="floating"][data-dock-pos="bottom"] {
    bottom: 12px; left: 50%; right: auto;
    transform: translateX(-50%);
    max-width: 80vw;
    width: fit-content;
  }
  .wm-dock[data-dock-layout="floating"][data-dock-pos="top"] {
    top: 12px; left: 50%; right: auto;
    transform: translateX(-50%);
    max-width: 80vw;
    width: fit-content;
  }
  .wm-dock[data-dock-layout="floating"][data-dock-pos="left"] {
    left: 12px; top: 50%; bottom: auto;
    transform: translateY(-50%);
    max-height: 80vh;
    height: fit-content;
  }
  .wm-dock[data-dock-layout="floating"][data-dock-pos="right"] {
    right: 12px; top: 50%; bottom: auto;
    transform: translateY(-50%);
    max-height: 80vh;
    height: fit-content;
  }
  /* Layout: island — pill-shaped, narrow, centered */
  .wm-dock[data-dock-layout="island"] {
    border-radius: var(--dock-radius, 999px);
    border: 1px solid var(--dock-border, rgba(255,255,255,0.35));
    gap: 12px;
    padding: 10px 20px;
  }
  .wm-dock[data-dock-layout="island"][data-dock-pos="bottom"] {
    bottom: 16px; left: 50%; right: auto;
    transform: translateX(-50%);
    max-width: 70vw;
    width: auto;
  }
  .wm-dock[data-dock-layout="island"][data-dock-pos="top"] {
    top: 16px; left: 50%; right: auto;
    transform: translateX(-50%);
    max-width: 70vw;
    width: auto;
  }
  .wm-dock[data-dock-layout="island"][data-dock-pos="left"] {
    left: 16px; top: 50%; bottom: auto;
    transform: translateY(-50%);
    max-height: 70vh;
    height: auto;
    padding: 20px 10px;
  }
  .wm-dock[data-dock-layout="island"][data-dock-pos="right"] {
    right: 16px; top: 50%; bottom: auto;
    transform: translateY(-50%);
    max-height: 70vh;
    height: auto;
    padding: 20px 10px;
  }

  /* Shadow direction */
  .wm-dock[data-dock-shadow="outer"][data-dock-pos="bottom"] { box-shadow: 0 -4px 20px rgba(0,0,0,0.15); }
  .wm-dock[data-dock-shadow="outer"][data-dock-pos="top"] { box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
  .wm-dock[data-dock-shadow="outer"][data-dock-pos="left"] { box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
  .wm-dock[data-dock-shadow="outer"][data-dock-pos="right"] { box-shadow: -4px 0 20px rgba(0,0,0,0.15); }
  .wm-dock[data-dock-shadow="inset"][data-dock-pos="bottom"] { box-shadow: inset 0 4px 12px rgba(0,0,0,0.1); }
  .wm-dock[data-dock-shadow="inset"][data-dock-pos="top"] { box-shadow: inset 0 -4px 12px rgba(0,0,0,0.1); }
  .wm-dock[data-dock-shadow="inset"][data-dock-pos="left"] { box-shadow: inset -4px 0 12px rgba(0,0,0,0.1); }
  .wm-dock[data-dock-shadow="inset"][data-dock-pos="right"] { box-shadow: inset 4px 0 12px rgba(0,0,0,0.1); }
  .wm-dock[data-dock-shadow="both"][data-dock-pos="bottom"] { box-shadow: 0 -4px 20px rgba(0,0,0,0.15), inset 0 4px 12px rgba(0,0,0,0.08); }
  .wm-dock[data-dock-shadow="both"][data-dock-pos="top"] { box-shadow: 0 4px 20px rgba(0,0,0,0.15), inset 0 -4px 12px rgba(0,0,0,0.08); }
  .wm-dock[data-dock-shadow="both"][data-dock-pos="left"] { box-shadow: 4px 0 20px rgba(0,0,0,0.15), inset -4px 0 12px rgba(0,0,0,0.08); }
  .wm-dock[data-dock-shadow="both"][data-dock-pos="right"] { box-shadow: -4px 0 20px rgba(0,0,0,0.15), inset 4px 0 12px rgba(0,0,0,0.08); }
  .wm-dock[data-dock-shadow="none"] { box-shadow: none !important; }

  /* Visibility: autohide + peek */
  .wm-dock[data-dock-visibility="autohide"],
  .wm-dock[data-dock-visibility="peek"] {
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s;
  }
  .wm-dock[data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="bottom"] { transform: translateY(calc(100% - 4px)); opacity: 0.4; }
  .wm-dock[data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="top"] { transform: translateY(calc(-100% + 4px)); opacity: 0.4; }
  .wm-dock[data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="left"] { transform: translateX(calc(-100% + 4px)); opacity: 0.4; }
  .wm-dock[data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="right"] { transform: translateX(calc(100% - 4px)); opacity: 0.4; }
  .wm-dock[data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="bottom"] { transform: translateY(calc(100% - 14px)); }
  .wm-dock[data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="top"] { transform: translateY(calc(-100% + 14px)); }
  .wm-dock[data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="left"] { transform: translateX(calc(-100% + 14px)); }
  .wm-dock[data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="right"] { transform: translateX(calc(100% - 14px)); }
  /* Floating layout needs combined transforms for centering + autohide/peek */
  .wm-dock[data-dock-layout="floating"][data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="bottom"],
  .wm-dock[data-dock-layout="floating"][data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="bottom"] {
    transform: translateX(-50%) translateY(calc(100% - 4px));
  }
  .wm-dock[data-dock-layout="floating"][data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="top"],
  .wm-dock[data-dock-layout="floating"][data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="top"] {
    transform: translateX(-50%) translateY(calc(-100% + 4px));
  }
  .wm-dock[data-dock-layout="floating"][data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="left"],
  .wm-dock[data-dock-layout="floating"][data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="left"] {
    transform: translateY(-50%) translateX(calc(-100% + 4px));
  }
  .wm-dock[data-dock-layout="floating"][data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="right"],
  .wm-dock[data-dock-layout="floating"][data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="right"] {
    transform: translateY(-50%) translateX(calc(100% - 4px));
  }
  /* Island layout needs transform-origin adjustment for combined transforms */
  .wm-dock[data-dock-layout="island"][data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="bottom"],
  .wm-dock[data-dock-layout="island"][data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="bottom"] {
    transform: translateX(-50%) translateY(calc(100% - 8px));
  }
  .wm-dock[data-dock-layout="island"][data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="top"],
  .wm-dock[data-dock-layout="island"][data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="top"] {
    transform: translateX(-50%) translateY(calc(-100% + 8px));
  }
  .wm-dock[data-dock-layout="island"][data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="left"],
  .wm-dock[data-dock-layout="island"][data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="left"] {
    transform: translateY(-50%) translateX(calc(-100% + 8px));
  }
  .wm-dock[data-dock-layout="island"][data-dock-visibility="autohide"][data-dock-hidden][data-dock-pos="right"],
  .wm-dock[data-dock-layout="island"][data-dock-visibility="peek"][data-dock-hidden][data-dock-pos="right"] {
    transform: translateY(-50%) translateX(calc(100% - 8px));
  }

  /* Handle styles */
  .wm-dock[data-dock-handle="line"] > .wm-dock-handle::after {
    content: "";
    width: 32px; height: 3px;
    background: rgba(120,120,120,0.5);
    border-radius: 2px;
  }
  .wm-dock[data-dock-handle="grip"] > .wm-dock-handle::after {
    content: "";
    width: 24px; height: 9px;
    background: repeating-linear-gradient(180deg, rgba(120,120,120,0.5) 0px, rgba(120,120,120,0.5) 1px, transparent 1px, transparent 3px);
    border-radius: 1px;
  }
  .wm-dock[data-dock-handle="pill"] > .wm-dock-handle::after {
    content: "";
    width: 48px; height: 5px;
    background: rgba(120,120,120,0.45);
    border-radius: 3px;
  }
  .wm-dock[data-dock-handle="none"] > .wm-dock-handle { display: none; }
  /* Vertical handle style overrides */
  .wm-dock[data-dock-pos="left"][data-dock-handle="line"] > .wm-dock-handle::after,
  .wm-dock[data-dock-pos="right"][data-dock-handle="line"] > .wm-dock-handle::after {
    width: 3px; height: 32px;
  }
  .wm-dock[data-dock-pos="left"][data-dock-handle="grip"] > .wm-dock-handle::after,
  .wm-dock[data-dock-pos="right"][data-dock-handle="grip"] > .wm-dock-handle::after {
    width: 9px; height: 24px;
    background: repeating-linear-gradient(90deg, rgba(120,120,120,0.5) 0px, rgba(120,120,120,0.5) 1px, transparent 1px, transparent 3px);
  }
  .wm-dock[data-dock-pos="left"][data-dock-handle="pill"] > .wm-dock-handle::after,
  .wm-dock[data-dock-pos="right"][data-dock-handle="pill"] > .wm-dock-handle::after {
    width: 5px; height: 48px;
  }

  /* Item shapes */
  .wm-dock[data-dock-item-shape="rounded"] > .wm-dock-item { border-radius: 8px; }
  .wm-dock[data-dock-item-shape="circle"] > .wm-dock-item {
    border-radius: 50%;
    aspect-ratio: 1 !important;
    overflow: hidden;
  }

  /* Magnification — scale hovered + adjacent items */
  .wm-dock[data-dock-magnify] > .wm-dock-item {
    transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), box-shadow 0.15s ease;
  }
  .wm-dock[data-dock-magnify] > .wm-dock-item:hover {
    transform: scale(var(--dock-magnify-scale, 1.3));
    z-index: 2;
  }
  .wm-dock[data-dock-magnify] > .wm-dock-item:hover + .wm-dock-item {
    transform: scale(calc(var(--dock-magnify-scale, 1.3) * 0.6 + 0.4));
    z-index: 1;
  }
  .wm-dock[data-dock-magnify] > .wm-dock-item:has(+ .wm-dock-item:hover) {
    transform: scale(calc(var(--dock-magnify-scale, 1.3) * 0.6 + 0.4));
    z-index: 1;
  }

  /* Glow effect on hover */
  .wm-dock[data-dock-glow] > .wm-dock-item:hover {
    box-shadow: 0 0 16px 4px var(--dock-glow-color, rgba(59,130,246,0.5));
  }

  /* ── Panels Strategy ── */
  .wm-panels {
    display: grid;
    width: 100%;
    height: 100%;
    /* grid-template-columns set dynamically by JS */
    /* grid-template-rows set dynamically by JS */
    gap: 0;
    background: var(--color-border);
  }

  .wm-panel {
    background: var(--color-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
  }
  /* Surfaces inside panels are structural — strip card chrome */
  .wm-panel > .wm-surface {
    border: none; border-radius: 0; background: transparent;
  }
  .wm-panel > .wm-surface > .wm-surface-content {
    padding: 0;
  }
  /* Panel header — lightweight title + chrome actions bar */
  .wm-panel-header {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    gap: 4px;
  }
  .wm-panel-header-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Full-width rows: header, footer, statusbar, dock */
  .wm-panel[data-wm-position="header"],
  .wm-panel[data-wm-position="footer"],
  .wm-panel[data-wm-position="statusbar"],
  .wm-panel[data-wm-position="dock"] {
    grid-column: 1 / -1;
  }

  .wm-panel[data-wm-position="header"] {
    border-bottom: 1px solid var(--color-border);
    padding: 6px 12px;
  }
  .wm-panel[data-wm-position="footer"],
  .wm-panel[data-wm-position="statusbar"] {
    border-top: 1px solid var(--color-border);
    padding: 4px 12px;
    font-size: 0.75rem;
    color: var(--color-dim);
  }
  .wm-panel[data-wm-position="dock"] {
    border-top: 1px solid var(--color-border);
    padding: 4px 8px;
    flex-direction: row;
    gap: 4px;
    align-items: center;
  }

  /* ── Panels Divider (draggable resize handle) ── */
  .wm-divider {
    width: 4px;
    cursor: col-resize;
    background: var(--color-border);
    transition: background 0.15s;
    flex-shrink: 0;
    position: relative;
  }
  .wm-divider:hover,
  .wm-divider.wm-divider-active {
    background: var(--color-accent);
  }
  .wm-divider::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    left: -4px; right: -4px;
  }

  /* ── Responsive: narrow viewport collapses to single-column ── */
  .wm-responsive-tabs {
    display: none;
    grid-column: 1 / -1;
    gap: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    flex-shrink: 0;
  }
  .wm-responsive-tab {
    padding: 6px 14px;
    font-size: 0.75rem;
    color: var(--color-dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
  }
  .wm-responsive-tab:hover { color: var(--color-text); }
  .wm-responsive-tab[data-active="true"] {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
  }

  @media (max-width: 768px) {
    .wm-panels {
      grid-template-columns: 1fr !important;
    }
    .wm-panels > .wm-divider { display: none; }
    .wm-panel[data-wm-responsive-hidden="true"] { display: none !important; }
    .wm-responsive-tabs { display: flex; }
  }

  /* ── Strip Bar ── */
  .wm-strip-bar {
    display: flex;
    overflow-x: auto;
    gap: 1px;
    background: rgba(128,128,128,0.08);
    border-bottom: 1px solid rgba(128,128,128,0.15);
    min-height: 28px;
    align-items: stretch;
    scrollbar-width: thin;
  }
  .wm-strip-bar::-webkit-scrollbar { height: 2px; }
  .wm-strip-bar::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.3); border-radius: 1px; }
  .wm-strip-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    font-size: 0.7rem;
    color: var(--text-muted, rgba(128,128,128,0.7));
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
  }
  .wm-strip-item:hover { color: var(--color-text); background: rgba(128,128,128,0.05); }
  .wm-strip-item[data-active="true"] {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    background: rgba(128,128,128,0.03);
  }
  .wm-strip-item-label {
    pointer-events: none;
  }
  .wm-strip-item-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.6rem;
    padding: 0 2px;
    opacity: 0;
    line-height: 1;
    transition: opacity 0.15s;
  }
  .wm-strip-item:hover .wm-strip-item-close { opacity: 1; }
  .wm-strip-item-close:hover { color: var(--color-accent); }
  .wm-strip-bar .wm-chrome-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; padding-right: 8px; flex-shrink: 0; }

  /* ── Strip Stage ── */
  .wm-strip-stage {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
  }

  /* Desktop strip bar */
  .wm-desktop-strip {
    display: flex;
    gap: 2px;
    padding: 2px 8px;
    background: rgba(128,128,128,0.06);
    border-bottom: 1px solid rgba(128,128,128,0.12);
    min-height: 30px;
    align-items: center;
    position: relative;
    z-index: 1;
  }
  .wm-desktop-strip-item {
    padding: 4px 16px;
    font-size: 0.72rem;
    color: var(--text-muted, rgba(128,128,128,0.7));
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    transition: color 0.15s, background 0.15s;
  }
  .wm-desktop-strip-item:hover { color: var(--color-text); background: rgba(128,128,128,0.08); }
  .wm-desktop-strip-item[data-active="true"] {
    color: var(--color-accent);
    background: rgba(128,128,128,0.1);
    font-weight: 500;
  }

  /* ── Strip Drag Reorder ── */
  .wm-strip-item[draggable="true"] {
    cursor: grab;
  }
  .wm-strip-item.wm-strip-dragging {
    opacity: 0.4;
  }
  .wm-strip-item.wm-strip-drop-before {
    box-shadow: inset 2px 0 0 var(--color-accent, #4a9eff);
  }
  .wm-strip-item.wm-strip-drop-after {
    box-shadow: inset -2px 0 0 var(--color-accent, #4a9eff);
  }

  /* ── Strip Overflow Indicators ── */
  .wm-strip-bar {
    position: relative;
  }
  .wm-strip-bar.wm-strip-overflow-left::before,
  .wm-strip-bar.wm-strip-overflow-right::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    pointer-events: none;
    z-index: 2;
  }
  .wm-strip-bar.wm-strip-overflow-left::before {
    left: 0;
    background: linear-gradient(to right, var(--color-bg, #1e1e1e), transparent);
  }
  .wm-strip-bar.wm-strip-overflow-right::after {
    right: 0;
    background: linear-gradient(to left, var(--color-bg, #1e1e1e), transparent);
  }

  /* ── Strip Context Menu ── */
  .wm-strip-context-menu {
    background: var(--color-bg, #252526);
    border: 1px solid rgba(128,128,128,0.25);
    border-radius: 6px;
    padding: 4px 0;
    min-width: 160px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    font-size: 0.78rem;
    color: var(--color-text, #ccc);
  }
  .wm-strip-context-menu-item {
    padding: 6px 16px;
    cursor: pointer;
    white-space: nowrap;
  }
  .wm-strip-context-menu-item:hover {
    background: rgba(128,128,128,0.15);
  }

  /* ── Overlay Layer (Phase 4) ── */
  .wm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
  }
  .wm-overlay > * {
    pointer-events: auto;
  }

  /* ── Mission Control / Exposé ── */
  /* ── Focus Mode ── */
  .wm-focus-mode::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    z-index: 8999;
    pointer-events: none;
  }
  .wm-fm-overview > .wm-surface {
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
    cursor: pointer;
  }
  /* Hide resize/drag in overview, show in focus */
  .wm-fm-overview > .wm-rz,
  .wm-fm-overview > .wm-surface > .wm-rz,
  .wm-fm-overview > .wm-surface > .wm-drag-grip {
    display: none;
  }
  .wm-fm-focus > .wm-surface:not([data-fm-focused]) > .wm-rz,
  .wm-fm-focus > .wm-surface:not([data-fm-focused]) > .wm-drag-grip {
    display: none;
  }
  .wm-fm-focus > .wm-surface[data-fm-focused] {
    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 2px var(--color-accent);
    border-radius: 8px;
  }
  .wm-fm-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    cursor: pointer;
  }
  /* Dismiss X button — hidden until hover */
  .wm-fm-dismiss {
    position: absolute;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    z-index: 9200;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.15s ease;
    pointer-events: auto;
  }
  .wm-fm-dismiss:hover {
    opacity: 1;
    background: rgba(255,60,60,0.7);
    color: #fff;
  }
  .wm-fm-focus:hover .wm-fm-dismiss {
    opacity: 0.6;
  }
  /* Add side-by-side button */
  .wm-fm-add-btn {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.4);
    font-size: 13px;
    cursor: pointer;
    z-index: 9200;
    opacity: 0;
    transition: opacity 0.25s ease, background 0.15s ease;
    pointer-events: auto;
    user-select: none;
  }
  .wm-fm-focus:hover .wm-fm-add-btn {
    opacity: 1;
  }
  .wm-fm-add-btn:hover {
    background: rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.8);
  }
