.app:has(#page-chats.on) {
  background:
    radial-gradient(ellipse 72% 48% at 12% -12%, rgba(255, 174, 132, .14), transparent 70%),
    radial-gradient(ellipse 70% 50% at 90% -14%, rgba(160, 142, 255, .15), transparent 72%),
    linear-gradient(180deg, #f8f5f8 0, var(--ds-canvas) 420px);
}

.app:has(#page-chats.on) .content {
  width: 100%;
  max-width: none;
  padding: 8px 32px 32px;
}

#page-chats { min-width: 0; }
#page-chats button, #set-chats button { -webkit-tap-highlight-color: transparent; }
#page-chats svg, #set-chats svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-nav-count { min-width: 22px; justify-content: center; color: var(--ds-accent-strong); background: rgba(var(--ds-accent-rgb), .1); }

.chat-toolbar {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 12px 16px 12px 20px;
  border: 1px solid var(--ds-line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 10px 30px rgba(37, 28, 55, .04);
}
.chat-toolbar-copy { display: grid; gap: 3px; min-width: 260px; }
.chat-toolbar-copy strong { font-size: 17px; line-height: 1.25; letter-spacing: -.018em; }
.chat-toolbar-copy span { color: var(--ds-ink-secondary); font-size: 14px; line-height: 1.4; }
.chat-toolbar-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-all-btn { height: 44px; padding: 0 14px; border: 1px solid var(--ds-line); border-radius: 14px; color: var(--ds-ink); background: var(--ds-surface); font-size: 13px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.chat-all-btn b { margin-left: 7px; color: var(--ds-accent-strong); }
.chat-search { display: flex; width: min(360px, 28vw); height: 44px; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--ds-line); border-radius: 14px; background: var(--ds-surface); }
.chat-search svg { flex: 0 0 18px; color: var(--ds-ink-tertiary); }
.chat-search input { width: 100%; height: 100%; padding: 0 !important; border: 0 !important; outline: 0 !important; background: transparent; box-shadow: none !important; font-size: 14px; }
.chat-select, .chat-settings-select { min-width: 170px; height: 44px; padding: 0 38px 0 14px; border: 1px solid var(--ds-line); border-radius: 14px; color: var(--ds-ink); background-color: var(--ds-surface); font-size: 14px; font-weight: 600; }

.chat-health {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.chat-access-state[hidden] { display: none; }
.chat-access-state { margin: 0 0 16px; }
.chat-health-card {
  display: grid;
  min-height: 92px;
  grid-template-columns: 44px minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--ds-line);
  border-radius: 22px;
  color: var(--ds-ink);
  background: rgba(255,255,255,.84);
  box-shadow: 0 10px 28px rgba(35,25,54,.04);
  text-align: left;
  cursor: pointer;
  transition: transform 150ms var(--ds-ease-out), border-color 150ms, box-shadow 150ms;
}
.chat-health-card:hover { transform: translateY(-1px); box-shadow: var(--ds-shadow-card); }
.chat-health-card.on { border-color: rgba(var(--ds-accent-rgb),.28); box-shadow: 0 0 0 3px rgba(var(--ds-accent-rgb),.07), var(--ds-shadow-card); }
.chat-health-icon { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 14px; color: var(--ds-accent-strong); background: var(--ds-accent-soft); }
.chat-health-icon svg { width: 23px !important; height: 23px !important; }
.chat-health-card.amber .chat-health-icon { color: var(--ds-amber); background: var(--ds-amber-soft); }
.chat-health-card.blue .chat-health-icon { color: var(--ds-blue); background: var(--ds-blue-soft); }
.chat-health-card.red .chat-health-icon { color: var(--ds-red); background: var(--ds-red-soft); }
.chat-health-card.completed .chat-health-icon { color: var(--ds-green); background: var(--ds-green-soft); }
.chat-health-copy { display: grid; min-width: 0; gap: 4px; }
.chat-health-copy b { font-size: 15px; line-height: 1.22; }
.chat-health-copy small { display: none; }
.chat-health-card > strong { min-width: 30px; font-size: 27px; line-height: 1; letter-spacing: -.05em; text-align: right; font-variant-numeric: tabular-nums; }

.chat-workspace {
  display: grid;
  min-height: 650px;
  height: calc(100vh - 314px);
  grid-template-columns: minmax(300px, .85fr) minmax(440px, 1.55fr) minmax(280px, .8fr);
  overflow: hidden;
  border: 1px solid var(--ds-line);
  border-radius: 26px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--ds-shadow-card);
}
.chat-queue, .chat-thread, .chat-context { min-width: 0; min-height: 0; }
.chat-queue { display: flex; flex-direction: column; border-right: 1px solid var(--ds-line); background: rgba(249,249,251,.72); }
.chat-queue-head { display: flex; min-height: 82px; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px; border-bottom: 1px solid var(--ds-line); }
.chat-queue-head h2 { margin: 0 0 3px; font-size: 19px; line-height: 1.2; letter-spacing: -.025em; }
.chat-queue-head p { margin: 0; color: var(--ds-ink-secondary); font-size: 13px; }
.chat-queue-actions { display: flex; gap: 8px; }
.chat-icon-btn { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 1px solid var(--ds-line); border-radius: 14px; color: var(--ds-ink-secondary); background: var(--ds-surface); cursor: pointer; }
.chat-list { flex: 1; overflow: auto; padding: 8px; }
.chat-row { display: grid; width: 100%; gap: 7px; padding: 15px 14px; border: 1px solid transparent; border-radius: 17px; color: var(--ds-ink); background: transparent; text-align: left; cursor: pointer; }
.chat-row + .chat-row { margin-top: 4px; }
.chat-row:hover { background: rgba(255,255,255,.82); }
.chat-row.on { border-color: rgba(var(--ds-accent-rgb),.2); background: var(--ds-surface); box-shadow: 0 8px 24px rgba(35,25,54,.055); }
.chat-row-top { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; }
.chat-row-top b { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-top time { color: var(--ds-ink-tertiary); font-size: 12px; font-variant-numeric: tabular-nums; }
.chat-mp { display: inline-grid; width: 34px; height: 28px; place-items: center; border-radius: 10px; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: -.02em; }
.chat-mp-wb { background: #8d2dd1; }
.chat-mp-ozon { background: #196cff; }
.chat-mp-ym { color: #171717; background: #ffd52f; }
.chat-row-store { overflow: hidden; color: var(--ds-ink-secondary); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-preview { display: -webkit-box; min-height: 40px; overflow: hidden; color: var(--ds-ink); font-size: 14px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.chat-row-foot { display: flex; align-items: center; gap: 7px; color: var(--ds-ink-secondary); font-size: 12px; }
.chat-row-foot em { margin-left: auto; color: var(--ds-ink-tertiary); font-style: normal; }
.chat-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ds-ink-tertiary); }
.chat-status-dot.human { background: var(--ds-amber); }
.chat-status-dot.ai { background: var(--ds-accent); }
.chat-status-dot.waiting { background: var(--ds-blue); }
.chat-status-dot.error { background: var(--ds-red); }
.chat-empty { display: grid; place-items: center; gap: 6px; min-height: 240px; padding: 24px; color: var(--ds-ink-secondary); text-align: center; }
.chat-empty b { color: var(--ds-ink); font-size: 16px; }

.chat-thread { display: flex; flex-direction: column; background: var(--ds-surface); }
.chat-thread-head { display: flex; min-height: 82px; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--ds-line); }
.chat-thread-title { display: flex; min-width: 0; align-items: center; gap: 12px; }
.chat-thread-title h2 { margin: 0; font-size: 18px; line-height: 1.2; }
.chat-thread-title p { margin: 4px 0 0; overflow: hidden; color: var(--ds-ink-secondary); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread-actions { display: flex; align-items: center; gap: 8px; }
.chat-capability { padding: 7px 10px; border-radius: 999px; color: var(--ds-ink-secondary); background: var(--ds-surface-subtle); font-size: 12px; font-weight: 650; white-space: nowrap; }
.chat-secondary-btn, .chat-primary-btn { min-height: 42px; padding: 0 15px; border-radius: 13px; font-size: 13px; font-weight: 650; cursor: pointer; }
.chat-secondary-btn { border: 1px solid var(--ds-line); color: var(--ds-ink); background: var(--ds-surface); }
.chat-primary-btn { border: 0; color: #fff; background: var(--ds-accent); }
.chat-primary-btn:hover { background: var(--ds-accent-strong); }
.chat-generate-btn { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid rgba(var(--ds-accent-rgb),.18); border-radius: 13px; color: var(--ds-accent-strong); background: var(--ds-accent-soft); font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.chat-generate-btn:hover { border-color: rgba(var(--ds-accent-rgb),.3); background: var(--ds-accent-selection); }
.chat-generate-btn svg { width: 17px !important; height: 17px !important; }
.chat-messages { flex: 1; overflow: auto; padding: 22px 22px 14px; }
.chat-date { margin: 0 auto 20px; color: var(--ds-ink-tertiary); font-size: 12px; text-align: center; }
.chat-message { width: fit-content; max-width: 76%; margin-bottom: 12px; padding: 11px 13px 9px; border-radius: 17px 17px 17px 5px; background: var(--ds-surface-subtle); }
.chat-message.marps, .chat-message.agent { margin-left: auto; border-radius: 17px 17px 5px 17px; background: #f2edfb; }
.chat-message-author { display: block; margin-bottom: 5px; color: var(--ds-ink-secondary); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .035em; }
.chat-message p { margin: 0; font-size: 15px; line-height: 1.5; }
.chat-message time { display: block; margin-top: 6px; color: var(--ds-ink-tertiary); font-size: 11px; text-align: right; }
.chat-message.transport-queued time, .chat-message.transport-sending time { color: var(--ds-accent-strong); }
.chat-message.transport-ambiguous time { color: var(--ds-amber); }
.chat-message.transport-failed { background: var(--ds-red-soft); }
.chat-message.transport-failed time { color: var(--ds-red); }
.chat-primary-btn:disabled, .chat-generate-btn:disabled { opacity: .58; cursor: default; }
.chat-primary-btn:disabled:hover { background: var(--ds-accent); }

.chat-handoff { margin: 18px 0 2px; padding: 17px; border: 1px solid rgba(197,43,54,.17); border-radius: 19px; background: #fff8f8; }
.chat-handoff.is-error { background: #fffafa; }
.chat-handoff-title { display: flex; align-items: flex-start; gap: 12px; }
.chat-handoff-title > span { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 12px; color: var(--ds-red); background: var(--ds-red-soft); }
.chat-handoff-title > span svg { width: 20px !important; height: 20px !important; }
.chat-handoff-title b { display: block; margin-bottom: 4px; color: var(--ds-red); font-size: 16px; }
.chat-handoff-title p { margin: 0; color: var(--ds-ink-secondary); font-size: 13px; line-height: 1.5; }
.chat-handoff-reasons { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0 15px 50px; }
.chat-handoff-reasons span { padding: 6px 9px; border-radius: 999px; color: var(--ds-red); background: rgba(197,43,54,.075); font-size: 12px; font-weight: 650; }
.chat-handoff dl { display: grid; gap: 10px; margin: 0; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.72); }
.chat-handoff dl > div { display: grid; grid-template-columns: 130px minmax(0,1fr); gap: 12px; }
.chat-handoff dt { color: var(--ds-ink-secondary); font-size: 12px; font-weight: 650; }
.chat-handoff dd { margin: 0; font-size: 13px; line-height: 1.45; }

.chat-composer { margin: 0 14px 14px; padding: 14px; border: 1px solid var(--ds-line); border-radius: 20px; background: #fbfbfc; }
.chat-composer.manual { background: #fffdfd; }
.chat-composer-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.chat-composer-label b { font-size: 13px; }
.chat-composer-label span { color: var(--ds-ink-tertiary); font-size: 12px; }
.chat-composer textarea { width: 100%; min-height: 82px; resize: vertical; padding: 12px !important; border: 1px solid var(--ds-line) !important; background: var(--ds-surface); font-size: 14px; line-height: 1.5; }
.chat-composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.chat-composer-actions { display: flex; align-items: center; gap: 8px; }
.chat-generation-error { margin: 8px 0 0; color: var(--ds-red); font-size: 12px; font-weight: 650; }
.chat-empty-main { min-height: 420px; place-content: center; }

.chat-context { overflow: auto; border-left: 1px solid var(--ds-line); background: rgba(249,249,251,.7); }
.chat-context-block { padding: 19px; border-bottom: 1px solid var(--ds-line); }
.chat-context-kicker, .chat-settings-kicker { display: block; margin-bottom: 13px; color: var(--ds-ink-tertiary); font-size: 11px; font-weight: 750; letter-spacing: .055em; text-transform: uppercase; }
.chat-product-main { display: flex; align-items: center; gap: 12px; }
.chat-product-thumb { display: grid; width: 52px; height: 52px; flex: 0 0 52px; place-items: center; border-radius: 15px; color: var(--ds-accent-strong); background: var(--ds-accent-soft); font-size: 20px; font-weight: 750; }
.chat-product-main h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.chat-product-main p { margin: 4px 0 0; color: var(--ds-ink-secondary); font-size: 12px; }
.chat-facts { display: grid; gap: 11px; margin: 17px 0 0; }
.chat-facts > div { display: grid; grid-template-columns: 90px minmax(0,1fr); gap: 10px; }
.chat-facts dt { color: var(--ds-ink-tertiary); font-size: 12px; }
.chat-facts dd { margin: 0; overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.chat-source { display: flex; align-items: center; gap: 10px; padding: 11px 0; }
.chat-source + .chat-source { border-top: 1px solid var(--ds-line); }
.chat-source > span { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border-radius: 10px; color: var(--ds-green); background: var(--ds-green-soft); font-size: 12px; font-weight: 750; }
.chat-source.conflict > span { color: var(--ds-red); background: var(--ds-red-soft); }
.chat-source b, .chat-source small { display: block; }
.chat-source b { font-size: 12px; line-height: 1.35; }
.chat-source small { margin-top: 3px; color: var(--ds-ink-tertiary); font-size: 11px; }
.chat-context-muted { color: var(--ds-ink-secondary); font-size: 13px; }
.chat-event { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.chat-event-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: var(--ds-accent); box-shadow: 0 0 0 4px var(--ds-accent-soft); }
.chat-event-dot.human, .chat-event-dot.error { background: var(--ds-red); box-shadow: 0 0 0 4px var(--ds-red-soft); }
.chat-event-dot.waiting { background: var(--ds-blue); box-shadow: 0 0 0 4px var(--ds-blue-soft); }
.chat-event-dot.neutral { background: var(--ds-ink-tertiary); box-shadow: 0 0 0 4px var(--ds-surface-subtle); }
.chat-event b, .chat-event small { display: block; }
.chat-event b { font-size: 12px; }
.chat-event small { margin-top: 2px; color: var(--ds-ink-tertiary); font-size: 11px; }

.chat-settings { display: grid; gap: 18px; margin-top: 24px; }
.chat-settings-card { padding: 24px; border: 1px solid var(--ds-line); border-radius: 24px; background: var(--ds-surface); box-shadow: var(--ds-shadow-card); }
.chat-settings-card h2, .chat-settings-card h3 { margin: 0; letter-spacing: -.025em; }
.chat-settings-card h2 { font-size: 24px; }
.chat-settings-card h3 { font-size: 18px; }
.chat-settings-card p { margin: 8px 0 0; color: var(--ds-ink-secondary); font-size: 14px; line-height: 1.55; }
.chat-settings-hero, .chat-settings-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.chat-settings-hero > div { max-width: 720px; }
.chat-settings-kicker { margin-bottom: 9px; color: var(--ds-accent-strong); }
.chat-store-list { display: grid; gap: 2px; margin-top: 18px; }
.chat-store-row { display: grid; min-height: 72px; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 13px; padding: 10px 0; border-top: 1px solid var(--ds-line); }
.chat-store-copy { display: grid; gap: 4px; }
.chat-store-copy b { font-size: 15px; }
.chat-store-copy span { color: var(--ds-ink-secondary); font-size: 12px; }
.chat-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.chat-settings-grid .chat-secondary-btn { margin-top: 18px; }
.chat-rules-list { display: grid; gap: 16px; }
.chat-rules-empty { display: grid; justify-items: start; gap: 10px; }
.chat-rules-empty b { font-size: 18px; }
.chat-rules-empty > span { max-width: 760px; color: var(--ds-ink-secondary); font-size: 14px; line-height: 1.55; }
.chat-rule-card { overflow: hidden; border: 1px solid var(--ds-line); border-radius: 24px; background: var(--ds-surface); box-shadow: var(--ds-shadow-card); }
.chat-rule-card.is-off { opacity: .7; }
.chat-rule-head { display: grid; grid-template-columns: 76px minmax(0,1fr) auto auto 32px; align-items: center; gap: 12px; min-height: 82px; padding: 16px 20px; }
.chat-rule-order { display: grid; grid-template-columns: 22px 28px 22px; align-items: center; gap: 2px; color: var(--ds-ink-secondary); font-size: 12px; font-weight: 750; }
.chat-rule-order span { display: grid; width: 28px; height: 30px; place-items: center; border-radius: 9px; background: var(--ds-surface-subtle); }
.chat-rule-order button { width: 22px; height: 30px; border-radius: 8px; color: var(--ds-ink-tertiary); background: transparent; font-size: 13px; }
.chat-rule-order button:hover:not(:disabled) { color: var(--ds-accent-strong); background: var(--ds-accent-soft); }
.chat-rule-order button:disabled { opacity: .24; cursor: default; }
.chat-rule-title { display: grid; min-width: 0; gap: 4px; }
.chat-rule-title b { overflow: hidden; color: var(--ds-ink); font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.chat-rule-title span { overflow: hidden; color: var(--ds-ink-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.chat-rule-mode { padding: 6px 10px; border-radius: 999px; color: var(--ds-ink-secondary); background: var(--ds-surface-subtle); font-size: 11px; font-weight: 750; }
.chat-rule-mode.auto { color: var(--ds-green); background: var(--ds-green-soft); }
.chat-rule-remove { width: 32px; height: 32px; border-radius: 10px; color: var(--ds-ink-tertiary); background: transparent; font-size: 22px; line-height: 1; }
.chat-rule-remove:hover { color: var(--ds-red); background: var(--ds-red-soft); }
.chat-switch { position: relative; width: 42px; height: 25px; }
.chat-switch input { position: absolute; opacity: 0; pointer-events: none; }
.chat-switch span { display: block; width: 100%; height: 100%; border-radius: 999px; background: var(--ds-line-strong, #d7dae1); transition: background .18s; }
.chat-switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(15,23,42,.18); transition: transform .18s; }
.chat-switch input:checked + span { background: var(--ds-accent); }
.chat-switch input:checked + span::after { transform: translateX(17px); }
.chat-rule-body { border-top: 1px solid var(--ds-line); }
.chat-rule-section { padding: 22px 24px; border-top: 1px solid var(--ds-line); }
.chat-rule-section:first-child { border-top: 0; }
.chat-rule-section-title { display: grid; gap: 4px; margin-bottom: 17px; }
.chat-rule-section-title b { color: var(--ds-ink); font-size: 15px; }
.chat-rule-section-title span { color: var(--ds-ink-secondary); font-size: 12px; }
.chat-rule-grid { display: grid; gap: 14px; }
.chat-rule-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.chat-rule-grid.three { grid-template-columns: repeat(3,minmax(0,1fr)); margin-top: 16px; }
.chat-field { display: grid; gap: 7px; min-width: 0; }
.chat-field > span, .chat-field-group > span { color: var(--ds-ink-secondary); font-size: 11px; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
.chat-field input, .chat-field select, .chat-field textarea { width: 100%; min-height: 44px; padding: 0 13px; border: 1px solid var(--ds-line); border-radius: 13px; outline: 0; color: var(--ds-ink); background: var(--ds-surface); font: 600 13px var(--font-ui, sans-serif); }
.chat-field textarea { padding-block: 11px; resize: vertical; line-height: 1.45; }
.chat-field input:focus, .chat-field select:focus, .chat-field textarea:focus { border-color: var(--ds-accent); box-shadow: 0 0 0 3px var(--ds-accent-soft); }
.chat-field-group { display: grid; gap: 9px; margin-top: 16px; }
.chat-field-group small { color: var(--ds-ink-tertiary); font-size: 11px; }
.chat-choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-choice { display: inline-flex; min-height: 38px; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid var(--ds-line); border-radius: 12px; color: var(--ds-ink-secondary); background: var(--ds-surface); cursor: pointer; font-size: 12px; font-weight: 650; }
.chat-choice input { width: 15px; height: 15px; margin: 0; accent-color: var(--ds-accent); }
.chat-choice.on { border-color: color-mix(in srgb, var(--ds-accent) 24%, transparent); color: var(--ds-accent-strong); background: var(--ds-accent-soft); }
.chat-choice.locked { cursor: default; color: var(--ds-ink-secondary); background: var(--ds-surface-subtle); }
.chat-choice .chat-mp { width: 26px; height: 26px; border-radius: 8px; }
.chat-rule-empty { color: var(--ds-ink-tertiary); font-size: 12px; }
.chat-action-cards { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.chat-action-choice { position: relative; display: grid; gap: 5px; min-height: 92px; padding: 15px 16px 14px 42px; border: 1px solid var(--ds-line); border-radius: 16px; cursor: pointer; background: var(--ds-surface); }
.chat-action-choice input { position: absolute; top: 17px; left: 16px; width: 16px; height: 16px; accent-color: var(--ds-accent); }
.chat-action-choice b { color: var(--ds-ink); font-size: 13px; }
.chat-action-choice span { color: var(--ds-ink-secondary); font-size: 12px; line-height: 1.4; }
.chat-action-choice.on { border-color: color-mix(in srgb, var(--ds-accent) 26%, transparent); background: var(--ds-accent-soft); }
.chat-rule-grid.muted, .chat-line-toggle.muted { opacity: .5; }
.chat-line-toggle { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 15px; padding: 14px 0 0; border-top: 1px solid var(--ds-line); }
.chat-line-toggle > span { display: grid; gap: 3px; }
.chat-line-toggle b { color: var(--ds-ink); font-size: 13px; }
.chat-line-toggle small { color: var(--ds-ink-secondary); font-size: 11px; }
.chat-line-toggle > input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--ds-accent); }
.chat-after-human { width: min(440px,100%); margin-top: 18px; }
.chat-settings-fields, .chat-style-description { margin-top: 18px; }
.chat-knowledge-list { display: grid; gap: 12px; margin-top: 18px; }
.chat-knowledge-item { display: grid; grid-template-columns: minmax(150px,.55fr) minmax(0,1fr) 32px; align-items: end; gap: 10px; padding-top: 12px; border-top: 1px solid var(--ds-line); }
.chat-test-card { display: grid; gap: 18px; }
.chat-test-dialog { display: grid; gap: 8px; max-width: 760px; padding: 16px; border-radius: 16px; background: var(--ds-surface-subtle); }
.chat-test-dialog p { margin: 0; color: var(--ds-ink); }
.chat-test-dialog b { margin-right: 8px; }
.chat-test-result { padding: 15px 17px; border-radius: 16px; color: var(--ds-ink-secondary); background: var(--ds-surface-subtle); }
.chat-test-result.passed { color: var(--ds-green); background: var(--ds-green-soft); }
.chat-test-result span { display: block; font-size: 14px; font-weight: 750; }
.chat-test-result p { margin-top: 5px; color: inherit; }

@media (max-width: 1320px) {
  .chat-health { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .chat-workspace { height: auto; min-height: 720px; grid-template-columns: 300px minmax(430px,1fr); }
  .chat-context { display: none; }
}

@media (max-width: 980px) {
  .app:has(#page-chats.on) .content { padding-inline: 20px; }
  .chat-toolbar { align-items: stretch; flex-direction: column; }
  .chat-toolbar-actions { width: 100%; }
  .chat-search { width: 100%; flex: 1; }
  .chat-health { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .chat-workspace { grid-template-columns: 1fr; }
  .chat-queue { max-height: 430px; border-right: 0; border-bottom: 1px solid var(--ds-line); }
  .chat-settings-grid { grid-template-columns: 1fr; }
  .chat-action-cards, .chat-rule-grid.three { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app:has(#page-chats.on) .content { padding-inline: 12px; }
  .chat-health { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .chat-health-card { min-width: 230px; }
  .chat-toolbar-actions, .chat-thread-head, .chat-settings-hero, .chat-settings-head { align-items: stretch; flex-direction: column; }
  .chat-select { width: 100%; }
  .chat-workspace { border-radius: 20px; }
  .chat-thread-actions { flex-wrap: wrap; }
  .chat-message { max-width: 92%; }
  .chat-handoff dl > div { grid-template-columns: 1fr; gap: 4px; }
  .chat-composer-foot { align-items: stretch; flex-direction: column; }
  .chat-composer-actions { align-items: stretch; flex-direction: column; }
  .chat-store-row { grid-template-columns: auto minmax(0,1fr); }
  .chat-store-row .ds-select, .chat-store-row .chat-settings-select { grid-column: 1 / -1; width: 100%; }
  .chat-rule-head { grid-template-columns: 76px minmax(0,1fr) auto auto; padding: 14px; }
  .chat-rule-mode { grid-column: 2 / -1; justify-self: start; }
  .chat-rule-remove { grid-column: 4; grid-row: 1; }
  .chat-rule-grid.two { grid-template-columns: 1fr; }
  .chat-rule-section { padding: 18px 16px; }
  .chat-knowledge-item { grid-template-columns: 1fr 32px; }
  .chat-knowledge-item .chat-field:nth-child(2) { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-health-card { transition: none; }
}

/* Chats workbench: information density follows the rest of MARPS. */
.chat-toolbar {
  min-height: 48px;
  justify-content: flex-start;
  margin-bottom: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.chat-toolbar-actions { width: 100%; }
.chat-search { width: min(520px, 48vw); }
.chat-select { margin-left: auto; }
.chat-health {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid var(--ds-line);
  border-radius: 16px;
  background: rgba(255,255,255,.7);
}
.chat-health-card {
  display: inline-flex;
  min-height: 38px;
  flex: 0 0 auto;
  grid-template-columns: none;
  gap: 8px;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  box-shadow: none;
  transition: background 120ms var(--ds-ease-out), color 120ms var(--ds-ease-out);
}
.chat-health-card:hover { transform: none; background: var(--ds-surface); box-shadow: none; }
.chat-health-card.on { border: 0; background: var(--ds-surface); box-shadow: 0 4px 14px rgba(35,25,54,.07); }
.chat-health-card > span { color: var(--ds-ink-secondary); font-size: 13px; font-weight: 650; }
.chat-health-card.on > span { color: var(--ds-ink); }
.chat-health-card > strong { min-width: 0; font-size: 13px; letter-spacing: 0; color: var(--ds-ink-tertiary); }
.chat-health-card.on > strong { color: var(--ds-accent-strong); }
.chat-workspace {
  min-height: 680px;
  height: calc(100vh - 245px);
  grid-template-columns: minmax(300px, .68fr) minmax(520px, 1.7fr);
}
.chat-context { display: none; }
.chat-row { gap: 6px; padding-block: 13px; }
.chat-row-preview { min-height: 0; -webkit-line-clamp: 1; color: var(--ds-ink-secondary); }
.chat-assignee { display: grid; gap: 3px; }
.chat-assignee > span { color: var(--ds-ink-tertiary); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.chat-assignee select, .chat-product-picker {
  height: 36px;
  max-width: 220px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--ds-line);
  border-radius: 11px;
  color: var(--ds-ink);
  background: var(--ds-surface);
  font: 600 12px var(--font-ui, sans-serif);
}
.chat-assignee-static { color: var(--ds-ink-secondary); font-size: 12px; font-weight: 650; }
.chat-product-line {
  display: flex;
  min-height: 62px;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--ds-line);
  background: rgba(249,249,251,.6);
}
.chat-product-line img { width: 40px; height: 40px; flex: 0 0 40px; object-fit: cover; border-radius: 11px; }
.chat-product-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }
.chat-product-copy > span { color: var(--ds-ink-tertiary); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.chat-product-copy b, .chat-product-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-product-copy b { font-size: 13px; }
.chat-product-copy small { color: var(--ds-ink-secondary); font-size: 11px; }
.chat-assistance {
  max-width: 680px;
  margin: 18px auto 4px;
  padding: 14px 16px;
  border: 1px solid var(--ds-line);
  border-radius: 16px;
  background: var(--ds-surface);
}
.chat-assistance.needs-review { border-color: color-mix(in srgb, var(--ds-amber) 28%, var(--ds-line)); }
.chat-assistance-head { display: flex; justify-content: space-between; gap: 12px; }
.chat-assistance-head b { font-size: 13px; }
.chat-assistance-head span { color: var(--ds-ink-tertiary); font-size: 11px; }
.chat-assistance > p { margin: 7px 0 11px; color: var(--ds-ink-secondary); font-size: 12px; }
.chat-assistance dl { display: grid; gap: 7px; margin: 0; }
.chat-assistance dl > div { display: grid; grid-template-columns: 145px minmax(0,1fr); gap: 12px; }
.chat-assistance dt { color: var(--ds-ink-tertiary); font-size: 11px; }
.chat-assistance dd { margin: 0; font-size: 12px; line-height: 1.4; }
.chat-answer-basis { overflow: hidden; color: var(--ds-ink-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 980px) {
  .chat-workspace { height: auto; grid-template-columns: 1fr; }
  .chat-select { margin-left: 0; }
}
@media (max-width: 680px) {
  .chat-search { width: 100%; }
  .chat-health-card { min-width: auto; min-height: 44px; }
  .chat-icon-btn { width: 44px; min-width: 44px; flex-basis: 44px; }
  .chat-icon-btn, .chat-generate-btn, .chat-primary-btn, .chat-secondary-btn { min-height: 44px; }
  .chat-product-line { align-items: stretch; flex-direction: column; }
  .chat-product-picker { width: 100%; max-width: none; }
  .chat-assistance dl > div { grid-template-columns: 1fr; gap: 2px; }
}

.chat-attachment{display:inline-flex;flex-direction:column;gap:4px;max-width:210px;margin:8px 8px 4px 0;overflow-wrap:anywhere}.chat-attachment img{max-width:100%;max-height:180px;object-fit:contain;border-radius:8px}
