:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #060a12;
  --page-grid: rgba(113, 145, 193, 0.045);
  --sidebar-bg: #070b14;
  --topbar-bg: rgba(8, 13, 23, 0.9);
  --surface-1: #0c121d;
  --surface-2: #111927;
  --surface-raised: #151f2f;
  --surface-hover: #182437;
  --border-subtle: rgba(153, 177, 211, 0.16);
  --border-strong: rgba(162, 190, 230, 0.3);
  --focus-ring: #7c9cff;
  --text-primary: #f5f7fb;
  --text-secondary: #aab6c8;
  --text-muted: #738197;
  --text-tertiary: #7a879b;
  --text-inverse: #07101c;
  --accent-blue: #5a82ff;
  --accent-cyan: #4ed6cb;
  --accent-violet: #8d76ff;
  --accent-pink: #e95b9f;
  --accent-orange: #f2a65a;
  --status-success: #42cda4;
  --status-warning: #f1c75b;
  --status-danger: #ef7186;
  --status-info: #69a1ff;
  --chart-1: #5f86ff;
  --chart-2: #52d3c6;
  --chart-3: #9c7cff;
  --chart-4: #e75fa6;
  --chart-5: #f4a261;
  --chart-6: #f5cf66;
  --chart-7: #6eb7ff;
  --chart-8: #8fd6a8;
  --chart-axis: #74849a;
  --chart-grid: rgba(147, 169, 201, 0.12);
  --chart-tooltip: #171f2c;
  --shadow-raised: 0 18px 46px rgba(0, 0, 0, 0.28);
  --radius-panel: 12px;

  /* Legacy aliases kept while the remaining workflows migrate. */
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border-subtle);
  --panel: var(--surface-1);
  --page: var(--page-bg);
  --blue: var(--accent-blue);
  --navy: var(--sidebar-bg);
  --pink: var(--accent-pink);
  --teal: var(--accent-cyan);
  --yellow: var(--status-warning);
  --orange: var(--accent-orange);
  --green: var(--status-success);
  --shadow: var(--shadow-raised);
}

html {
  background: var(--page-bg);
}

body {
  min-width: 320px;
  color: var(--text-primary);
  background-color: var(--page-bg);
  background-image:
    linear-gradient(var(--page-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--page-grid) 1px, transparent 1px),
    radial-gradient(circle at 78% 2%, rgba(77, 118, 208, 0.1), transparent 34%);
  background-size: 32px 32px, 32px 32px, auto;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

::selection {
  color: var(--text-primary);
  background: rgba(90, 130, 255, 0.42);
}

.login-screen,
body.password-change-required .password-change-screen {
  background:
    radial-gradient(circle at 20% 10%, rgba(141, 118, 255, 0.18), transparent 34%),
    radial-gradient(circle at 85% 88%, rgba(78, 214, 203, 0.12), transparent 30%),
    var(--page-bg);
}

.login-card,
.password-change-panel,
.modal {
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
  background: rgba(12, 18, 29, 0.96);
  box-shadow: var(--shadow-raised);
}

.login-card,
.password-change-panel {
  border-top: 1px solid rgba(124, 156, 255, 0.65);
}

.login-form input,
input,
select,
textarea,
.audit-toolbar select,
.audit-toolbar input {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
  outline-color: var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

.form-grid select,
.url-import input {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
  outline-color: var(--focus-ring);
}

.form-grid label span,
.url-import span,
.upload-option,
.upload-zone span {
  color: var(--text-secondary);
}

.upload-zone,
.library-help {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.upload-zone strong {
  color: var(--text-primary);
}

.upload-zone.dragging {
  border-color: var(--accent-blue);
  background: rgba(94, 128, 240, 0.12);
  box-shadow: inset 0 0 0 1px rgba(124, 156, 255, 0.22);
}

.app-shell {
  grid-template-columns: 228px minmax(0, 1fr);
}

.sidebar {
  z-index: 30;
  gap: 28px;
  padding: 22px 16px;
  color: var(--text-primary);
  border-right: 1px solid var(--border-subtle);
  background:
    linear-gradient(180deg, rgba(112, 135, 179, 0.06), transparent 28%),
    var(--sidebar-bg);
}

.brand strong,
.sidebar-footer strong {
  color: var(--text-primary);
}

.brand span,
.sidebar-footer span {
  color: var(--text-muted);
}

.brand-mark {
  filter: drop-shadow(0 0 14px rgba(90, 130, 255, 0.2));
}

.nav-list {
  gap: 6px;
}

.nav-item {
  min-height: 46px;
  height: auto;
  color: var(--text-secondary);
  border-radius: 9px;
}

.nav-item:hover {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-hover);
}

.nav-item.active {
  position: relative;
  color: var(--text-primary);
  border-color: rgba(110, 139, 255, 0.45);
  background: linear-gradient(90deg, rgba(87, 126, 255, 0.2), rgba(141, 118, 255, 0.08));
}

.nav-item.active::before {
  position: absolute;
  inset: 8px auto 8px -1px;
  width: 2px;
  content: "";
  border-radius: 999px;
  background: linear-gradient(var(--accent-cyan), var(--accent-blue), var(--accent-pink));
}

.nav-icon {
  color: var(--text-primary);
  background: rgba(126, 151, 193, 0.12);
}

.sidebar-footer {
  border-color: var(--border-subtle);
  background: var(--surface-1);
}

.workspace {
  max-width: 1760px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 26px 40px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  margin: -22px -26px 22px;
  padding: 18px 26px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  color: var(--text-primary);
  font-size: clamp(24px, 2vw, 30px);
  letter-spacing: -0.03em;
}

.eyebrow {
  color: var(--accent-cyan);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card,
.panel,
.insight-card,
.ops-item,
.insight-list article,
.doc-card,
.quick-card,
.template-card,
.role-row,
.review-list article,
.generation-history article,
.todo-list article,
.activity-strip article,
.roadmap article,
.format-check,
.pending-intake-list article {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-1);
  box-shadow: none;
}

.panel,
.metric-card {
  border-radius: var(--radius-panel);
}

.panel {
  padding: 18px;
}

.panel-heading h2,
.panel h2,
.metric-card strong,
.insight-card strong,
.doc-card h3,
.quick-card strong {
  color: var(--text-primary);
}

.panel-subtitle,
.metric-card span,
.metric-card small,
.insight-card span,
.insight-card small,
.ops-item span,
.ops-item small,
.doc-meta,
.doc-card p,
.quick-card span,
.template-card p,
.roadmap p {
  color: var(--text-secondary);
}

.metric-card {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--border-subtle);
}

.metric-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  content: "";
  background: var(--chart-1);
}

.metric-card:nth-child(2)::before { background: var(--chart-2); }
.metric-card:nth-child(3)::before { background: var(--chart-4); }
.metric-card:nth-child(4)::before { background: var(--chart-6); }

.primary-button {
  color: white;
  border: 1px solid rgba(141, 165, 255, 0.35);
  background: linear-gradient(90deg, #566ff0, #7d63ee);
  box-shadow: 0 10px 24px rgba(76, 98, 222, 0.2);
}

.primary-button:hover {
  filter: brightness(1.08);
}

.text-button,
.icon-button,
.compact-button {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: var(--surface-1);
}

.text-button:hover,
.icon-button:hover,
.compact-button:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.pill {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: rgba(112, 137, 179, 0.12);
}

.pill.success,
.text-button.success {
  color: var(--status-success);
  border-color: rgba(66, 205, 164, 0.28);
  background: rgba(66, 205, 164, 0.1);
}

.pill.warning {
  color: var(--status-warning);
  border-color: rgba(241, 199, 91, 0.28);
  background: rgba(241, 199, 91, 0.1);
}

.chart-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-panel);
  background: var(--surface-1);
}

.chart-canvas {
  width: 100%;
  min-height: 260px;
}

.chart-canvas[data-chart-state="missing-data"],
.chart-canvas[data-chart-state="missing-runtime"] {
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  border: 1px dashed var(--border-subtle);
  border-radius: 8px;
  background: rgba(5, 10, 18, 0.28);
}

.chart-summary {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

.aurora-command {
  position: relative;
  overflow: hidden;
  border-color: rgba(104, 139, 255, 0.28);
  background:
    radial-gradient(circle at 88% 12%, rgba(141, 118, 255, 0.13), transparent 34%),
    var(--surface-1);
}

.aurora-command::after {
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue), var(--accent-pink), transparent 82%);
}

.aurora-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.aurora-kpi {
  position: relative;
  min-width: 0;
  min-height: 118px;
  display: grid;
  align-content: space-between;
  gap: 7px;
  padding: 15px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(92, 125, 190, 0.08), transparent 55%), var(--surface-1);
}

.aurora-kpi::after {
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  content: "";
  opacity: 0.72;
  background: linear-gradient(90deg, var(--chart-1), transparent 72%);
}

.aurora-kpi:nth-child(2)::after { background-image: linear-gradient(90deg, var(--chart-2), transparent 72%); }
.aurora-kpi:nth-child(3)::after { background-image: linear-gradient(90deg, var(--chart-4), transparent 72%); }
.aurora-kpi:nth-child(4)::after { background-image: linear-gradient(90deg, var(--chart-5), transparent 72%); }
.aurora-kpi:nth-child(5)::after { background-image: linear-gradient(90deg, var(--chart-3), transparent 72%); }

.aurora-kpi span,
.aurora-kpi small {
  color: var(--text-tertiary);
}

.aurora-kpi span {
  font-size: 12px;
  letter-spacing: 0.04em;
}

.aurora-kpi strong {
  color: var(--text-primary);
  font-size: clamp(27px, 2.3vw, 38px);
  line-height: 1;
}

.aurora-kpi small {
  font-size: 11px;
}

.aurora-kpi-grid .aurora-kpi {
  --kpi-icon: var(--chart-1);
}

.aurora-kpi-grid .aurora-kpi:nth-child(2) { --kpi-icon: var(--chart-2); }
.aurora-kpi-grid .aurora-kpi:nth-child(3) { --kpi-icon: var(--chart-4); }
.aurora-kpi-grid .aurora-kpi:nth-child(4) { --kpi-icon: var(--chart-5); }
.aurora-kpi-grid .aurora-kpi:nth-child(5) { --kpi-icon: var(--chart-3); }
.aurora-kpi-grid .aurora-kpi:nth-child(6) { --kpi-icon: var(--chart-7); }

.aurora-kpi-grid .aurora-kpi-label {
  max-width: calc(100% - 58px);
}

.aurora-kpi-grid .aurora-kpi-icon {
  width: 48px;
  height: 48px;
  position: absolute;
  top: 13px;
  right: 13px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--kpi-icon);
  border: 1px solid color-mix(in srgb, var(--kpi-icon) 30%, transparent);
  border-radius: 14px;
  background:
    radial-gradient(circle at 34% 24%, color-mix(in srgb, var(--kpi-icon) 36%, transparent), transparent 42%),
    linear-gradient(145deg, color-mix(in srgb, var(--kpi-icon) 18%, var(--surface-raised)), rgba(8, 14, 24, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -8px 18px rgba(0, 0, 0, 0.2),
    0 10px 24px color-mix(in srgb, var(--kpi-icon) 14%, transparent);
  transform: rotate(-5deg);
}

.aurora-kpi-grid .aurora-kpi-icon::after {
  width: 32px;
  height: 10px;
  position: absolute;
  top: -4px;
  left: 3px;
  content: "";
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  filter: blur(5px);
}

.aurora-kpi-grid .aurora-kpi-icon svg {
  width: 25px;
  height: 25px;
  position: relative;
  z-index: 1;
  stroke-width: 1.8;
  filter: drop-shadow(0 3px 5px color-mix(in srgb, var(--kpi-icon) 34%, transparent));
  transform: rotate(5deg);
}

.aurora-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.aurora-dashboard-grid > .panel {
  margin: 0;
}

.dashboard-activity-panel {
  grid-column: span 8;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  align-content: stretch;
}

.dashboard-activity-panel .chart-canvas {
  height: 100%;
  min-height: 260px;
}
.dashboard-health-panel { grid-column: span 4; }
.dashboard-review-panel,
.dashboard-quality-panel,
.dashboard-todo-panel { grid-column: span 4; }

.insights-kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.insights-diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.insights-diagnostic-grid > .panel,
.insights-ops-grid > .panel {
  margin: 0;
}

.insights-activity-panel,
.insights-acceptance-panel { grid-column: span 8; }

.insights-quality-panel,
.insights-sources-panel { grid-column: span 4; }

.insights-review-panel,
.insights-feedback-panel { grid-column: span 6; }

.insights-ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.compact-chart {
  min-height: 220px;
}

.dashboard-health-grid {
  margin-top: 4px;
}

.dashboard-health-grid article {
  background: var(--surface-2);
}

.dashboard-health-grid span,
.ops-grid span,
.panel-subtitle,
.chart-summary {
  color: var(--text-tertiary);
}

.aurora-dashboard-bottom {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  margin-top: 14px;
}

.library-command-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.library-command-grid > .panel {
  margin: 0;
}

.library-coverage-panel { grid-column: span 4; }
.library-ingestion-panel { grid-column: span 5; }
.library-upload-panel { grid-column: span 3; grid-row: span 2; }
.library-format-panel { grid-column: span 9; }

.library-upload-panel {
  align-self: stretch;
}

.library-command-grid.is-read-only .library-coverage-panel,
.library-command-grid.is-read-only .library-ingestion-panel {
  grid-column: span 6;
}

.library-command-grid.is-read-only .library-format-panel {
  grid-column: span 12;
}

.library-acceptance-details {
  margin-bottom: 14px;
}

.library-acceptance-details > summary {
  min-height: 30px;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 700;
}

.library-acceptance-details[open] > summary {
  margin-bottom: 14px;
  color: var(--text-primary);
}

.library-heading {
  gap: 16px;
}

.library-heading .search-box {
  width: min(420px, 100%);
}

.library-toolbar {
  gap: 10px;
}

.library-organizer {
  position: relative;
  overflow: hidden;
  border-color: var(--border-subtle);
  background:
    linear-gradient(100deg, rgba(77, 104, 255, 0.07), rgba(46, 215, 195, 0.025) 48%, transparent),
    var(--surface-2);
}

.library-organizer::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: linear-gradient(180deg, #5d78ff, #42d9c3);
}

.library-organizer select {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-1);
}

.library-organizer select:focus,
.library-sort-controls button:focus-visible {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(104, 139, 255, 0.12);
  outline: 0;
}

.library-sort-controls > span {
  color: var(--text-muted);
}

.library-filter-group,
.library-view-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.library-view-toggle {
  margin-left: auto;
}

.library-view-toggle .active {
  color: var(--text-primary);
  border-color: rgba(104, 139, 255, 0.42);
  background: rgba(90, 130, 255, 0.16);
}

.document-table-view {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 10px;
}

.document-table-view .doc-card {
  min-width: 0;
  min-height: 136px;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-1);
}

.document-table-view .doc-thumb {
  width: 58px;
  height: 76px;
}

.document-table-view .doc-card > div:nth-child(2) {
  min-width: 0;
}

.document-table-view .doc-card h3 {
  max-width: 100%;
  margin-bottom: 4px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-table-view .doc-meta,
.document-table-view .doc-fingerprint {
  font-size: 10px;
  line-height: 1.45;
}

.document-table-view .doc-card > div:nth-child(2) > .doc-meta:last-of-type {
  display: -webkit-box;
  max-height: 2.9em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.document-table-view .doc-tags {
  max-height: 22px;
  margin: 4px 0;
  overflow: hidden;
}

.document-table-view .doc-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.document-table-view .doc-actions .pill {
  margin-right: auto;
}

.document-table-view .doc-actions button {
  min-height: 26px;
  padding-inline: 7px;
  font-size: 10px;
}

.document-card-view {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.document-card-view .doc-card {
  min-width: 0;
  grid-template-columns: 58px minmax(0, 1fr);
}

.document-card-view .doc-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 960px) {
  .document-table-view,
  .document-card-view {
    grid-template-columns: 1fr;
  }
}

.skeleton {
  overflow: hidden;
  color: transparent;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-hover), var(--surface-2));
  background-size: 240% 100%;
  animation: aurora-skeleton 1.4s ease-in-out infinite;
}

@keyframes aurora-skeleton {
  to { background-position: -240% 0; }
}

.modal-backdrop {
  background: rgba(1, 4, 10, 0.78);
  backdrop-filter: blur(8px);
}

pre,
.command-snippet,
#healthOutput,
#generatedOutput {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: #070c14;
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 204px minmax(0, 1fr); }
  .workspace { padding-inline: 20px; }
  .topbar { margin-inline: -20px; padding-inline: 20px; }
  .aurora-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-activity-panel { grid-column: span 12; }
  .dashboard-health-panel,
  .dashboard-review-panel,
  .dashboard-quality-panel,
  .dashboard-todo-panel { grid-column: span 6; }
  .insights-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .insights-activity-panel,
  .insights-quality-panel,
  .insights-acceptance-panel,
  .insights-sources-panel,
  .insights-review-panel,
  .insights-feedback-panel { grid-column: span 6; }
  .library-coverage-panel,
  .library-ingestion-panel,
  .library-upload-panel,
  .library-format-panel { grid-column: span 6; grid-row: auto; }
}

@media (max-width: 780px) {
  body { padding-bottom: 74px; }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 80;
    inset: auto 0 0;
    width: 100%;
    height: 68px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-strong);
    border-right: 0;
    background: rgba(7, 11, 20, 0.96);
    backdrop-filter: blur(18px);
  }

  .sidebar > .brand,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    height: 100%;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
  }

  .nav-item {
    min-width: 0;
    min-height: 48px;
    height: 48px;
    justify-content: center;
    padding: 0;
  }

  .nav-item.active::before {
    inset: auto 14px -1px;
    width: auto;
    height: 2px;
  }

  .nav-icon {
    width: 30px;
    height: 30px;
  }

  .workspace,
  body.compact .workspace {
    width: 100%;
    padding: 14px 12px 22px;
    overflow-x: clip;
  }

  .topbar {
    margin: -14px -12px 14px;
    padding: 12px;
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  .topbar h1 {
    max-width: 100%;
    font-size: 22px;
    overflow-wrap: anywhere;
  }

  .top-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 7px;
  }

  #currentUserBadge,
  #logoutBtn,
  .top-actions [data-view-shortcut="ask"] {
    display: none;
  }

  #backendStatus {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel,
  body.compact .panel {
    padding: 14px;
  }

  .metrics-grid,
  .insight-metrics,
  .intake-summary,
  .ops-grid,
  .ops-summary,
  .ops-check-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .aurora-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .aurora-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-activity-panel,
  .dashboard-health-panel,
  .dashboard-review-panel,
  .dashboard-quality-panel,
  .dashboard-todo-panel {
    grid-column: auto;
  }

  .dashboard-activity-panel {
    display: block;
  }

  .dashboard-activity-panel .chart-canvas {
    height: 240px;
    min-height: 240px;
  }

  .aurora-dashboard-bottom {
    grid-template-columns: 1fr;
  }

  .insights-diagnostic-grid,
  .insights-ops-grid {
    grid-template-columns: 1fr;
  }

  .insights-activity-panel,
  .insights-quality-panel,
  .insights-acceptance-panel,
  .insights-sources-panel,
  .insights-review-panel,
  .insights-feedback-panel {
    grid-column: auto;
  }

  .library-command-grid {
    grid-template-columns: 1fr;
  }

  .library-coverage-panel,
  .library-ingestion-panel,
  .library-upload-panel,
  .library-format-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .library-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .library-filter-group,
  .library-view-toggle {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }

  .library-filter-group button,
  .library-view-toggle button {
    flex: 1;
    min-height: 44px;
  }

  .document-table-view,
  .document-card-view {
    grid-template-columns: 1fr;
  }

  .document-table-view .doc-card,
  .document-card-view .doc-card {
    min-height: 0;
    grid-template-columns: 62px minmax(0, 1fr);
    padding: 12px;
  }

  .document-table-view .doc-actions,
  .document-card-view .doc-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
  }

  .metric-card,
  .insight-card {
    min-width: 0;
  }

  .chart-canvas {
    min-height: 240px;
  }

  .modal {
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }
}

/* Board workspace: a focused, read-only knowledge surface. */
.board-read-only-label,
.board-library-intro {
  display: none;
}

body.board-library-mode:not(.guest-mode) .app-shell,
body.board-library-mode:not(.guest-mode).image-studio-active .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.board-library-mode:not(.guest-mode) .sidebar {
  display: none;
}

body.board-library-mode:not(.guest-mode) .workspace {
  min-height: 100vh;
  padding-inline: clamp(18px, 2.4vw, 48px);
}

body.board-library-mode:not(.guest-mode) .topbar {
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 560px) auto;
  gap: clamp(14px, 1.5vw, 28px);
  margin-inline: calc(clamp(18px, 2.4vw, 48px) * -1);
  padding-inline: clamp(18px, 2.4vw, 48px);
}

body.board-library-mode:not(.guest-mode) .topbar > .global-search {
  width: 100%;
  max-width: 560px;
  display: grid;
  justify-self: stretch;
}

body.board-library-mode:not(.guest-mode) .topbar-context {
  display: none;
}

body.board-library-mode:not(.guest-mode) .board-read-only-label {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  color: color-mix(in srgb, var(--accent-cyan) 82%, var(--text-primary));
  border: 1px solid color-mix(in srgb, var(--accent-cyan) 34%, var(--border-subtle));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-cyan) 10%, var(--surface-1));
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

body.board-library-mode:not(.guest-mode) .board-read-only-label svg {
  width: 13px;
  height: 13px;
}

body.board-library-mode:not(.guest-mode) #library.view.active {
  width: min(100%, 1680px);
  margin-inline: auto;
  gap: 16px;
}

body.board-library-mode:not(.guest-mode) .board-library-intro {
  min-height: 112px;
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  overflow: hidden;
  padding: 18px 20px;
  border: 1px solid color-mix(in srgb, var(--accent-blue) 28%, var(--border-subtle));
  border-radius: 18px;
  background:
    linear-gradient(105deg, color-mix(in srgb, var(--accent-blue) 10%, var(--surface-1)), var(--surface-1) 56%),
    var(--surface-1);
  box-shadow: 0 14px 38px rgba(22, 38, 77, 0.1);
}

body.board-library-mode:not(.guest-mode) .board-library-intro::before {
  width: 42%;
  height: 3px;
  position: absolute;
  top: 0;
  left: 0;
  content: "";
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan), transparent);
}

.board-library-intro-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--accent-blue) 72%, var(--text-primary));
  border: 1px solid color-mix(in srgb, var(--accent-blue) 30%, var(--border-subtle));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent-blue) 11%, var(--surface-raised));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07);
}

.board-library-intro-icon svg {
  width: 25px;
  height: 25px;
}

.board-library-intro > div:nth-child(2) {
  min-width: 0;
}

.board-library-intro > div:nth-child(2) > span {
  color: var(--accent-cyan);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.board-library-intro h2 {
  margin: 3px 0 5px;
  color: var(--text-primary);
  font-size: clamp(20px, 1.45vw, 26px);
  line-height: 1.18;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.board-library-intro p {
  max-width: 760px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.65;
  text-wrap: pretty;
}

.board-library-scope {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-raised) 82%, transparent);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.board-library-scope svg {
  width: 15px;
  height: 15px;
  color: var(--accent-cyan);
}

body.board-library-mode:not(.guest-mode) #library .library-kpis,
body.board-library-mode:not(.guest-mode) #library .library-acceptance-details,
body.board-library-mode:not(.guest-mode) [data-board-hidden],
body.board-library-mode:not(.guest-mode) #askLauncher {
  display: none !important;
}

body.board-library-mode:not(.guest-mode) #library .library-results-panel {
  padding: clamp(16px, 1.35vw, 22px);
  border-radius: 18px;
  box-shadow: 0 16px 44px rgba(22, 38, 77, 0.08);
}

body.board-library-mode:not(.guest-mode) #library .library-heading h2::after {
  content: " · 只读";
  color: var(--text-muted);
  font-size: 0.72em;
  font-weight: 650;
}

body.board-library-mode:not(.guest-mode) #library .doc-card {
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

body.board-library-mode:not(.guest-mode) #library .doc-card:hover {
  border-color: color-mix(in srgb, var(--accent-blue) 30%, var(--border-subtle));
  box-shadow: 0 12px 30px rgba(22, 38, 77, 0.08);
  transform: translateY(-1px);
}

@media (max-width: 980px) {
  body.board-library-mode:not(.guest-mode) .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  body.board-library-mode:not(.guest-mode) .topbar > .global-search {
    display: none;
  }

  body.board-library-mode:not(.guest-mode) .board-library-intro {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .board-library-intro-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .board-library-scope {
    display: none;
  }
}

@media (max-width: 620px) {
  body.board-library-mode:not(.guest-mode) .workspace {
    padding-inline: 12px;
  }

  body.board-library-mode:not(.guest-mode) .topbar {
    margin-inline: -12px;
    padding-inline: 12px;
  }

  body.board-library-mode:not(.guest-mode) .board-read-only-label {
    display: none;
  }

  body.board-library-mode:not(.guest-mode) .board-library-intro {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px;
    border-radius: 15px;
  }

  .board-library-intro-icon {
    width: 42px;
    height: 42px;
  }

  .board-library-intro p {
    font-size: 11px;
  }
}

/* Aurora v2: full-site visual harmonization. Legacy workflows now share the
   same dark surfaces, controls and contrast rules as the dashboard. */

[data-lucide],
.lucide {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  stroke: currentColor;
}

.nav-icon .lucide {
  width: 16px;
  height: 16px;
}

.primary-button,
.text-button,
.status-button,
.image-start-primary,
.image-start-outline {
  gap: 8px;
}

.primary-button .lucide,
.text-button .lucide,
.status-button .lucide,
.image-start-primary .lucide,
.image-start-outline .lucide {
  width: 15px;
  height: 15px;
}

.topbar > div:first-child {
  min-width: 210px;
}

.top-actions {
  flex: 1;
  flex-wrap: nowrap;
}

.global-search {
  width: min(340px, 28vw);
  height: 38px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  padding: 0 11px;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: rgba(14, 22, 34, 0.86);
}

.global-search:focus-within {
  color: var(--text-secondary);
  border-color: rgba(106, 140, 255, 0.52);
  box-shadow: 0 0 0 3px rgba(90, 130, 255, 0.1);
}

.global-search input {
  min-width: 0;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.global-search kbd {
  padding: 2px 6px;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--surface-2);
  font: inherit;
  font-size: 10px;
}

.status-button,
#logoutBtn,
.top-actions [data-view-shortcut="ask"] {
  display: inline-flex;
  align-items: center;
}

/* Ask: remove the light canvas and give the conversation a compact cockpit. */

body.ask-active {
  overflow: hidden;
}

body.ask-active .app-shell,
body.ask-active .workspace {
  height: 100dvh;
  min-height: 0;
}

body.ask-active .workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding-bottom: 18px;
}

body.ask-active #ask.active {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#ask .ask-layout {
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: stretch;
  overflow: hidden;
}

#ask .ask-panel,
#ask .source-panel {
  border-color: var(--border-subtle);
  background: linear-gradient(145deg, rgba(90, 130, 255, 0.035), transparent 40%), var(--surface-1);
}

#ask .ask-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: min-content minmax(0, 1fr) min-content;
  overflow: hidden;
}

.chat-window {
  height: auto;
  min-height: 420px;
  max-height: 62vh;
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background:
    radial-gradient(circle at 20% 0%, rgba(92, 126, 255, 0.08), transparent 34%),
    rgba(4, 9, 16, 0.62);
}

#ask .chat-window {
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 14px;
}

#ask .ask-form {
  position: relative;
  z-index: 2;
  align-items: center;
  margin-top: 0;
  padding-top: 12px;
  background: linear-gradient(180deg, transparent 0, var(--surface-1) 30%);
}

#ask .ask-form > .primary-button {
  height: 44px;
  min-height: 44px;
  align-self: center;
  white-space: nowrap;
}

#ask .source-panel {
  order: 0;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.message,
.message.assistant {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.message.user {
  border-color: rgba(116, 145, 255, 0.48);
  background: linear-gradient(135deg, #4d6ce8, #745ae6);
}

.assistant-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.assistant-identity > span:last-child {
  display: grid;
  line-height: 1.2;
}

.assistant-identity strong {
  font-size: 13px;
  letter-spacing: 0.02em;
}

.assistant-identity small {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 10px;
}

.xiaoyi-avatar {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  flex: 0 0 30px;
  border: 1px solid rgba(119, 155, 255, 0.48);
  border-radius: 50%;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  background: linear-gradient(145deg, #4f79ee, #7657df);
  box-shadow: 0 5px 18px rgba(75, 99, 218, 0.24);
}

.xiaoyi-heading-label {
  margin-left: 7px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.guided-questions {
  border-color: var(--border-subtle);
}

.guided-questions-label {
  color: var(--text-secondary);
}

.guided-question-button {
  color: var(--text-primary);
  border-color: rgba(110, 139, 255, 0.3);
  background: rgba(86, 111, 222, 0.1);
}

.guided-question-button span {
  color: var(--accent-cyan);
}

.guided-question-button:hover {
  border-color: rgba(110, 139, 255, 0.58);
  background: rgba(86, 111, 222, 0.18);
}

.source-citation,
.search-match,
.search-empty,
.scope-list button {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.scope-list button:hover,
.source-citation:hover {
  color: var(--text-primary);
  border-color: rgba(110, 139, 255, 0.55);
  background: var(--surface-hover);
}

.source-note {
  color: var(--text-secondary);
  border-color: rgba(78, 214, 203, 0.2);
  background: rgba(42, 151, 142, 0.08);
}

.ask-form input,
.ask-form textarea {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

/* Brand library: dark albums, filters, review cards and dialogs. */

#brand-assets .brand-asset-command {
  border-left: 0;
  border-color: rgba(104, 139, 255, 0.28);
  background:
    radial-gradient(circle at 88% 12%, rgba(141, 118, 255, 0.13), transparent 34%),
    var(--surface-1);
}

#brand-assets .brand-asset-command::after {
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue), var(--accent-pink), transparent 82%);
}

.brand-asset-command,
.brand-asset-album-panel,
.brand-asset-filters,
.brand-asset-ai-toolbar,
.brand-asset-review-toolbar,
.brand-asset-management-toolbar,
.brand-asset-gallery,
.brand-asset-detail {
  position: relative;
  border-color: var(--border-subtle);
  background: var(--surface-1);
}

.brand-asset-status-tabs .text-button {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: var(--surface-1);
}

.brand-asset-status-tabs .text-button.active {
  color: var(--text-primary);
  border-color: rgba(110, 139, 255, 0.48);
  background: linear-gradient(90deg, rgba(90, 130, 255, 0.22), rgba(141, 118, 255, 0.12));
}

.brand-asset-album-search input,
.brand-asset-filters input,
.brand-asset-filters select,
.brand-asset-dialog input,
.brand-asset-dialog select,
.brand-asset-dialog textarea,
.review-task-toolbar select,
.audit-toolbar input,
.audit-toolbar select {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.brand-asset-album,
.brand-asset-management-menu summary,
.brand-asset-management-menu button,
.brand-asset-card {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.brand-asset-album:hover,
.brand-asset-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.brand-asset-album.active {
  color: var(--text-primary);
  border-color: rgba(101, 134, 255, 0.7);
  background: linear-gradient(145deg, rgba(90, 130, 255, 0.16), rgba(141, 118, 255, 0.07)), var(--surface-2);
  box-shadow: 0 0 0 1px rgba(90, 130, 255, 0.18);
}

.brand-asset-album-cover,
.brand-asset-preview-missing,
.brand-asset-card img,
.brand-asset-detail-preview {
  color: var(--text-muted);
  background: #080e18;
}

.brand-asset-album-cover .lucide {
  width: 25px;
  height: 25px;
}

.brand-asset-ai-review {
  border-color: rgba(141, 118, 255, 0.24);
  background: rgba(105, 87, 224, 0.09);
}

.brand-asset-ai-review > strong {
  color: var(--accent-violet);
}

.asset-status {
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  background: rgba(8, 15, 25, 0.9);
  backdrop-filter: blur(10px);
}

.asset-ai-state {
  color: var(--accent-violet);
  border: 1px solid rgba(141, 118, 255, 0.2);
  background: rgba(24, 20, 53, 0.9);
}

.brand-asset-dialog {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface-1);
}

/* Legacy operation cards: stop white islands from appearing on long pages. */

.acceptance-summary,
.acceptance-quality-grid article,
.acceptance-history-item,
.acceptance-item,
.role-row,
.user-list article,
.review-list article,
.generation-history article,
.generation-image-card,
.format-check,
.pending-intake-list article,
.audit-list article,
.ops-summary,
.ops-check,
.ops-next article,
.roadmap article,
.source-context-section,
.queue-list div {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.empty-state,
.brand-asset-grid > .empty-state,
.brand-asset-detail > .empty-state {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: rgba(7, 13, 22, 0.56);
}

.brand-asset-grid > .empty-state,
.brand-asset-detail > .empty-state {
  min-height: 108px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed var(--border-subtle);
  border-radius: 8px;
}

.user-form input,
.user-form select,
.brand-asset-workflow-form input,
.brand-asset-workflow-form select,
.brand-asset-workflow-form textarea {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.user-password-field small,
.user-form-status {
  color: var(--text-muted);
}

.user-form [aria-invalid="true"] {
  border-color: color-mix(in srgb, var(--status-danger) 72%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-danger) 14%, transparent);
}

.user-form-status.is-error {
  color: var(--status-danger);
}

.user-form-status.is-success {
  color: var(--status-success);
}

.acceptance-history-item:hover,
.acceptance-history-item.selected,
.role-row.active,
.review-record.published,
.review-record.archived {
  color: var(--text-primary);
  border-color: rgba(104, 139, 255, 0.44);
  background: var(--surface-hover);
}

.review-actions button {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: var(--surface-1);
}

.review-actions button:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.review-answer {
  border-color: rgba(102, 128, 174, 0.28);
  background:
    linear-gradient(135deg, rgba(81, 104, 255, 0.08), rgba(45, 220, 194, 0.025)),
    rgba(5, 11, 20, 0.48);
}

.review-answer summary {
  color: var(--text-primary);
  border-bottom: 1px solid transparent;
}

.review-answer[open] summary {
  border-bottom-color: rgba(102, 128, 174, 0.22);
}

.review-answer summary:hover {
  background: rgba(104, 139, 255, 0.08);
}

.review-answer-heading {
  color: #77e8d6;
}

.review-answer-toggle {
  color: var(--text-muted);
}

.review-answer-copy {
  color: var(--text-secondary);
  scrollbar-color: rgba(119, 232, 214, 0.5) transparent;
}

.review-answer-empty {
  color: var(--status-warning);
}

.modal,
.source-modal {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface-1);
}

.document-detail-modal {
  width: min(1180px, 100%);
  height: min(780px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 0%, rgba(107, 93, 255, 0.1), transparent 30%),
    var(--surface-1);
}

.document-detail-heading {
  align-items: flex-start;
}

.document-detail-heading h2 {
  max-width: 860px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-detail-tags {
  display: flex;
  min-height: 26px;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.document-detail-tags span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11px;
}

.document-detail-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 12px;
}

.document-original-panel,
.document-parsed-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: rgba(5, 11, 20, 0.54);
}

.document-original-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

.document-parsed-panel {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.document-detail-section-heading,
.document-original-actions,
.document-content-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.document-detail-section-heading h3,
.document-detail-section-heading p {
  margin: 0;
}

.document-detail-section-heading h3 {
  color: var(--text-primary);
  font-size: 14px;
}

.document-detail-section-heading p,
.document-content-pagination span {
  color: var(--text-tertiary);
  font-size: 11px;
}

.document-original-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.document-original-actions .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.document-original-preview,
.document-parsed-content {
  min-height: 0;
  overflow: auto;
  border: 1px solid rgba(113, 135, 176, 0.18);
  border-radius: 8px;
  background: #050a12;
}

.document-original-preview iframe,
.document-original-preview img {
  width: 100%;
  height: 100%;
  min-height: 460px;
  display: block;
  border: 0;
  object-fit: contain;
}

.document-preview-placeholder {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 28px;
  color: var(--text-tertiary);
  text-align: center;
}

.document-preview-placeholder svg {
  width: 42px;
  height: 42px;
  color: #7185ff;
  filter: drop-shadow(0 0 14px rgba(113, 133, 255, 0.34));
}

.document-preview-placeholder strong {
  color: var(--text-primary);
}

.document-preview-placeholder p {
  max-width: 340px;
  margin: 0;
  line-height: 1.6;
}

.document-content-chunk {
  padding: 14px;
}

.document-content-chunk + .document-content-chunk {
  border-top: 1px solid var(--border-subtle);
}

.document-content-chunk > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.document-content-chunk strong {
  color: #7ce7d4;
  font-size: 12px;
}

.document-content-chunk span {
  color: var(--text-tertiary);
  font-size: 11px;
}

.document-content-chunk p {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.72;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.document-content-pagination {
  justify-content: center;
}

.document-content-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

@media (max-width: 960px) {
  .document-detail-modal {
    height: calc(100vh - 32px);
    max-height: calc(100vh - 32px);
    overflow: auto;
  }

  .document-detail-layout {
    grid-template-columns: 1fr;
  }

  .document-original-panel,
  .document-parsed-panel {
    min-height: 420px;
  }

  .document-original-preview iframe,
  .document-original-preview img {
    min-height: 340px;
  }
}

/* Image studio home and editor: preserve its specialist layout, but bring it
   into the same Aurora shell instead of switching the entire app to white. */

body.image-studio-active,
body.image-studio-active.image-studio-home,
body.image-studio-active .workspace {
  color: var(--text-primary);
  background-color: var(--page-bg);
  background-image:
    linear-gradient(var(--page-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--page-grid) 1px, transparent 1px),
    radial-gradient(circle at 74% 0%, rgba(77, 118, 208, 0.12), transparent 36%);
  background-size: 32px 32px, 32px 32px, auto;
}

body.image-studio-active .app-shell {
  grid-template-columns: 228px minmax(0, 1fr);
}

.image-start-screen {
  color: var(--text-primary);
  background: transparent;
}

.image-start-header > div:first-child > span,
.image-start-header p,
.image-start-steps li,
.image-start-steps small,
.image-start-quick-panel header small,
.image-start-quick-fields label,
.image-start-copy > small,
.image-start-copy > b,
.image-start-card-footer > span,
.image-start-side-card small,
.image-start-side-card time,
.image-start-side-card p,
.image-start-rules article small,
.image-start-rules > p {
  color: var(--text-secondary);
}

.image-start-outline,
.image-start-side-card button {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: var(--surface-1);
}

.image-start-outline:hover,
.image-start-side-card button:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.image-start-primary {
  color: #fff;
  border-color: rgba(141, 165, 255, 0.38);
  background: linear-gradient(90deg, #566ff0, #7d63ee);
  box-shadow: 0 10px 24px rgba(76, 98, 222, 0.2);
}

.image-start-quick-panel,
.image-start-card {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-1);
  box-shadow: none;
}

.image-start-quick-panel {
  background:
    radial-gradient(circle at 86% 0%, rgba(141, 118, 255, 0.11), transparent 32%),
    var(--surface-1);
}

.image-start-quick-panel header em {
  color: var(--accent-violet);
  background: rgba(141, 118, 255, 0.12);
}

.image-start-selection-status > span {
  color: var(--text-secondary);
  background: rgba(133, 151, 188, 0.1);
}

.image-start-quick-fields input,
.image-start-quick-fields select {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.image-start-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-raised);
}

.image-start-card.selected {
  border-color: rgba(105, 139, 255, 0.82);
  box-shadow: 0 0 0 1px rgba(105, 139, 255, 0.26), 0 18px 42px rgba(0, 0, 0, 0.18);
}

.image-start-card.selected .image-start-visual::after {
  content: "当前模板";
}

.image-start-copy {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.image-start-copy > span > em {
  color: var(--template-accent);
}

.image-start-card-footer {
  border-color: var(--border-subtle);
  background: rgba(8, 14, 25, 0.72);
}

.image-start-card-footer > button {
  color: var(--text-primary);
  border-color: rgba(var(--template-accent-rgb), 0.32);
  background: rgba(var(--template-accent-rgb), 0.11);
}

.image-start-card.selected .image-start-card-footer > button {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(100deg, var(--template-accent), #7d63ee);
  box-shadow: 0 8px 18px rgba(var(--template-accent-rgb), 0.18);
}

.image-studio-toolbar {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: rgba(8, 13, 23, 0.94);
  backdrop-filter: blur(18px);
}

.image-studio-title span,
.image-studio-tools label > span,
.image-settings-panel label > span,
.image-advanced-settings summary,
.image-reference-settings summary,
.image-provider-note,
.image-reference-upload {
  color: var(--text-secondary);
}

.image-studio-tools select,
.image-toolbar-icon,
.image-toolbar-button,
.image-artboard-tools,
.image-artboard-tools button,
.image-settings-title button,
.image-settings-panel select {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.image-studio-shell,
.image-artboard-area {
  background-color: #080e18;
  background-image:
    radial-gradient(circle, rgba(117, 145, 190, 0.16) 1px, transparent 1.1px),
    radial-gradient(circle at 50% 45%, rgba(81, 96, 229, 0.08), transparent 34%);
}

.image-artboard-heading > strong,
.image-artboard-tools,
.image-canvas-hint,
.image-settings-panel,
.image-template-dialog,
.image-history-dialog,
.image-template-dialog > header,
.image-history-dialog > header {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: rgba(12, 18, 29, 0.94);
  box-shadow: var(--shadow-raised);
}

.image-settings-title {
  background: linear-gradient(180deg, rgba(12, 18, 29, 0.99) 76%, rgba(12, 18, 29, 0));
}

.image-reference-upload,
.image-history-item {
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.image-history-copy .image-history-resume {
  color: var(--accent-violet);
}

.image-history-loading {
  grid-column: 1 / -1;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-primary);
  text-align: left;
}

.image-history-loading > div {
  display: grid;
  gap: 4px;
}

.image-history-loading small {
  color: var(--text-muted);
}

.image-history-loading-spinner {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border: 3px solid color-mix(in srgb, var(--accent-violet) 22%, transparent);
  border-top-color: var(--accent-violet);
  border-radius: 50%;
  animation: image-history-spin 0.8s linear infinite;
}

@keyframes image-history-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .image-history-loading-spinner {
    animation-duration: 1.8s;
  }
}

/* Acceptance workbench v2 — compact batches on the left, actionable evidence on the right. */
.acceptance-history-item {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 7px;
  padding: 9px 10px;
  text-align: left;
  border-radius: 8px;
}

.acceptance-history-topline,
.acceptance-history-score,
.acceptance-history-metrics,
.acceptance-issue-heading,
.acceptance-all-results > summary {
  min-width: 0;
  display: flex;
  align-items: center;
}

.acceptance-history-topline {
  justify-content: space-between;
  gap: 8px;
}

.acceptance-history-date {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acceptance-history-topline .pill {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 2px 8px;
  font-size: 10px;
}

.acceptance-history-score {
  flex-wrap: wrap;
  gap: 4px 9px;
}

.acceptance-history-score > strong {
  color: var(--text-primary);
  font-size: 21px;
  line-height: 1;
  letter-spacing: -0.035em;
}

.acceptance-history-score > strong small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.acceptance-history-score > span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 650;
}

.acceptance-history-score .acceptance-history-delta.positive {
  color: var(--status-success);
}

.acceptance-history-score .acceptance-history-delta.negative {
  color: var(--status-danger);
}

.acceptance-history-metrics {
  grid-column: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.acceptance-history-metrics span {
  padding: 3px 7px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
  border: 1px solid color-mix(in srgb, var(--border-subtle) 78%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-raised) 72%, transparent);
}

.acceptance-history-item.selected {
  box-shadow: inset 3px 0 0 var(--accent-blue);
}

.acceptance-history-item.regression {
  box-shadow: inset 3px 0 0 var(--status-warning);
}

.acceptance-history-item.selected.regression {
  box-shadow: inset 3px 0 0 var(--status-danger);
}

.acceptance-gaps {
  display: grid;
  gap: 8px;
}

.acceptance-issue-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 1px 0 8px;
  background: color-mix(in srgb, var(--surface-1) 94%, transparent);
  backdrop-filter: blur(10px);
}

.acceptance-filter-chip {
  min-height: 28px;
  padding: 4px 9px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.acceptance-filter-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.acceptance-filter-chip.active {
  color: var(--text-primary);
  border-color: color-mix(in srgb, var(--accent-blue) 58%, var(--border-subtle));
  background: linear-gradient(110deg, color-mix(in srgb, var(--accent-blue) 18%, var(--surface-2)), color-mix(in srgb, var(--accent-violet) 15%, var(--surface-2)));
}

.acceptance-filter-chip strong {
  margin-left: 3px;
  color: inherit;
}

.acceptance-issue-groups {
  display: grid;
  gap: 8px;
}

.acceptance-issue-group {
  min-width: 0;
  overflow: clip;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface-2) 58%, transparent);
}

.acceptance-issue-group[hidden] {
  display: none;
}

.acceptance-issue-heading {
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-raised) 68%, transparent);
}

.acceptance-issue-heading > div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.acceptance-issue-heading strong {
  color: var(--text-primary);
  font-size: 12px;
}

.acceptance-issue-heading small,
.acceptance-issue-heading > span {
  color: var(--text-muted);
  font-size: 10px;
}

.acceptance-issue-heading > span {
  flex: 0 0 auto;
}

details.acceptance-issue-item {
  display: block;
  border-top: 1px solid color-mix(in srgb, var(--border-subtle) 72%, transparent);
}

details.acceptance-issue-item:first-of-type {
  border-top: 0;
}

.acceptance-issue-item > summary {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(170px, 0.85fr) 14px;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
  list-style: none;
  cursor: pointer;
}

.acceptance-issue-item > summary::-webkit-details-marker {
  display: none;
}

.acceptance-issue-item > summary::after {
  content: "›";
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  transition: transform 150ms ease;
}

.acceptance-issue-item[open] > summary::after {
  transform: rotate(90deg);
}

.acceptance-issue-item[open] > summary {
  background: color-mix(in srgb, var(--accent-blue) 7%, transparent);
}

.acceptance-issue-question {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.acceptance-issue-question strong {
  min-width: 0;
  color: var(--text-primary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acceptance-issue-question small,
.acceptance-issue-reason {
  color: var(--text-muted);
  font-size: 10px;
}

.acceptance-issue-reason {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acceptance-evidence-section {
  display: grid;
  gap: 4px;
}

.acceptance-evidence-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.acceptance-evidence-empty,
.acceptance-item-source {
  margin: 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.acceptance-no-gaps {
  min-height: 80px;
  display: grid;
  place-content: center;
  gap: 4px;
  padding: 16px;
  text-align: center;
  border: 1px dashed var(--border-subtle);
  border-radius: 9px;
  background: color-mix(in srgb, var(--status-success) 5%, transparent);
}

.acceptance-no-gaps strong {
  color: var(--status-success);
}

.acceptance-no-gaps span {
  color: var(--text-muted);
  font-size: 11px;
}

.acceptance-all-results {
  display: block;
  margin-top: 2px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface-2) 54%, transparent);
  overflow: clip;
}

.acceptance-all-results > summary {
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 8px 10px;
  list-style: none;
  cursor: pointer;
}

.acceptance-all-results > summary::-webkit-details-marker {
  display: none;
}

.acceptance-all-results > summary > span:first-child {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.acceptance-all-results > summary strong {
  color: var(--text-primary);
  font-size: 12px;
}

.acceptance-all-results > summary small,
.acceptance-all-results > summary > span:last-child {
  color: var(--text-muted);
  font-size: 10px;
}

.acceptance-list-inner {
  display: grid;
  gap: 5px;
  padding: 8px;
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 900px) {
  .acceptance-issue-toolbar {
    position: static;
    background: transparent;
    backdrop-filter: none;
  }

  .acceptance-issue-item > summary {
    grid-template-columns: minmax(0, 1fr) 14px;
  }

  .acceptance-issue-reason {
    grid-column: 1;
    grid-row: 2;
    white-space: normal;
  }

  .acceptance-issue-item > summary::after {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .acceptance-item-body {
    padding-left: 12px;
  }
}

/* Keep the native tone select accessible without allowing the generic select
   rule to expand the visually-hidden control and create a horizontal bar. */
.image-settings-panel select.sr-only {
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.image-settings-panel {
  overflow-x: hidden;
}

.image-prompt-dock {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: rgba(12, 18, 29, 0.96);
  box-shadow: var(--shadow-raised);
  backdrop-filter: blur(18px);
}

.image-prompt-dock textarea {
  color: var(--text-primary);
  background: transparent;
}

.image-prompt-dock textarea::placeholder {
  color: var(--text-muted);
}

.image-progress {
  background:
    radial-gradient(circle at 42% 42%, rgba(103, 91, 232, 0.2), transparent 29%),
    radial-gradient(circle at 62% 58%, rgba(54, 211, 189, 0.09), transparent 31%),
    rgba(4, 9, 17, 0.74);
}

.image-progress-card {
  border-color: var(--border-strong);
  background:
    radial-gradient(circle at 100% 0%, rgba(130, 94, 231, 0.12), transparent 34%),
    linear-gradient(135deg, rgba(18, 28, 46, 0.97), rgba(8, 15, 27, 0.98));
  box-shadow: var(--shadow-raised), inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.image-progress-copy strong {
  color: var(--text-primary);
}

.image-progress-copy small,
.image-progress-card > p {
  color: var(--text-secondary);
}

.image-tone-picker,
.image-advanced-settings,
.image-reference-settings {
  border-color: var(--border-subtle);
}

.image-advanced-settings summary span,
.image-reference-settings summary span,
.image-settings-title small,
.image-setting-help {
  color: var(--text-muted);
}

.image-brand-note {
  color: var(--accent-violet);
  background: rgba(141, 118, 255, 0.1);
}

.image-brand-note small {
  color: var(--text-secondary);
}

@media (max-width: 1280px) {
  .global-search {
    display: none;
  }

  #ask .ask-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

@media (max-width: 940px) {
  body.ask-active {
    overflow: auto;
  }

  body.ask-active .app-shell,
  body.ask-active .workspace {
    height: auto;
    min-height: 100dvh;
  }

  body.ask-active .workspace {
    display: block;
    overflow: visible;
    padding-bottom: 24px;
  }

  body.ask-active #ask.active,
  #ask .ask-layout {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  #ask .ask-layout {
    grid-template-columns: 1fr;
  }

  #ask .ask-panel {
    height: clamp(500px, calc(100dvh - 132px), 720px);
  }

  #ask .source-panel {
    order: 0;
    height: auto;
    overflow: visible;
  }

  #ask .chat-window {
    min-height: 0;
    max-height: none;
  }

  body.image-studio-active .app-shell {
    grid-template-columns: 204px minmax(0, 1fr);
  }
}

@media (max-width: 780px) {
  body.image-studio-active .app-shell {
    display: block;
  }

  .nav-list,
  body.image-studio-active .nav-list {
    grid-template-columns: repeat(9, minmax(34px, 1fr));
  }

  body.image-studio-active {
    min-height: 100vh;
    padding-bottom: 74px;
    overflow: auto;
  }

  body.image-studio-active .sidebar {
    position: fixed;
    z-index: 80;
    inset: auto 0 0;
    width: 100%;
    height: 68px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-strong);
    border-right: 0;
    background: rgba(7, 11, 20, 0.97);
    backdrop-filter: blur(18px);
  }

  body.image-studio-active .sidebar > .brand,
  body.image-studio-active .sidebar-footer {
    display: none;
  }

  body.image-studio-active .nav-item {
    min-width: 0;
    min-height: 48px;
    height: 48px;
    justify-content: center;
    padding: 0;
  }

  body.image-studio-active .nav-item span:last-child {
    display: none;
  }

  body.image-studio-active .nav-item.active::before {
    inset: auto 9px -1px;
    width: auto;
    height: 2px;
  }

  body.image-studio-active .workspace {
    width: 100%;
    min-height: 100vh;
    padding: 0 0 22px;
    overflow-x: clip;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  #ask .ask-panel {
    grid-template-rows: auto minmax(280px, 43vh) auto;
  }

  #ask .chat-window {
    min-height: 280px;
    max-height: 43vh;
  }

  .status-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .image-start-screen {
    padding-inline: 12px;
  }

  .image-start-grid,
  .image-start-rail {
    grid-template-columns: 1fr;
  }

  .image-start-rules {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .top-actions { grid-template-columns: auto minmax(0, 1fr); }
  .top-actions > :last-child { display: none; }
}

/* Aurora v3: responsive workspace cohesion.
   The dashboard is a full-width operating surface; every workflow now shares
   the same gutters, density and dark component treatment. */

:root {
  --shell-sidebar: 216px;
  --content-gutter: clamp(14px, 1.15vw, 24px);
  --section-gap: clamp(10px, 0.8vw, 14px);
  --panel-padding: clamp(13px, 0.95vw, 16px);
}

.app-shell,
body.image-studio-active .app-shell {
  grid-template-columns: var(--shell-sidebar) minmax(0, 1fr);
}

.workspace,
body.compact .workspace,
body.image-studio-active .workspace {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--content-gutter) var(--content-gutter) 32px;
}

.view.active {
  width: 100%;
  gap: var(--section-gap);
}

.panel,
body.compact .panel {
  padding: var(--panel-padding);
}

.topbar {
  min-height: 76px;
  margin: calc(var(--content-gutter) * -1) calc(var(--content-gutter) * -1) var(--section-gap);
  padding: 13px var(--content-gutter) 12px;
}

.topbar h1 {
  font-size: clamp(23px, 1.7vw, 28px);
}

.top-actions {
  min-width: 0;
  gap: 9px;
}

.top-actions > *,
.status-button,
#logoutBtn,
.top-actions [data-view-shortcut="ask"] {
  flex: 0 0 auto;
  white-space: nowrap;
}

.global-search {
  width: clamp(230px, 24vw, 340px);
}

.panel-heading {
  margin-bottom: 12px;
}

.aurora-kpi-grid,
.aurora-dashboard-grid,
.insights-diagnostic-grid,
.insights-ops-grid,
.library-command-grid,
.split-layout,
.two-column,
.ask-layout,
.generator-layout,
.dashboard-layout,
.dashboard-main,
.dashboard-side,
.dashboard-bottom {
  gap: var(--section-gap);
}

.aurora-kpi-grid {
  margin: var(--section-gap) 0;
}

.aurora-kpi {
  min-height: 102px;
  padding: 13px;
}

.chart-canvas {
  min-height: 220px;
}

.compact-chart {
  min-height: 190px;
}

#dashboard .dashboard-command {
  min-height: 94px;
}

.aurora-dashboard-bottom,
.insights-ops-grid {
  margin-top: var(--section-gap);
}

/* Retire the remaining light-theme islands from legacy workflows. */

.template-card.active,
.intake-summary article,
.runbook-item,
.search-box,
.doc-thumb,
.message-meta,
.queue-list .error,
.generation-controls select,
.doc-tags span,
.match-score,
.match-terms span,
.format-check b {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.template-card.active {
  border-color: rgba(105, 139, 255, 0.62);
  background: linear-gradient(145deg, rgba(90, 130, 255, 0.18), rgba(141, 118, 255, 0.07)), var(--surface-2);
  box-shadow: inset 2px 0 0 var(--accent-blue);
}

.search-box {
  box-shadow: none;
}

.search-box input {
  color: var(--text-primary);
  background: transparent;
}

.doc-thumb {
  background-color: #080e18;
}

.doc-tags span,
.match-terms span {
  color: var(--text-secondary);
  background: rgba(90, 130, 255, 0.11);
}

.match-score,
.format-check.pass b,
.message-meta {
  color: var(--status-success);
  background: rgba(66, 205, 164, 0.1);
}

.format-check.warn b {
  color: var(--status-warning);
  background: rgba(241, 199, 91, 0.11);
}

.format-check.fail b,
.queue-list .error {
  color: var(--status-danger);
  background: rgba(239, 113, 134, 0.1);
}

.generation-controls select {
  background-color: var(--surface-2);
}

.generator-layout {
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
}

#generatedOutput {
  min-height: clamp(220px, 32vh, 340px);
  max-height: 44vh;
}

.generation-visual-prompt {
  position: relative;
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(90, 130, 255, 0.28);
  border-radius: var(--radius-panel);
  background:
    linear-gradient(135deg, rgba(90, 130, 255, 0.1), rgba(141, 118, 255, 0.07) 54%, rgba(78, 214, 203, 0.04)),
    var(--surface-2);
}

.generation-visual-prompt::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue), var(--accent-violet), var(--accent-pink));
}

.generation-visual-prompt[hidden] {
  display: none;
}

.generation-visual-prompt-heading {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.generation-visual-prompt-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--accent-cyan);
  border: 1px solid rgba(78, 214, 203, 0.24);
  border-radius: 10px;
  background: rgba(78, 214, 203, 0.09);
}

.generation-visual-prompt-icon .lucide {
  width: 18px;
  height: 18px;
}

.generation-visual-prompt-heading h3,
.generation-visual-prompt-heading p {
  margin: 0;
}

.generation-visual-prompt-heading h3 {
  font-size: 15px;
}

.generation-visual-prompt-heading p {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.generation-visual-prompt-field {
  display: grid;
  gap: 6px;
}

.generation-visual-prompt-field > span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.generation-visual-prompt-field textarea {
  min-height: 118px;
  max-height: 220px;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  background: rgba(5, 10, 18, 0.7);
  line-height: 1.65;
}

.generation-visual-prompt-field textarea:focus {
  color: var(--text-primary);
  border-color: rgba(90, 130, 255, 0.58);
}

.generation-visual-prompt-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.generation-visual-prompt-actions small {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-right: auto;
  color: var(--text-muted);
  line-height: 1.45;
}

.generation-visual-prompt-actions small .lucide,
.generation-visual-prompt-actions .primary-button .lucide {
  width: 15px;
  height: 15px;
}

.generation-visual-prompt-actions .primary-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
}

@media (max-width: 720px) {
  .generation-visual-prompt-heading {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .generation-visual-prompt-heading .pill {
    grid-column: 2;
    justify-self: start;
  }

  .generation-visual-prompt-actions {
    flex-wrap: wrap;
  }

  .generation-visual-prompt-actions small {
    flex-basis: 100%;
  }
}

/* Image studio: align to the shared shell instead of a fixed 1280px island. */

body.image-studio-active.image-studio-home .workspace,
body.image-studio-active.image-studio-home .image-studio-view.active {
  width: 100%;
  max-width: none;
}

.image-start-screen {
  min-height: 100dvh;
  padding: 18px var(--content-gutter) 28px;
}

.image-start-header,
.image-start-layout {
  width: 100%;
  max-width: none;
}

.image-start-header {
  margin-bottom: 12px;
}

.image-start-layout {
  display: block;
}

.image-start-quick-panel {
  margin-bottom: var(--section-gap);
}

.image-start-quick-panel {
  padding: 13px;
}

.image-start-grid {
  gap: var(--section-gap);
}

.image-start-visual {
  height: clamp(154px, 9.2vw, 176px);
}

.image-start-copy {
  padding: 11px 12px 12px;
}

/* Brand library: denser albums/toolbars and more gallery columns on wide screens. */

#brand-assets.view.active {
  gap: 10px;
}

.brand-asset-command,
.brand-asset-status-tabs,
.brand-asset-album-panel,
.brand-asset-filters,
.brand-asset-ai-toolbar,
.brand-asset-review-toolbar,
.brand-asset-management-toolbar {
  margin: 0;
}

.brand-asset-album-panel {
  padding: 14px;
}

.brand-asset-album-heading {
  margin-bottom: 10px;
}

.brand-asset-albums {
  grid-auto-columns: 132px;
  gap: 9px;
  padding-bottom: 4px;
}

.brand-asset-management-album,
.brand-asset-album {
  width: 132px;
}

.brand-asset-album {
  grid-template-rows: 72px auto auto;
  gap: 5px;
  padding-bottom: 8px;
}

.brand-asset-album-cover {
  height: 72px;
}

.brand-asset-ai-toolbar,
.brand-asset-review-toolbar,
.brand-asset-management-toolbar {
  min-height: 48px;
  padding: 8px 12px;
}

.brand-asset-filters {
  grid-template-columns: minmax(240px, 1fr) repeat(5, minmax(104px, auto));
  gap: 8px;
  padding: 12px;
}

.brand-asset-filters input,
.brand-asset-filters select,
.brand-asset-album-search input {
  min-height: 36px;
}

.brand-asset-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 12px;
}

.brand-asset-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.brand-asset-card {
  gap: 5px;
  padding-bottom: 10px;
}

.brand-asset-card-shell {
  display: flex;
  flex-direction: column;
}

.brand-asset-card-shell .brand-asset-card {
  height: auto;
  flex: 1 1 auto;
}

.brand-asset-detail {
  top: 88px;
}

.brand-asset-detail-preview {
  min-height: 150px;
  max-height: 280px;
}

.brand-asset-pagination,
.brand-asset-actions {
  margin-top: 12px;
}

.brand-asset-detail-actions {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
}

.brand-asset-detail-actions > div:first-child {
  display: grid;
  gap: 3px;
}

.brand-asset-detail-actions small,
.brand-asset-album-safety-note {
  color: var(--text-muted);
}

.brand-asset-detail-actions .brand-asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
}

.danger-button-soft {
  color: #ff918d;
  border-color: rgba(255, 106, 101, 0.42);
  background: rgba(255, 91, 86, 0.08);
}

.danger-button-soft:hover {
  border-color: rgba(255, 106, 101, 0.7);
  background: rgba(255, 91, 86, 0.15);
}

.brand-asset-album-safety-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 0;
  font-size: 12px;
}

.brand-asset-album-safety-note .lucide {
  width: 15px;
  height: 15px;
  color: var(--success);
}

.brand-asset-management-menu summary {
  min-width: 54px;
  padding-inline: 9px;
  font-size: 12px;
}

.brand-asset-safe-delete-callout {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(61, 207, 168, 0.28);
  border-radius: 10px;
  color: var(--text-secondary);
  background: rgba(39, 185, 145, 0.08);
}

.brand-asset-safe-delete-callout strong {
  color: var(--success);
}

.brand-asset-permanent-confirm {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid rgba(255, 106, 101, 0.35);
  border-radius: 10px;
  color: var(--text-secondary);
  background: rgba(255, 91, 86, 0.07);
}

.brand-asset-permanent-confirm[hidden] {
  display: none;
}

.brand-asset-permanent-confirm input {
  margin-top: 2px;
}

/* Operations pages keep more signal above the fold. */

.ops-check-grid {
  gap: 10px;
}

.ops-check {
  min-height: 118px;
  padding: 12px;
}

.runbook-item {
  grid-template-rows: auto auto minmax(130px, 1fr);
  gap: 9px;
  padding: 12px;
}

.command-snippet {
  min-height: 130px;
}

.roadmap article {
  min-height: 124px;
  padding: 14px;
}

@media (min-width: 1700px) {
  .brand-asset-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .image-start-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .image-start-visual {
    height: clamp(148px, 8.2vw, 170px);
  }

  .image-start-copy > small {
    min-height: 27px;
  }

  .ops-check-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 1500px) {
  :root {
    --shell-sidebar: 204px;
    --content-gutter: 18px;
  }

  .global-search {
    display: none;
  }

  .top-actions {
    gap: 7px;
  }
}

@media (max-width: 1280px) {
  .brand-asset-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .brand-asset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 1180px) {
  #currentUserBadge {
    display: none;
  }

  .generator-layout {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  }

  .image-start-layout {
    grid-template-columns: 1fr;
  }

  .image-start-grid,
  .image-start-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) and (min-width: 781px) {
  :root {
    --shell-sidebar: 76px;
    --content-gutter: 16px;
  }

  .sidebar {
    gap: 18px;
    padding: 16px 10px;
  }

  .sidebar > .brand,
  .sidebar-footer {
    justify-content: center;
    padding-inline: 8px;
  }

  .sidebar > .brand > div,
  .sidebar-footer > div,
  .nav-item > span:last-child {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding-inline: 0;
  }

  .nav-icon {
    width: 32px;
    height: 32px;
  }

  .generator-layout,
  #ask .ask-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .image-start-grid,
  .image-start-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  :root {
    --content-gutter: 12px;
  }

  .app-shell,
  body.image-studio-active .app-shell {
    display: block;
  }

  .nav-list,
  body.image-studio-active .nav-list {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-item,
  body.image-studio-active .nav-item {
    flex: 0 0 56px;
  }

  .workspace,
  body.compact .workspace,
  body.image-studio-active .workspace {
    padding: 12px 12px 22px;
  }

  .topbar {
    margin: -12px -12px 12px;
  }

  .brand-asset-layout,
  .generator-layout,
  #ask .ask-layout {
    grid-template-columns: 1fr;
  }

  .brand-asset-filters,
  .brand-asset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand-asset-detail {
    position: static;
  }

  .image-start-layout,
  .image-start-grid,
  .image-start-rail {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 820px) and (min-width: 781px) {
  :root {
    --content-gutter: 14px;
    --section-gap: 10px;
    --panel-padding: 12px;
  }

  .sidebar {
    gap: 14px;
    padding-block: 14px;
  }

  .nav-list {
    gap: 3px;
  }

  .nav-item {
    min-height: 40px;
  }

  .topbar {
    min-height: 66px;
    padding-block: 9px;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: 11px;
  }

  .aurora-kpi {
    min-height: 88px;
    padding: 11px;
  }

  .aurora-kpi strong {
    font-size: 28px;
  }

  .chart-canvas {
    min-height: 180px;
  }

  .dashboard-activity-panel {
    grid-template-rows: auto minmax(180px, 1fr) auto;
  }

  .dashboard-activity-panel .chart-canvas {
    min-height: 180px;
  }

  .compact-chart {
    min-height: 160px;
  }

  .image-start-screen {
    padding-top: 14px;
  }

  .image-start-header {
    margin-bottom: 9px;
  }

  .image-start-header h1 {
    font-size: 23px;
  }

  .image-start-steps {
    padding: 11px 16px;
  }

  .image-start-quick-panel,
  .image-start-side-card {
    padding: 11px;
  }

  .image-start-quick-panel {
    gap: 9px;
  }

  .image-start-visual {
    height: 132px;
  }

  .image-start-copy {
    gap: 4px;
    padding: 9px 10px 10px;
  }

  .image-start-copy > small {
    min-height: 0;
  }

  .image-start-recent-list article {
    padding-block: 6px;
  }

  .brand-asset-album-panel {
    padding: 12px;
  }

  .brand-asset-ai-toolbar,
  .brand-asset-review-toolbar,
  .brand-asset-management-toolbar {
    min-height: 42px;
    padding-block: 6px;
  }

  .ops-check {
    min-height: 104px;
  }

  #generatedOutput {
    min-height: 220px;
    max-height: 38vh;
  }
}

/* Backend workspace: keep quality, review and account operations inside one
   viewport instead of stacking three long operational surfaces. */

.review-workspace-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: rgba(7, 13, 22, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.review-workspace-tab {
  min-width: 0;
  min-height: 50px;
  display: grid;
  grid-template-columns: 30px auto minmax(0, 1fr);
  grid-template-rows: repeat(2, auto);
  align-content: center;
  align-items: center;
  column-gap: 9px;
  padding: 7px 12px;
  color: var(--text-secondary);
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.review-workspace-tab .lucide {
  width: 18px;
  height: 18px;
  grid-row: 1 / 3;
  place-self: center;
  color: var(--text-muted);
}

.review-workspace-tab span {
  align-self: end;
  color: inherit;
  font-size: 13px;
  font-weight: 800;
}

.review-workspace-tab small {
  grid-column: 2 / 4;
  align-self: start;
  color: var(--text-tertiary);
  font-size: 10px;
}

.review-workspace-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--surface-hover);
}

.review-workspace-tab.active {
  color: var(--text-primary);
  border-color: rgba(105, 139, 255, 0.52);
  background: linear-gradient(135deg, rgba(70, 119, 255, 0.18), rgba(154, 92, 255, 0.08)), var(--surface-2);
  box-shadow: inset 2px 0 0 var(--accent-blue), 0 8px 24px rgba(33, 58, 118, 0.12);
}

.review-workspace-tab.active .lucide {
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 8px rgba(75, 216, 214, 0.36));
}

.review-workspace-tab:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.review-workspace-panel[hidden] {
  display: none !important;
}

.review-admin-layout {
  display: contents;
}

.acceptance-overview {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.62fr) minmax(0, 1.38fr);
  gap: 10px;
}

.acceptance-overview .acceptance-summary,
.acceptance-overview .acceptance-quality-grid article {
  min-height: 72px;
}

.acceptance-overview .acceptance-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  align-content: center;
  padding: 10px 12px;
}

.acceptance-overview .acceptance-summary strong {
  white-space: nowrap;
}

.acceptance-overview .acceptance-summary span {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.acceptance-overview .acceptance-quality-grid article {
  padding: 9px 10px;
}

.acceptance-overview .acceptance-quality-grid strong {
  font-size: 20px;
  line-height: 1;
}

.acceptance-workspace-grid {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 0.72fr) minmax(0, 1.28fr);
  gap: 10px;
}

.acceptance-history-block,
.acceptance-detail-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: rgba(7, 13, 22, 0.48);
}

.acceptance-history,
.acceptance-detail-scroll {
  min-width: 0;
  min-height: 0;
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.acceptance-history {
  gap: 4px;
  align-content: start;
  grid-auto-rows: max-content;
  padding-right: 3px;
}

.acceptance-detail-scroll {
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 4px;
}

.acceptance-history-item {
  position: relative;
  min-height: 48px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 5px 9px;
  padding: 8px 9px;
}

.acceptance-history-metrics {
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.acceptance-history-item > .pill {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

details.acceptance-item {
  display: block;
  padding: 0;
  border-left-width: 3px;
  overflow: clip;
}

.acceptance-detail-scroll .acceptance-list {
  gap: 5px;
}

.acceptance-item summary {
  min-width: 0;
  min-height: 40px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  list-style: none;
  cursor: pointer;
}

.acceptance-item summary::-webkit-details-marker {
  display: none;
}

.acceptance-item summary::before {
  content: "›";
  width: 16px;
  color: var(--text-tertiary);
  font-size: 19px;
  line-height: 1;
  transition: transform 160ms ease;
}

.acceptance-item[open] summary::before {
  transform: rotate(90deg);
}

.acceptance-item-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  grid-column: 2;
}

.acceptance-item-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acceptance-item-heading small {
  flex: 0 0 auto;
  color: var(--text-tertiary);
  font-size: 11px;
}

.acceptance-item-summary-badges,
.acceptance-item-checks {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}

.acceptance-item-summary-badges {
  grid-column: 3;
  grid-row: 1;
}

.acceptance-item-summary-badges .pill,
.acceptance-item-checks .pill {
  font-size: 10px;
}

.acceptance-item-body {
  display: grid;
  gap: 7px;
  padding: 10px 12px 12px 27px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(4, 9, 16, 0.28);
}

.acceptance-item-body p {
  margin: 0;
  line-height: 1.6;
}

.acceptance-item-checks {
  justify-content: flex-start;
}

@media (min-width: 901px) {
  #review.view.active {
    height: calc(100dvh - 126px);
    min-height: 560px;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  #review > .review-workspace-panel,
  #review > .review-admin-layout > .review-workspace-panel {
    min-height: 0;
    height: 100%;
    overflow: auto;
    overscroll-behavior: contain;
  }

  #review > .acceptance-panel {
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 10px;
    overflow: hidden;
  }

  #review > .acceptance-panel > .panel-heading {
    margin-bottom: 0;
  }
}

@media (max-height: 820px) and (min-width: 901px) {
  #review.view.active {
    height: calc(100dvh - 108px);
  }

  .review-workspace-tab {
    min-height: 44px;
    padding-block: 5px;
  }

  .acceptance-overview .acceptance-summary,
  .acceptance-overview .acceptance-quality-grid article {
    min-height: 62px;
  }

  .acceptance-history-block,
  .acceptance-detail-pane {
    padding: 9px;
  }
}

@media (max-width: 1180px) and (min-width: 901px) {
  .acceptance-overview {
    grid-template-columns: minmax(250px, 0.5fr) minmax(0, 1.5fr);
  }

  .acceptance-workspace-grid {
    grid-template-columns: minmax(310px, 0.64fr) minmax(0, 1.36fr);
  }
}

@media (max-width: 900px) {
  #review.view.active {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .review-workspace-tabs {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .acceptance-overview,
  .acceptance-workspace-grid {
    grid-template-columns: 1fr;
  }

  .acceptance-overview .acceptance-summary {
    grid-template-columns: 1fr;
  }

  .acceptance-overview .acceptance-summary span {
    text-align: left;
  }

  .acceptance-history {
    max-height: 360px;
  }

  .acceptance-detail-scroll {
    max-height: none;
    overflow: visible;
  }

  .acceptance-item summary {
    grid-template-columns: 16px minmax(0, 1fr);
  }

  .acceptance-item-summary-badges {
    grid-column: 2;
    grid-row: auto;
    justify-content: flex-start;
    padding-left: 24px;
  }

  .review-workspace-panel {
    height: auto;
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* AI image studio — canvas-first creation with a conversation rail. */
body.image-studio-active .workspace {
  height: 100dvh;
  padding: 0;
  overflow: hidden;
}

.image-studio-view.active,
.image-editor-screen {
  height: 100%;
  min-height: 0;
}

.image-editor-screen {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
}

.image-studio-toolbar {
  height: 64px;
  min-height: 64px;
  padding: 0 16px;
  border-bottom: 1px solid #26354a;
  background: rgba(7, 14, 25, 0.96);
}

.image-studio-tools {
  gap: 8px;
}

.image-studio-tools select,
.image-toolbar-button {
  height: 36px;
  border-color: #26354a;
  background: #0d1726;
}

.image-canvas-add-button {
  cursor: pointer;
}

.image-studio-shell {
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  overflow: hidden;
  background: #07101d;
}

.image-artboard-area {
  min-height: 0;
  position: relative;
  inset: auto;
  border-right: 1px solid #26354a;
  background-color: #07101d;
  background-image:
    radial-gradient(circle, rgba(118, 151, 202, 0.18) 1px, transparent 1.2px),
    radial-gradient(circle at 50% 42%, rgba(102, 116, 244, 0.08), transparent 34%);
  background-size: 24px 24px, 100% 100%;
}

.image-artboard-area.is-drop-target {
  box-shadow: inset 0 0 0 2px #42d5bc, inset 0 0 80px rgba(66, 213, 188, 0.08);
}

.image-artboard-heading {
  right: 18px;
}

.image-artboard-heading > strong,
.image-artboard-tools {
  border-color: rgba(55, 72, 99, 0.9);
  background: rgba(13, 23, 38, 0.9);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.image-artboard-heading > strong:hover,
.image-artboard-heading > strong:focus-visible {
  border-color: rgba(111, 121, 255, 0.76);
  background: rgba(17, 29, 48, 0.96);
  box-shadow: 0 0 0 3px rgba(92, 103, 239, 0.14), 0 14px 32px rgba(0, 0, 0, 0.28);
}

.image-project-title-input {
  caret-color: #7c84ff;
}

.image-canvas-hint {
  right: 18px;
  bottom: 18px;
  color: #7f8da5;
  border-color: rgba(55, 72, 99, 0.86);
  background: rgba(13, 23, 38, 0.86);
}

.image-artboard-stage {
  min-height: 0;
  inset: 0;
  padding: 0;
  place-items: center;
}

.image-artwork-cluster {
  width: 1px;
  height: 1px;
  position: relative;
  display: block;
  transform: scale(var(--canvas-zoom, 0.75));
  transform-origin: center;
}

.image-canvas-empty {
  width: 300px;
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 24px;
  color: #8795ac;
  border: 1px dashed #31425d;
  border-radius: 16px;
  background: rgba(13, 23, 38, 0.7);
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.image-canvas-empty[hidden] {
  display: none;
}

.image-canvas-empty > span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #aeb8ff;
  border: 1px solid rgba(102, 116, 244, 0.42);
  border-radius: 50%;
  background: rgba(102, 116, 244, 0.12);
  font-size: 23px;
}

.image-canvas-empty strong {
  color: #e6ebf5;
  font-size: 15px;
}

.image-canvas-empty small {
  font-size: 11px;
}

.image-canvas-nodes {
  position: absolute;
  left: 0;
  top: 0;
}

.image-canvas-node {
  width: 480px;
  position: absolute;
  left: var(--node-x, 0px);
  top: var(--node-y, 0px);
  overflow: hidden;
  border: 1px solid #2a3a51;
  border-radius: 14px;
  background: #0d1726;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.34);
  transform: translate(-50%, -50%);
  cursor: move;
  user-select: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.image-canvas-node.selected {
  border-color: #7482ff;
  box-shadow: 0 0 0 3px rgba(102, 116, 244, 0.2), 0 22px 58px rgba(0, 0, 0, 0.42);
}

.image-canvas-node.is-reference {
  border-color: #45d7b7;
  box-shadow: 0 0 0 3px rgba(69, 215, 183, 0.18), 0 22px 58px rgba(0, 0, 0, 0.42);
}

.image-canvas-node.is-dragging {
  transition: none;
}

.image-canvas-node > img {
  width: 100%;
  max-height: 680px;
  display: block;
  object-fit: contain;
  background: #080f1a;
  user-select: none;
  -webkit-user-drag: none;
}

.image-canvas-node-bar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 11px;
  color: #9aa8bd;
  font-size: 10px;
}

.image-canvas-node-actions {
  display: flex;
  gap: 5px;
}

.image-canvas-node-actions button {
  min-height: 25px;
  padding: 0 8px;
  color: #aeb8c9;
  border: 1px solid #30415a;
  border-radius: 7px;
  background: #111d2e;
  font-size: 9px;
  cursor: pointer;
}

.image-canvas-node-actions button:hover {
  color: #ffffff;
  border-color: #6674f4;
}

.image-canvas-node.is-reference .image-node-reference-button {
  color: #75efd3;
  border-color: rgba(69, 215, 183, 0.5);
  background: rgba(23, 119, 100, 0.18);
}

.image-progress {
  inset: 0;
  padding: 24px;
}

.image-chat-panel {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #0d1726;
}

.image-chat-header {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid #26354a;
}

.image-chat-header > div {
  display: grid;
  gap: 2px;
}

.image-chat-header span {
  color: #42d5bc;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.image-chat-header h2 {
  margin: 0;
  color: #f3f6fb;
  font-size: 16px;
}

.image-chat-header .image-provider-note {
  max-width: 160px;
  color: #7f8da5;
  letter-spacing: 0;
  text-align: right;
}

.image-chat-messages {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  overflow: auto;
  overscroll-behavior: contain;
}

.image-chat-message {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
}

.image-chat-message.user {
  padding: 11px;
  border: 1px solid rgba(102, 116, 244, 0.25);
  border-radius: 12px;
  background: rgba(102, 116, 244, 0.09);
}

.image-chat-avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #c9d0ff;
  border: 1px solid rgba(102, 116, 244, 0.3);
  border-radius: 9px;
  background: rgba(102, 116, 244, 0.12);
  font-size: 11px;
}

.image-chat-message > div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.image-chat-message strong {
  color: #e8edf6;
  font-size: 12px;
}

.image-chat-message p {
  margin: 0;
  color: #8c9ab0;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.image-chat-message.success .image-chat-avatar {
  color: #42d5bc;
  border-color: rgba(66, 213, 188, 0.35);
  background: rgba(66, 213, 188, 0.1);
}

.image-chat-message.warning .image-chat-avatar {
  color: #ffab74;
  border-color: rgba(255, 129, 87, 0.35);
  background: rgba(255, 129, 87, 0.1);
}

.image-chat-message-preview {
  width: 76px;
  height: 76px;
  margin-top: 4px;
  border: 1px solid #2a3a51;
  border-radius: 9px;
  object-fit: cover;
}

.image-chat-composer {
  position: relative;
  display: grid;
  gap: 9px;
  margin: 0 12px 12px;
  padding: 10px;
  border: 1px solid #2c3b52;
  border-radius: 15px;
  background: #101c2d;
  box-shadow: 0 -14px 38px rgba(5, 10, 18, 0.24);
  transition: border-color 180ms ease, box-shadow 180ms ease, inset 180ms ease;
}

.image-chat-composer:focus-within {
  border-color: rgba(102, 116, 244, 0.72);
  box-shadow: 0 0 0 3px rgba(102, 116, 244, 0.11), 0 -14px 38px rgba(5, 10, 18, 0.24);
}

.image-prompt-field {
  min-height: 0;
  position: relative;
  display: flex;
}

.image-chat-composer textarea {
  width: 100%;
  min-height: 104px;
  max-height: 220px;
  resize: none;
  padding: 2px 36px 2px 2px;
  color: #f1f4fa;
  border: 0;
  outline: 0;
  background: transparent;
  line-height: 1.6;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-start) transparent;
}

.image-chat-composer textarea::-webkit-scrollbar {
  width: 6px;
}

.image-chat-composer textarea::-webkit-scrollbar-track {
  background: transparent;
}

.image-chat-composer textarea::-webkit-scrollbar-thumb {
  border: 1px solid transparent;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--scrollbar-thumb-start), var(--scrollbar-thumb-end));
  background-clip: padding-box;
}

.image-chat-composer textarea::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--scrollbar-thumb-hover-start), var(--scrollbar-thumb-hover-end));
  background-clip: padding-box;
}

.image-chat-composer textarea::placeholder {
  color: #65738a;
}

.image-prompt-expand {
  width: 28px;
  height: 28px;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 0;
  color: #7f8da5;
  border: 1px solid rgba(77, 95, 124, 0.68);
  border-radius: 8px;
  background: rgba(13, 23, 38, 0.9);
  box-shadow: 0 6px 18px rgba(4, 9, 16, 0.22);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.image-prompt-expand:hover,
.image-prompt-expand:focus-visible {
  color: #f1f4fa;
  border-color: rgba(116, 130, 255, 0.74);
  background: rgba(32, 42, 73, 0.96);
  outline: 0;
}

.image-prompt-expand svg {
  width: 15px;
  height: 15px;
  transition: transform 180ms ease;
}

.image-chat-composer.is-expanded {
  position: absolute;
  inset: 78px 12px 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 14px;
  border-color: rgba(102, 116, 244, 0.76);
  background: linear-gradient(155deg, rgba(16, 28, 45, 0.99), rgba(11, 20, 34, 0.99));
  box-shadow: 0 0 0 1px rgba(102, 116, 244, 0.08), 0 24px 60px rgba(3, 8, 15, 0.58);
}

.image-chat-composer.is-expanded .image-prompt-field {
  flex: 1 1 auto;
}

.image-chat-composer.is-expanded .image-prompt-field textarea {
  height: 100% !important;
  min-height: 220px;
  max-height: none;
  padding-top: 4px;
  font-size: 13px;
  line-height: 1.75;
}

.image-chat-composer.is-expanded .image-prompt-expand svg {
  transform: rotate(180deg);
}

.image-reference-chip {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid rgba(66, 213, 188, 0.24);
  border-radius: 10px;
  background: rgba(66, 213, 188, 0.07);
}

.image-reference-chip[hidden] {
  display: none;
}

.image-reference-chip img {
  width: 46px;
  height: 46px;
  border-radius: 7px;
  object-fit: cover;
}

.image-reference-chip > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.image-reference-chip strong,
.image-reference-chip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-reference-chip strong {
  color: #e4ebf5;
  font-size: 10px;
}

.image-reference-chip small {
  color: #42d5bc;
  font-size: 9px;
}

.image-reference-chip button {
  width: 26px;
  height: 26px;
  color: #8e9bb0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}

.image-chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-chat-actions > small {
  flex: 1;
  color: #65738a;
  font-size: 8px;
  text-align: right;
}

.image-chat-attach {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  color: #aab5c7;
  border: 1px solid #31415a;
  border-radius: 9px;
  background: #0d1726;
  font-size: 10px;
  cursor: pointer;
}

.image-chat-actions .primary-button {
  min-width: 76px;
  min-height: 34px;
}

@media (max-width: 1040px) {
  .image-studio-shell {
    grid-template-columns: minmax(0, 1fr) 330px;
  }

  .image-studio-tools label > span,
  .image-toolbar-button > span {
    display: none;
  }
}

@media (max-width: 780px) {
  body.image-studio-active .workspace {
    height: auto;
    min-height: 100dvh;
  }

  .image-editor-screen {
    min-height: 100dvh;
  }

  .image-studio-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(430px, 58dvh) minmax(360px, 42dvh);
    overflow: visible;
  }

  .image-artboard-area {
    border-right: 0;
    border-bottom: 1px solid #26354a;
  }

  .image-chat-panel {
    min-height: 360px;
  }

  .image-chat-composer.is-expanded {
    inset: 76px 10px 10px;
  }

  .image-canvas-node {
    width: 280px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-canvas-node,
  .image-chat-composer,
  .image-artwork-cluster {
    transition: none !important;
  }
}

/* EO personalized workbench header: greeting, navigation context and account
   identity share one compact rhythm instead of floating as unrelated tags. */

.topbar {
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(260px, 360px) auto;
  align-items: center;
  gap: clamp(16px, 1.35vw, 26px);
  position: sticky;
  isolation: isolate;
  overflow: hidden;
}

.topbar::after {
  content: "";
  width: 210px;
  height: 1px;
  position: absolute;
  left: var(--content-gutter);
  bottom: -1px;
  background: linear-gradient(90deg, #42d5bc 0%, #6674f4 54%, rgba(190, 104, 222, 0) 100%);
  box-shadow: 0 0 14px rgba(102, 116, 244, 0.48);
  pointer-events: none;
}

.topbar-identity {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.topbar-greeting-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #7f8da5;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.topbar-greeting-line strong {
  color: #aeb9ca;
  font-size: 11px;
  font-weight: 650;
}

.topbar-greeting-mark {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #42d5bc;
  box-shadow: 0 0 0 4px rgba(66, 213, 188, 0.09), 0 0 12px rgba(66, 213, 188, 0.48);
}

.topbar-title-line {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.topbar .topbar-title-line h1 {
  min-width: 0;
  margin: 0;
  color: #f1f4fa;
  font-size: clamp(21px, 1.45vw, 25px);
  line-height: 1.14;
  letter-spacing: -0.035em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-context {
  flex: 0 0 auto;
  color: #64738a;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.topbar > .global-search {
  width: 100%;
  max-width: 360px;
  justify-self: center;
  margin: 0;
  border-color: rgba(54, 72, 101, 0.82);
  background: rgba(13, 23, 38, 0.78);
}

.topbar .top-actions {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 7px;
}

.topbar .top-actions > button,
.top-user-badge {
  min-height: 38px;
}

.top-user-badge {
  min-width: 136px;
  max-width: 176px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 4px 10px 4px 5px;
  border: 1px solid rgba(69, 86, 113, 0.68);
  border-radius: 12px;
  background: rgba(18, 29, 47, 0.82);
}

.top-user-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: #dce3ff;
  border: 1px solid rgba(102, 116, 244, 0.44);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(102, 116, 244, 0.3), rgba(190, 104, 222, 0.15));
  font-size: 12px;
  font-weight: 750;
}

.top-user-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.top-user-copy strong,
.top-user-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-user-copy strong {
  color: #e7ebf4;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
}

.top-user-copy small {
  color: #7e8da5;
  font-size: 9.5px;
  line-height: 1.2;
}

.top-user-badge[data-role="admin"] .top-user-avatar {
  color: #e5dcff;
  border-color: rgba(159, 121, 255, 0.5);
  background: linear-gradient(145deg, rgba(102, 116, 244, 0.34), rgba(190, 104, 222, 0.24));
}

.top-user-badge[data-role="editor"] .top-user-avatar {
  color: #bff8ee;
  border-color: rgba(66, 213, 188, 0.44);
  background: rgba(66, 213, 188, 0.14);
}

.top-user-badge[data-role="reviewer"] .top-user-avatar {
  color: #d5f7d8;
  border-color: rgba(88, 210, 132, 0.44);
  background: rgba(88, 210, 132, 0.13);
}

.top-user-badge[data-role="viewer"] .top-user-avatar {
  color: #d6dfed;
  border-color: rgba(132, 150, 178, 0.38);
  background: rgba(132, 150, 178, 0.12);
}

@media (max-width: 1500px) {
  .topbar {
    grid-template-columns: minmax(280px, 1fr) auto;
  }

  .topbar > .global-search {
    display: none;
  }
}

@media (max-width: 1280px) {
  .topbar-context {
    display: none;
  }
}

@media (max-width: 940px) {
  .topbar-greeting-line > span:last-child,
  #backendStatus > span,
  #logoutBtn > span,
  .top-actions [data-view-shortcut="ask"] > span {
    display: none;
  }

  .topbar .top-actions > button {
    width: 38px;
    min-width: 38px;
    padding-inline: 0;
    justify-content: center;
  }
}

@media (max-width: 780px) {
  .topbar {
    min-height: 66px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding-block: 9px;
  }

  .topbar-title-line {
    gap: 0;
  }

  .topbar .topbar-title-line h1 {
    font-size: 19px;
  }

  .topbar-greeting-line {
    font-size: 9px;
  }

  .topbar::after {
    width: 130px;
  }
}

/* Floating Xiaoyi assistant: a compact EO knowledge companion available from every workspace. */

.assistant-launcher {
  position: fixed;
  right: clamp(16px, 1.5vw, 26px);
  bottom: clamp(16px, 1.5vw, 26px);
  z-index: 3300;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: visible;
  color: #ffffff;
  border: 1px solid rgba(139, 164, 255, 0.58);
  border-radius: 50%;
  background: linear-gradient(145deg, #3f66e8 4%, #6656e3 58%, #8a4bd4 100%);
  box-shadow: 0 16px 40px rgba(26, 42, 104, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  cursor: pointer;
  isolation: isolate;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 150ms ease;
}

.assistant-launcher[hidden],
body:not(.authenticated) .assistant-launcher,
body.password-change-required .assistant-launcher {
  display: none !important;
}

.assistant-launcher::before {
  position: absolute;
  inset: -7px;
  z-index: -2;
  content: "";
  border: 1px solid rgba(91, 210, 196, 0.3);
  border-radius: inherit;
  background: radial-gradient(circle, rgba(95, 128, 255, 0.16), transparent 68%);
  animation: assistant-launcher-pulse 2.8s ease-in-out infinite;
}

.assistant-launcher:hover {
  transform: translateY(-3px) scale(1.035);
  box-shadow: 0 20px 46px rgba(45, 55, 148, 0.52), 0 0 0 5px rgba(84, 205, 191, 0.08);
}

.assistant-launcher:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 4px;
}

.assistant-launcher > svg {
  position: relative;
  z-index: 2;
  width: 27px;
  height: 27px;
  stroke-width: 1.8;
}

.assistant-launcher-orbit,
.assistant-launcher-orbit i {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.assistant-launcher-orbit {
  overflow: hidden;
  opacity: 0.7;
}

.assistant-launcher-orbit i {
  border: 2px solid transparent;
  border-top-color: #57d6c6;
  transform: rotate(18deg);
}

.assistant-launcher-orbit i:nth-child(2) {
  inset: 6px;
  border-top-color: #f3c85c;
  transform: rotate(132deg);
}

.assistant-launcher-orbit i:nth-child(3) {
  inset: 12px;
  border-top-color: #f06c9e;
  transform: rotate(242deg);
}

.assistant-launcher-badge {
  position: absolute;
  top: -4px;
  right: -3px;
  z-index: 3;
  min-width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  color: #ffffff;
  border: 2px solid var(--page-bg);
  border-radius: 999px;
  background: linear-gradient(135deg, #e95b9f, #8d76ff);
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28);
}

body.assistant-drawer-open .assistant-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
}

.nav-item.assistant-open {
  color: #ffffff;
  border-color: rgba(102, 129, 255, 0.38);
  background: linear-gradient(90deg, rgba(82, 111, 225, 0.2), rgba(126, 82, 220, 0.1));
}

#ask.assistant-drawer {
  position: fixed;
  inset: 18px 18px 18px auto;
  z-index: 3400;
  width: min(440px, calc(100vw - 36px));
  height: calc(100dvh - 36px);
  min-height: 520px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(135, 160, 204, 0.22);
  border-radius: 22px;
  background: rgba(8, 14, 24, 0.96);
  box-shadow: -18px 0 56px rgba(0, 0, 0, 0.34), 0 24px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(22px);
  opacity: 0;
  transform: translateX(28px) scale(0.985);
  transform-origin: right bottom;
}

#ask.assistant-drawer.active {
  display: block;
}

#ask.assistant-drawer.is-open {
  opacity: 1;
  transform: translateX(0) scale(1);
  animation: assistant-drawer-enter 220ms cubic-bezier(0.22, 0.8, 0.24, 1) both;
}

#ask.assistant-drawer .ask-layout {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  overflow: hidden;
}

#ask.assistant-drawer .ask-panel {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 84% 0%, rgba(110, 86, 228, 0.13), transparent 30%),
    linear-gradient(180deg, rgba(16, 25, 39, 0.98), rgba(9, 15, 25, 0.99));
}

#ask.assistant-drawer .assistant-drawer-heading {
  position: relative;
  z-index: 8;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(12, 20, 32, 0.88);
  backdrop-filter: blur(18px);
}

.assistant-drawer-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.assistant-drawer-identity > span:last-child {
  min-width: 0;
}

.assistant-drawer-identity h2,
.assistant-drawer-identity small {
  display: block;
}

.assistant-drawer-identity h2 {
  margin: 0;
  font-size: 16px;
}

.assistant-drawer-identity small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#ask.assistant-drawer .assistant-drawer-heading .heading-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 6px;
}

#ask.assistant-drawer #aiStatusBadge {
  max-width: 112px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#ask.assistant-drawer .assistant-drawer-heading .icon-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

#ask.assistant-drawer .assistant-drawer-heading .icon-button svg {
  width: 15px;
  height: 15px;
}

#ask.assistant-drawer .assistant-context-toggle[aria-expanded="true"] {
  color: #ffffff;
  border-color: rgba(110, 141, 255, 0.58);
  background: linear-gradient(135deg, rgba(75, 108, 232, 0.82), rgba(117, 78, 218, 0.8));
}

#ask.assistant-drawer .chat-window {
  height: auto;
  min-height: 0;
  max-height: none;
  display: grid;
  align-content: start;
  gap: 12px;
  margin: 0;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(rgba(77, 107, 160, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 107, 160, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 15% 0%, rgba(75, 112, 235, 0.08), transparent 35%),
    rgba(5, 10, 18, 0.62);
  background-size: 24px 24px, 24px 24px, auto, auto;
}

#ask.assistant-drawer .message {
  max-width: 90%;
  padding: 11px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.62;
}

#ask.assistant-drawer .message.user {
  border-bottom-right-radius: 5px;
}

#ask.assistant-drawer .message.assistant {
  border-bottom-left-radius: 5px;
}

#ask.assistant-drawer .assistant-identity {
  margin-bottom: 8px;
}

#ask.assistant-drawer .ask-loading-message {
  min-width: 0;
  width: 90%;
}

#ask.assistant-drawer .ask-form {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(10, 17, 28, 0.94);
  backdrop-filter: blur(18px);
}

#ask.assistant-drawer .ask-form input {
  height: 44px;
  min-width: 0;
  padding: 0 12px;
  border-color: rgba(139, 163, 204, 0.22);
  border-radius: 12px;
  background: rgba(20, 30, 47, 0.88);
}

#ask.assistant-drawer .ask-form > .primary-button {
  width: 48px;
  min-width: 48px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
}

#ask.assistant-drawer .ask-form > .primary-button span {
  display: none;
}

#ask.assistant-drawer .source-panel {
  position: absolute;
  inset: 0;
  z-index: 12;
  height: 100%;
  min-height: 0;
  display: block;
  padding: 0 14px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 84% 0%, rgba(110, 86, 228, 0.12), transparent 30%),
    rgba(10, 17, 28, 0.985);
  box-shadow: -20px 0 40px rgba(0, 0, 0, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translateX(102%);
  transition: transform 210ms cubic-bezier(0.22, 0.8, 0.24, 1), opacity 160ms ease;
}

#ask.assistant-drawer.context-open .source-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.assistant-context-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -14px 14px;
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(10, 17, 28, 0.96);
  backdrop-filter: blur(18px);
}

.assistant-context-heading .eyebrow {
  margin-bottom: 3px;
  color: var(--accent-cyan);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.assistant-context-heading h2 {
  font-size: 16px;
}

.assistant-context-intro {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

#ask.assistant-drawer .source-panel .scope-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#ask.assistant-drawer .source-panel .scope-list button {
  position: relative;
  min-height: 42px;
  padding: 9px 28px 9px 10px;
  border-color: var(--border-subtle);
  border-radius: 10px;
  color: var(--text-secondary);
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  touch-action: manipulation;
}

#ask.assistant-drawer .source-panel .scope-list button::after {
  content: "›";
  position: absolute;
  top: 50%;
  right: 11px;
  color: var(--accent-cyan);
  font-size: 20px;
  line-height: 1;
  transform: translateY(-52%);
}

#ask.assistant-drawer .source-note,
#ask.assistant-drawer .search-preview {
  margin-top: 14px;
}

@keyframes assistant-launcher-pulse {
  0%, 100% { opacity: 0.56; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.06); }
}

@keyframes assistant-drawer-enter {
  from { opacity: 0; transform: translateX(28px) scale(0.985); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@media (max-width: 780px) {
  body.assistant-drawer-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  #ask.assistant-drawer {
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: var(--assistant-layout-height, 100svh);
    max-height: 100vh;
    max-height: var(--assistant-layout-height, 100svh);
    min-height: 0;
    border: 0;
    border-radius: 0;
  }

  #ask.assistant-drawer .ask-layout,
  #ask.assistant-drawer .ask-panel {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  #ask.assistant-drawer .assistant-drawer-heading {
    min-height: 66px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  }

  #ask.assistant-drawer .assistant-drawer-identity {
    flex: 1 1 auto;
    overflow: hidden;
  }

  #ask.assistant-drawer .assistant-drawer-heading .heading-actions {
    flex: 0 0 auto;
    align-items: center;
  }

  #ask.assistant-drawer .assistant-drawer-heading .icon-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  #ask.assistant-drawer #aiStatusBadge {
    display: none;
  }

  #ask.assistant-drawer .chat-window {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  #ask.assistant-drawer .ask-form {
    position: sticky;
    inset: auto 0 0;
    z-index: 20;
    align-self: end;
    transform: translate3d(0, calc(-1 * var(--assistant-keyboard-offset, 0px)), 0);
    will-change: transform;
    padding: 10px 12px max(12px, env(safe-area-inset-bottom));
    box-shadow: 0 -12px 28px rgba(4, 10, 20, 0.16);
  }

  #ask.assistant-drawer .source-panel {
    padding: 0 12px max(20px, env(safe-area-inset-bottom));
  }

  #ask.assistant-drawer .assistant-context-heading {
    margin: 0 -12px 12px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  }

  #ask.assistant-drawer .assistant-context-heading h2 {
    font-size: 18px;
    line-height: 1.3;
  }

  #ask.assistant-drawer .assistant-context-intro {
    margin-bottom: 12px;
    font-size: 13px;
  }
}

@media (max-width: 520px) {
  #ask.assistant-drawer .source-panel .scope-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #ask.assistant-drawer .source-panel .scope-list button {
    min-height: 50px;
    padding: 12px 36px 12px 14px;
    border-radius: 12px;
    font-size: 14px;
  }

  #ask.assistant-drawer .source-panel .scope-list button::after {
    right: 14px;
  }

  #ask.assistant-drawer .source-note,
  #ask.assistant-drawer .search-preview {
    margin-top: 12px;
  }

  #ask.assistant-drawer .source-note {
    padding: 14px;
  }

  #ask.assistant-drawer .source-note p {
    font-size: 13px;
    line-height: 1.65;
  }

  #ask.assistant-drawer .search-preview-heading {
    flex-wrap: wrap;
    gap: 8px;
  }

  #ask.assistant-drawer .search-preview-heading button {
    min-height: 40px;
  }
}

@media (max-width: 390px) {
  #ask.assistant-drawer .assistant-drawer-identity small {
    max-width: 128px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .assistant-launcher,
  .assistant-launcher::before,
  #ask.assistant-drawer,
  #ask.assistant-drawer .source-panel {
    animation: none !important;
    transition: none !important;
  }
}

/* 2026-08-04 workbench refinement: one compact command cluster, one account
   surface, and one disciplined 12-column dashboard rhythm. */

.topbar {
  overflow: visible;
  grid-template-columns: minmax(250px, 1fr) minmax(240px, 340px) minmax(330px, max-content);
}

.topbar .top-actions {
  align-items: center;
  gap: 8px;
}

.top-system-cluster {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 3px;
  border: 1px solid rgba(66, 84, 113, 0.62);
  border-radius: 12px;
  background: rgba(13, 23, 38, 0.76);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.top-system-cluster .theme-switch-topbar,
.top-system-cluster .status-button {
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
}

/* The connection probe remains active, but its technical status is kept out
   of the primary navigation. It is still available inside the account menu. */
.top-system-cluster .status-button {
  display: none !important;
}

.top-system-cluster .theme-switch-topbar {
  width: 70px;
  min-width: 70px;
  height: 34px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 28px);
  place-items: center;
  gap: 4px;
  padding: 3px;
  overflow: hidden;
  color: rgba(143, 158, 184, 0.72);
  border: 0;
  border-radius: 9px;
  background: rgba(5, 12, 23, 0.38);
  box-shadow: inset 0 0 0 1px rgba(93, 113, 146, 0.18);
  transition: background 180ms ease, box-shadow 180ms ease;
}

.top-system-cluster .theme-switch-topbar::before {
  width: 28px;
  height: 28px;
  position: absolute;
  z-index: 0;
  top: 3px;
  left: 3px;
  content: "";
  border: 1px solid rgba(164, 145, 255, 0.42);
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(83, 107, 232, 0.62), rgba(126, 86, 225, 0.78));
  box-shadow: 0 5px 14px rgba(69, 68, 185, 0.28), inset 0 1px rgba(255, 255, 255, 0.14);
  transform: translateX(32px);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), background 180ms ease, box-shadow 180ms ease;
}

.top-system-cluster .theme-switch-topbar .theme-switch-sun,
.top-system-cluster .theme-switch-topbar .theme-switch-moon {
  width: 15px;
  height: 15px;
  position: relative;
  z-index: 1;
  display: block !important;
  pointer-events: none;
  transition: color 180ms ease, opacity 180ms ease, filter 180ms ease, transform 180ms ease;
}

.top-system-cluster .theme-switch-topbar .theme-switch-sun {
  color: rgba(205, 169, 97, 0.58);
  opacity: 0.66;
}

.top-system-cluster .theme-switch-topbar .theme-switch-moon {
  color: #f2efff;
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(181, 158, 255, 0.52));
}

.top-system-cluster .theme-switch-topbar:hover {
  color: inherit;
  background: rgba(10, 18, 33, 0.66);
  box-shadow: inset 0 0 0 1px rgba(118, 139, 178, 0.28), 0 5px 16px rgba(0, 0, 0, 0.12);
}

.top-system-cluster .theme-switch-topbar:hover .theme-switch-sun,
.top-system-cluster .theme-switch-topbar:hover .theme-switch-moon {
  transform: translateY(-1px);
}

.top-system-cluster .theme-switch-topbar:focus-visible {
  outline: 2px solid rgba(128, 151, 255, 0.9);
  outline-offset: 2px;
}

.top-system-cluster .status-button {
  position: relative;
  padding-inline: 12px 11px;
}

.top-system-cluster .status-button::before {
  width: 1px;
  height: 20px;
  position: absolute;
  left: 0;
  content: "";
  background: rgba(91, 111, 143, 0.32);
}

.account-menu {
  position: relative;
  z-index: 3;
}

.top-user-badge {
  width: auto;
  min-width: 154px;
  max-width: 190px;
  grid-template-columns: 30px minmax(0, 1fr) 16px;
  padding-right: 8px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.top-user-badge:hover,
.account-menu.open .top-user-badge {
  border-color: rgba(111, 139, 244, 0.58);
  background: rgba(24, 37, 59, 0.96);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16), inset 0 1px rgba(255, 255, 255, 0.05);
}

.account-menu-chevron {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  transition: transform 160ms ease;
}

.account-menu.open .account-menu-chevron {
  transform: rotate(180deg);
}

.account-popover {
  width: 286px;
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 50;
  padding: 8px;
  color: var(--text-primary);
  border: 1px solid rgba(75, 94, 125, 0.72);
  border-radius: 16px;
  background:
    radial-gradient(circle at 88% 0%, rgba(112, 75, 220, 0.16), transparent 34%),
    rgba(12, 20, 33, 0.985);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(22px);
  transform-origin: top right;
  animation: account-popover-in 150ms cubic-bezier(0.22, 0.8, 0.24, 1);
}

.account-popover[hidden] {
  display: none;
}

.account-popover-heading {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 9px 9px 13px;
  border-bottom: 1px solid var(--border-subtle);
}

.account-popover-heading > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.account-popover-heading strong,
.account-popover-heading small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-popover-heading strong {
  color: var(--text-primary);
  font-size: 14px;
}

.account-popover-heading small {
  color: var(--text-tertiary);
  font-size: 11px;
}

.account-popover-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #ffffff;
  border: 1px solid rgba(126, 145, 255, 0.54);
  border-radius: 13px;
  background: linear-gradient(145deg, #556be4, #8551cf);
  box-shadow: 0 9px 20px rgba(77, 75, 190, 0.28), inset 0 1px rgba(255, 255, 255, 0.24);
  font-size: 16px;
  font-weight: 750;
}

.account-popover-status,
.account-popover-action {
  min-height: 42px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin-top: 5px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

.account-popover-status {
  color: var(--text-tertiary);
  font-size: 11px;
}

.account-popover-status strong {
  color: var(--text-secondary);
  font-size: 11px;
}

.account-popover-status strong.success {
  color: var(--status-success);
}

.account-popover-status svg,
.account-popover-action svg {
  width: 17px;
  height: 17px;
}

.account-popover-action {
  width: 100%;
  grid-template-columns: 20px minmax(0, 1fr);
  color: var(--text-secondary);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.account-popover-action:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.account-popover-action.danger {
  color: #e78ba1;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0 0 10px 10px;
}

#dashboard.view.active {
  gap: 12px;
}

#dashboard .aurora-command {
  min-height: 84px;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
}

#dashboard .aurora-command h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

#dashboard .aurora-command .eyebrow {
  margin-bottom: 4px;
  font-size: 10px;
}

#dashboard .aurora-command .panel-subtitle {
  margin-bottom: 0;
  font-size: 11px;
}

#dashboard .command-actions {
  flex-wrap: nowrap;
}

#dashboard .dashboard-kpis {
  gap: 10px;
  margin: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#dashboard .dashboard-kpis .aurora-kpi {
  min-height: 94px;
  padding: 13px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  background: var(--surface-1);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  isolation: isolate;
}

#dashboard .dashboard-kpis .aurora-kpi::before {
  display: none;
}

#dashboard .dashboard-kpis .aurora-kpi-icon {
  width: 38px;
  height: 38px;
  top: 12px;
  right: 12px;
  z-index: 2;
  border-radius: 11px;
}

#dashboard .dashboard-kpis .aurora-kpi-icon svg {
  width: 20px;
  height: 20px;
}

#dashboard .dashboard-kpis .aurora-kpi strong {
  font-size: clamp(28px, 2vw, 35px);
}

#dashboard .aurora-dashboard-grid {
  gap: 12px;
}

#dashboard .aurora-dashboard-grid > .panel {
  padding: 16px;
  border-radius: 14px;
}

#dashboard .aurora-dashboard-grid .panel-heading {
  min-height: 34px;
  margin-bottom: 8px;
}

#dashboard .dashboard-activity-panel,
#dashboard .dashboard-health-panel {
  min-height: 388px;
}

#dashboard .dashboard-activity-panel {
  grid-template-rows: auto minmax(280px, 1fr) auto;
}

#dashboard .dashboard-activity-panel .chart-canvas {
  min-height: 280px;
}

#dashboard .dashboard-health-panel {
  display: grid;
  grid-template-rows: auto minmax(205px, 1fr) auto auto;
  align-content: stretch;
}

#dashboard .dashboard-health-panel .compact-chart {
  min-height: 205px;
}

#dashboard .dashboard-review-panel,
#dashboard .dashboard-quality-panel,
#dashboard .dashboard-todo-panel {
  min-height: 302px;
}

#dashboard .dashboard-review-panel,
#dashboard .dashboard-quality-panel {
  display: grid;
  grid-template-rows: auto minmax(208px, 1fr) auto;
}

#dashboard .dashboard-review-panel .chart-canvas,
#dashboard .dashboard-quality-panel .chart-canvas {
  min-height: 208px;
}

#dashboard .dashboard-todo-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

#dashboard .dashboard-todo-panel .todo-list {
  align-content: start;
  gap: 8px;
}

#dashboard .dashboard-todo-panel .todo-list article {
  min-height: 48px;
  padding: 9px 10px;
}

#dashboard .dashboard-health-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

#dashboard .dashboard-health-grid article {
  min-height: 58px;
  padding: 10px;
  border-radius: 10px;
}

#dashboard .chart-summary {
  min-height: 19px;
  margin: 7px 0 0;
}

#dashboard .aurora-dashboard-bottom {
  gap: 12px;
  margin-top: 0;
}

@keyframes account-popover-in {
  from { opacity: 0; transform: translateY(-5px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1500px) {
  .topbar {
    grid-template-columns: minmax(260px, 1fr) auto;
  }
}

@media (max-width: 1180px) {
  #dashboard .dashboard-kpis {
    gap: 10px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  #dashboard .dashboard-kpis .aurora-kpi,
  #dashboard .dashboard-kpis .aurora-kpi:last-child {
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--surface-1);
  }

  #dashboard .dashboard-kpis .aurora-kpi::before {
    display: none;
  }

  #dashboard .dashboard-activity-panel,
  #dashboard .dashboard-health-panel {
    min-height: 350px;
  }
}

@media (max-width: 940px) {
  .top-system-cluster .status-button {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }

  .top-system-cluster .status-button span {
    display: none;
  }

  .account-popover {
    width: min(286px, calc(100vw - 32px));
  }
}

@media (max-width: 620px) {
  .top-user-badge {
    min-width: 42px;
    width: 42px;
    grid-template-columns: 30px;
    padding: 5px;
  }

  .top-user-copy,
  .account-menu-chevron {
    display: none;
  }

  #dashboard .command-actions {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .account-popover,
  .account-menu-chevron {
    animation: none !important;
    transition: none !important;
  }
}

/* Brand asset upload: compact workflow with a dedicated file-selection stage. */
.brand-asset-upload-modal {
  width: min(940px, calc(100vw - 32px));
  height: min(780px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  gap: 0;
  overflow: hidden;
  border-top-color: color-mix(in srgb, var(--accent-blue) 72%, var(--border-strong));
  background:
    radial-gradient(circle at 88% 0%, color-mix(in srgb, var(--accent-violet) 11%, transparent), transparent 30%),
    var(--surface-1);
}

.brand-asset-upload-modal .brand-asset-workflow-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: 0;
}

.brand-asset-upload-header {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin: 0;
  padding: 20px 24px 16px;
  gap: 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
}

.brand-asset-upload-header > div {
  min-width: 0;
}

.brand-asset-upload-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.brand-asset-upload-header .panel-subtitle {
  margin-top: 5px;
  max-width: 640px;
}

.brand-asset-upload-close {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 11px;
}

.brand-asset-upload-close svg {
  width: 18px;
  height: 18px;
}

.brand-asset-upload-body {
  display: grid;
  align-content: start;
  min-height: 0;
  padding: 20px 24px 24px;
  gap: 18px;
  overflow: auto;
}

.brand-asset-upload-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--accent-blue) 34%, var(--border-subtle));
  border-radius: 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-blue) 9%, transparent), transparent 54%),
    var(--surface-2);
}

.brand-asset-upload-stage:has(#brandAssetFileField[hidden]):has(.brand-asset-batch-tools[hidden]) {
  display: none;
}

.brand-asset-file-field {
  display: grid !important;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 4px 14px !important;
  cursor: pointer;
}

.brand-asset-upload-icon {
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--accent-blue);
  border: 1px solid color-mix(in srgb, var(--accent-blue) 34%, var(--border-subtle));
  border-radius: 13px;
  background: color-mix(in srgb, var(--accent-blue) 12%, var(--surface-raised));
  box-shadow: inset 0 1px color-mix(in srgb, white 10%, transparent);
}

.brand-asset-upload-icon svg {
  width: 23px;
  height: 23px;
}

.brand-asset-upload-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.brand-asset-upload-copy strong {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 760;
}

.brand-asset-upload-copy small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 560;
}

.brand-asset-file-field input[type="file"] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 44px;
  padding: 5px;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-raised) 86%, transparent);
  cursor: pointer;
}

.brand-asset-file-field input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  padding: 0 14px;
  color: #fff;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-violet));
  font: inherit;
  font-weight: 720;
  cursor: pointer;
}

.brand-asset-batch-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.brand-asset-batch-tools[hidden] {
  display: none;
}

.brand-asset-batch-tools button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  gap: 7px;
}

.brand-asset-batch-tools button svg {
  width: 16px;
  height: 16px;
}

#brandAssetSelectionSummary {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.brand-asset-metadata-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px 18px;
}

.brand-asset-metadata-grid > label,
.brand-asset-upload-album-field,
.brand-asset-upload-album-field > label {
  min-width: 0;
}

.brand-asset-metadata-grid label > span {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 720;
}

.brand-asset-metadata-grid label > span small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.brand-asset-metadata-grid input:not([type="checkbox"]),
.brand-asset-metadata-grid select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
}

.brand-asset-upload-album-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.brand-asset-upload-album-field > label {
  grid-column: 1 / -1;
}

.brand-asset-upload-album-field .field-hint,
.brand-asset-upload-album-field .form-error {
  grid-column: 1 / -1;
}

.brand-asset-description-field {
  grid-column: 1 / -1;
}

.brand-asset-upload-modal .brand-asset-description-field textarea {
  width: 100%;
  min-height: 96px;
  max-height: 180px;
  padding: 12px;
  border-radius: 10px;
  line-height: 1.55;
  resize: vertical;
}

.brand-asset-rights-attestation {
  grid-column: 1 / -1;
  display: flex !important;
  align-items: center;
  min-height: 48px;
  padding: 12px 14px;
  gap: 10px !important;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent-cyan) 7%, var(--surface-2));
}

.brand-asset-rights-attestation input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: var(--accent-blue);
}

.brand-asset-rights-attestation > span {
  color: var(--text-secondary) !important;
  font-size: 12px !important;
  font-weight: 650 !important;
}

.brand-asset-upload-modal .form-error:empty,
.brand-asset-upload-modal .brand-asset-batch-status:empty {
  display: none;
}

.brand-asset-upload-footer {
  min-height: 68px;
  margin: 0;
  padding: 12px 24px;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-raised) 92%, transparent);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.13);
}

.brand-asset-upload-footer > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.brand-asset-upload-footer > span svg {
  width: 16px;
  height: 16px;
  color: var(--accent-cyan);
}

.brand-asset-upload-footer .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  min-height: 42px;
  gap: 8px;
}

.brand-asset-upload-footer .primary-button svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 720px) {
  .brand-asset-upload-modal {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .brand-asset-upload-header,
  .brand-asset-upload-body,
  .brand-asset-upload-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .brand-asset-metadata-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .brand-asset-description-field,
  .brand-asset-rights-attestation {
    grid-column: auto;
  }

  #brandAssetSelectionSummary {
    width: 100%;
    margin-left: 0;
  }

  .brand-asset-upload-footer > span {
    display: none;
  }

  .brand-asset-upload-footer .primary-button {
    width: 100%;
  }
}

/* 2026-08-26 desktop responsive containment.
   Responsive decisions are based on the usable workspace width (after the
   sidebar), so browser zoom, OS scaling and compact laptop screens reflow
   instead of pushing controls or panels beyond the viewport. */

html,
body,
.app-shell,
.workspace,
.view,
.view.active {
  max-width: 100%;
}

body.authenticated {
  overflow-x: clip;
}

.app-shell,
.workspace,
.view,
.view.active,
.panel,
.topbar,
.topbar-identity,
.top-actions,
.top-system-cluster,
.aurora-command,
.aurora-kpi-grid,
.aurora-dashboard-grid,
.aurora-dashboard-bottom,
.insights-diagnostic-grid,
.insights-ops-grid,
.library-command-grid,
.split-layout,
.two-column,
.ask-layout,
.generator-layout,
.dashboard-layout,
.dashboard-main,
.dashboard-side,
.dashboard-bottom,
.brand-asset-layout,
.brand-asset-filters,
.brand-asset-grid {
  min-width: 0;
}

.workspace {
  overflow-x: clip;
}

.view.active,
.panel,
.panel-heading,
.aurora-command > *,
.aurora-kpi,
.aurora-dashboard-grid > *,
.aurora-dashboard-bottom > *,
.brand-asset-layout > *,
.brand-asset-filters > * {
  min-width: 0;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

input,
select,
textarea,
pre,
.command-snippet,
#healthOutput,
#generatedOutput {
  max-width: 100%;
}

.panel h1,
.panel h2,
.panel h3,
.panel p,
.panel li,
.panel td,
.panel th,
.aurora-kpi span,
.aurora-kpi small,
.topbar-title-line,
.top-user-copy {
  overflow-wrap: anywhere;
}

/* Wide data remains usable inside its own region without widening the page. */
.table-wrap,
.data-table-wrap,
.audit-table-wrap,
.document-table-view,
.acceptance-table-wrap,
.account-audit-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

#dashboard {
  container: dashboard-workspace / inline-size;
}

#dashboard .dashboard-kpis,
#dashboard .aurora-dashboard-grid,
#dashboard .aurora-dashboard-bottom {
  width: 100%;
  max-width: 100%;
}

/* Keep five cards only when the content surface really has enough room. */
@container dashboard-workspace (max-width: 1180px) {
  #dashboard .dashboard-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #dashboard .dashboard-kpis > .aurora-kpi {
    grid-column: span 2;
  }

  #dashboard .dashboard-kpis > .aurora-kpi:nth-last-child(-n + 2) {
    grid-column: span 3;
  }

  #dashboard .dashboard-activity-panel {
    grid-column: span 12;
  }

  #dashboard .dashboard-health-panel,
  #dashboard .dashboard-review-panel,
  #dashboard .dashboard-quality-panel,
  #dashboard .dashboard-todo-panel {
    grid-column: span 6;
  }
}

@container dashboard-workspace (max-width: 780px) {
  #dashboard .dashboard-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #dashboard .dashboard-kpis > .aurora-kpi,
  #dashboard .dashboard-kpis > .aurora-kpi:nth-last-child(-n + 2) {
    grid-column: auto;
  }

  #dashboard .dashboard-kpis > .aurora-kpi:last-child {
    grid-column: 1 / -1;
  }

  #dashboard .dashboard-health-panel,
  #dashboard .dashboard-review-panel,
  #dashboard .dashboard-quality-panel,
  #dashboard .dashboard-todo-panel {
    grid-column: span 12;
  }
}

@container dashboard-workspace (max-width: 500px) {
  #dashboard .dashboard-kpis {
    grid-template-columns: minmax(0, 1fr);
  }

  #dashboard .dashboard-kpis > .aurora-kpi,
  #dashboard .dashboard-kpis > .aurora-kpi:last-child {
    grid-column: auto;
  }
}

/* Viewport fallback for older browsers without container queries. */
@media (max-width: 1440px) and (min-width: 1101px) {
  :root {
    --shell-sidebar: clamp(184px, 15vw, 204px);
    --content-gutter: clamp(14px, 1.25vw, 18px);
  }

  .topbar {
    grid-template-columns: minmax(230px, 1fr) auto;
    gap: 12px;
  }

  .topbar > .global-search {
    display: none;
  }

  .topbar .top-actions {
    gap: 6px;
  }

  #dashboard .dashboard-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #dashboard .dashboard-kpis > .aurora-kpi {
    grid-column: span 2;
  }

  #dashboard .dashboard-kpis > .aurora-kpi:nth-last-child(-n + 2) {
    grid-column: span 3;
  }
}

@media (max-width: 1180px) and (min-width: 781px) {
  .topbar-greeting-line > span:last-child,
  .topbar-context {
    display: none;
  }

  .top-user-badge {
    min-width: 42px;
    width: 42px;
    grid-template-columns: 30px;
    padding: 5px;
  }

  .top-user-copy,
  .account-menu-chevron {
    display: none;
  }

  .topbar .top-actions > button {
    min-width: 38px;
  }

  #dashboard .dashboard-activity-panel {
    grid-column: span 12;
  }

  #dashboard .dashboard-health-panel,
  #dashboard .dashboard-review-panel,
  #dashboard .dashboard-quality-panel,
  #dashboard .dashboard-todo-panel {
    grid-column: span 6;
  }
}

@media (max-width: 940px) and (min-width: 781px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  #dashboard .dashboard-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #dashboard .dashboard-kpis > .aurora-kpi,
  #dashboard .dashboard-kpis > .aurora-kpi:nth-last-child(-n + 2) {
    grid-column: auto;
  }

  #dashboard .dashboard-kpis > .aurora-kpi:last-child {
    grid-column: 1 / -1;
  }

  #dashboard .dashboard-health-panel,
  #dashboard .dashboard-review-panel,
  #dashboard .dashboard-quality-panel,
  #dashboard .dashboard-todo-panel {
    grid-column: span 12;
  }
}

/* Dialogs follow the visual viewport and never force page-level overflow. */
.modal,
.modal-card,
.brand-asset-upload-modal,
.image-history-modal,
.document-viewer-modal {
  max-width: calc(100vw - 24px);
}

@media (max-height: 760px) and (min-width: 781px) {
  .modal,
  .modal-card,
  .brand-asset-upload-modal,
  .image-history-modal,
  .document-viewer-modal {
    max-height: calc(100dvh - 24px);
  }
}

/* Board knowledge overview: content-level signals only, with no operational or
   editing controls. */
.board-dashboard-heading {
  display: none;
}

body.board-library-mode:not(.guest-mode) #library .board-knowledge-dashboard {
  display: grid;
  gap: 12px;
  padding: clamp(16px, 1.35vw, 22px);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  background: var(--surface-1);
  box-shadow: 0 16px 44px rgba(22, 38, 77, 0.08);
}

body.board-library-mode:not(.guest-mode) #library .board-dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

body.board-library-mode:not(.guest-mode) #library .board-dashboard-heading > div {
  min-width: 0;
}

body.board-library-mode:not(.guest-mode) #library .board-dashboard-heading span {
  display: block;
  margin-bottom: 3px;
  color: var(--accent-cyan);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .13em;
}

body.board-library-mode:not(.guest-mode) #library .board-dashboard-heading h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(18px, 1.25vw, 22px);
  line-height: 1.2;
  letter-spacing: -.02em;
  text-wrap: balance;
}

body.board-library-mode:not(.guest-mode) #library .board-dashboard-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: right;
  text-wrap: pretty;
}

body.board-library-mode:not(.guest-mode) #library .library-kpis {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi {
  min-height: 112px;
  padding: 15px 16px;
  border-radius: 14px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent-blue) 5%, var(--surface-raised)), var(--surface-raised));
  box-shadow: none;
}

body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi strong {
  font-variant-numeric: tabular-nums;
}

body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi:nth-child(2) .aurora-kpi-icon {
  color: var(--accent-cyan);
}

body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi:nth-child(3) .aurora-kpi-icon {
  color: var(--status-success);
}

body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi:nth-child(4) .aurora-kpi-icon {
  color: var(--accent-magenta);
}

body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi:nth-child(5) .aurora-kpi-icon {
  color: var(--accent-violet);
}

body.board-library-mode:not(.guest-mode) #library .library-command-grid {
  display: grid !important;
  gap: 16px;
}

body.board-library-mode:not(.guest-mode) #library .library-command-grid .panel {
  border-radius: 18px;
  box-shadow: 0 16px 44px rgba(22, 38, 77, 0.08);
}

body.board-library-mode:not(.guest-mode) #library .library-upload-panel {
  display: none !important;
}

body.board-library-mode:not(.guest-mode) #library .chart-summary {
  min-height: 3em;
  text-wrap: pretty;
}

@media (max-width: 1180px) {
  body.board-library-mode:not(.guest-mode) #library .library-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi:nth-last-child(-n + 2) {
    grid-column: span 1;
  }
}

@media (max-width: 720px) {
  body.board-library-mode:not(.guest-mode) #library .board-dashboard-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  body.board-library-mode:not(.guest-mode) #library .board-dashboard-heading p {
    text-align: left;
  }

  body.board-library-mode:not(.guest-mode) #library .library-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi:last-child {
    grid-column: 1 / -1;
  }

  body.board-library-mode:not(.guest-mode) #library .library-command-grid {
    gap: 12px;
  }
}

@media (max-width: 440px) {
  body.board-library-mode:not(.guest-mode) #library .board-knowledge-dashboard {
    padding: 14px;
  }

  body.board-library-mode:not(.guest-mode) #library .library-kpis {
    grid-template-columns: 1fr;
  }

  body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi,
  body.board-library-mode:not(.guest-mode) #library .library-kpis .aurora-kpi:last-child {
    min-height: 96px;
    grid-column: auto;
  }
}
