/* Shared semantic palette; auto retains its identity and follows the system. */
:root { --as-bg:#f6f5fb; --as-panel:#fff; --as-raised:#eeecf8; --as-ink:#201b35; --as-muted:#625b78; --as-accent:#624ce0; --as-line:#d8d2e9; --as-focus:#7056f2; }
:root[data-assembling-theme="dark"], :root[data-assembling-theme="cosmic"] { --as-bg:#0b0b1a; --as-panel:#17172d; --as-raised:#25243f; --as-ink:#f5f2ff; --as-muted:#b7b1cf; --as-accent:#b8adff; --as-line:#4a4565; --as-focus:#b8adff; }
@media (prefers-color-scheme:dark) { :root[data-assembling-theme="auto"] { --as-bg:#0b0b1a; --as-panel:#17172d; --as-raised:#25243f; --as-ink:#f5f2ff; --as-muted:#b7b1cf; --as-accent:#b8adff; --as-line:#4a4565; --as-focus:#b8adff; } }
:root[data-assembling-theme="orange"] { --as-bg:#fff8f0; --as-panel:#fff; --as-raised:#ffebd5; --as-ink:#4a2c0f; --as-muted:#76532d; --as-accent:#bb4208; --as-line:#e8c7a4; --as-focus:#bb4208; }
:root[data-assembling-theme="mustard"] { --as-bg:#fffbeb; --as-panel:#fff; --as-raised:#fef3c7; --as-ink:#422006; --as-muted:#854d0e; --as-accent:#986400; --as-line:#e7c45b; --as-focus:#986400; }
:root[data-assembling-theme="forest"] { --as-bg:#f0fdf4; --as-panel:#fff; --as-raised:#dcfce7; --as-ink:#052e16; --as-muted:#166534; --as-accent:#137a37; --as-line:#86cda0; --as-focus:#137a37; }
:root[data-assembling-theme="sky"] { --as-bg:#f0f9ff; --as-panel:#fff; --as-raised:#e0f2fe; --as-ink:#082f49; --as-muted:#075985; --as-accent:#03699d; --as-line:#89c7e9; --as-focus:#03699d; }
:root[data-assembling-theme="indigo"] { --as-bg:#eef2ff; --as-panel:#fff; --as-raised:#e0e7ff; --as-ink:#1e1b4b; --as-muted:#3730a3; --as-accent:#4f46e5; --as-line:#a5b4fc; --as-focus:#4f46e5; }
:root[data-assembling-theme="magenta"] { --as-bg:#faf5ff; --as-panel:#fff; --as-raised:#fae8ff; --as-ink:#4a044e; --as-muted:#86198f; --as-accent:#a21caf; --as-line:#df8be5; --as-focus:#a21caf; }
:root[data-assembling-theme="crimson"] { --as-bg:#fef2f2; --as-panel:#fff; --as-raised:#fee2e2; --as-ink:#450a0a; --as-muted:#7f1d1d; --as-accent:#b91c1c; --as-line:#f3a5a5; --as-focus:#b91c1c; }
:root[data-assembling-theme="violet"] { --as-bg:#0f0418; --as-panel:#1c0b2e; --as-raised:#2a1043; --as-ink:#f3e8ff; --as-muted:#c4b5fd; --as-accent:#c084fc; --as-line:#70429b; --as-focus:#c084fc; }

/* Account, sign-in and other shared screens use the global palette. */
html[data-assembling-module="service"][data-assembling-theme] {
  --b-bg: var(--as-bg);
  --b-surface: var(--as-panel);
  --b-surface-2: var(--as-raised);
  --b-surface-3: var(--as-raised);
  --b-solid: var(--as-panel);
  --b-text: var(--as-ink);
  --b-muted: var(--as-muted);
  --b-border: var(--as-line);
  --b-accent: var(--as-accent);
  --b-accent-text: var(--as-accent);
  --b-accent-soft: var(--as-raised);
  --b-accent-fg: var(--as-panel);
}

#as-theme-dialog {
  box-sizing: border-box;
  width: min(28rem, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 18px;
  border: 1px solid var(--as-line);
  border-radius: 14px;
  background: var(--as-panel);
  color: var(--as-ink);
  font: 400 14px/1.45 system-ui, sans-serif;
}
#as-theme-dialog::backdrop { background: rgb(7 7 23 / .58); }
#as-theme-dialog h2 { margin: 0 0 14px; color: inherit; font-size: 1.2rem; }
#as-theme-dialog label { display: block; margin-bottom: 4px; }
#as-theme-dialog select,
#as-theme-dialog button {
  padding: 6px 10px;
  min-height: 44px;
  border: 1px solid var(--as-line);
  border-radius: 8px;
  background: var(--as-raised);
  color: inherit;
  font: inherit;
}
#as-theme-dialog select { box-sizing: border-box; width: 100%; }
#as-theme-dialog button:not(:disabled) { cursor: pointer; }
#as-theme-dialog button[type="submit"] { border-color: var(--as-accent); }
#as-theme-dialog :is(select, button):focus-visible { outline: 2px solid var(--as-focus); outline-offset: 2px; }
#as-theme-dialog p { margin: 10px 0 0; color: var(--as-muted); }
#as-theme-dialog p:empty { display: none; }
.as-theme-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Product identity stays in one row; each workspace owns the tools below it. */
.as-product-header {
  position:relative; z-index:85; box-sizing:border-box; flex:0 0 56px;
  display:flex; align-items:center; gap:12px; width:100%; height:56px; min-width:0;
  padding:0 max(16px,env(safe-area-inset-right)) 0 max(16px,env(safe-area-inset-left));
  background:var(--as-panel); color:var(--as-ink); border-bottom:1px solid var(--as-line);
  font:500 14px/1.25 system-ui,sans-serif;
}
.as-product-header * {box-sizing:border-box}
.as-product-header .as-module-menu {position:relative;flex:none;margin:0;padding:0;border:0;background:transparent}
.as-product-header summary {
  list-style:none; cursor:pointer; display:flex; align-items:center; gap:8px; min-height:44px;
  padding:0; color:var(--as-ink); font:700 16px/1.15 system-ui,sans-serif;
}
.as-product-header summary::-webkit-details-marker {display:none}
.as-product-header summary::before {
  content:"◆"; display:grid; place-items:center; width:26px; height:26px; border-radius:8px;
  background:linear-gradient(135deg,var(--as-accent),var(--as-raised)); color:var(--as-bg); font-size:14px;
}
.as-product-header summary::after {content:"▾";font-size:12px;color:var(--as-muted)}
.as-module-menu nav,.as-product-header .sp-project-more[aria-expanded=true]+.sp-project-actions {
  border:1px solid var(--as-line); border-radius:12px; background:var(--as-panel); color:var(--as-ink);
  box-shadow:0 12px 36px #0003;
}
.as-module-menu nav {position:absolute;top:100%;left:0;width:min(280px,85vw);padding:4px}
.as-module-menu nav a {display:block;padding:8px 12px;border-radius:8px;text-decoration:none;color:var(--as-ink);font-weight:650}
.as-module-menu nav small {display:block;font-weight:400;color:var(--as-muted);margin-top:2px}
.as-module-menu nav a:is(:hover,[aria-current=page]) {background:var(--as-raised)}
.as-product-header .sp-project-switch,.as-product-header .sp-project-actions {
  display:flex;align-items:center;gap:6px;min-width:0;white-space:nowrap;
}
.as-product-header .sp-project-actions label {display:flex;align-items:center;gap:6px;margin:0;color:var(--as-muted)}
.as-product-header :where(.as-account,.sp-project-switch button,.sp-project-switch select,.sp-project-switch a) {
  display:inline-flex;align-items:center;justify-content:center; flex:none;
  height:34px;min-height:34px;min-width:0;margin:0;padding:0 10px;border:1px solid var(--as-line);border-radius:8px;
  background:var(--as-panel);color:var(--as-ink);text-decoration:none;cursor:pointer;font:600 13px/1 system-ui,sans-serif;
}
.as-product-header .as-account {margin-left:auto}
.as-product-header .sp-project-more {display:none}
.as-product-header :focus-visible {outline:2px solid var(--as-focus);outline-offset:2px}
.as-product-header #sidebar-toggle {position:static;inset:auto;flex:none;margin:0}
body:has(.as-product-header) #brand-name {display:none}
body:has(.as-product-header) #top-header .subtitle {display:none}
@media (max-width:1050px) {
  .as-product-header {gap:6px;padding-inline:max(8px,env(safe-area-inset-left)) max(8px,env(safe-area-inset-right))}
  .as-product-header summary {gap:4px;font-size:14px}
  .as-product-header .sp-project-switch {flex:0 1 auto}
  .as-product-header #product-select {flex:1 1 auto;width:clamp(48px,20vw,224px);min-width:0}
  .as-product-header .sp-project-more {display:inline-flex}
  .as-product-header .sp-project-actions {display:none}
  .as-product-header .sp-project-more[aria-expanded=true]+.sp-project-actions {
    position:absolute;top:calc(100% - 3px);inset-inline-end:8px;padding:8px;display:flex;
    flex-direction:column;align-items:stretch;max-width:calc(100% - 16px)
  }
  .as-product-header :where(.as-account,.sp-project-switch button,.sp-project-switch select,.sp-project-switch a) {height:44px;padding-inline:7px}
}
@media (max-width:480px) {
  .as-product-header summary::before {display:none}
  .as-product-header #product-select {width:clamp(44px,14vw,80px)}
}
@media print {.as-product-header {display:none}}
