:root { --accent-strong: #755427; --danger: #b42318; --warn: #805b24; }
:focus-visible, .app-shell :focus-visible, .auth-body :focus-visible { outline: 3px solid #2457a6; outline-offset: 3px; }
button, input, select, textarea, summary { scroll-margin-block: 100px; }
.skip-link { position: fixed; left: 16px; top: -120px; z-index: 1000; padding: 12px; background: white; color: #1e1a17; border: 2px solid #2457a6; }
.skip-link:focus { top: 12px; }
.app-shell .global-status { position: sticky; top: 0; z-index: 35; padding: 10px 16px; margin: 0; background: #eef6ef; border: 1px solid #497454; border-radius: 10px; white-space: pre-line; }
.app-shell .global-status:empty { padding: 0; border: 0; min-height: 0; }
.app-shell .global-status.status-error { background: #fff0ee; border-color: var(--danger); }
[data-dialog-status] { white-space: pre-line; padding: 10px; }
/* Account balance stays with the account; details never push the workspace down. */
/* Raise the header's backdrop-filter stacking context above project tabs, below dialogs (40+). */
.app-shell > .topbar { position: relative; z-index: 30; }
.topbar .topbar-status-cluster { margin-inline-start: 0; }
.credit-budget-strip { position: relative; flex: 0 0 auto; margin-inline-start: auto; font-size: .85rem; }
.credit-budget-strip[hidden] { display: none; }
.credit-budget-strip details { position: relative; }
.credit-budget-strip summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 9px 12px;
  list-style: none; cursor: pointer; border: 1px solid rgba(164, 128, 71, .24);
  border-radius: 999px; background: #f8f4ec; color: var(--accent-strong);
}
.credit-budget-strip summary::-webkit-details-marker { display: none; }
.credit-budget-strip summary:hover, .credit-budget-strip details[open] summary { background: #f0e7d8; border-color: rgba(164, 128, 71, .42); }
.credit-budget-label { white-space: nowrap; }
.credit-budget-label strong { color: var(--text); font-size: .95rem; font-variant-numeric: tabular-nums; }
.credit-budget-icon { width: 20px; height: 20px; flex-shrink: 0; }
.credit-budget-chevron { width: 14px; height: 14px; flex-shrink: 0; }
.credit-budget-strip details[open] .credit-budget-chevron { transform: rotate(180deg); }
#credit-budget-content {
  position: absolute; z-index: 40; inset-block-start: calc(100% + 10px); inset-inline-end: 0;
  width: min(360px, calc(100vw - 48px)); max-height: min(480px, 65dvh); overflow: auto;
  padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 14px 40px rgba(45, 35, 22, .14); color: var(--muted-strong); line-height: 1.55;
}
#credit-budget-content p { margin: 0 0 12px; }
#credit-budget-content p:last-child { margin-bottom: 0; }
#credit-budget-content button { width: 100%; min-height: 44px; }
#credit-budget-content .credit-budget-receipt { color: var(--success); background: var(--success-soft); padding: 10px 12px; border-radius: 10px; font-weight: 600; }
#credit-receipt:empty { display: none; }
details.project-intake-block > summary { cursor: pointer; font-weight: 700; padding: 10px 4px; }
/* Project counts are supporting information, presented as one quiet row. */
.workspace-header .workspace-header-top { align-items: center; }
.workspace-header .workspace-header-controls { align-items: center; }
.workspace-header .workspace-header-kpis { align-items: center; gap: 0; }
.workspace-header .mini-kpi { display: flex; align-items: baseline; gap: 7px; min-width: 0; padding: 4px 12px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.workspace-header .mini-kpi + .mini-kpi { border-inline-start: 1px solid var(--line); }
.workspace-header .mini-kpi span { font-size: .78rem; color: var(--muted-strong); }
.workspace-header .mini-kpi strong { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
@media (min-width: 981px) and (max-width: 1250px) {
  .topbar .topbar-main { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px 14px; }
  .topbar .topbar-account { grid-column: 1 / -1; }
  .topbar .credit-budget-strip { margin-inline-start: 0; justify-self: start; }
  .workspace-header .workspace-header-top { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .workspace-header .workspace-header-controls { justify-content: flex-start; }
}
@media (min-width: 681px) and (max-width: 980px) {
  .topbar .credit-budget-strip { align-self: flex-start; margin-inline-start: 0; }
  #credit-budget-content { inset-inline-start: 0; inset-inline-end: auto; }
}
.credit-hint, #document-credit-estimate { font-size: .88rem; color: var(--muted-strong); line-height: 1.5; }
.project-lifecycle-filter { display: flex; align-items: center; gap: 8px; }
.project-lifecycle-filter select { min-height: 44px; }
.project-history { display: grid; gap: 16px; margin-top: 24px; }
.project-history details { border: 1px solid var(--line); padding: 16px; border-radius: 12px; background: var(--panel); }
.project-history summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.document-version-row, .operation-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.document-version-row button { margin: 4px; }
.historical-document { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; line-height: 1.6; }
.billing-usage-cards { display: grid; gap: 12px; margin-block: 16px; }
.billing-account-table td::before { display: none; }
.auth-body .primary-button, .auth-body .secondary-button { min-height: 44px; padding: 12px 18px; }
.auth-body [hidden] { display: none !important; }
.auth-body .auth-tab { min-height: 44px; }
@media (max-width: 680px) {
  .app-shell { padding: 12px; }
  .app-shell .topbar { gap: 8px; padding-block: 8px; }
  .topbar .brand-copy p, .topbar .brand-copy .eyebrow { display: none; }
  .topbar .brand-mark, .topbar .brand-logo { max-height: 44px; max-width: 100px; }
  .topbar .topbar-actions { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .topbar-actions button, .project-tab { min-height: 44px; }
  .topbar .topbar-account { width: 100%; }
  .workspace-header { padding: 12px; gap: 8px; }
  .workspace-header-top { display: flex; flex-direction: column; gap: 8px; }
  .workspace-header-controls, .workspace-header-actions { justify-content: flex-start; }
  .workspace-header .mini-kpi { padding: 8px; }
  .workspace-header .mini-kpi strong { font-size: 1rem; }
  .workspace-navigation { display: block; }
  .project-tabs-primary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; gap: 4px; }
  .project-tabs-primary .project-tab { white-space: normal; padding: 8px; text-align: center; }
  .tutorial-checklist-steps { display: grid; gap: 8px; }
  .tutorial-checklist-step { padding: 10px; grid-template-columns: 20px minmax(0, 1fr) auto; }
  .tutorial-checklist-step p { display: none; }
  .tutorial-checklist-summary { display: block; }
  .tutorial-checklist-summary .status-pill { display: none; }
  .conversation-panel { padding: 12px; }
  .conversation-layout { grid-template-columns: minmax(0, 1fr); }
  .conversation-stage { gap: 10px; }
  .conversation-stage .quick-prompts-card { padding: 8px; }
  .quick-prompts-card .section-title-row { display: none; }
  .quick-prompts { display: flex; overflow-x: auto; gap: 6px; }
  .quick-prompts button { flex: 0 0 75%; }
  .conversation-stage .messages { max-height: none; overflow: visible; min-height: 0; }
  .composer { position: static; bottom: auto; background: var(--panel); padding: 10px 0; z-index: 5; }
  .composer textarea { min-height: 88px; }
  .project-directory-row { display: grid; }
  .project-intake-grid, .technical-preference-fields { grid-template-columns: minmax(0, 1fr); }
  .billing-account-table { min-width: 0; width: 100%; }
  .billing-account-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .billing-account-table tbody, .billing-account-table tr, .billing-account-table td { display: block; width: auto; }
  .billing-account-table tr { padding: 10px; margin: 8px 0; border: 1px solid var(--line); }
  .billing-account-table td { border: 0; padding: 4px; overflow-wrap: anywhere; }
  .billing-account-table .mobile-cell-label { display: inline; font-weight: 700; }
  .billing-account-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-shell { display: block; padding: 16px; }
  .auth-hero { padding: 8px; }
  .auth-hero-logo { max-height: 80px; width: auto; }
}
#confirm-message { white-space: pre-line; }
.document-subtab-item { position: relative; min-width: 0; }
.document-subtab-item > .document-subtab { width: 100%; height: 100%; }
.document-subtab-item:has(.document-subtab-generate) > .document-subtab { padding-right: 48px; }
.document-subtab-item > .document-subtab-generate { position: absolute; top: 8px; right: 6px; width: 36px; height: 36px; padding: 8px; }
@media (max-width: 680px) { .document-subtab-item > .document-subtab-generate { width: 44px; height: 44px; } }
@media (max-width: 680px) {
  .app-shell .topbar { width: 100%; margin: 0; padding: 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .topbar .brand-zone { grid-area: 1 / 1; padding: 0; border: 0; min-width: 0; }
  .topbar .topbar-main { display: contents; }
  .topbar .topbar-account { grid-area: 2 / 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 0; }
  .topbar #current-user-email, .topbar #current-organization-badge { display: none; }
  .topbar .credit-budget-strip { grid-area: 2 / 2; align-self: center; margin: 0; }
  .topbar .credit-budget-strip summary { padding: 8px 10px; gap: 6px; }
  .topbar .credit-budget-icon { display: none; }
  .topbar .session-user { min-width: 0; max-width: 100%; }
  .topbar #current-user-name { overflow-wrap: anywhere; }
  .topbar .topbar-status-cluster { grid-area: 1 / 2; width: auto; height: auto; gap: 4px; flex-direction: row; flex-wrap: wrap; justify-content: end; }
  .topbar .language-switcher { min-height: 44px; padding: 0 6px; }
  .topbar .language-switcher select { min-height: 44px; }
  .topbar .topbar-actions { grid-area: 3 / 1 / 4 / 3; justify-content: start; }
  .workspace-header .workspace-header-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; width: 100%; }
  .workspace-header .workspace-header-phase { grid-area: 1 / 1; width: auto; }
  .workspace-header .workspace-header-actions { grid-area: 1 / 2; }
  .workspace-header .hero-kpis { grid-area: 2 / 1 / 3 / 3; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 4px; }
  .workspace-header .mini-kpi span { font-size: .75rem; }
  .workspace-header .project-tab, .workspace-header .icon-button, .workspace-header .header-back-button { min-height: 44px; }
  .workspace-header .project-tab { padding: 8px; }
  .project-history summary, .project-history button { min-height: 44px; }
}
@media (max-width: 680px) {
  .workspace-header .workspace-header-phase { white-space: normal; overflow-wrap: anywhere; font-size: .8rem; line-height: 1.4; }
}

.mobile-cell-label { display: none; }
.confirm-panel.documents-generate-panel { box-sizing: border-box; height: min(780px, calc(100dvh - 32px)); max-height: calc(100dvh - 32px); grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; gap: 12px; padding: 18px; }
.documents-generate-scroll { min-height: 0; overflow: auto; }
.documents-generate-panel .documents-generate-list { max-height: none; overflow: visible; }
#document-credit-estimate { white-space: pre-line; }
.documents-generate-head { min-width: 0; }
.documents-generate-head p { margin-block: 6px; }
.danger-button { color: #b42318 !important; }
.messages, .message, .message-content { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.message pre, .message table, .markdown-view pre, .markdown-view table { display: block; max-width: 100%; overflow-x: auto; }
.tutorial-next-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mobile-document-picker { display: none; }
@media (max-width: 680px) {
  .messages .message { width: 100%; max-width: 100%; box-sizing: border-box; padding: 12px; }
  .message ul, .message ol { padding-inline-start: 20px; }
  .workspace-header .hero-kpis, .workspace-header #current-project-description { display: none; }
  .workspace-header .workspace-header-top { gap: 4px; }
  .workspace-header h2 { font-size: 1.2rem; margin: 4px 0; }
  .project-tabs-primary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .project-tabs-primary .project-tab { font-size: .78rem; padding: 6px 3px; }
  .mobile-document-picker { display: block; margin-block: 12px; }
  .mobile-document-picker select { width: 100%; min-height: 44px; }
  #documents-tabs { display: none; }
  .workspace-jump-controls { position: static; }
  .tutorial-next-action { align-items: start; }
  .confirm-panel.documents-generate-panel { width: calc(100vw - 20px); padding: 12px; }
  .documents-generate-head { align-items: start; }
}
