/*
 * Design tokens (color/spacing/radius/shadow/motion/type) live in
 * /shared/design-tokens/tokens.css — loaded BEFORE this file via <link> in
 * index.html. Do NOT redeclare `--ds-*` or theme overrides here.
 */

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
  background: #111827;
  color: #f8fafc;
  border-right: 1px solid #0f172a;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
}

.brand-row strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.brand-row span {
  display: block;
  margin-top: 3px;
  color: #b8c2cc;
  font-size: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #0e7490;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.sidebar-section {
  display: grid;
  gap: 8px;
}

.sidebar-section.grow {
  flex: 1;
  min-height: 0;
}

.section-label,
.eyebrow {
  margin: 0;
  color: #6b7785;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.sidebar .section-label {
  color: #9aa7b4;
}

select,
input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

select,
input {
  padding: 0 12px;
}

textarea {
  display: block;
  padding: 11px 12px;
  line-height: 1.45;
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--ds-input-border-focus);
  box-shadow: 0 0 0 2px var(--ds-input-ring-focus);
}

.recent-list {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  min-height: 0;
}

.recent-item {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 50px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #f8fafc;
  text-align: left;
}

.recent-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

.recent-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-item small {
  color: #9aa7b4;
  font-size: 11px;
}

.main-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 20px;
  font-weight: 750;
  line-height: 1.25;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 240px;
  padding: 0 10px;
  border: 1px solid rgba(14, 116, 144, 0.26);
  border-radius: 8px;
  background: var(--accent-soft);
  color: #0f596b;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.soft {
  border-color: rgba(249, 115, 22, 0.22);
  background: #fff4eb;
  color: #9a4d00;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  flex: 1;
  min-height: 0;
}

.chat-pane,
.context-pane {
  min-height: 0;
}

.chat-pane {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #fbfcfd;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow: auto;
  padding: 32px min(7vw, 72px);
}

.welcome {
  display: grid;
  gap: 12px;
  max-width: 720px;
  margin: auto;
  padding: 8px;
}

.welcome h2 {
  margin: 0;
  font-size: 32px;
  font-weight: 760;
  line-height: 1.12;
}

.welcome p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.prompt-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.prompt-row button,
.feedback-row button {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.prompt-row button:hover,
.feedback-row button:hover,
.secondary-button:hover {
  border-color: var(--accent);
}

.message {
  display: grid;
  grid-template-columns: 42px minmax(0, 760px);
  gap: 12px;
  align-items: start;
}

.message.user {
  justify-content: end;
}

.message-label {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #e9eef3;
  color: #435160;
  font-size: 12px;
  font-weight: 800;
}

.message.user .message-label {
  background: #fff4eb;
  color: #9a4d00;
}

.message-body {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.message.user .message-body {
  border-color: rgba(14, 116, 144, 0.24);
  background: var(--accent-soft);
}

.message.pending .message-body {
  color: var(--muted);
}

.message.failed .message-body {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff1f0;
  color: var(--danger);
}

.message-body p {
  margin: 0 0 10px;
  line-height: 1.65;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body pre,
.mini-card code {
  display: block;
  overflow: auto;
  max-width: 100%;
  margin: 12px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.feedback-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.feedback-note {
  margin-top: 12px;
  color: var(--success);
  font-size: 13px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 10px;
  padding: 16px min(7vw, 72px) 22px;
  background: linear-gradient(180deg, rgba(251, 252, 253, 0.1), #fbfcfd 34%);
}

.composer textarea {
  max-height: 180px;
  min-height: 48px;
  border-color: #cdd5de;
  box-shadow: var(--shadow);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 750;
}

.primary-button {
  border: 1px solid var(--ds-button-primary-bg);
  background: var(--ds-button-primary-bg);
  color: var(--ds-button-primary-fg);
}

.primary-button:hover {
  background: var(--ds-button-primary-bg-hover);
  border-color: var(--ds-button-primary-bg-hover);
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.wide {
  width: 100%;
}

.context-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.tab-button.active {
  border-color: rgba(14, 116, 144, 0.2);
  background: var(--accent-soft);
  color: #0f596b;
}

.tab-content {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.panel-block {
  display: grid;
  gap: 10px;
}

.panel-block h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.panel-block p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ops-status-panel {
  gap: 12px;
}

.ops-status-head,
.ops-status-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ops-status-head h2 {
  margin-top: 3px;
}

.ops-status-summary {
  align-items: flex-start;
}

.ops-version-code {
  overflow: hidden;
  max-width: 190px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ops-status-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  min-height: 94px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.ops-status-card strong,
.ops-status-card span,
.ops-status-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-status-card strong {
  color: var(--ink);
  font-size: 12px;
}

.ops-status-card span {
  font-size: 13px;
  font-weight: 760;
}

.ops-status-card small {
  color: var(--muted);
  font-size: 11px;
}

.ops-status-card.is-ok,
.status-pill.is-ok {
  border-color: rgba(22, 163, 74, 0.24);
  background: #ecfdf3;
  color: #166534;
}

.ops-status-card.is-warning,
.status-pill.is-warning {
  border-color: rgba(217, 119, 6, 0.24);
  background: #fffbeb;
  color: #92400e;
}

.ops-status-card.is-error,
.status-pill.is-error {
  border-color: rgba(220, 38, 38, 0.24);
  background: #fef2f2;
  color: #991b1b;
}

.ops-meta-list {
  margin-top: 0;
}

.upload-form,
.run-form {
  display: grid;
  gap: 8px;
}

.upload-form {
  grid-template-columns: minmax(0, 1fr) 104px 92px;
}

.upload-form .secondary-button {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.app-menu-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-menu-chip {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(14, 116, 144, 0.24);
  border-radius: 8px;
  background: var(--accent-soft);
  color: #0f596b;
  font-size: 12px;
  font-weight: 750;
}

.app-menu-chip:hover {
  border-color: var(--accent);
  background: #d9f0f5;
}

.app-detail-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(14, 116, 144, 0.2);
  border-radius: 8px;
  background: #f8fbfc;
}

.app-detail-panel h3 {
  margin: 2px 0 0;
  font-size: 17px;
  line-height: 1.25;
}

.app-detail-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.app-workflow-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(14, 116, 144, 0.2);
  border-radius: 8px;
  background: #f8fbfc;
}

.app-workflow-head h3 {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.3;
}

.app-workflow-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-workflow-steps li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.app-workflow-steps li > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(14, 116, 144, 0.22);
  border-radius: 999px;
  background: #ffffff;
  color: #0f596b;
  font-size: 11px;
  font-weight: 800;
}

.app-workflow-steps strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.app-workflow-steps small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.app-workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.app-workflow-actions span {
  min-height: 28px;
  padding: 6px 9px;
  border: 1px solid rgba(14, 116, 144, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #0f596b;
  font-size: 12px;
  font-weight: 750;
}

.app-input-fields {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(14, 116, 144, 0.18);
  border-radius: 8px;
  background: #f8fbfc;
}

.app-input-head {
  display: grid;
  gap: 3px;
}

.app-input-head span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.app-input-field {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
}

.app-input-field small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.app-input-field--checkbox {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.app-input-field--checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.app-detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.app-detail-meta div {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.app-detail-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.app-detail-meta dd {
  min-width: 0;
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.app-result-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(14, 116, 144, 0.22);
  border-radius: 8px;
  background: #f8fbfc;
}

.app-result-card strong {
  font-size: 14px;
  line-height: 1.35;
}

.operator-progress-panel {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(14, 116, 144, 0.14);
}

.operator-progress-current-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.operator-progress-current-step div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.operator-progress-current-step small,
.operator-progress-milestone small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.operator-progress-current-step strong,
.operator-progress-step strong,
.operator-progress-milestone strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.operator-progress-counts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.operator-progress-counts div {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

.operator-progress-counts b {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.1;
}

.operator-progress-counts em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 720;
}

.operator-progress-steps,
.operator-progress-milestones {
  display: grid;
  gap: 6px;
}

.operator-progress-step,
.operator-progress-milestone {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  font-size: 12px;
}

.operator-progress-step.is-current {
  border-color: rgba(14, 116, 144, 0.24);
  background: rgba(236, 253, 245, 0.72);
}

.operator-progress-milestone {
  grid-template-columns: auto minmax(0, 1fr);
}

.operator-progress-milestone small {
  grid-column: 2;
}

.operator-progress-status {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.operator-progress-status--completed,
.operator-progress-status--done,
.operator-progress-status--available {
  background: #dcfce7;
  color: #166534;
}

.operator-progress-status--waiting,
.operator-progress-status--waiting-input,
.operator-progress-status--running {
  background: #fef3c7;
  color: #92400e;
}

.operator-progress-status--failed {
  background: #fee2e2;
  color: #991b1b;
}

.required-input-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(14, 116, 144, 0.2);
  border-radius: 8px;
  background: #ffffff;
}

.required-input-head {
  display: grid;
  gap: 3px;
}

.required-input-head strong {
  font-size: 14px;
}

.required-input-head small,
.required-input-field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.required-input-field {
  display: grid;
  gap: 5px;
  font-size: 13px;
  font-weight: 720;
}

.required-input-actions {
  display: flex;
  justify-content: flex-end;
}

.workflow-action-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(14, 116, 144, 0.16);
  border-radius: 8px;
  background: rgba(248, 251, 252, 0.88);
}

.workflow-action-head {
  display: grid;
  gap: 2px;
}

.workflow-action-head small,
.workflow-action-head span,
.approved-manual-map-form small,
.submission-readiness-row small,
.required-document-row small,
.company-context-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.submission-readiness-panel,
.required-documents-panel,
.company-context-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(14, 116, 144, 0.14);
  border-radius: 8px;
  background: #ffffff;
}

.submission-readiness-list,
.required-documents-list,
.company-context-list {
  display: grid;
  gap: 8px;
}

.submission-readiness-group {
  display: grid;
  gap: 6px;
}

.submission-readiness-group > b {
  color: #334155;
  font-size: 12px;
  font-weight: 850;
}

.submission-readiness-row {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  background: #f8fafc;
}

.submission-readiness-row span {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.submission-readiness-row.is-blocking {
  border-color: rgba(185, 28, 28, 0.28);
  background: #fff7f7;
}

.submission-readiness-row.is-renewal {
  border-color: rgba(180, 83, 9, 0.28);
  background: #fffbeb;
}

.submission-readiness-row.is-public-mydata {
  border-color: rgba(3, 105, 161, 0.24);
  background: #f0f9ff;
}

.submission-readiness-row.is-deferred {
  border-color: rgba(71, 85, 105, 0.22);
  background: #f8fafc;
}

.required-document-row,
.company-context-row {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: #f8fafc;
}

.required-document-row b,
.company-context-row b {
  color: #0f596b;
  font-size: 12px;
  font-weight: 850;
}

.required-document-row strong,
.company-context-row span {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.required-document-row.is-blocking {
  border-color: rgba(185, 28, 28, 0.28);
  background: #fff7f7;
}

.required-document-row.is-blocking b {
  color: #b91c1c;
}

.company-context-row.is-muted {
  opacity: 0.68;
}

.workflow-action-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.workflow-action-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(14, 116, 144, 0.22);
  border-radius: 8px;
  background: #ffffff;
  color: #0f596b;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.workflow-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.approved-manual-map-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: end;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  background: #ffffff;
}

.approved-manual-map-form > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.approved-manual-map-form strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.evidence-card {
  margin-top: 12px;
  border: 1px solid rgba(14, 116, 144, 0.22);
  border-radius: 8px;
  background: #f8fbfc;
}

.evidence-card summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  padding: 11px 12px;
  color: #0f596b;
  font-weight: 800;
}

.evidence-card summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}

.evidence-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 10px;
}

.evidence-meta span,
.evidence-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.source-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.source-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.source-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.source-card-head strong,
.source-card-head span {
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.source-card-head span {
  color: var(--muted);
  white-space: nowrap;
}

.source-snippet {
  margin: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
}

.evidence-note {
  margin: 0;
  padding: 0 12px 12px;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.document-actions button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.document-actions button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.run-form label,
.login-card label {
  display: grid;
  gap: 7px;
  color: #425160;
  font-size: 13px;
  font-weight: 700;
}

.item-list {
  display: grid;
  gap: 8px;
}

.mini-card,
.app-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.mini-card {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.mini-card.selected-document {
  border-color: rgba(14, 116, 144, 0.42);
  background: #f0fafc;
  box-shadow: inset 3px 0 0 var(--accent);
}

.mini-card strong,
.app-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
}

.mini-card span,
.app-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.app-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 11px;
  color: var(--ink);
  text-align: left;
}

.app-card:hover,
.app-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.app-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.context-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.context-list div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.context-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.context-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.empty-note {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.noise-note {
  margin: 6px 0 0;
  padding: 0 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

/* .login-dialog uses ds-modal Tier 3 tokens (71 §4.2).
 * Aligned to ds-modal--sm (560px) per Phase 3.3 user confirm (2026-05-24). */
.login-dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--ds-modal-border);
  border-radius: var(--ds-modal-radius);
  box-shadow: var(--ds-modal-shadow);
  background: var(--ds-modal-surface);
  outline: none;
}

.login-dialog::backdrop {
  background: var(--ds-modal-overlay);
}

.login-card {
  display: grid;
  gap: var(--ds-space-4);
  padding: var(--ds-space-6);
  background: var(--ds-modal-surface);
}

.login-card h2 {
  margin: 3px 0 0;
  font-size: 22px;
}

.subtle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.error-text {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

/* Enterprise AI Workspace product refresh */
body {
  background:
    linear-gradient(180deg, rgba(79, 70, 229, 0.035), transparent 280px),
    var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

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

.sidebar {
  gap: 16px;
  padding: 20px 16px;
  background:
    linear-gradient(180deg, var(--ds-color-sidebar-2), var(--ds-color-sidebar));
  border-right: 1px solid rgba(226, 232, 240, 0.08);
}

.brand-mark {
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.26);
}

.theme-toggle {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 800;
  transition: background var(--motion), border-color var(--motion), transform var(--motion);
}

.theme-toggle:hover,
.nav-item:hover,
.nav-item.active {
  border-color: rgba(34, 211, 238, 0.38);
  background: rgba(255, 255, 255, 0.1);
}

.theme-toggle:hover,
.nav-item:hover {
  transform: translateY(-1px);
}

.nav-section {
  gap: 7px;
}

.nav-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  transition: background var(--motion), border-color var(--motion), transform var(--motion);
}

.nav-item span {
  font-size: 14px;
  font-weight: 820;
  line-height: 1.25;
}

.nav-item small {
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.3;
}

select,
input,
textarea {
  border-color: var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
}

.main-pane {
  background: var(--bg);
}

.workspace-hero {
  min-height: 96px;
  padding: 22px 30px;
  background: var(--ds-color-surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.hero-copy {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status-pill {
  min-height: 34px;
  border-radius: 999px;
  border-color: rgba(79, 70, 229, 0.22);
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill.soft {
  border-color: rgba(6, 182, 212, 0.24);
  background: var(--ds-color-cyan-soft);
  color: #0891b2;
}

.status-pill.glass {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink-soft);
}

[data-theme="dark"] .status-pill.glass {
  background: rgba(255, 255, 255, 0.06);
}

.workbench {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
}

.chat-pane {
  background:
    linear-gradient(180deg, rgba(6, 182, 212, 0.04), transparent 300px),
    var(--bg);
}

.message-list {
  gap: 20px;
  padding: 36px min(6vw, 72px);
}

.workspace-welcome {
  width: min(1120px, 100%);
  max-width: none;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  align-items: center;
  margin: auto;
  gap: 22px;
}

.welcome-intro,
.artifact-workspace,
.app-command-grid button {
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  background: var(--ds-color-surface);
  box-shadow: var(--shadow-panel);
}

.welcome-intro {
  display: grid;
  gap: 14px;
  padding: clamp(22px, 4vw, 38px);
}

.welcome h2 {
  max-width: 760px;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: 0;
}

.artifact-workspace {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.artifact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.artifact-head h3 {
  margin: 3px 0 0;
  font-size: 22px;
}

.artifact-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.artifact-preview-grid {
  display: grid;
  gap: 10px;
}

.artifact-preview-card {
  display: grid;
  gap: 5px;
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.artifact-preview-card strong {
  font-size: 14px;
}

.artifact-preview-card span {
  color: var(--muted);
  font-size: 12px;
}

.app-command-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.app-command-grid button {
  display: grid;
  gap: 5px;
  min-height: 90px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  transition: border-color var(--motion), transform var(--motion), box-shadow var(--motion);
}

.app-command-grid button:hover,
.prompt-row button:hover,
.mini-card:hover,
.app-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.app-command-grid strong {
  font-size: 15px;
}

.app-command-grid span {
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-head h3 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.prompt-row button,
.feedback-row button,
.message-label,
.message-body,
.mini-card,
.app-card,
.app-detail-panel,
.app-workflow-panel,
.app-input-fields,
.evidence-card,
.source-card,
.app-result-card,
.empty-note,
.document-actions button,
.app-menu-chip,
.login-dialog,
.login-card {
  border-radius: var(--radius-lg);
}

.message {
  grid-template-columns: 42px minmax(0, 820px);
}

.message-body {
  background: var(--ds-color-surface);
  box-shadow: var(--shadow-panel);
}

.message.user .message-body {
  border-color: rgba(79, 70, 229, 0.22);
  background: var(--accent-soft);
}

.message-body h3,
.message-body h4,
.message-body h5 {
  margin: 16px 0 9px;
  color: var(--ink);
  line-height: 1.25;
}

.message-body h3 {
  font-size: 20px;
}

.message-body h4,
.message-body h5 {
  font-size: 16px;
}

.message-body code:not(pre code) {
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.message-body pre,
.code-block,
.mini-card code {
  border-radius: var(--radius-lg);
  background: #0b1020;
}

.list-line {
  padding-left: 2px;
}

.markdown-table-wrap {
  overflow: auto;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.markdown-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  background: var(--surface);
  font-size: 13px;
}

.markdown-table th,
.markdown-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown-table th {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 800;
}

.thinking-state {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.thinking-orb {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: conic-gradient(from 180deg, var(--accent), var(--accent-2), var(--accent));
  animation: spin 1.4s linear infinite;
}

.workflow-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.workflow-progress span {
  min-height: 28px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.workflow-progress span.active {
  border-color: rgba(79, 70, 229, 0.22);
  background: var(--accent-soft);
  color: var(--accent);
}

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

.composer {
  grid-template-columns: minmax(0, 1fr) 96px;
  background: linear-gradient(180deg, transparent, var(--bg) 35%);
}

.composer textarea {
  border-radius: var(--radius-xl);
  background: var(--ds-color-surface);
  box-shadow: var(--shadow-float, var(--shadow));
}

.primary-button,
.secondary-button {
  border-radius: var(--radius-md);
}

.primary-button {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.context-pane {
  background: var(--ds-color-surface);
  border-left: 1px solid var(--line);
}

.tabs {
  display: flex;
  overflow-x: auto;
  grid-template-columns: none;
  gap: 6px;
  padding: 13px;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 36px;
  border-radius: 999px;
  padding: 0 12px;
}

.tab-button.active {
  border-color: rgba(79, 70, 229, 0.22);
  background: var(--accent-soft);
  color: var(--accent);
}

.tab-content {
  gap: 16px;
  padding: 18px;
}

.panel-block h2 {
  font-size: 17px;
}

.tool-status-list,
.workflow-timeline,
.knowledge-grid {
  display: grid;
  gap: 10px;
}

.tool-status-card,
.workflow-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.tool-status-card small,
.workflow-step small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot,
.workflow-step > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.workflow-step.active {
  border-color: rgba(79, 70, 229, 0.26);
  background: linear-gradient(180deg, var(--surface), var(--accent-soft));
}

.source-list.compact {
  padding: 0;
}

[data-theme="dark"] .sidebar .section-label,
[data-theme="dark"] .brand-row span {
  color: #94a3b8;
}

[data-theme="dark"] .upload-form .secondary-button,
[data-theme="dark"] .prompt-row button,
[data-theme="dark"] .feedback-row button,
[data-theme="dark"] .document-actions button {
  background: var(--surface);
  color: var(--ink);
}

[data-theme="dark"] .source-snippet {
  color: var(--ds-color-ink-soft);
}

@media (max-width: 1100px) {
  .workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .context-pane {
    min-height: 0;
    max-height: min(520px, 48vh);
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
  }

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

  .sidebar-section.grow {
    max-height: min(260px, 38vh);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .status-stack {
    justify-content: flex-start;
  }

  .message-list {
    padding: 22px 16px;
  }

  .message {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .message-label {
    width: 32px;
    height: 32px;
  }

  .prompt-row {
    grid-template-columns: 1fr;
  }

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

  .composer {
    grid-template-columns: 1fr;
    padding: 12px 16px 16px;
  }

  .upload-form {
    grid-template-columns: 1fr;
  }
}

/* AI Native reference adaptation: light-first product workspace */
.app-shell {
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94)),
    var(--surface);
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.7);
}

.brand-row strong,
.nav-item span,
.recent-item span {
  color: var(--ink);
}

.brand-row span,
.nav-item small,
.recent-item small,
.sidebar .section-label {
  color: var(--muted);
}

.brand-mark {
  border: 0;
  border-radius: 18px;
}

.theme-toggle {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.theme-toggle:hover,
.nav-item:hover,
.nav-item.active {
  border-color: rgba(79, 70, 229, 0.18);
  background: linear-gradient(180deg, #ffffff, #f3f6ff);
}

.nav-item {
  color: var(--ink);
}

.recent-item {
  color: var(--ink);
}

.recent-item:hover {
  border-color: rgba(79, 70, 229, 0.16);
  background: #f8faff;
}

.sidebar select {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.sidebar .secondary-button {
  border-color: var(--line);
  background: #111827;
  color: #ffffff;
}

[data-theme="dark"] .sidebar {
  background:
    linear-gradient(180deg, var(--ds-color-sidebar-2), var(--ds-color-sidebar));
  color: #f8fafc;
  border-right-color: rgba(226, 232, 240, 0.08);
}

[data-theme="dark"] .brand-row strong,
[data-theme="dark"] .nav-item span,
[data-theme="dark"] .recent-item span {
  color: #f8fafc;
}

[data-theme="dark"] .theme-toggle {
  border-color: rgba(226, 232, 240, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

[data-theme="dark"] .theme-toggle:hover,
[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .nav-item.active {
  border-color: rgba(34, 211, 238, 0.38);
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .recent-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .sidebar .secondary-button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.workspace-hero {
  position: sticky;
  top: 0;
  z-index: 20;
}

.context-pane {
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(18px);
}

[data-theme="dark"] .context-pane {
  background: rgba(24, 24, 27, 0.86);
}

.context-panel-head {
  padding: 4px 2px 2px;
}

.context-panel-head h2 {
  margin-top: 3px;
  font-size: 19px;
}

/* Calm Portal v1: ChatGPT/Claude-style product surface */
.app-shell {
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  gap: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
}

.brand-row {
  min-height: 42px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 12px;
}

.new-chat-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #111827;
  color: #ffffff;
  font-weight: 800;
}

.new-chat-button:hover {
  background: #020617;
}

.nav-section {
  gap: 5px;
}

.nav-item {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
}

.nav-item span {
  font-size: 14px;
}

.nav-item small {
  display: none;
}

.recent-list {
  gap: 3px;
}

.recent-item {
  min-height: 38px;
  padding: 8px 10px;
}

.theme-toggle {
  min-height: 34px;
}

.workspace-hero {
  min-height: 76px;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.86);
}

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

.hero-copy {
  font-size: 13px;
}

.status-stack {
  gap: 6px;
}

.status-pill {
  min-height: 30px;
  font-size: 11px;
}

.workbench {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
}

html[data-portal-tab="home"] .workbench {
  grid-template-columns: minmax(0, 1fr);
}

html[data-portal-tab="home"] .context-pane {
  display: none;
}

.chat-pane {
  background:
    radial-gradient(circle at 50% 12%, rgba(79, 70, 229, 0.06), transparent 32%),
    #ffffff;
}

.message-list {
  padding: 36px clamp(22px, 7vw, 96px);
}

.calm-chat-home {
  width: min(760px, 100%);
  max-width: none;
  justify-items: center;
  align-self: center;
  margin: auto;
  gap: 18px;
  padding: 24px 8px 18px;
  text-align: center;
}

.home-project-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: min(100%, 620px);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calm-chat-home h2 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 760;
  line-height: 1.18;
  letter-spacing: 0;
  word-break: keep-all;
}

.calm-chat-home p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
  word-break: keep-all;
}

.quick-start-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(640px, 100%);
  margin-top: 8px;
}

.quick-start-grid button {
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
  text-align: left;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color var(--motion), box-shadow var(--motion), transform var(--motion);
}

.quick-start-grid button:hover {
  border-color: rgba(79, 70, 229, 0.26);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.composer {
  width: min(760px, calc(100% - 44px));
  margin: 0 auto;
  padding: 0 0 28px;
  background: transparent;
}

.composer textarea {
  min-height: 58px;
  border-radius: 18px;
  background: #ffffff;
}

.composer .primary-button {
  min-height: 58px;
  border-radius: 18px;
  background: #111827;
}

.context-pane {
  background: rgba(255, 255, 255, 0.92);
}

.right-panel-empty {
  display: none;
}

[data-theme="dark"] .sidebar {
  background: rgba(9, 9, 11, 0.96);
}

[data-theme="dark"] .new-chat-button {
  background: #f8fafc;
  color: #09090b;
}

[data-theme="dark"] .chat-pane {
  background:
    radial-gradient(circle at 50% 12%, rgba(129, 140, 248, 0.11), transparent 32%),
    var(--bg);
}

[data-theme="dark"] .home-project-pill,
[data-theme="dark"] .quick-start-grid button,
[data-theme="dark"] .composer textarea {
  background: rgba(24, 24, 27, 0.88);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .nav-item {
    justify-content: start;
    text-align: left;
  }

  .workspace-hero {
    display: none;
  }

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

  .composer {
    width: calc(100% - 28px);
    grid-template-columns: 1fr;
  }
}

.mini-card,
.app-card,
.app-detail-panel,
.app-workflow-panel,
.app-input-fields,
.source-card,
.tool-status-card,
.workflow-step {
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .mini-card,
[data-theme="dark"] .app-card,
[data-theme="dark"] .app-detail-panel,
[data-theme="dark"] .app-workflow-panel,
[data-theme="dark"] .app-input-fields,
[data-theme="dark"] .source-card,
[data-theme="dark"] .tool-status-card,
[data-theme="dark"] .workflow-step {
  background: rgba(24, 24, 27, 0.92);
}

.document-actions button {
  border-radius: 999px;
}

.message-body {
  border-radius: var(--radius-xl);
}

.message-label {
  border-radius: 14px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

/* Artifact Canvas v1 */
html[data-portal-tab="outputs"] .workbench {
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 0.78fr);
}

.artifact-studio {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(320px, 1.08fr);
  align-items: start;
  gap: 14px;
}

.artifact-library,
.artifact-canvas-shell {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.artifact-library {
  padding: 14px;
  max-height: 70vh;
  overflow: auto;
}

.artifact-canvas-shell {
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(79, 70, 229, 0.04), transparent 180px),
    rgba(255, 255, 255, 0.92);
}

.empty-artifact-canvas {
  min-height: 220px;
  align-content: center;
}

.artifact-list-item {
  color: var(--ink);
  text-align: left;
}

.artifact-path-line {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-list-item.selected-artifact {
  border-color: rgba(79, 70, 229, 0.36);
  background: linear-gradient(180deg, #ffffff, #f4f6ff);
  box-shadow: inset 3px 0 0 var(--accent);
}

.artifact-preview-button {
  width: 100%;
  color: var(--ink);
  text-align: left;
}

.artifact-canvas-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.artifact-canvas-toolbar h3 {
  margin: 3px 0 0;
  font-size: 20px;
  line-height: 1.25;
  word-break: keep-all;
}

.artifact-canvas-toolbar p:not(.eyebrow) {
  max-width: 100%;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.artifact-mode-switch {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.artifact-mode-switch button {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.artifact-mode-switch button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.artifact-meta-row,
.artifact-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.artifact-meta-row span {
  min-height: 28px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.artifact-action-row button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 820;
}

.artifact-action-row button:hover {
  border-color: rgba(79, 70, 229, 0.26);
  background: var(--accent-soft);
}

.artifact-action-row .primary-inline {
  border-color: transparent;
  background: #111827;
  color: #ffffff;
}

.artifact-canvas-body {
  min-width: 0;
}

.artifact-document-preview,
.artifact-editor {
  width: 100%;
  min-height: 420px;
  max-height: 58vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.artifact-document-preview {
  padding: 18px;
}

.artifact-document-preview p,
.artifact-document-preview .list-line {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

.artifact-document-preview h3,
.artifact-document-preview h4,
.artifact-document-preview h5 {
  margin: 18px 0 10px;
  color: var(--ink);
}

.artifact-editor {
  padding: 16px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.artifact-version-rail {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.artifact-version-rail > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.artifact-version-rail strong {
  font-size: 13px;
}

.artifact-version-list {
  display: grid;
  gap: 8px;
}

.artifact-version-list button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 2px 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.artifact-version-list button.active {
  border-color: rgba(79, 70, 229, 0.3);
  background: var(--accent-soft);
}

.artifact-version-list button > span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.artifact-version-list small {
  color: var(--muted);
  font-size: 11px;
}

[data-theme="dark"] .artifact-library,
[data-theme="dark"] .artifact-canvas-shell,
[data-theme="dark"] .artifact-document-preview,
[data-theme="dark"] .artifact-editor,
[data-theme="dark"] .artifact-list-item.selected-artifact {
  background: rgba(24, 24, 27, 0.9);
}

[data-theme="dark"] .artifact-action-row .primary-inline {
  background: #f8fafc;
  color: #09090b;
}

@media (max-width: 1200px) {
  html[data-portal-tab="outputs"] .workbench {
    grid-template-columns: 1fr;
  }

  .artifact-studio {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .artifact-canvas-toolbar {
    display: grid;
  }

  .artifact-mode-switch {
    width: fit-content;
  }

  .artifact-document-preview,
  .artifact-editor {
    min-height: 320px;
  }
}

/* Premium Product Detail System v1 */
:root {
  --premium-surface: var(--ds-color-surface);
  --premium-surface-strong: var(--ds-color-surface-solid);
  --premium-border: var(--ds-color-line);
  --premium-shadow: var(--ds-shadow-xs);
}

.premium-product-shell-v1 {
  font-family: var(--ds-font-family-sans);
  font-size: var(--ds-text-body-15);
  line-height: var(--ds-leading-reading);
  background:
    radial-gradient(circle at 52% 8%, rgba(79, 70, 229, 0.075), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #f7f8fb 42%, #f4f7fb 100%);
}

[data-theme="dark"] .premium-product-shell-v1 {
  background:
    radial-gradient(circle at 52% 8%, rgba(129, 140, 248, 0.12), transparent 28%),
    linear-gradient(180deg, #09090b 0%, #111113 100%);
}

.premium-product-shell-v1 .app-shell {
  grid-template-columns: 268px minmax(0, 1fr);
}

.premium-product-shell-v1 .sidebar {
  padding: 18px 14px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(22px);
}

.premium-product-shell-v1 .brand-row strong {
  font-size: var(--ds-text-title-18);
  font-weight: var(--ds-weight-semibold);
}

.premium-product-shell-v1 .section-label,
.premium-product-shell-v1 .eyebrow {
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-semibold);
  letter-spacing: 0;
}

.premium-product-shell-v1 .nav-item {
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  min-height: 40px;
  padding: 7px 10px;
  border-radius: 12px;
  transition: var(--ds-motion-hover);
}

.premium-product-shell-v1 .nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--premium-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent);
  font-size: 11px;
  font-weight: var(--ds-weight-semibold);
}

.premium-product-shell-v1 .nav-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.premium-product-shell-v1 .recent-item,
.premium-product-shell-v1 .new-chat-button,
.premium-product-shell-v1 .theme-toggle {
  transition: var(--ds-motion-hover);
}

.workspace-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.workspace-cover {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(79, 70, 229, 0.95), rgba(6, 182, 212, 0.9)),
    #4f46e5;
  color: #ffffff;
  font-weight: var(--ds-weight-bold);
  box-shadow: 0 16px 38px rgba(79, 70, 229, 0.22);
}

.premium-product-shell-v1 .workspace-hero {
  min-height: 82px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--ds-shadow-hairline, 0 1px 0 rgba(15, 23, 42, 0.05));
}

.premium-product-shell-v1 .topbar h1 {
  font-size: var(--ds-text-title-20);
  font-weight: var(--ds-weight-semibold);
  line-height: var(--ds-leading-title);
}

.state-indicator {
  position: relative;
  gap: 7px;
  font-weight: var(--ds-weight-semibold);
}

.state-indicator::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 14%, transparent);
}

.premium-product-shell-v1 .chat-pane {
  background:
    radial-gradient(circle at 50% 12%, rgba(79, 70, 229, 0.075), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 250, 252, 0.98));
}

.premium-product-shell-v1 .calm-chat-home {
  animation: fade-in-up 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.premium-product-shell-v1 .calm-chat-home h2 {
  font-size: clamp(34px, 4.4vw, var(--ds-text-display-40));
  font-weight: var(--ds-weight-semibold);
  line-height: var(--ds-leading-tight);
}

.premium-product-shell-v1 .calm-chat-home p,
.premium-product-shell-v1 .message-body p,
.premium-product-shell-v1 .artifact-document-preview p {
  font-size: var(--ds-text-body-15);
  line-height: var(--ds-leading-reading);
  font-weight: var(--ds-weight-regular);
}

.premium-card,
.premium-product-shell-v1 .mini-card,
.premium-product-shell-v1 .app-card,
.premium-product-shell-v1 .app-detail-panel,
.premium-product-shell-v1 .app-workflow-panel,
.premium-product-shell-v1 .app-input-fields,
.premium-product-shell-v1 .artifact-library,
.premium-product-shell-v1 .artifact-canvas-shell,
.premium-product-shell-v1 .evidence-card,
.premium-product-shell-v1 .source-card {
  border-color: var(--premium-border);
  background: var(--premium-surface-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.soft-hover-lift,
.premium-product-shell-v1 .quick-start-grid button,
.premium-product-shell-v1 .mini-card,
.premium-product-shell-v1 .app-card,
.premium-product-shell-v1 .artifact-preview-card,
.premium-product-shell-v1 .artifact-action-row button {
  transition: var(--ds-motion-hover);
}

.soft-hover-lift:hover,
.premium-product-shell-v1 .quick-start-grid button:hover,
.premium-product-shell-v1 .mini-card:hover,
.premium-product-shell-v1 .app-card:hover,
.premium-product-shell-v1 .artifact-preview-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--premium-shadow);
}

.result-highlight {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.result-highlight span {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(79, 70, 229, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-semibold);
}

.app-result-card.result-highlight {
  display: grid;
  justify-content: stretch;
}

.ai-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  box-shadow: 0 10px 26px rgba(79, 70, 229, 0.2);
}

.premium-product-shell-v1 .message {
  grid-template-columns: 38px minmax(0, 780px);
}

.premium-product-shell-v1 .message-body {
  padding: 16px 18px;
  border-color: var(--premium-border);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.streaming-cursor {
  display: inline-block;
  width: 7px;
  height: 1.12em;
  margin-left: 5px;
  border-radius: 999px;
  background: var(--accent);
  vertical-align: -2px;
  animation: streaming-cursor var(--ds-motion-streaming, 900ms steps(2, jump-none) infinite);
}

.composer-surface {
  display: grid;
  gap: 8px;
  width: min(790px, calc(100% - 44px));
  padding: 10px;
  border: 1px solid var(--premium-border);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 56px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(18px);
}

.composer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 4px;
}

.composer-tool-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.86);
  color: var(--muted);
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-semibold);
}

.composer-tool-button:hover {
  border-color: rgba(79, 70, 229, 0.22);
  background: var(--accent-soft);
  color: var(--accent);
}

.composer-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
  align-items: end;
}

.composer-surface textarea {
  min-height: 52px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  font-size: var(--ds-text-body-15);
  line-height: var(--ds-leading-body);
}

.composer-surface textarea:focus {
  box-shadow: none;
}

.artifact-live-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--ds-color-cyan-soft);
  color: #0891b2;
  font-size: 10px;
  font-weight: var(--ds-weight-bold);
  text-transform: none;
}

.premium-product-shell-v1 .artifact-document-preview {
  font-size: var(--ds-text-body-15);
  line-height: var(--ds-leading-document);
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes streaming-cursor {
  50% {
    opacity: 0;
  }
}

[data-theme="dark"] .premium-product-shell-v1 .sidebar,
[data-theme="dark"] .composer-surface,
[data-theme="dark"] .result-highlight span {
  background: rgba(24, 24, 27, 0.86);
}

[data-theme="dark"] .premium-product-shell-v1 .workspace-hero {
  background: rgba(9, 9, 11, 0.72);
}

@media (max-width: 900px) {
  .composer-surface {
    width: calc(100% - 28px);
  }

  .composer-input-row {
    grid-template-columns: 1fr;
  }
}

/* AI Workspace Product Renewal v28 */
:root {
  --ds-leading-body: 1.58;
}

.service-product-v28 {
  background:
    radial-gradient(circle at 50% 14%, rgba(79, 70, 229, 0.06), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #fafbfc 56%, #f7f8fb 100%);
}

.service-product-v28 .app-shell {
  grid-template-columns: 260px minmax(0, 1fr);
}

.service-product-v28 .sidebar {
  padding: 18px 14px 16px;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: none;
}

.service-product-v28 .brand-row {
  padding: 0 2px 8px;
}

.service-product-v28 .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 13px;
  box-shadow: 0 10px 26px rgba(79, 70, 229, 0.18);
}

.service-product-v28 .brand-row strong {
  font-size: 16px;
  font-weight: 680;
  line-height: 1.18;
}

.service-product-v28 .new-chat-button {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  background: #0f172a;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
}

.service-product-v28 .project-switcher {
  padding: 4px 0 2px;
}

.service-product-v28 .nav-section {
  gap: 3px;
}

.service-product-v28 .nav-item {
  grid-template-columns: 26px minmax(0, 1fr);
  min-height: 38px;
  padding: 7px 9px;
  border-radius: 11px;
  color: var(--ink-soft);
}

.service-product-v28 .nav-item.active {
  border-color: rgba(79, 70, 229, 0.14);
  background: #f6f7ff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.service-product-v28 .nav-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: #ffffff;
}

.service-product-v28 .recent-item {
  min-height: 36px;
  border-radius: 10px;
}

html[data-portal-tab="home"] .service-product-v28 .workspace-hero {
  display: none;
}

.service-product-v28 .chat-pane {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 28%, rgba(79, 70, 229, 0.055), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

.service-product-v28 .message-list {
  padding: clamp(42px, 9vh, 92px) clamp(22px, 7vw, 104px) 28px;
}

.service-product-v28 .calm-chat-home {
  width: min(720px, 100%);
  gap: 17px;
  padding-top: 0;
}

.service-product-v28 .home-project-pill {
  min-height: 32px;
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.86);
  color: #667085;
}

.service-product-v28 .calm-chat-home h2 {
  font-size: clamp(34px, 4.2vw, 44px);
  font-weight: 680;
  line-height: 1.16;
}

.service-product-v28 .quick-start-grid button {
  min-height: 48px;
  border-radius: 15px;
  font-weight: 680;
}

.service-product-v28 .result-highlight span {
  color: #667085;
}

.service-product-v28 .composer-surface {
  width: min(790px, calc(100% - 48px));
  margin-bottom: 22px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 56px rgba(15, 23, 42, 0.13);
}

.service-product-v28 .composer-toolbar {
  align-items: center;
}

.composer-model-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-left: auto;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-semibold);
}

.service-product-v28 .composer-surface textarea {
  min-height: 54px;
}

.service-product-v28 .composer .primary-button {
  min-height: 52px;
  border: 0;
  border-radius: 18px;
  background: #0f172a;
}

.service-product-v28 .context-pane {
  background: rgba(255, 255, 255, 0.96);
}

[data-theme="dark"] .service-product-v28 {
  background:
    radial-gradient(circle at 50% 14%, rgba(129, 140, 248, 0.13), transparent 28%),
    linear-gradient(180deg, #09090b 0%, #101014 100%);
}

[data-theme="dark"] .service-product-v28 .sidebar,
[data-theme="dark"] .service-product-v28 .chat-pane,
[data-theme="dark"] .service-product-v28 .composer-surface {
  background: rgba(15, 15, 18, 0.96);
}

[data-theme="dark"] .service-product-v28 .nav-item.active {
  background: rgba(129, 140, 248, 0.14);
}

[data-theme="dark"] .composer-model-pill {
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 900px) {
  .service-product-v28 .app-shell {
    grid-template-columns: 1fr;
  }

  .service-product-v28 .chat-pane {
    min-height: calc(100vh - 280px);
  }

  .service-product-v28 .message-list {
    padding: 38px 18px 24px;
  }

  .composer-model-pill {
    margin-left: 0;
  }

  .approved-manual-map-form {
    grid-template-columns: 1fr;
  }
}

/* ====================================================================== *
 * .btn — unified button system (71-component-rulebook.md §4.1)
 * 5 variants: primary, secondary, ghost, danger, link. No other variants.
 * Solid backgrounds are ONLY allowed for primary and danger.
 * Phase 3.1.E (2026-05-24): all JS/HTML callsites migrated to .btn.
 * Legacy .primary-button / .secondary-button / .primary-inline /
 * .composer-tool-button CSS rules below are orphaned and slated for
 * removal in Phase 4 lint (test_token_usage_lint.py).
 * ====================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  border: 1px solid transparent;
  border-radius: var(--ds-radius-xs);
  font: inherit;
  font-weight: var(--ds-weight-semibold);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition:
    background-color var(--ds-motion-fast),
    border-color var(--ds-motion-fast),
    color var(--ds-motion-fast),
    box-shadow var(--ds-motion-fast);
}

.btn:focus-visible {
  outline: 2px solid var(--ds-color-accent);
  outline-offset: 2px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.btn--sm { min-height: 28px; padding: 0 var(--ds-space-3); font-size: var(--ds-text-caption-13); }
.btn.btn--md { min-height: 36px; padding: 0 var(--ds-space-4); font-size: var(--ds-text-body-14); }
.btn.btn--lg { min-height: 44px; padding: 0 var(--ds-space-5); font-size: var(--ds-text-body-15); }

.btn.btn--primary {
  background: var(--ds-button-primary-bg);
  color: var(--ds-button-primary-fg);
  border-color: var(--ds-button-primary-bg);
}
.btn.btn--primary:hover:not(:disabled) {
  background: var(--ds-button-primary-bg-hover);
  border-color: var(--ds-button-primary-bg-hover);
}

.btn.btn--secondary {
  background: var(--ds-button-secondary-bg);
  color: var(--ds-button-secondary-fg);
  border-color: var(--ds-button-secondary-border);
}
.btn.btn--secondary:hover:not(:disabled) {
  background: var(--ds-button-secondary-bg-hover);
  border-color: var(--ds-color-line-strong);
}

.btn.btn--ghost {
  background: transparent;
  color: var(--ds-button-ghost-fg);
  border-color: transparent;
}
.btn.btn--ghost:hover:not(:disabled) {
  background: var(--ds-button-ghost-bg-hover);
}

.btn.btn--danger {
  background: var(--ds-button-danger-bg);
  color: var(--ds-button-danger-fg);
  border-color: var(--ds-button-danger-bg);
}
.btn.btn--danger:hover:not(:disabled) {
  background: var(--ds-button-danger-bg-hover);
  border-color: var(--ds-button-danger-bg-hover);
}

.btn.btn--link {
  background: transparent;
  color: var(--ds-button-link-fg);
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
  min-height: auto;
}
.btn.btn--link:hover:not(:disabled) {
  text-decoration: underline;
}

/* ====================================================================== *
 * .ds-input — unified input system (71-component-rulebook.md §4.4)
 * Sizes: sm 32px, md 40px (default), lg 48px.
 * States: idle / hover / focus / disabled / invalid.
 * Error state changes border only — never bg.
 * ====================================================================== */

.ds-input {
  width: 100%;
  border: 1px solid var(--ds-input-border);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-input-bg);
  color: var(--ds-input-fg);
  font: inherit;
  outline: none;
  transition:
    border-color var(--ds-motion-fast),
    box-shadow var(--ds-motion-fast);
}

.ds-input::placeholder { color: var(--ds-input-placeholder); }

.ds-input.ds-input--sm { min-height: 32px; padding: 0 12px; font-size: var(--ds-text-caption-13); }
.ds-input.ds-input--md { min-height: 40px; padding: 0 14px; font-size: var(--ds-text-body-14); }
.ds-input.ds-input--lg { min-height: 48px; padding: 0 16px; font-size: var(--ds-text-body-15); }

.ds-input:hover:not(:disabled):not([aria-invalid="true"]) {
  border-color: var(--ds-input-border-hover);
}

.ds-input:focus,
.ds-input:focus-visible {
  border-color: var(--ds-input-border-focus);
  box-shadow: 0 0 0 2px var(--ds-input-ring-focus);
}

.ds-input:disabled {
  background: var(--ds-input-bg-disabled);
  color: var(--ds-input-fg-muted);
  cursor: not-allowed;
}

/* Native <select> chevron (Phase 3.6) — replace browser-default arrow with
 * a token-driven inline SVG so the visual stays consistent across OS/UA. */
select.ds-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: var(--ds-input-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 32px;
}
select.ds-input::-ms-expand { display: none; }

.ds-input[aria-invalid="true"] {
  border-color: var(--ds-input-border-invalid);
}

/* Search wrapper: leading icon + optional trailing clear button */
.ds-search {
  position: relative;
  display: block;
}

.ds-search .ds-input {
  padding-left: 36px;
}

.ds-search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ds-input-fg-muted);
  pointer-events: none;
}

.ds-search__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--ds-radius-xs);
  color: var(--ds-input-fg-muted);
  font: inherit;
  line-height: 1;
}

.ds-search__clear:hover {
  background: var(--ds-color-surface-muted);
  color: var(--ds-color-ink);
}

/* ====================================================================== *
 * .ds-modal — unified modal system (71-component-rulebook.md §4.2)
 * 3-slot anatomy: .ds-modal__header / .ds-modal__body / .ds-modal__footer
 * Sizes: sm 560px, md 720px (default), lg 960px.
 * Light/dark via Tier 2 swap (no [data-theme="dark"] selectors here).
 * Coexists with legacy .login-dialog for incremental migration; new modals
 * MUST use .ds-modal*.
 * ====================================================================== */

.ds-modal__overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-6);
  background: var(--ds-modal-overlay);
}
.ds-modal__overlay.is-open { display: flex; }

.ds-modal {
  background: var(--ds-modal-surface);
  border: 1px solid var(--ds-modal-border);
  border-radius: var(--ds-modal-radius);
  box-shadow: var(--ds-modal-shadow);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  width: 100%;
}

.ds-modal.ds-modal--sm { max-width: 560px; }
.ds-modal.ds-modal--md { max-width: 720px; }
.ds-modal.ds-modal--lg { max-width: 960px; }

.ds-modal__header {
  padding: var(--ds-space-6);
  border-bottom: 1px solid var(--ds-modal-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ds-space-4);
  flex-shrink: 0;
}

.ds-modal__body {
  padding: var(--ds-space-6);
  overflow-y: auto;
  flex: 1 1 auto;
}

.ds-modal__footer {
  padding: var(--ds-space-6);
  border-top: 1px solid var(--ds-modal-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ds-space-3);
  flex-shrink: 0;
}

/* ====================================================================== *
 * .ds-chip — segmented + count (71-component-rulebook.md §4.5)
 * 2 variants only. Coexists with legacy .tab-button via selector grouping.
 * ====================================================================== */
.ds-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-1);
  background: var(--ds-chip-bg);
  color: var(--ds-chip-fg);
  border: 1px solid var(--ds-chip-border);
  font: inherit;
  font-size: var(--ds-text-body-14);
  cursor: pointer;
  transition: background var(--ds-motion-fast), color var(--ds-motion-fast), border-color var(--ds-motion-fast);
}
.ds-chip:hover:not([aria-disabled="true"]) {
  background: var(--ds-chip-bg-hover);
}
.ds-chip:focus-visible {
  outline: 2px solid var(--ds-color-accent);
  outline-offset: 2px;
}
.ds-chip[aria-pressed="true"],
.ds-chip.is-active {
  background: var(--ds-chip-bg-active);
  color: var(--ds-chip-fg-active);
  border-color: var(--ds-chip-bg-active);
}
.ds-chip.ds-chip--segmented {
  min-height: 32px;
  padding: 0 var(--ds-space-3);
  border-radius: var(--ds-radius-xs);
}
.ds-chip.ds-chip--count {
  min-height: 22px;
  padding: 0 var(--ds-space-2);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-chip-count-bg);
  color: var(--ds-chip-count-fg);
  border-color: transparent;
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-semibold);
}

/* ====================================================================== *
 * .ds-badge — status indicator (71-component-rulebook.md §4.6)
 * 5 variants: ok, warn, bad, info, neutral. Dot variant: 8px round, fg only.
 * ====================================================================== */
.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-1);
  min-height: 22px;
  padding: 2px var(--ds-space-2);
  border-radius: var(--ds-radius-pill);
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-medium);
  background: var(--ds-badge-neutral-bg);
  color: var(--ds-badge-neutral-fg);
}
.ds-badge.ds-badge--ok      { background: var(--ds-badge-ok-bg);   color: var(--ds-badge-ok-fg); }
.ds-badge.ds-badge--warn    { background: var(--ds-badge-warn-bg); color: var(--ds-badge-warn-fg); }
.ds-badge.ds-badge--bad     { background: var(--ds-badge-bad-bg);  color: var(--ds-badge-bad-fg); }
.ds-badge.ds-badge--info    { background: var(--ds-badge-info-bg); color: var(--ds-badge-info-fg); }
.ds-badge.ds-badge--neutral { background: var(--ds-badge-neutral-bg); color: var(--ds-badge-neutral-fg); }

.ds-badge.ds-badge--dot {
  width: 8px;
  height: 8px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.ds-badge.ds-badge--dot.ds-badge--ok      { color: var(--ds-badge-ok-fg); }
.ds-badge.ds-badge--dot.ds-badge--warn    { color: var(--ds-badge-warn-fg); }
.ds-badge.ds-badge--dot.ds-badge--bad     { color: var(--ds-badge-bad-fg); }
.ds-badge.ds-badge--dot.ds-badge--info    { color: var(--ds-badge-info-fg); }
.ds-badge.ds-badge--dot.ds-badge--neutral { color: var(--ds-badge-neutral-fg); }

/* ====================================================================== *
 * .ds-tile — dashboard/hub stat tile (71-component-rulebook.md §4.7)
 * Anatomy: [dot? · number · label]. Same visual weight per row.
 * ====================================================================== */
.ds-tile {
  background: var(--ds-tile-bg);
  border: 1px solid var(--ds-tile-border);
  border-radius: var(--ds-tile-radius);
  padding: var(--ds-tile-padding);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
  min-height: 84px;
}
.ds-tile__top {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  color: var(--ds-tile-label-fg);
  font-size: var(--ds-text-micro-11);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ds-tile__num {
  font-size: var(--ds-text-heading-32);
  font-weight: var(--ds-weight-semibold);
  color: var(--ds-tile-num-fg);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ds-tile.ds-tile--muted .ds-tile__num { color: var(--ds-color-ink-soft); }

/* ====================================================================== *
 * .ds-checkbox — minimal pattern (rulebook §4.8 not yet defined)
 * Native <input type="checkbox"> with custom appearance.
 * ====================================================================== */
.ds-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--ds-checkbox-border);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-color-surface-solid);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: border-color var(--ds-motion-fast), background var(--ds-motion-fast);
  vertical-align: middle;
  flex-shrink: 0;
}
.ds-checkbox:hover:not(:disabled) {
  border-color: var(--ds-checkbox-border-hover);
}
.ds-checkbox:checked {
  background: var(--ds-checkbox-bg-checked);
  border-color: var(--ds-checkbox-bg-checked);
}
.ds-checkbox:checked::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--ds-checkbox-fg-checked);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
}
.ds-checkbox:focus-visible {
  outline: 2px solid var(--ds-color-accent);
  outline-offset: 2px;
}

/* ====================================================================== *
 * .ds-card — generic card (71-component-rulebook.md §4.3)
 * 3 variants: default, interactive, static. Optional 3-slot anatomy.
 * ====================================================================== */
.ds-card {
  background: var(--ds-card-bg);
  border: 1px solid var(--ds-card-border);
  border-radius: var(--ds-card-radius);
  padding: var(--ds-card-padding);
  box-shadow: var(--ds-card-shadow);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3);
  transition: border-color var(--ds-motion-fast), box-shadow var(--ds-motion-fast), transform var(--ds-motion-fast);
}

.ds-card.ds-card--interactive:hover {
  border-color: var(--ds-card-border-hover);
  box-shadow: var(--ds-card-shadow-hover);
  transform: translateY(-1px);
}

.ds-card.ds-card--static {
  transition: none;
  cursor: default;
}

.ds-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
}
.ds-card__body { flex: 1 1 auto; min-width: 0; }
.ds-card__footer {
  display: flex;
  gap: var(--ds-space-2);
  justify-content: flex-end;
  margin-top: var(--ds-space-2);
}

/* WDS AI Portal alignment — conversation-first shell */
.wds-ai-portal-v1 {
  background: var(--ds-color-bg);
  color: var(--ds-color-ink);
  font-family: var(--ds-font-family-sans);
  font-size: var(--ds-text-body-15);
  letter-spacing: 0;
}

.wds-ai-portal-v1 .app-shell {
  grid-template-columns: 260px minmax(0, 1fr);
}

.wds-ai-portal-v1 .sidebar {
  gap: var(--ds-space-4);
  padding: var(--ds-space-5) var(--ds-space-4);
  background: var(--ds-color-sidebar);
  color: var(--ds-color-on-accent);
  border-right: 1px solid var(--ds-color-line);
  box-shadow: none;
  backdrop-filter: none;
}

.wds-ai-portal-v1 .brand-row {
  padding: 0;
}

.wds-ai-portal-v1 .brand-mark,
.wds-ai-portal-v1 .workspace-cover {
  width: 36px;
  height: 36px;
  border: 1px solid color-mix(in srgb, var(--ds-color-on-accent) 22%, transparent);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-color-sidebar-2);
  color: var(--ds-color-on-accent);
  box-shadow: none;
}

.wds-ai-portal-v1 .brand-row strong {
  color: var(--ds-color-on-accent);
  font-size: var(--ds-text-title-18);
  font-weight: var(--ds-weight-semibold);
}

.wds-ai-portal-v1 .brand-row span,
.wds-ai-portal-v1 .sidebar .section-label,
.wds-ai-portal-v1 .recent-item small {
  color: color-mix(in srgb, var(--ds-color-on-accent) 68%, transparent);
}

.wds-ai-portal-v1 .new-chat-button {
  min-height: 42px;
  border: 1px solid color-mix(in srgb, var(--ds-color-on-accent) 18%, transparent);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-button-secondary-bg);
  color: var(--ds-button-secondary-fg);
  box-shadow: none;
  font-weight: var(--ds-weight-semibold);
}

.wds-ai-portal-v1 .theme-toggle,
.wds-ai-portal-v1 .nav-item {
  border-radius: var(--ds-radius-xs);
  transform: none;
}

.wds-ai-portal-v1 .nav-item {
  grid-template-columns: 26px minmax(0, 1fr);
  min-height: 38px;
  padding: var(--ds-space-2) var(--ds-space-3);
  color: var(--ds-color-on-accent);
}

.wds-ai-portal-v1 .nav-item span:not(.nav-icon) {
  display: block;
  color: color-mix(in srgb, var(--ds-color-on-accent) 84%, transparent);
}

.wds-ai-portal-v1 .nav-item:hover,
.wds-ai-portal-v1 .nav-item.active {
  border-color: color-mix(in srgb, var(--ds-color-on-accent) 18%, transparent);
  background: color-mix(in srgb, var(--ds-color-on-accent) 9%, transparent);
  transform: none;
}

.wds-ai-portal-v1 .nav-item.active {
  box-shadow: inset 3px 0 0 var(--ds-color-accent-2);
}

.wds-ai-portal-v1 .nav-item:hover span:not(.nav-icon),
.wds-ai-portal-v1 .nav-item.active span:not(.nav-icon) {
  color: var(--ds-color-on-accent);
}

.wds-ai-portal-v1 .nav-icon {
  width: 22px;
  height: 22px;
  border: 1px solid color-mix(in srgb, var(--ds-color-on-accent) 16%, transparent);
  border-radius: var(--ds-radius-xs);
  background: color-mix(in srgb, var(--ds-color-on-accent) 8%, transparent);
  color: var(--ds-color-on-accent);
}

.wds-ai-portal-v1 .recent-item {
  min-height: 40px;
  border-radius: var(--ds-radius-xs);
  color: var(--ds-color-on-accent);
}

.wds-ai-portal-v1 .main-pane,
.wds-ai-portal-v1 .chat-pane {
  background: var(--ds-color-bg);
}

.wds-ai-portal-v1 .workspace-hero {
  min-height: 72px;
  padding: var(--ds-space-4) var(--ds-space-6);
  background: var(--ds-color-surface-solid);
  border-bottom: 1px solid var(--ds-color-line);
  box-shadow: none;
  backdrop-filter: none;
}

.wds-ai-portal-v1 .hero-copy {
  margin-top: var(--ds-space-1);
  color: var(--ds-color-muted);
  font-size: var(--ds-text-caption-13);
  line-height: var(--ds-leading-body);
}

.wds-ai-portal-v1 .status-stack {
  gap: var(--ds-space-2);
}

.wds-ai-portal-v1 .status-pill {
  min-height: 28px;
  border: 1px solid var(--ds-badge-neutral-bg);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-badge-neutral-bg);
  color: var(--ds-badge-neutral-fg);
  box-shadow: none;
}

.wds-ai-portal-v1 .status-pill.soft {
  background: var(--ds-badge-info-bg);
  color: var(--ds-badge-info-fg);
  border-color: var(--ds-badge-info-bg);
}

.wds-ai-portal-v1 .workbench {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
}

html[data-portal-tab="home"] .wds-ai-portal-v1 .workspace-hero,
html[data-portal-tab="home"] .wds-ai-portal-v1 .context-pane {
  display: none;
}

html[data-portal-tab="home"] .wds-ai-portal-v1 .workbench {
  grid-template-columns: minmax(0, 1fr);
}

.wds-ai-portal-v1 .message-list {
  gap: var(--ds-space-5);
  padding: clamp(var(--ds-space-8), 8vh, var(--ds-space-10)) clamp(var(--ds-space-5), 7vw, 104px) var(--ds-space-6);
}

.wds-ai-portal-v1 .calm-chat-home {
  width: min(760px, 100%);
  gap: var(--ds-space-5);
  text-align: center;
}

.wds-ai-portal-v1 .home-project-pill {
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-color-surface-solid);
  color: var(--ds-color-ink-soft);
  box-shadow: var(--ds-shadow-xs);
}

.wds-ai-portal-v1 .calm-chat-home h2 {
  margin: 0;
  color: var(--ds-color-ink);
  font-size: clamp(var(--ds-text-heading-32), 4vw, var(--ds-text-display-40));
  font-weight: var(--ds-weight-semibold);
  line-height: var(--ds-leading-tight);
}

.wds-ai-portal-v1 .calm-chat-home p {
  color: var(--ds-color-muted);
  font-size: var(--ds-text-body-15);
  line-height: var(--ds-leading-reading);
}

.wds-ai-portal-v1 .quick-start-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ds-space-2);
}

.wds-ai-portal-v1 .quick-start-grid button {
  min-height: 44px;
  border: 1px solid var(--ds-card-border);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-card-bg);
  color: var(--ds-color-ink);
  box-shadow: none;
  font-weight: var(--ds-weight-medium);
}

.wds-ai-portal-v1 .quick-start-grid button:hover {
  border-color: var(--ds-card-border-hover);
  box-shadow: var(--ds-card-shadow);
  transform: none;
}

.wds-ai-portal-v1 .portal-context-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--ds-space-2);
}

.wds-ai-portal-v1 .portal-context-strip span,
.wds-ai-portal-v1 .composer-chip {
  min-height: 26px;
  padding: var(--ds-space-1) var(--ds-space-2);
  border: 1px solid var(--ds-chip-border);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-chip-bg);
  color: var(--ds-chip-fg);
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-medium);
}

.wds-ai-portal-v1 .message {
  grid-template-columns: 38px minmax(0, 780px);
}

.wds-ai-portal-v1 .message-body {
  padding: var(--ds-space-4) var(--ds-space-5);
  border-color: transparent;
  border-radius: var(--ds-radius-xs);
  background: transparent;
  box-shadow: none;
}

.wds-ai-portal-v1 .message.user {
  justify-content: end;
}

.wds-ai-portal-v1 .message.user .message-body {
  border: 1px solid var(--ds-color-line);
  background: var(--ds-color-accent-soft);
  box-shadow: var(--ds-shadow-xs);
}

.wds-ai-portal-v1 .message-label {
  border-radius: var(--ds-radius-xs);
  background: var(--ds-color-surface-muted);
  color: var(--ds-color-ink-soft);
}

.wds-ai-portal-v1 .ai-avatar {
  background: var(--ds-color-sidebar);
  color: var(--ds-color-on-accent);
  box-shadow: none;
}

.wds-ai-portal-v1 .thinking-state {
  grid-template-columns: 18px minmax(0, 1fr);
  gap: var(--ds-space-3);
  align-items: center;
}

.wds-ai-portal-v1 .thinking-orb {
  width: 10px;
  height: 10px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-color-accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.wds-ai-portal-v1 .answer-activity {
  margin-top: var(--ds-space-3);
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-color-surface-solid);
  box-shadow: var(--ds-shadow-xs);
}

.wds-ai-portal-v1 .answer-activity summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  min-height: 42px;
  padding: 0 var(--ds-space-4);
  cursor: pointer;
}

.wds-ai-portal-v1 .answer-activity summary span {
  color: var(--ds-color-ink);
  font-weight: var(--ds-weight-semibold);
}

.wds-ai-portal-v1 .answer-activity summary small,
.wds-ai-portal-v1 .evidence-note {
  color: var(--ds-color-muted);
  font-size: var(--ds-text-caption-12);
}

.wds-ai-portal-v1 .evidence-strip,
.wds-ai-portal-v1 .source-list {
  display: grid;
  gap: var(--ds-space-2);
  padding: 0 var(--ds-space-4) var(--ds-space-4);
}

.wds-ai-portal-v1 .source-card {
  border: 1px solid var(--ds-card-border);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-color-surface-solid);
  box-shadow: none;
}

.wds-ai-portal-v1 .composer-surface {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto auto;
  align-content: start;
  width: min(860px, calc(100% - var(--ds-space-8)));
  gap: var(--ds-space-2);
  margin: 0 auto var(--ds-space-5);
  padding: var(--ds-space-3);
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-surface-solid);
  box-shadow: var(--ds-shadow-md);
  backdrop-filter: none;
}

.wds-ai-portal-v1 .composer-status-rail {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: var(--ds-space-3);
  min-height: 20px;
  color: var(--ds-color-muted);
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-medium);
  line-height: var(--ds-leading-body);
}

.wds-ai-portal-v1 .composer-attachment-lane,
.wds-ai-portal-v1 .composer-action-dock {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-space-2);
  min-height: 32px;
}

.wds-ai-portal-v1 .composer-prompt-body,
.wds-ai-portal-v1 .composer-input-row {
  grid-column: 1 / -1;
  display: block;
  width: 100%;
}

.wds-ai-portal-v1 .composer-surface textarea {
  width: 100%;
  min-height: 58px;
  max-height: 160px;
  padding: var(--ds-space-3);
  border: 1px solid var(--ds-input-border);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-input-bg);
  color: var(--ds-input-fg);
  box-shadow: none;
  resize: none;
}

.wds-ai-portal-v1 .composer-surface textarea:focus {
  border-color: var(--ds-input-border-focus);
  box-shadow: 0 0 0 2px var(--ds-input-ring-focus);
}

.wds-ai-portal-v1 .composer-tool-button,
.wds-ai-portal-v1 .composer-model-pill {
  min-height: 32px;
  border: 1px solid var(--ds-button-secondary-border);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-button-secondary-bg);
  color: var(--ds-button-secondary-fg);
  font-size: var(--ds-text-caption-13);
  font-weight: var(--ds-weight-medium);
}

.wds-ai-portal-v1 .composer-tool-button:hover {
  border-color: var(--ds-color-line-strong);
  background: var(--ds-button-secondary-bg-hover);
  color: var(--ds-button-secondary-fg);
}

.wds-ai-portal-v1 .composer-model-pill {
  margin-left: auto;
  color: var(--ds-color-muted);
}

.wds-ai-portal-v1 #sendButton {
  min-height: 36px;
  border-radius: var(--ds-radius-xs);
}

.wds-ai-portal-v1 .context-pane {
  background: var(--ds-color-surface-solid);
  border-left: 1px solid var(--ds-color-line);
}

.wds-ai-portal-v1 .tabs {
  padding: var(--ds-space-3);
  border-bottom: 1px solid var(--ds-color-line);
}

.wds-ai-portal-v1 .tab-button {
  border-radius: var(--ds-radius-xs);
}

.wds-ai-portal-v1 .panel-block,
.wds-ai-portal-v1 .app-detail-panel,
.wds-ai-portal-v1 .app-workflow-panel,
.wds-ai-portal-v1 .app-input-fields,
.wds-ai-portal-v1 .app-result-card,
.wds-ai-portal-v1 .mini-card,
.wds-ai-portal-v1 .app-card {
  border-radius: var(--ds-radius-xs);
  box-shadow: none;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

@media (max-width: 900px) {
  .wds-ai-portal-v1 .app-shell {
    grid-template-columns: 1fr;
  }

  .wds-ai-portal-v1 .sidebar {
    min-height: auto;
  }

  .wds-ai-portal-v1 .workbench {
    grid-template-columns: 1fr;
  }

  .wds-ai-portal-v1 .context-pane {
    display: block;
  }

  html[data-portal-tab="home"] .wds-ai-portal-v1 .context-pane {
    display: none;
  }

  .wds-ai-portal-v1 .quick-start-grid {
    grid-template-columns: 1fr;
  }

  .wds-ai-portal-v1 .composer-surface {
    width: calc(100% - var(--ds-space-5));
  }

  .wds-ai-portal-v1 .composer-status-rail,
  .wds-ai-portal-v1 .composer-action-dock {
    align-items: stretch;
    flex-direction: column;
  }

  .wds-ai-portal-v1 .composer-model-pill {
    margin-left: 0;
  }

  .ops-status-head,
  .ops-status-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .ops-status-grid {
    grid-template-columns: 1fr;
  }

  .ops-version-code {
    max-width: 100%;
  }
}

/* WDS pattern fidelity pass — Login / AI Chat / Light-first workspace */
.wds-pattern-fidelity-v2 {
  --ds-color-accent: var(--wds-color-primary);
  --ds-color-accent-soft: var(--wds-color-primary-subtle);
  --ds-input-border-focus: var(--wds-input-border-focus);
  --ds-input-ring-focus: var(--wds-color-focus-ring);
  --ds-button-primary-bg: var(--wds-button-bg);
  --ds-button-primary-bg-hover: var(--wds-button-bg-hover);
  --ds-button-link-fg: var(--wds-color-link);
  min-height: 100vh;
  background: var(--ds-color-bg);
  color: var(--ds-color-ink);
  font-family: var(--ds-font-family-sans);
  letter-spacing: 0;
}

.wds-pattern-fidelity-v2 .app-shell {
  grid-template-columns: 252px minmax(0, 1fr);
  background: var(--ds-color-bg);
}

.wds-pattern-fidelity-v2 .sidebar {
  gap: var(--ds-space-4);
  padding: var(--ds-space-5) var(--ds-space-4);
  background: var(--ds-color-surface-muted);
  color: var(--ds-color-ink-soft);
  border-right: 1px solid var(--ds-color-line);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .brand-row {
  min-height: 42px;
  padding: 0;
}

.wds-pattern-fidelity-v2 .brand-mark,
.wds-pattern-fidelity-v2 .workspace-cover {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-color-accent-soft);
  color: var(--ds-color-accent);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .brand-row strong {
  color: var(--ds-color-ink);
  font-size: var(--ds-text-title-18);
  font-weight: var(--ds-weight-semibold);
}

.wds-pattern-fidelity-v2 .brand-row span,
.wds-pattern-fidelity-v2 .sidebar .section-label,
.wds-pattern-fidelity-v2 .recent-item small {
  color: var(--ds-color-muted);
}

.wds-pattern-fidelity-v2 .new-chat-button,
.wds-pattern-fidelity-v2 .theme-toggle {
  min-height: 40px;
  border: 1px solid var(--ds-button-secondary-border);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-button-secondary-bg);
  color: var(--ds-button-secondary-fg);
  box-shadow: none;
  font-weight: var(--ds-weight-semibold);
}

.wds-pattern-fidelity-v2 .new-chat-button:hover,
.wds-pattern-fidelity-v2 .theme-toggle:hover {
  border-color: var(--ds-color-line-strong);
  background: var(--ds-button-secondary-bg-hover);
  transform: none;
}

.wds-pattern-fidelity-v2 .project-switcher select {
  min-height: 36px;
  border-color: var(--ds-input-border);
  border-radius: var(--ds-radius-xs);
  background-color: var(--ds-input-bg);
  color: var(--ds-input-fg);
}

.wds-pattern-fidelity-v2 .nav-item {
  grid-template-columns: 28px minmax(0, 1fr);
  min-height: 38px;
  padding: var(--ds-space-2) var(--ds-space-3);
  border: 1px solid transparent;
  border-radius: var(--ds-radius-xs);
  background: transparent;
  color: var(--ds-color-ink-soft);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .nav-item span:not(.nav-icon) {
  color: var(--ds-color-ink-soft);
  font-weight: var(--ds-weight-medium);
}

.wds-pattern-fidelity-v2 .nav-icon {
  width: 24px;
  height: 24px;
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-xs);
  background: var(--ds-color-surface-solid);
  color: var(--ds-color-muted);
}

.wds-pattern-fidelity-v2 .nav-item:hover {
  border-color: var(--ds-color-line);
  background: var(--ds-color-surface-solid);
  transform: none;
}

.wds-pattern-fidelity-v2 .nav-item.active {
  border-color: var(--ds-color-accent);
  background: var(--ds-color-accent-soft);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .nav-item.active span:not(.nav-icon),
.wds-pattern-fidelity-v2 .nav-item.active .nav-icon {
  color: var(--ds-color-accent);
}

.wds-pattern-fidelity-v2 .recent-item {
  min-height: 38px;
  border-radius: var(--ds-radius-xs);
  color: var(--ds-color-ink-soft);
}

.wds-pattern-fidelity-v2 .recent-item:hover {
  border-color: var(--ds-color-line);
  background: var(--ds-color-surface-solid);
}

.wds-pattern-fidelity-v2 .main-pane,
.wds-pattern-fidelity-v2 .chat-pane {
  background: var(--ds-color-bg);
}

.wds-pattern-fidelity-v2 .workspace-hero {
  min-height: 70px;
  padding: var(--ds-space-4) var(--ds-space-7);
  background: var(--ds-color-surface-solid);
  border-bottom: 1px solid var(--ds-color-line);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .workbench {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}

.wds-pattern-fidelity-v2 .chat-pane {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.wds-pattern-fidelity-v2 .portal-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  width: min(760px, calc(100% - var(--ds-space-8)));
  margin: var(--ds-space-6) auto 0;
  padding: var(--ds-space-2);
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-surface-solid);
  box-shadow: var(--ds-shadow-xs);
}

.wds-pattern-fidelity-v2 .state-segment-group {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-1);
  min-height: 36px;
  padding: var(--ds-space-1);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-color-surface-muted);
}

.wds-pattern-fidelity-v2 .state-segment-label,
.wds-pattern-fidelity-v2 .state-segment {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 var(--ds-space-2);
  border-radius: var(--ds-radius-xs);
  color: var(--ds-color-muted);
  font-size: var(--ds-text-caption-12);
  font-weight: var(--ds-weight-semibold);
  white-space: nowrap;
}

.wds-pattern-fidelity-v2 .state-segment.is-active {
  border: 1px solid var(--ds-color-line);
  background: var(--ds-color-surface-solid);
  color: var(--ds-color-accent);
  box-shadow: var(--ds-shadow-xs);
}

.wds-pattern-fidelity-v2 .message-list {
  align-items: center;
  gap: var(--ds-space-4);
  padding: var(--ds-space-7) var(--ds-space-6) var(--ds-space-5);
}

.wds-pattern-fidelity-v2 .calm-chat-home {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: var(--ds-space-7);
  border: 1px solid var(--ds-card-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-card-bg);
  box-shadow: var(--ds-shadow-xs);
  text-align: left;
}

.wds-pattern-fidelity-v2 .home-project-pill {
  width: fit-content;
  min-height: 26px;
  border-color: var(--ds-color-line);
  background: var(--ds-color-surface-muted);
  color: var(--ds-color-muted);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .calm-chat-home h2 {
  color: var(--ds-color-ink);
  font-size: var(--ds-text-heading-32);
  font-weight: var(--ds-weight-semibold);
  line-height: var(--ds-leading-tight);
}

.wds-pattern-fidelity-v2 .calm-chat-home p {
  color: var(--ds-color-ink-soft);
  font-size: var(--ds-text-body-15);
  line-height: var(--ds-leading-body);
}

.wds-pattern-fidelity-v2 .quick-start-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wds-pattern-fidelity-v2 .quick-start-grid button {
  min-height: 42px;
  border-radius: var(--ds-radius-xs);
  background: var(--ds-button-secondary-bg);
  color: var(--ds-button-secondary-fg);
  box-shadow: none;
  text-align: left;
}

.wds-pattern-fidelity-v2 .portal-context-strip {
  justify-content: flex-start;
}

.wds-pattern-fidelity-v2 .message {
  width: min(760px, 100%);
  grid-template-columns: 34px minmax(0, 1fr);
}

.wds-pattern-fidelity-v2 .message-body {
  border: 1px solid transparent;
  border-radius: var(--ds-radius-lg);
  background: var(--ds-color-surface-solid);
  box-shadow: var(--ds-shadow-xs);
}

.wds-pattern-fidelity-v2 .message.assistant .message-body,
.wds-pattern-fidelity-v2 .message.system .message-body {
  border-color: var(--ds-card-border);
}

.wds-pattern-fidelity-v2 .message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
  justify-content: center;
}

.wds-pattern-fidelity-v2 .message.user .message-label {
  order: 2;
}

.wds-pattern-fidelity-v2 .message.user .message-body {
  order: 1;
  background: var(--ds-color-accent-soft);
}

.wds-pattern-fidelity-v2 .message-label,
.wds-pattern-fidelity-v2 .ai-avatar {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ds-color-line);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-color-accent-soft);
  color: var(--ds-color-accent);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .composer-surface {
  width: min(760px, calc(100% - var(--ds-space-8)));
  margin: 0 auto var(--ds-space-6);
  padding: var(--ds-space-3);
  border: 1px solid var(--ds-card-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-color-surface-solid);
  box-shadow: var(--ds-shadow-md);
}

.wds-pattern-fidelity-v2 .composer-status-rail {
  align-items: center;
  color: var(--ds-color-muted);
}

.wds-pattern-fidelity-v2 .composer-surface textarea {
  min-height: 54px;
  border-radius: var(--ds-radius-xs);
}

.wds-pattern-fidelity-v2 .composer-tool-button,
.wds-pattern-fidelity-v2 .composer-model-pill {
  min-height: 32px;
  padding: 0 var(--ds-space-3);
  border-radius: var(--ds-radius-xs);
}

.wds-pattern-fidelity-v2 #sendButton {
  min-width: 86px;
  border-radius: var(--ds-radius-xs);
}

.wds-pattern-fidelity-v2 .context-pane {
  background: var(--ds-color-surface-solid);
  border-left: 1px solid var(--ds-color-line);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .tabs {
  gap: var(--ds-space-2);
  padding: var(--ds-space-3);
  background: var(--ds-color-surface-solid);
}

.wds-pattern-fidelity-v2 .tab-button {
  min-height: 32px;
  border-radius: var(--ds-radius-xs);
}

.wds-pattern-fidelity-v2 .panel-block,
.wds-pattern-fidelity-v2 .app-detail-panel,
.wds-pattern-fidelity-v2 .app-workflow-panel,
.wds-pattern-fidelity-v2 .app-input-fields,
.wds-pattern-fidelity-v2 .app-result-card,
.wds-pattern-fidelity-v2 .mini-card,
.wds-pattern-fidelity-v2 .app-card,
.wds-pattern-fidelity-v2 .artifact-studio,
.wds-pattern-fidelity-v2 .artifact-editor {
  border-color: var(--ds-card-border);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-color-surface-solid);
  box-shadow: none;
}

.wds-pattern-fidelity-v2 .login-dialog {
  width: min(390px, calc(100vw - var(--wds-space-8, 2rem)));
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: 0;
}

.wds-pattern-fidelity-v2 .login-dialog::backdrop {
  background: color-mix(in srgb, var(--wds-color-surface, var(--ds-color-bg)) 86%, transparent);
  backdrop-filter: blur(1px);
}

.wds-pattern-fidelity-v2 .login-service-badge .login-service-logo {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--wds-radius-full);
  background: var(--wds-color-surface-muted);
  color: var(--wds-color-text-muted);
  font-size: var(--wds-font-size-caption);
}

.wds-pattern-fidelity-v2 .login-surface ._brand_1p22z_32 {
  font-weight: var(--wds-font-weight-regular);
}

.wds-pattern-fidelity-v2 .login-service-name {
  display: inline;
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: var(--wds-font-weight-medium);
  line-height: inherit;
  white-space: nowrap;
}

.wds-pattern-fidelity-v2 .login-surface ._title_1p22z_43 {
  font-weight: var(--wds-font-weight-regular);
}

.wds-pattern-fidelity-v2 .login-password-toggle {
  display: grid;
  place-items: center;
  width: var(--wds-control-height-sm);
  height: var(--wds-control-height-sm);
  border: 0;
  border-radius: var(--wds-button-radius);
  background: transparent;
  color: var(--wds-color-text-muted);
  cursor: pointer;
}

.wds-pattern-fidelity-v2 .login-password-toggle:hover {
  background: var(--wds-color-surface-hover);
  color: var(--wds-color-text);
}

.wds-pattern-fidelity-v2 .login-password-toggle:focus-visible {
  outline: 2px solid var(--wds-color-focus-ring);
  outline-offset: 2px;
}

.wds-pattern-fidelity-v2 .login-password-icon--eye-off,
.wds-pattern-fidelity-v2 .login-password-toggle[aria-pressed="true"] .login-password-icon--eye {
  display: none;
}

.wds-pattern-fidelity-v2 .login-password-toggle[aria-pressed="true"] .login-password-icon--eye-off {
  display: block;
}

.wds-pattern-fidelity-v2 .login-field-error {
  margin: 0;
}

.wds-pattern-fidelity-v2 .login-field-error:empty {
  display: none;
}

.wds-pattern-fidelity-v2 .login-surface ._label_2lf8x_7,
.wds-pattern-fidelity-v2 .login-surface ._root_1ergb_2,
.wds-pattern-fidelity-v2 .login-surface ._label_1ergb_100 {
  /* WDS Login art direction: avoid heavy text inside the auth surface. */
  font-weight: var(--wds-font-weight-regular);
}

.wds-pattern-fidelity-v2 .login-surface ._field_2lf8x_2 {
  display: flex;
  gap: var(--wds-space-2);
}

.wds-pattern-fidelity-v2 .login-surface ._label_2lf8x_7 {
  display: block;
  color: var(--wds-color-text);
  font-size: var(--wds-font-size-body-2);
  line-height: 1.4;
}

.wds-pattern-fidelity-v2 .login-surface ._wrap_1h2ox_2 ._input_1h2ox_100,
.wds-pattern-fidelity-v2 .login-surface ._wrap_1h2ox_2 ._input_1h2ox_100:hover,
.wds-pattern-fidelity-v2 .login-surface ._wrap_1h2ox_2 ._input_1h2ox_100:focus,
.wds-pattern-fidelity-v2 .login-surface ._wrap_1h2ox_2 ._input_1h2ox_100:focus-visible {
  width: auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--wds-input-fg);
  box-shadow: none;
  outline: none;
  line-height: normal;
}

.wds-pattern-fidelity-v2 .login-surface ._root_1ergb_2 {
  display: inline-flex;
  align-items: center;
  gap: var(--wds-space-2);
  color: var(--wds-color-text-muted);
  font-size: var(--wds-font-size-body-2);
  line-height: 1.4;
}

.wds-pattern-fidelity-v2 .login-surface ._label_1ergb_100 {
  color: var(--wds-color-text-muted);
  font-size: var(--wds-font-size-body-2);
  line-height: 1.4;
}

.wds-pattern-fidelity-v2 .login-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wds-space-3);
  min-height: var(--wds-control-height-md);
}

.wds-pattern-fidelity-v2 .login-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--wds-control-height-md);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--wds-color-primary-text);
  font: inherit;
  font-size: var(--wds-font-size-body-2);
  font-weight: var(--wds-font-weight-regular);
  line-height: 1.4;
  cursor: pointer;
}

.wds-pattern-fidelity-v2 .login-surface ._button_lt829_2 {
  font-weight: var(--wds-font-weight-medium);
}

.wds-pattern-fidelity-v2 .login-help {
  margin: 0;
}

.wds-pattern-fidelity-v2 .login-help span {
  color: var(--wds-color-primary-text);
  font-weight: var(--wds-font-weight-regular);
}

.wds-pattern-fidelity-v2 .login-form-message[data-empty="true"] {
  display: none;
}

.wds-pattern-fidelity-v2 .login-button-spinner[hidden] {
  display: none !important;
}

.wds-pattern-fidelity-v2.is-auth-gate .app-shell {
  background: var(--ds-color-bg);
}

.wds-pattern-fidelity-v2.is-auth-gate .portal-status-bar,
.wds-pattern-fidelity-v2.is-auth-gate .composer-surface,
.wds-pattern-fidelity-v2.is-auth-gate .calm-chat-home,
.wds-pattern-fidelity-v2.is-auth-gate .context-pane {
  filter: none;
}

@media (max-width: 900px) {
  .wds-pattern-fidelity-v2 .app-shell {
    grid-template-columns: 1fr;
  }

  .wds-pattern-fidelity-v2 .sidebar {
    min-height: auto;
  }

  .wds-pattern-fidelity-v2 .portal-status-bar,
  .wds-pattern-fidelity-v2 .composer-surface {
    width: calc(100% - var(--ds-space-5));
  }

  .wds-pattern-fidelity-v2 .portal-status-bar {
    justify-content: flex-start;
    margin-top: var(--ds-space-4);
  }

  .wds-pattern-fidelity-v2 .state-segment-group {
    max-width: 100%;
    overflow-x: auto;
  }

  .wds-pattern-fidelity-v2 .message-list {
    padding: var(--ds-space-5) var(--ds-space-3);
  }

  .wds-pattern-fidelity-v2 .calm-chat-home {
    padding: var(--ds-space-5);
  }

  .wds-pattern-fidelity-v2 .quick-start-grid {
    grid-template-columns: 1fr;
  }

  .wds-pattern-fidelity-v2 .nav-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wds-pattern-fidelity-v2 .nav-item {
    grid-template-columns: 24px minmax(0, 1fr);
    justify-content: start;
    min-width: 0;
    text-align: left;
  }

  .wds-pattern-fidelity-v2 .nav-item span:not(.nav-icon) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

}
