/* Shared fixed-height workspace chrome. Preview editors keep their own scoped stylesheet. */
body.workspace-shell[data-q-ui="aima"] {
  --ink:#252623; --ink-2:#4d4f49; --ink-3:#666962;
  --ground:#fcfcfa; --surface:#ffffff; --surface-muted:#f0f0eb;
  --workspace-sidebar:#f5f5f0; --workspace-hover:#eaeae3;
  --line:#e3e4dd; --line-strong:#80867b;
  /* AiMa accent from the approved family palette (docs/q-platforms-ui-stage1.md). */
  --brand:#6d28d9; --brand-hover:#5b21b6; --brand-active:#4c1d95;
  --brand-strong:#4c1d95; --brand-soft:#ede9fe; --on-brand:#ffffff; --focus:#6d28d9;
  color:var(--ink); background:var(--ground);
  block-size:100dvh; min-block-size:320px; overflow:hidden;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  -webkit-font-smoothing:antialiased;
}
.workspace-shell .workspace-layout {
  display:grid; grid-template-columns:248px minmax(0,1fr);
  block-size:100%; min-block-size:0; inline-size:100%;
}
.workspace-shell #preview-sidebar.workspace-sidebar {
  position:relative; inset:auto; display:flex; flex-direction:column; gap:20px;
  min-inline-size:0; min-block-size:0; padding:24px 16px 16px;
  margin:0; border:0; border-inline-end:1px solid var(--line); border-radius:0;
  background:var(--workspace-sidebar); box-shadow:none; overflow-x:hidden; overflow-y:auto;
  overscroll-behavior:contain;
}
.workspace-shell #preview-sidebar .workspace-brand {
  display:flex; align-items:center; gap:10px; min-block-size:36px; padding-block:0; padding-inline:8px;
  color:var(--ink); text-decoration:none; font-size:22px; font-weight:650; letter-spacing:-.7px;
}
.workspace-shell #preview-sidebar .workspace-brand:hover { background:transparent; }
.workspace-shell #preview-sidebar .workspace-brand .mark {
  inline-size:30px; block-size:30px; border-radius:9px;
  font-size:24px; background:var(--brand); color:var(--on-brand);
}
.workspace-shell #preview-sidebar .workspace-brand .muted { font-weight:450; font-size:14px; letter-spacing:0; }
.workspace-shell .workspace-nav,
.workspace-shell .workspace-primary-nav { display:grid; gap:4px; }
.workspace-shell #preview-sidebar :is(a,button) { overflow-wrap:anywhere; }
.workspace-shell #preview-sidebar :is(.workspace-nav,.workspace-primary-nav) :is(a,button),
.workspace-shell #preview-sidebar .workspace-new-chat {
  display:flex; align-items:center; gap:10px; min-block-size:42px; inline-size:100%;
  padding:10px 12px; margin:0; border:1px solid transparent; border-radius:9px;
  color:var(--ink); background:transparent; font-size:13px; font-weight:500;
  line-height:1.45; text-decoration:none; text-align:start; box-shadow:none;
}
.workspace-shell #preview-sidebar :is(.workspace-nav,.workspace-primary-nav) :is(a,button):hover,
.workspace-shell #preview-sidebar .workspace-new-chat:hover { background:var(--workspace-hover); border-color:transparent; }
.workspace-shell #preview-sidebar :is(.workspace-nav,.workspace-primary-nav) [aria-current="page"] {
  background:var(--workspace-hover); font-weight:600;
}
.workspace-shell #preview-sidebar .workspace-new-chat {
  background:var(--surface); border-color:var(--line);
}
.workspace-shell :is(.workspace-nav,.workspace-primary-nav,.workspace-account) svg,
.workspace-shell .workspace-icon { inline-size:18px; block-size:18px; flex:0 0 18px; }
.workspace-shell button span { margin-inline-start:0; }
.workspace-shell .workspace-section-label,
.workspace-shell .workspace-history>h2,
.workspace-shell .workspace-projects>h2 {
  margin:0 0 9px; padding-inline:12px; color:var(--ink-3);
  font-size:11px; line-height:1.5; font-weight:600; letter-spacing:.02em;
}
.workspace-shell .workspace-history { min-block-size:120px; flex:1 1 0; overflow-y:auto; overscroll-behavior:contain; }
.workspace-shell .workspace-projects { min-block-size:0; max-block-size:25%; overflow-y:auto; }
.workspace-shell .workspace-history :is(nav,ul),
.workspace-shell .workspace-projects :is(nav,ul) { display:grid; gap:2px; margin:0; padding:0; border:0; list-style:none; }
.workspace-shell :is(.workspace-history,.workspace-projects) :is(a,button) {
  display:block; inline-size:100%; max-inline-size:100%; min-block-size:36px;
  padding:8px 12px; margin:0; border:1px solid transparent; border-radius:8px;
  color:var(--ink-2); background:transparent; font-size:12px; font-weight:450;
  line-height:1.5; text-decoration:none; text-align:start;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.workspace-shell :is(.workspace-history,.workspace-projects) :is(a,button):hover,
.workspace-shell :is(.workspace-history,.workspace-projects) [aria-current="page"] {
  color:var(--ink); background:var(--workspace-hover); border-color:transparent;
}
.workspace-shell :is(.workspace-history,.workspace-projects) [aria-current="page"] { font-weight:600; }
.workspace-shell :is(.workspace-history,.workspace-projects)>p {
  margin:0; padding:0 12px; color:var(--ink-3); font-size:12px; line-height:1.6;
}
.workspace-shell #chat-search {
  min-block-size:34px; padding:7px 10px; margin:0 0 12px; border:1px solid var(--line-strong);
  border-radius:8px; background:var(--surface); color:var(--ink); font-size:12px;
}
.workspace-shell .workspace-history nav>p.small { margin:6px 12px 12px; font-size:11px; line-height:1.7; }
.workspace-shell .workspace-archive { margin-block-start:14px; border-block-start:1px solid var(--line); }
.workspace-shell .workspace-archive>summary {
  padding:11px 12px; color:var(--ink-3); font-size:11px; line-height:1.5; cursor:pointer;
}
.workspace-shell .workspace-account {
  display:grid; gap:8px; margin-block-start:auto; padding-block-start:12px;
  border-block-start:1px solid var(--line); flex-shrink:0;
}
.workspace-shell .workspace-account :is(a,button) {
  display:flex; align-items:center; gap:10px; min-block-size:38px; padding:8px 12px;
  border:1px solid transparent; border-radius:8px; font-size:12px; font-weight:500;
  background:transparent; color:var(--ink-2); text-decoration:none; text-align:start;
}
.workspace-shell .workspace-account :is(a,button):hover { background:var(--workspace-hover); border-color:transparent; }
.workspace-shell .workspace-account #identity {
  margin:0; padding-inline:12px; color:var(--ink-3); font-size:11px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.workspace-shell .workspace-account>details>summary {
  padding:9px 12px; min-block-size:36px; color:var(--ink-2); font-size:12px;
  font-weight:550; cursor:pointer; overflow-wrap:anywhere;
}
.workspace-shell .workspace-account>details[open] { background:var(--workspace-hover); border-radius:9px; }
body.workspace-shell[data-q-ui="aima"] main.workspace-main {
  display:flex; flex-direction:column; min-inline-size:0; min-block-size:0;
  max-inline-size:none; inline-size:100%; margin:0; padding:0;
}
.workspace-shell .workspace-topbar {
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  min-block-size:52px; block-size:auto; padding:8px 20px; flex-shrink:0;
  background:var(--ground); border:0;
}
.workspace-shell .workspace-topbar :is(h1,h2) {
  margin:0; color:var(--ink); font-size:16px; font-weight:550;
  line-height:1.4; letter-spacing:-.25px;
}
.workspace-shell .workspace-topbar>div { display:flex; align-items:center; gap:12px; min-inline-size:0; }
.workspace-shell .workspace-topbar :is(button,a) {
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  min-block-size:36px; padding:7px 10px; border:1px solid transparent; border-radius:8px;
  color:var(--ink-2); background:transparent; font-size:12px; font-weight:500; text-decoration:none;
}
.workspace-shell .workspace-topbar :is(button,a):hover { background:var(--surface-muted); border-color:transparent; }
.workspace-shell #workspace-chat-actions { position:relative; }
.workspace-shell #workspace-chat-actions>summary {
  display:grid; place-items:center; inline-size:36px; block-size:36px;
  padding:6px; list-style:none; color:var(--ink-2); border-radius:8px;
  font-size:13px; cursor:pointer;
}
.workspace-shell #workspace-chat-actions>summary::-webkit-details-marker { display:none; }
.workspace-shell #workspace-chat-actions>summary:hover { background:var(--surface-muted); }
.workspace-shell .workspace-chat-menu {
  position:absolute; z-index:30; inset-block-start:42px; inset-inline-end:0;
  display:grid; inline-size:170px; gap:3px; padding:6px;
  border:1px solid var(--line); border-radius:11px; background:var(--surface);
  box-shadow:0 8px 28px #25262318;
}
.workspace-shell .workspace-chat-menu button { justify-content:flex-start; text-align:start; inline-size:100%; }
.workspace-shell .workspace-content {
  position:relative; display:flex; flex-direction:column;
  flex:1 1 0; min-inline-size:0; min-block-size:0; overflow:auto;
}
.workspace-shell #prochat-mount { flex:1 1 0; min-inline-size:0; min-block-size:0; block-size:100%; }
.workspace-shell[data-auth-page="owner"] .workspace-content>#preview-content { inline-size:100%; min-block-size:0; padding:24px 36px 64px; }
.workspace-shell .workspace-content .card {
  max-inline-size:850px; margin-inline:auto; padding:0; border:0;
  background:transparent; box-shadow:none; border-radius:0;
}
.workspace-shell .workspace-content .card>h2 { margin-block-end:20px; font-size:26px; font-weight:550; letter-spacing:-.7px; }
.workspace-shell .workspace-content :is(#gate,.workspace-gate) {
  margin:auto; padding:36px 28px; max-inline-size:480px; text-align:center;
}
.workspace-shell .workspace-content :is(label,input,textarea,select) { font-size:13px; }
.workspace-shell .workspace-content :is(input,textarea,select) { border-radius:10px; background:var(--surface); }
.workspace-shell .workspace-content :is(.scope-note,.workspace-note) {
  margin-block:16px; padding:12px 14px; border:0; border-radius:10px;
  color:var(--ink-2); background:var(--surface-muted); font-size:12px; line-height:1.6;
}
.workspace-shell #workspace-status:empty { display:none; }
.workspace-shell #workspace-status:not(:empty) {
  flex-shrink:0; inline-size:min(calc(100% - 48px),760px); max-block-size:70px;
  overflow:auto; margin:0 auto; padding:8px 0; color:var(--ink-2); font-size:12px; line-height:1.6;
}
.workspace-shell #menu { display:none; }
.workspace-shell #workspace-scrim { display:none; }
.workspace-shell :is(button,a,input,textarea,select,summary):focus-visible {
  outline:2px solid var(--focus); outline-offset:3px;
}
.workspace-shell :is(#preview-sidebar,.workspace-content,.pc-log) { scrollbar-width:thin; scrollbar-color:var(--line-strong) transparent; }
.workspace-shell dialog {
  max-inline-size:min(480px,calc(100vw - 32px)); max-block-size:calc(100dvh - 32px);
  padding:26px; border:1px solid var(--line); border-radius:16px;
  background:var(--surface); color:var(--ink); box-shadow:0 18px 70px #0003;
}
.workspace-shell dialog::backdrop { background:#15171366; }
.workspace-shell .workspace-empty {
  max-inline-size:560px; margin-inline:auto; padding:clamp(30px,9vh,105px) 24px 24px;
  text-align:center; color:var(--ink);
}
.workspace-shell .workspace-empty :is(h1,h2) {
  margin:0 0 18px; font-family:Georgia,"Times New Roman",serif;
  font-size:clamp(29px,3.8vw,42px); line-height:1.2; font-weight:450; letter-spacing:-1px;
}
.workspace-shell .workspace-empty p { color:var(--ink-3); font-size:13px; line-height:1.8; }
.workspace-shell .workspace-empty>a { display:inline-flex; margin:12px 6px 0; }
.workspace-shell .workspace-empty>a:not(.button-link) { color:var(--brand); font-size:12px; }
.workspace-shell :is(#workspace-settings,.workspace-dialog) {
  inline-size:min(820px,calc(100vw - 40px)); max-inline-size:820px;
  max-block-size:calc(100dvh - 48px); padding:0; overflow:hidden;
}
.workspace-shell :is(#workspace-settings,.workspace-dialog)>:is(header,.workspace-dialog-heading) {
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  block-size:auto; min-block-size:64px; padding:16px 24px;
  border-block-end:1px solid var(--line); background:var(--surface);
}
.workspace-shell :is(#workspace-settings,.workspace-dialog)>:is(header,.workspace-dialog-heading) :is(h1,h2) {
  margin:0; font-size:19px; font-weight:550; letter-spacing:-.4px;
}
.workspace-shell #settings-close {
  padding:7px 11px; min-block-size:36px; border:1px solid transparent;
  border-radius:8px; color:var(--ink-2); background:transparent; font-size:12px;
}
.workspace-shell #settings-close:hover { background:var(--surface-muted); }
/* The Settings window keeps a fixed size; categories stay put and only the open
   section scrolls (see .settings-layout in personal-ui.css). */
.workspace-shell #workspace-settings[open] { display:flex; flex-direction:column; block-size:min(640px,calc(100dvh - 32px)); inline-size:min(880px,calc(100vw - 32px)); max-inline-size:880px; }
.workspace-shell #settings-content { flex:1; min-block-size:0; display:flex; flex-direction:column; }
body.workspace-shell[data-q-ui="aima"] #workspace-settings .ai-settings-page {
  display:flex; flex-direction:column; flex:1; min-block-size:0;
  max-inline-size:none; inline-size:100%; margin:0; padding:0; overflow:hidden;
}
.workspace-shell #workspace-settings .ai-settings-page>:is(#ai-settings-status,.ai-settings-actions) { margin:0; padding:8px 24px; }
.workspace-shell #workspace-settings #ai-settings-private { flex:1; min-block-size:0; border-block-start:1px solid var(--line); }
.workspace-shell #workspace-settings .ai-settings-page>h1 { font-size:23px; margin:0 0 12px; letter-spacing:-.5px; }
.workspace-shell #workspace-settings .ai-settings-page>p { color:var(--ink-2); font-size:12px; line-height:1.7; }
.workspace-shell #workspace-settings .card {
  padding:22px 0; margin:0; border:0; border-block-end:1px solid var(--line);
  border-radius:0; box-shadow:none; background:transparent;
}
.workspace-shell #workspace-settings .card:last-child { border-block-end:0; }
.workspace-shell #workspace-settings h2 { font-size:16px; margin:0 0 10px; font-weight:600; letter-spacing:-.25px; }
.workspace-shell #workspace-settings p { font-size:12px; line-height:1.7; margin:8px 0; }
.workspace-shell #workspace-settings .small { font-size:11px; }
.workspace-shell #workspace-settings :is(label,input,select,button,.button-link) { font-size:12px; }
.workspace-shell #workspace-settings input { padding-block:10px; }
.workspace-shell #workspace-settings .ai-provider-grid { gap:12px; margin-block-start:16px; }
.workspace-shell #workspace-settings .ai-provider-card { padding:14px; border-color:var(--line); border-radius:12px; background:var(--ground); }
.workspace-shell #workspace-settings .ai-provider-card h3 { font-size:14px; }
.workspace-shell .workspace-settings-nav {
  display:flex; flex-wrap:wrap; gap:8px; margin-block:8px 12px;
}
.workspace-shell .workspace-settings-nav a {
  padding:7px 11px; border:1px solid var(--line); border-radius:8px;
  color:var(--ink-2); background:var(--surface); font-size:12px; text-decoration:none;
}
.workspace-shell .workspace-settings-nav a:hover { background:var(--surface-muted); }
.workspace-shell #rename-dialog {
  inline-size:min(440px,calc(100vw - 32px)); padding:25px; overflow:auto;
}
.workspace-shell #rename-dialog h2 { font-size:20px; margin-block:0 20px; }
.workspace-shell #rename-dialog form { margin:0; }
.workspace-shell .workspace-dialog-actions { display:flex; justify-content:flex-end; gap:9px; margin-block-start:24px; }
@media(max-width:800px) {
  .workspace-shell .workspace-layout { grid-template-columns:minmax(0,1fr); }
  .workspace-shell #preview-sidebar.workspace-sidebar {
    position:fixed; z-index:40; inset-block:0; inset-inline-start:0; inset-inline-end:auto;
    inline-size:min(288px,calc(100vw - 56px)); block-size:100dvh; display:none;
    padding-block-start:20px; box-shadow:10px 0 32px #0002;
  }
  .workspace-shell #preview-sidebar.workspace-sidebar[data-open] { display:flex; }
  .workspace-shell #workspace-scrim:not([hidden]) {
    position:fixed; z-index:39; display:block; inset:0; inline-size:100%; block-size:100%;
    margin:0; padding:0; border:0; border-radius:0; background:#25262366; cursor:default;
  }
  .workspace-shell #menu { display:inline-flex; inline-size:36px; min-inline-size:36px; }
  .workspace-shell .workspace-topbar { min-block-size:48px; padding:6px 14px; gap:10px; }
  .workspace-shell .workspace-topbar :is(h1,h2) { font-size:15px; }
  .workspace-shell[data-auth-page="owner"] .workspace-content>#preview-content { padding:20px 20px 44px; }
  .workspace-shell .workspace-content .card>h2 { font-size:24px; }
  .workspace-shell :is(#workspace-settings,.workspace-dialog) {
    inline-size:calc(100vw - 24px); max-block-size:calc(100dvh - 24px);
  }
  body.workspace-shell[data-q-ui="aima"] #workspace-settings .ai-settings-page {
    padding:16px 18px 24px; max-block-size:calc(100dvh - 106px);
  }
  .workspace-shell :is(#workspace-settings,.workspace-dialog)>:is(header,.workspace-dialog-heading) { padding:14px 18px; }
  .workspace-shell #workspace-settings .ai-provider-grid { grid-template-columns:minmax(0,1fr); }
}
@media(max-width:420px) {
  .workspace-shell .workspace-topbar { padding-inline:10px; }
  .workspace-shell .workspace-topbar>div { gap:7px; }
  .workspace-shell .workspace-topbar :is(button,a) { padding-inline:8px; }
  .workspace-shell[data-auth-page="owner"] .workspace-content>#preview-content { padding-inline:16px; }
}
@media(prefers-color-scheme:dark) {
  :where(:root:not([data-appearance="light"])) body.workspace-shell[data-q-ui="aima"] {
    --ink:#eeeeea; --ink-2:#ccccbf; --ink-3:#a7aaa1;
    --ground:#232421; --surface:#2c2d29; --surface-muted:#343630;
    --workspace-sidebar:#1c1d1a; --workspace-hover:#343630;
    --line:#3e4039; --line-strong:#858a7e;
    --brand:#c4b5fd; --brand-hover:#ddd6fe; --brand-active:#a78bfa;
    --brand-strong:#ddd6fe; --brand-soft:#30234b; --on-brand:#17181a; --focus:#c4b5fd;
    color-scheme:dark;
  }
}
/* Explicit browser preference also works when the device uses the opposite theme. */
:where(:root[data-appearance="dark"]) body.workspace-shell[data-q-ui="aima"] {
    --ink:#eeeeea; --ink-2:#ccccbf; --ink-3:#a7aaa1;
    --ground:#232421; --surface:#2c2d29; --surface-muted:#343630;
    --workspace-sidebar:#1c1d1a; --workspace-hover:#343630;
    --line:#3e4039; --line-strong:#858a7e;
    --brand:#c4b5fd; --brand-hover:#ddd6fe; --brand-active:#a78bfa;
    --brand-strong:#ddd6fe; --brand-soft:#30234b; --on-brand:#17181a; --focus:#c4b5fd;
    color-scheme:dark;
  }

@media(forced-colors:active) {
  .workspace-shell #preview-sidebar.workspace-sidebar { border-inline-end:1px solid CanvasText; }
  .workspace-shell :is(a,button)[aria-current="page"] { outline:1px solid Highlight; }
  .workspace-shell :is(button,a,input,textarea,select,summary):focus-visible { outline-color:Highlight; }
}


/* The desktop control shares the existing sidebar without changing phone drawer semantics. */
.workspace-shell #desktop-menu { display:inline-flex; inline-size:36px; min-inline-size:36px; flex-shrink:0; }
.workspace-shell .workspace-topbar #conversation-title { flex:1; }
@media(min-width:801px) {
  .workspace-shell .workspace-layout[data-collapsed] { grid-template-columns:minmax(0,1fr); }
  .workspace-shell .workspace-layout[data-collapsed] #preview-sidebar { display:none; }
}
@media(max-width:800px) { .workspace-shell #desktop-menu { display:none; } }
