:root {
  --accent: #34507e;
  --accent-soft: #eef1f6;
  --ink: #222725;
  --muted: #6b716e;
  --line: #c5cad3;
  --paper: #ffffff;
  --canvas: #f7f7f5;
  --soft: #f0f2ef;
  --danger: #a53f45;
  --radius: 2px;
  --shadow: 0 18px 50px rgba(25, 35, 30, 0.12);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Login */

.login-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow);
}

.login-mark,
.brand-mark {
  display: inline-flex;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: var(--accent);
  position: relative;
}

.login-mark span,
.brand-mark span {
  position: absolute;
  background: var(--paper);
  border-radius: var(--radius);
}

.login-mark span:first-child,
.brand-mark span:first-child {
  width: 4px;
  height: 14px;
  left: 9px;
  top: 8px;
}

.login-mark span:last-child,
.brand-mark span:last-child {
  width: 10px;
  height: 4px;
  left: 9px;
  top: 13px;
}

.login-card h1 {
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  margin: 18px 0 4px;
}

.login-lead {
  color: var(--muted);
  margin: 0 0 26px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  background: var(--paper);
}

.field input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary-button,
.send-button {
  border: 0;
  border-radius: var(--radius);
  padding: 11px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.primary-button:disabled,
.send-button:disabled,
.send-button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  background: var(--paper);
}

.text-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 650;
}

.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.danger-button {
  border: 0;
  border-radius: var(--radius);
  padding: 10px 16px;
  background: var(--danger);
  color: #fff;
}

.status-message {
  min-height: 1.25rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.status-message.error {
  color: var(--danger);
}

.login-foot {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 24px 0 0;
  text-align: center;
}

/* Shell */

.chat-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft, #fbfbfa);
  padding: 20px 16px 16px;
  min-height: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: -0.01em;
  padding: 0 6px;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 10px 13px;
  font-weight: 600;
  text-align: left;
}

.new-chat:hover {
  border-color: #ccd4ce;
  background: var(--surface, #fff);
}

.history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 2px;
}

.history-group h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 6px;
  padding: 0 6px;
}

.history-empty {
  color: var(--muted);
  font-size: 0.875rem;
  padding: 0 6px;
}

.history-item {
  position: relative;
  border-radius: var(--radius);
}

.history-item:hover,
.history-item.active {
  background: var(--soft);
}

.history-open {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 0;
  background: none;
  border-radius: var(--radius);
  padding: 9px 10px;
  text-align: left;
}

.history-title {
  font-size: 0.9rem;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-actions {
  display: none;
  position: absolute;
  right: 6px;
  top: 6px;
  gap: 4px;
  background: var(--soft);
  border-radius: var(--radius);
}

.history-item:hover .history-actions,
.history-item:focus-within .history-actions {
  display: flex;
}

.history-actions button {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 4px 6px;
  border-radius: var(--radius);
}

.history-actions button:hover {
  color: var(--ink);
  background: var(--surface-sunk, #e4e7e3);
}

.sidebar-footer {
  position: relative;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 8px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.user-email {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.user-menu-button:hover,
.user-menu-button[aria-expanded="true"] {
  border-color: var(--line);
  background: var(--soft);
  color: var(--ink);
}

.user-menu-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.user-menu-item {
  display: block;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
  padding: 10px 11px;
  text-align: left;
  text-decoration: none;
  font-size: 0.9rem;
}

.user-menu-item:hover {
  background: var(--soft);
}

.user-menu-signout {
  color: var(--danger);
  font-weight: 600;
}

/* Main */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--canvas);
}

.thread-header {
  padding: 18px 24px 8px;
  text-align: center;
}

.thread-header h1 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.thread > * {
  width: min(760px, 100%);
  margin-left: auto;
  margin-right: auto;
}

/* Empty state */

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 22px;
  justify-content: center;
  min-height: 100%;
}

.empty-drop {
  border: 1.5px dashed #ccd4ce;
  border-radius: var(--radius);
  background: var(--surface, #fcfcfb);
  padding: 42px 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.empty-drop:hover,
.empty-drop:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.empty-drop h2 {
  font-size: 1.35rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin: 0 auto 6px;
  max-width: 520px;
}

.empty-drop p {
  color: var(--muted);
  margin: 0;
}

.example-prompts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.example-prompt {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 13px 15px;
  text-align: left;
  color: var(--ink);
}

.example-prompt:hover {
  border-color: #ccd4ce;
  background: var(--surface, #fff);
}

/* Messages */

.message {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: rise 160ms ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.message-user {
  align-items: flex-end;
}

.message-user .bubble {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 11px 15px;
  max-width: min(620px, 88%);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-user .bubble-compact {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.pasted-preview {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pasted-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  padding: 3px 10px;
  font-size: 0.74rem;
  font-weight: 600;
}

.pasted-details summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pasted-full {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow: auto;
}

.message-assistant .bubble {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 17px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.review-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.attachment-errors {
  display: grid;
  gap: 6px;
}

.attachment-errors p {
  margin: 0;
  border-left: 3px solid var(--danger);
  background: var(--workspace-rose, #fbf1f1);
  color: var(--red, #7d3034);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.9rem;
}

.send-error {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 3px solid var(--danger);
  background: var(--workspace-rose, #fbf1f1);
  color: var(--red, #7d3034);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9rem;
}

.send-error p {
  margin: 0;
}

.send-error .chip {
  flex: none;
}

.provider-banner {
  margin: 12px 24px 0;
  border-left: 3px solid var(--danger);
  background: var(--workspace-rose, #fbf1f1);
  color: var(--red, #7d3034);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9rem;
}

.provider-unavailable-bubble {
  border-left: 3px solid var(--danger);
  background: var(--workspace-rose, #fbf1f1);
  color: var(--red, #7d3034);
}

.rules-check {
  margin-top: .5rem;
}

.rules-check ul {
  margin: .4rem 0;
  padding-left: 1.2rem;
}

.rules-check li + li {
  margin-top: .35rem;
}

.rules-check-ref,
.rules-check-more {
  color: var(--muted, #62667a);
  font-size: .88rem;
}

.provider-banner-link,
.provider-unavailable-link {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
}

.provider-banner-link:hover,
.provider-unavailable-link:hover {
  color: var(--red, #5a2023);
}

/* Thinking */

.thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 4px 2px;
}

.thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.thinking-elapsed {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

/* First pass and answer content */

.first-pass {
  display: grid;
  gap: 14px;
}

.first-pass-type {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.first-pass h3 {
  font-size: 0.9rem;
  margin: 0 0 8px;
}

.first-pass-summary,
.first-pass-side {
  margin: 0;
}

.first-pass-side {
  color: var(--muted);
  font-size: 0.9rem;
}

.first-pass-answer {
  border: 1px solid #d9e6df;
  border-radius: var(--radius);
  background: var(--surface-soft, #f7faf8);
  padding: 12px 14px;
}

.first-pass-answer p {
  margin: 0;
}

.first-pass-bottom-line {
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  padding: 11px 13px;
}

.first-pass-bottom-line h3 {
  margin: 0 0 6px;
}

.first-pass-bottom-line p {
  margin: 0;
}

.first-pass-bottom-line ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.first-pass-bottom-line li {
  margin-top: 2px;
}

.first-pass-parties ul,
.first-pass-missing ul {
  margin: 0;
  padding-left: 20px;
}

.first-pass-parties li {
  display: flex;
  gap: 8px;
}

.first-pass-parties li span {
  color: var(--muted);
}

.first-pass-issues {
  display: grid;
  gap: 10px;
}

.issue-card {
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface, #fdfdfc);
}

.issue-high {
  border-left-color: #a3333f;
}

.issue-medium {
  border-left-color: #b47a14;
}

.issue-low {
  border-left-color: #2e7d5b;
}

.issue-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.issue-heading h4 {
  font-size: 0.94rem;
  margin: 0;
  flex: 1;
}

.issue-card p {
  margin: 8px 0 0;
  font-size: 0.92rem;
}

.severity {
  display: inline-block;
  border-radius: var(--radius);
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.severity-high {
  background: var(--workspace-rose, #f8e6e7);
  color: var(--red, #8d2a34);
}

.severity-medium {
  background: var(--workspace-warm, #faf0da);
  color: var(--medium-ink, #84580c);
}

.severity-low {
  background: var(--workspace-green, #e4f1eb);
  color: var(--low-ink, #245f47);
}

.cite {
  border: 1px solid #cdded6;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 1px 6px;
  white-space: nowrap;
}

.cite:hover {
  background: var(--workspace-green, #d6e8df);
}

.issue-wording-label {
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.issue-numbers-note {
  margin: 6px 0 0;
  color: var(--medium-ink, #84580c);
  font-size: 0.8rem;
}

.issue-wording {
  margin: 0;
  border-left: 2px solid var(--line);
  padding: 4px 0 4px 12px;
  color: var(--ink, #3c423f);
  font-size: 0.9rem;
}

.issue-wording p {
  margin: 0 0 6px;
}

.rl-del {
  color: var(--red, #8d2a34);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  background: var(--workspace-rose, #fbeaec);
}

.rl-ins {
  color: var(--low-ink, #245f47);
  text-decoration: underline;
  text-underline-offset: 2px;
  background: var(--workspace-green, #e7f4ed);
}

.answer-redline {
  margin-top: 12px;
}

.copy-wording {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 0.76rem;
  padding: 2px 8px;
}

.empty-note {
  color: var(--muted);
  margin: 0;
}

.limited-banner {
  margin: 10px 0 0;
  border: 1px solid #d8b97c;
  border-radius: var(--radius);
  padding: .55rem .7rem;
  background: var(--workspace-warm, #f8ecd0);
  color: var(--medium-ink, #7a520b);
  font-size: .85rem;
}

/* Follow up chips */

.follow-ups {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.side-prompt {
  flex-basis: 100%;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.side-known {
  display: flex;
  flex-basis: 100%;
  align-items: center;
  gap: 5px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.side-change {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.side-choices {
  display: contents;
}

.chip.chip-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  padding: 5px 11px;
  font-size: 0.8rem;
  color: var(--ink, #3c423f);
}

.chip:hover {
  border-color: #c4cec8;
  background: var(--surface, #fff);
}

.side-chip {
  color: var(--muted);
}

.side-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Composer */

.composer {
  padding: 10px 24px 18px;
  background: linear-gradient(to top, var(--canvas) 70%, rgba(247, 247, 245, 0));
}

.composer > * {
  width: min(760px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.composer-box {
  display: grid;
  border: 1px solid #d7dcd8;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(25, 35, 30, 0.06);
  padding: 10px 10px 8px 14px;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 24px rgba(25, 35, 30, 0.06);
}

.composer.drag-over .composer-box {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 24px rgba(25, 35, 30, 0.06);
}

.composer textarea {
  width: 100%;
  border: 0;
  resize: none;
  background: transparent;
  padding: 4px 2px;
  min-height: 46px;
  max-height: 220px;
  outline: none;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
}

.icon-button:hover {
  background: var(--soft);
  color: var(--ink);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attach-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding-inline: 8px;
}

.attach-label {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

@media (max-width: 480px) {
  .attach-label {
    display: none;
  }

  .attach-button {
    width: 34px;
    padding: 0;
  }
}

.send-button {
  padding: 8px 16px;
  font-size: 0.88rem;
}

.composer-hint {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
  margin: 7px 0 0;
}

.queued-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.queued-cancel {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.composer-more {
  position: relative;
  margin-right: auto;
  align-self: center;
}

.composer-more > summary {
  color: var(--muted);
  font-size: 0.74rem;
  cursor: pointer;
  list-style: none;
}

.composer-more > summary::-webkit-details-marker {
  display: none;
}

.composer-more > summary::before {
  content: "+ ";
}

.composer-more[open] > summary::before {
  content: "− ";
}

.composer-more .client-row {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 5;
  width: min(300px, 70vw);
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(25, 35, 30, 0.1);
}

.client-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-right: auto;
  color: var(--muted);
  font-size: 0.74rem;
}

.client-row > span {
  white-space: nowrap;
}

.client-hint {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.client-row select {
  max-width: 180px;
  width: 100%;
  padding: 3px 6px;
  border: 1px solid #d7dcd8;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.client-row select:disabled {
  opacity: 0.6;
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.attachment-state {
  flex-basis: 100%;
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 4px 6px 4px 9px;
  font-size: 0.78rem;
  max-width: 100%;
}

.attachment-chip.static {
  padding-right: 9px;
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.attachment-detail {
  color: var(--muted);
  font-size: 0.72rem;
}

.attachment-remove {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  border-radius: var(--radius);
}

.attachment-remove:hover {
  color: var(--danger);
}

/* Drop overlay */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(247, 247, 245, 0.82);
  backdrop-filter: blur(2px);
}

.drop-card {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 46px 64px;
  background: var(--paper);
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 600;
}

/* Drawer */

.drawer {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(25, 35, 30, 0.12);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  display: none;
  background: rgba(30, 36, 33, 0.32);
}

@media (max-width: 900px) {
  .drawer-backdrop:not(.hidden) {
    display: block;
  }

  .drawer {
    width: min(440px, 100vw);
  }
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-eyebrow {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.drawer-header h2 {
  font-size: 1rem;
  margin: 2px 0 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 28px;
}

.drawer-loading {
  color: var(--muted);
}

.review-clauses {
  display: grid;
  gap: 14px;
}

.review-clause {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.review-clause.is-cited {
  border-radius: var(--radius);
  background: var(--workspace-warm, #fff7cc);
  box-shadow: inset 3px 0 0 #e0b000;
  padding: 10px 12px;
}

.review-clause h3 {
  font-size: 0.88rem;
  margin: 0 0 6px;
}

.review-clause p {
  margin: 0 0 6px;
  font-size: 0.92rem;
}

.review-clause p:last-child {
  margin-bottom: 0;
}

mark.review-highlight {
  background: var(--workspace-warm, #ffe066);
  color: inherit;
  border-radius: var(--radius);
  padding: 0 2px;
  box-shadow: 0 0 0 1px #e0b000;
}

/* Toast and dialog */

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
}

.toast strong {
  display: block;
}

.toast span {
  color: var(--muted);
}

.toast-close {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1rem;
}

.toast .icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
}

.toast-error .icon {
  stroke: var(--danger);
}

.app-dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(30, 36, 33, 0.3);
}

.app-dialog h2 {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

.dialog-fields {
  display: grid;
  gap: 12px;
}

.dialog-field {
  display: grid;
  gap: 5px;
  font-size: 0.85rem;
  color: var(--muted);
}

.dialog-field input,
.dialog-field select,
.dialog-field textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  background: var(--paper);
  color: var(--ink);
}

.dialog-field small {
  font-size: 0.75rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Responsive */

@media (max-width: 780px) {
  .chat-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    gap: 10px;
  }

  .sidebar-brand {
    display: none;
  }

  .history {
    max-height: 120px;
  }

  .account-row {
    justify-content: flex-start;
  }

  .sidebar-footer {
    display: flex;
    align-items: center;
    gap: 14px;
    border-top: 0;
    padding-top: 0;
  }

  .thread {
    padding: 16px 14px 24px;
  }

  .composer {
    padding: 8px 14px 14px;
  }

  .example-prompts {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.bubble p,
.bubble ol,
.bubble ul {
  margin: 0 0 0.6em;
}

.bubble > :last-child {
  margin-bottom: 0;
}

.bubble ol,
.bubble ul {
  padding-left: 1.4em;
}

.bubble li + li {
  margin-top: 0.3em;
}

.bubble p,
.bubble ol,
.bubble ul,
.bubble li {
  white-space: normal;
}

.cite-repeat {
  font-size: 0.9em;
  opacity: 0.85;
}

.cite + .cite {
  margin-left: 0.25em;
}

.first-pass-compact {
  font-size: 0.9em;
  color: var(--muted, #555);
  margin: 0.25em 0;
}

.first-pass-compact p {
  margin: 0 0 0.35em;
}

/* Client approved-draft downloads (flag-gated) */
.client-drafts {
  padding: 0.5rem 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.client-drafts-heading {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #6b7280);
}
.client-drafts-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.client-draft-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.4rem;
  background: var(--surface-2, #f9fafb);
}
.client-draft-row strong {
  font-size: 0.85rem;
}
.client-draft-row .button-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* Client assistant ---------------------------------------------------------------------- */
.assistant-entry {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.assistant-entry:hover {
  border-color: var(--accent);
  background: var(--workspace-green, #dcebe4);
}

.assistant-entry[aria-current="page"] {
  background: var(--accent);
  color: #fff;
}

.assistant-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 24px 32px;
}

.assistant-panel {
  width: min(900px, 100%);
  margin: 0 auto;
}

.assistant-page h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.assistant-page .field-hint {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.assistant-page .button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.assistant-page .pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.assistant-page .pill-low {
  background: var(--accent-soft);
  color: var(--low-ink, #1f5a47);
}

.assistant-page .pill-medium {
  background: var(--workspace-warm, #f8ecd0);
  color: var(--medium-ink, #7a520b);
}

.assistant-page .pill-neutral {
  background: var(--soft);
  color: var(--muted);
}

.assistant-note {
  margin: 0;
  color: var(--muted);
}

.assistant-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  background: var(--paper);
  text-align: center;
}

.assistant-empty p {
  max-width: 460px;
  margin: 0 auto;
  color: var(--muted);
}

.assistant-start {
  display: grid;
  gap: 22px;
}

.assistant-page .ask-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.assistant-page .chip-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  background: var(--paper);
  font-size: 0.88rem;
  font-weight: 600;
}

.assistant-page .chip-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.assistant-page .queue-list {
  display: grid;
  gap: 8px;
}

.assistant-page .queue-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--paper);
}

.assistant-page .queue-card-main {
  min-width: 0;
  flex: 1;
}

.assistant-page .queue-card strong,
.assistant-page .queue-card-main span {
  display: block;
}

.assistant-page .queue-card-main span {
  color: var(--muted);
  font-size: 0.85rem;
}

.assistant-page .secondary-button.compact {
  padding: 6px 12px;
  font-size: 0.88rem;
}

.assistant-chat {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr);
  gap: 22px;
  align-items: start;
}

.assistant-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.assistant-chat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
}

.assistant-transcript {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 160px;
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--soft);
}

.assistant-msg {
  max-width: 86%;
  border-radius: var(--radius);
  padding: 8px 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.assistant-who {
  display: block;
  margin-bottom: 2px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.assistant-msg.client {
  justify-self: end;
  background: var(--accent);
  color: #fff;
}

.assistant-msg.agent {
  justify-self: start;
  border: 1px solid var(--line);
  background: var(--paper);
}

.assistant-msg.notice {
  justify-self: center;
  max-width: 100%;
  border: 1px dashed #c9d0cb;
  background: var(--surface-soft, #eef3f7);
  font-size: 0.88rem;
  text-align: center;
}

.assistant-question {
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 8px 13px;
  background: var(--accent-soft);
}

.assistant-question-label {
  display: block;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.assistant-question p {
  margin: 2px 0 0;
  font-weight: 600;
}

.assistant-form {
  display: grid;
  gap: 10px;
}

.assistant-form textarea {
  width: 100%;
  border: 1px solid #d7dcd8;
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--paper);
  resize: vertical;
}

.assistant-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.assistant-form textarea:disabled {
  background: var(--soft);
}

.assistant-page button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.assistant-submit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--accent-soft);
}

.assistant-submit .field-hint {
  flex: 1 1 14rem;
  margin: 0;
}

.assistant-page .notice {
  border: 1px solid var(--accent);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--accent-soft);
}

.assistant-page .notice strong {
  display: block;
}

.assistant-facts {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--paper);
}

.assistant-page .fact-list {
  display: grid;
}

.assistant-fact {
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.assistant-fact:last-child {
  border-bottom: 0;
}

.assistant-fact-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.assistant-fact-head strong {
  min-width: 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.assistant-fact-value {
  margin: 2px 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.assistant-fact.unknown .assistant-fact-value,
.assistant-fact.pending .assistant-fact-value {
  color: var(--muted);
  font-weight: 400;
}

.assistant-fact-evidence {
  margin: 6px 0 0;
  border-left: 3px solid #cfd8d2;
  padding: 1px 0 1px 10px;
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .assistant-chat {
    grid-template-columns: minmax(0, 1fr);
  }

  .assistant-msg {
    max-width: 94%;
  }
}
