:root {
  --paper: #f3efe8;
  --plate: #faf8f4;
  --white: #ffffff;
  --border: #e4ddd2;
  --ink: #1f1c19;
  --muted: #6c6358;
  --copper: #a2542a;
  --verdigris: #2f6b55;
  --crimson: #b33a3a;
  --vault: #243447;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  color: var(--ink);
  background: var(--plate);
  height: 100vh;
  overflow: hidden;
}

.mono { font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", monospace; }
.small { font-size: 12px; }
.bold { font-weight: 600; }
.muted { color: var(--muted); }
.green { color: var(--verdigris); }
.full { width: 100%; }

.shell {
  display: grid;
  grid-template-columns: 264px 1fr 308px;
  height: 100vh;
}
.shell.inspector-collapsed {
  grid-template-columns: 264px 1fr 0px;
}
.shell.inspector-collapsed .inspector {
  display: none;
}

.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--vault); color: var(--white);
  display: grid; place-items: center; font-weight: 700;
}
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--muted); }

.btn-new-chat {
  background: var(--white); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-weight: 600; font-size: 13px; color: var(--ink);
  cursor: pointer; text-align: left;
}
.btn-new-chat:hover { border-color: var(--copper); }

.compliance-pill {
  display: flex; align-items: center; gap: 8px;
  background: #edf5f1; border: 1px solid #cce2d8;
  border-radius: 8px; padding: 7px 10px; font-size: 12px; font-weight: 600;
  color: var(--verdigris);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--verdigris); }

.section-row { display: flex; justify-content: space-between; align-items: center; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }

.matter-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.matter-item {
  text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: 8px; padding: 9px 10px; cursor: pointer; color: var(--ink); font-size: 13px;
}
.matter-item:hover { background: rgba(255, 255, 255, 0.55); }
.matter-item.active { background: var(--white); border-color: var(--border); font-weight: 600; }
.matter-item-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sidebar-footer {
  border-top: 1px solid var(--border); padding-top: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.field-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; }
.select, .input {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--white); color: var(--ink); font-size: 13px;
}

.workspace {
  position: relative;
  background: var(--plate);
  display: flex; flex-direction: column; overflow: hidden;
}
.topbar {
  padding: 13px 24px; background: var(--white); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.matter-heading { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matter-pill {
  font-size: 11px; color: var(--muted); background: var(--paper);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.topbar-actions { display: flex; gap: 8px; }

.drag-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(250, 248, 244, 0.92);
  display: grid; place-items: center;
}
.drag-overlay[hidden] { display: none; }
.drag-overlay-box {
  background: var(--white); border: 2px dashed var(--copper);
  border-radius: 16px; padding: 36px 48px; text-align: center;
}

.chat-stream {
  flex: 1; overflow-y: auto; padding: 28px 24px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.chat-column {
  width: 100%; max-width: 820px; display: flex; flex-direction: column; gap: 18px;
}

.welcome-box {
  margin: auto 0; text-align: center; padding: 24px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.welcome-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.welcome-sub { margin: 0; max-width: 560px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.playbook-grid {
  width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: left;
}
.playbook-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer;
}
.playbook-card:hover { border-color: var(--copper); }
.playbook-title { font-weight: 600; font-size: 13px; color: var(--ink); }
.playbook-desc { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.4; }

.msg-user {
  align-self: flex-end; max-width: 78%;
  background: var(--vault); color: var(--white);
  border-radius: 16px 16px 4px 16px; padding: 12px 16px; font-size: 14px; line-height: 1.5;
}
.msg-assistant {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px;
}
.msg-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border);
  padding-bottom: 8px; margin-bottom: 12px;
}
.msg-actions { display: flex; gap: 8px; align-items: center; }

.md-body { font-size: 14.5px; line-height: 1.65; color: var(--ink); }
.md-body h2 { font-size: 17px; margin: 16px 0 8px; }
.md-body h3 { font-size: 15px; margin: 14px 0 6px; }
.md-body p { margin: 8px 0; }
.md-body ul, .md-body ol { margin: 8px 0; padding-left: 22px; }
.md-body li { margin: 4px 0; }
.md-body code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  background: var(--paper); padding: 1px 5px; border-radius: 4px; font-size: 12.5px;
}
.md-table-wrap { overflow-x: auto; margin: 12px 0; }
.md-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td {
  border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top;
}
.md-table th { background: var(--paper); font-weight: 600; }

.cite-pill {
  display: inline-block; background: #edf5f1; color: var(--verdigris);
  border: 1px solid #c6dcd2; border-radius: 6px; padding: 1px 6px;
  font-size: 12px; cursor: pointer; margin: 0 2px;
}
.cite-pill.unverified { background: #fdf2f2; color: var(--crimson); border-color: #f3c4c4; }

.composer-wrap {
  width: 100%; max-width: 868px; margin: 0 auto;
  padding: 8px 24px 16px; display: flex; flex-direction: column; gap: 8px;
}
.attached-strip {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; display: flex; flex-direction: column; gap: 6px;
}
.token-mini { display: flex; align-items: center; gap: 10px; }
.token-bar { flex: 1; height: 5px; background: var(--paper); border-radius: 999px; overflow: hidden; }
.token-fill { height: 100%; width: 0%; background: var(--verdigris); }
.doc-list { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 9px; font-size: 12px;
}
.doc-del { background: none; border: none; color: var(--muted); cursor: pointer; font-weight: 700; }

.quick-playbooks { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-pill {
  background: var(--white); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.quick-pill:hover { border-color: var(--copper); color: var(--copper); }

.composer {
  background: var(--white); border: 1.5px solid var(--border); border-radius: 16px;
  padding: 8px 10px; display: flex; align-items: flex-end; gap: 8px;
  box-shadow: 0 6px 24px rgba(31, 28, 25, 0.05);
}
.composer:focus-within { border-color: var(--copper); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--paper); color: var(--ink); font-size: 18px; cursor: pointer;
}
.composer-input {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  font-family: inherit; font-size: 14.5px; line-height: 1.45; padding: 6px 4px; max-height: 140px;
}
.btn-send {
  background: var(--copper); color: var(--white); border: none; border-radius: 10px;
  padding: 8px 16px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.composer-foot { text-align: center; }

.inspector {
  background: var(--paper); border-left: 1px solid var(--border);
  padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto;
}
.panel {
  background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 12px;
}
.roi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.roi-card { background: var(--plate); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.roi-label { font-size: 10px; font-weight: 700; color: var(--muted); }
.roi-val { font-size: 15px; font-weight: 700; margin-top: 2px; }

.citation-body {
  white-space: pre-wrap; font-size: 12px; background: var(--plate);
  padding: 10px; border-radius: 8px; max-height: 220px; overflow-y: auto; margin: 8px 0 0;
}
.feedback-form { display: flex; gap: 6px; margin-top: 8px; }
.audit-panel { flex: 1; display: flex; flex-direction: column; min-height: 160px; }
.audit-list { margin-top: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 11px; }
.audit-row { background: var(--plate); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }

.btn-secondary {
  background: var(--white); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font-weight: 600; cursor: pointer; font-size: 12px;
}
.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 12px;
}
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.dialog { border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-width: 560px; }
.code-box { background: #1a1816; color: #f5efe6; padding: 12px; border-radius: 8px; font-size: 12px; overflow-x: auto; }
