:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-soft: #f0f1ee;
  --ink: #171717;
  --muted: #6f706b;
  --line: #deded8;
  --accent: #111111;
  --accent-strong: #000000;
  --warn: #a66321;
  --danger: #a6403a;
  --sidebar: #20211f;
  --sidebar-muted: #a9aaa4;
  --shadow: 0 18px 50px rgba(20, 20, 18, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.link-button {
  border: 0;
  background: transparent;
  color: #0c5e84;
  padding: 0;
  text-align: left;
  font-weight: 760;
}

.auth-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.auth-status {
  min-height: 20px;
}

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 460px) 1fr;
}

.login-card {
  background: #fbfbfa;
  padding: 54px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 20, 18, 0.38);
}

.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(20, 20, 18, 0.22);
  padding: 24px;
  display: grid;
  gap: 18px;
}

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

.modal-head h2 {
  margin: 0 0 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 760;
  letter-spacing: 0;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #111;
  font-weight: 800;
}

.login h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.06;
  letter-spacing: 0;
}

.login p,
.muted {
  color: var(--muted);
}

.login-visual {
  padding: 56px;
  display: grid;
  align-content: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(45, 130, 255, 0.14), transparent 34%),
    radial-gradient(circle at 72% 62%, rgba(24, 126, 104, 0.14), transparent 30%),
    linear-gradient(135deg, #fbfbfa 0%, #f4f8fb 54%, #fbf7f0 100%);
}

.document-stack {
  max-width: 820px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 34px;
  border-radius: 14px;
  display: grid;
  gap: 24px;
  position: relative;
  overflow: hidden;
}

.document-stack::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, #0c6d79, #376cff, #f0a33a);
}

.document-stack h2 {
  margin: 6px 0 12px;
  max-width: 560px;
  font-family: inherit;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 780;
}

.login-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.eyebrow,
.workflow-kicker {
  color: #0c6d79;
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-preview-badge {
  flex: 0 0 auto;
  border: 1px solid #cfe1df;
  background: #ecf7f5;
  color: #0c5e54;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 780;
}

.login-workflow-illustration {
  display: grid;
  grid-template-columns: 170px 28px 1fr;
  gap: 18px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid #dfe3df;
  border-radius: 12px;
  background: linear-gradient(180deg, #f9fbfb, #f4f5f1);
}

.workflow-column {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 18px;
  border-radius: 10px;
  background: #111;
  color: #fff;
}

.workflow-column small {
  color: #cfd2cc;
}

.workflow-rail {
  display: grid;
  justify-items: center;
  align-content: center;
  grid-template-rows: 14px 1fr 14px 1fr 14px;
}

.rail-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid #c8d4d1;
  background: #fff;
}

.rail-dot.active {
  border-color: #0c6d79;
  background: #0c6d79;
}

.rail-line {
  width: 2px;
  min-height: 28px;
  background: #d9ded9;
}

.login-workflow-illustration .workflow-steps {
  display: grid;
  gap: 10px;
}

.login-workflow-illustration .workflow-step {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 72px;
  padding: 13px;
  border: 1px solid #e2e5e0;
  border-radius: 10px;
  background: #fff;
}

.login-workflow-illustration .workflow-step > span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8f4f2;
  color: #0c6d79;
  font-weight: 820;
}

.login-workflow-illustration .workflow-step strong,
.login-storage-strip strong {
  display: block;
}

.login-workflow-illustration .workflow-step small,
.login-storage-strip span {
  color: var(--muted);
  line-height: 1.35;
}

.login-storage-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.login-storage-strip > div {
  min-height: 82px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #e2e3df;
  background: #fbfaf7;
}

.form-row {
  display: grid;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

textarea {
  resize: vertical;
}

.button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 720;
}

.button.secondary {
  background: #ededea;
  color: var(--ink);
}

.button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

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

.sidebar {
  background: var(--sidebar);
  color: #f4f4ef;
  border-right: 1px solid #171817;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  border: 0;
  background: transparent;
  color: var(--sidebar-muted);
  text-align: left;
  border-radius: 8px;
  padding: 10px 11px;
  font-weight: 650;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar .muted {
  color: var(--sidebar-muted);
}

.main {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  background: rgba(247, 247, 245, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.mobile-nav {
  display: none;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e9e9e5;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 760;
}

.muted-pill {
  color: var(--muted);
}

.drive-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 720;
}

.drive-chip.connected {
  color: #17483f;
  background: #e9f3ef;
  border-color: #c7ded5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(390px, 0.86fr) minmax(520px, 1.14fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.workspace.with-research {
  grid-template-columns: minmax(360px, 0.78fr) minmax(430px, 0.92fr) minmax(320px, 0.58fr);
}

.chat {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--line);
  background: #fbfbfa;
  overflow: hidden;
}

.mode-strip {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.mode-strip button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--muted);
  padding: 8px 12px;
  font-weight: 720;
}

.mode-strip button.active {
  color: var(--ink);
  background: #ededea;
}

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

.workflow-step {
  border: 0;
  text-align: left;
  background: #f7f7f5;
  color: var(--ink);
  min-width: 0;
  min-height: 58px;
  padding: 12px 14px;
  display: grid;
  align-content: center;
  gap: 3px;
}

.workflow-step span {
  font-size: 12px;
  font-weight: 780;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.workflow-step small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.workflow-step.active {
  background: #fff;
  box-shadow: inset 0 -3px 0 #17483f;
}

.workflow-step.active span {
  color: #17483f;
}

.workflow-step.complete span {
  color: #315f55;
}

.workflow-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.workflow-nav strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.workflow-nav span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.workflow-nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.thread {
  padding: 22px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: 92%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 13px 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #ededea;
}

.message.intake-message {
  padding: 0;
  overflow: hidden;
  white-space: normal;
}

.missing-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.pending-missing-panel {
  display: grid;
  gap: 12px;
  border: 1px solid #c7ded5;
  border-radius: 10px;
  background: #f5fbf8;
  padding: 13px;
}

.missing-complete-card {
  border: 1px solid #dfe3df;
  border-radius: 10px;
  background: #fff;
  padding: 12px 13px;
}

.missing-complete-card p {
  margin: 4px 0 0;
  font-size: 13px;
}

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

.missing-card-head p {
  margin: 5px 0 0;
  font-size: 13px;
}

.missing-question {
  display: grid;
  gap: 7px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.missing-question textarea {
  min-height: 68px;
  background: #fbfbfa;
}

.missing-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.composer {
  background: #fbfbfa;
  border-top: 1px solid var(--line);
  padding: 14px 16px 16px;
  display: grid;
  gap: 10px;
  position: sticky;
  bottom: 0;
  z-index: 5;
}

.composer-controls {
  display: grid;
  grid-template-columns: 1fr 1.1fr 0.72fr;
  gap: 9px;
}

.handoff-card {
  border: 1px solid #c7ded5;
  border-radius: 10px;
  background: #f5fbf8;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.workspace-template-card {
  border: 1px solid #d8d8d2;
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: start;
}

.workspace-template-card.active {
  border-color: #c7ded5;
  background: #f7fbf9;
}

.workspace-template-card p {
  margin: 4px 0 0;
  font-size: 13px;
}

.workspace-template-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.template-selected-note {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #17483f;
}

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

.handoff-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.handoff-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.custom-draft-card {
  border: 1px solid #d8d8d2;
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 12px;
}

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

.custom-draft-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.custom-draft-grid {
  display: grid;
  gap: 10px;
}

.custom-template-row textarea {
  min-height: 88px;
}

.template-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.finding-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.finding-chip {
  border: 1px solid #c7ded5;
  border-radius: 999px;
  background: #fff;
  color: #17483f;
  max-width: 100%;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 720;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finding-chip.high {
  border-color: #efc1bd;
  color: #7d2d27;
  background: #fff7f5;
}

.finding-chip.medium {
  border-color: #ead2aa;
  color: #744915;
  background: #fffaf0;
}

.review-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.review-textarea {
  grid-column: 1 / -1;
}

.review-inputs textarea {
  min-height: 94px;
}

.upload-box {
  display: grid;
  gap: 7px;
}

.upload-box input[type="file"] {
  min-height: 42px;
  padding: 8px;
}

.hidden-file {
  display: none;
}

.attach-control {
  display: inline-flex;
}

.intake-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 12px;
}

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

.intake-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #f7f7f5;
  border-radius: 999px;
  padding: 5px 6px 5px 10px;
  font-size: 12px;
}

.attachment-chip button {
  border: 0;
  border-radius: 999px;
  background: #e3e3de;
  color: #333;
  padding: 3px 7px;
  font-size: 11px;
}

.review-attachment-list {
  margin-bottom: 8px;
}

.intake-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.intake-card li {
  margin: 4px 0;
  color: #30312f;
  font-size: 13px;
  line-height: 1.35;
}

.send-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 9px;
}

.document-panel {
  padding: 22px;
  overflow: auto;
  background: #f3f3f0;
  position: relative;
  min-width: 0;
}

.document-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.export-banner {
  margin: -4px 0 16px;
  border: 1px solid #c7ded5;
  border-radius: 8px;
  background: #eef6f3;
  color: #17483f;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  font-weight: 720;
}

.export-banner a {
  color: #17483f;
  font-weight: 820;
}

.document-page {
  background: #fff;
  border: 1px solid #d6d6cf;
  box-shadow: var(--shadow);
  width: min(820px, 100%);
  max-width: 100%;
  margin: 0 auto;
  padding: clamp(28px, 4vw, 54px) clamp(26px, 4.5vw, 58px);
  min-height: 780px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.62;
  white-space: normal;
}

.document-page[contenteditable="true"] {
  outline: 2px solid rgba(15, 107, 98, 0.18);
}

.clean-document h1,
.clean-document h2,
.clean-document h3,
.clean-document h4 {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  line-height: 1.25;
  color: #181a18;
}

.clean-document h1 {
  font-size: 26px;
  margin: 0 0 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid #dcdcd5;
}

.clean-document h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 30px 0 10px;
  color: #4b4d49;
}

.clean-document h3,
.clean-document h4 {
  font-size: 14px;
  margin: 22px 0 8px;
}

.clean-document p {
  margin: 9px 0;
  font-size: 15px;
}

.clean-document ul,
.clean-document ol {
  margin: 8px 0 16px;
  padding-left: 24px;
}

.clean-document li {
  margin: 5px 0;
  font-size: 15px;
}

.doc-status {
  display: inline-block;
  border: 1px solid #d8c19c;
  background: #fff7e8;
  color: #684a18;
  padding: 6px 9px;
  border-radius: 6px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 12px !important;
  font-weight: 740;
}

.verify {
  color: #8a4b00;
  background: #fff0d6;
  border-radius: 4px;
  padding: 1px 4px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.88em;
  font-weight: 720;
}

.selectable-document::selection {
  background: #dce9e5;
}

.selection-toolbar {
  position: absolute;
  z-index: 20;
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid #d8d8d2;
  border-radius: 8px;
  background: #181918;
  box-shadow: 0 12px 30px rgba(20, 20, 18, 0.18);
}

.selection-toolbar button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 740;
}

.selection-toolbar button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.research-drawer {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: #fbfbfa;
  padding: 18px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
}

.research-drawer-head,
.case-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.selected-quote {
  border-left: 3px solid #17483f;
  background: #eef6f3;
  color: #213b35;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.selected-quote strong {
  display: block;
  margin-bottom: 6px;
  color: #17483f;
  font-size: 12px;
}

.selected-quote p {
  margin: 0;
}

.research-ask {
  display: grid;
  gap: 8px;
}

.research-answer {
  display: grid;
  gap: 12px;
}

.answer-card,
.issue-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.answer-card h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.18;
}

.answer-card p,
.issue-card p,
.issue-card li {
  margin: 0;
  color: #30312f;
  font-size: 13px;
  line-height: 1.45;
}

.issue-card h4 {
  margin: 0;
  font-size: 13px;
}

.issue-card ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.verification-note {
  border-left: 3px solid #d8c19c;
  background: #fff8eb;
  padding: 8px 10px;
  color: #66420f;
  font-size: 12px;
  line-height: 1.4;
}

.citation-status {
  border: 1px solid #c7ded5;
  border-radius: 8px;
  background: #eef6f3;
  color: #17483f;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.35;
}

.research-query-card,
.support-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.research-query-card {
  display: grid;
  gap: 9px;
}

.research-query-card p,
.direct-answer {
  margin: 0;
  color: #30312f;
  font-size: 13px;
  line-height: 1.5;
}

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

.support-card strong,
.support-card span {
  display: block;
}

.support-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.support-card b {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e7efec;
  color: #17483f;
  padding: 8px 10px;
}

.support-card.unsupported {
  border-color: #ead3b2;
  background: #fff9ee;
}

.support-card.unsupported b {
  background: #f3dfc1;
  color: #7d4a10;
}

.research-label {
  width: fit-content;
  border-radius: 999px;
  background: #e7efec;
  color: #17483f;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}

.research-message {
  border-left: 3px solid #17483f;
}

.case-chip-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.case-chip {
  border: 1px solid #c7ded5;
  background: #f4fbf8;
  color: #17483f;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 720;
}

.case-results,
.extract-list {
  display: grid;
  gap: 10px;
}

.case-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.case-card p {
  margin: 0;
  color: #30312f;
  font-size: 13px;
  line-height: 1.45;
}

.legal-reference-marker {
  display: inline;
  margin-left: 4px;
  border-radius: 4px;
  background: #eef6f3;
  color: #17483f;
  padding: 1px 4px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78em;
  font-weight: 780;
}

.extract-list blockquote {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid #d8c19c;
  background: #fff8eb;
}

.extract-list p {
  margin: 0 0 6px;
  font-size: 13px;
}

.extract-list cite,
.research-disclaimer,
.empty-research {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.empty-doc {
  min-height: 520px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #c8c8c0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
}

.section {
  padding: 28px;
  overflow: auto;
}

.setup-guide-app-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.setup-guide-frame-shell {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(25, 25, 22, 0.08);
}

.setup-guide-frame {
  display: block;
  width: 100%;
  height: min(78vh, calc(100vh - 170px));
  min-height: 620px;
  border: 0;
  background: #fbfaf8;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0 0 6px;
}

.tabular-page {
  background:
    radial-gradient(circle at 12% 8%, rgba(47, 111, 235, 0.08), transparent 26%),
    radial-gradient(circle at 90% 12%, rgba(255, 111, 97, 0.08), transparent 24%),
    var(--bg);
}

.tabular-shell {
  display: grid;
  grid-template-columns: clamp(360px, 24vw, 430px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  max-width: 100%;
  overflow: hidden;
}

.tabular-controls {
  display: grid;
  gap: 12px;
  min-width: 0;
  position: relative;
  z-index: 2;
}

.tabular-controls .card {
  display: grid;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}

.tabular-controls h3 {
  margin-bottom: 0;
}

.tabular-upload-control {
  border: 1px dashed #c9cac3;
  border-radius: 10px;
  background: #fbfbfa;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.tabular-upload-control .button {
  width: 100%;
}

.file-picker-button {
  cursor: pointer;
}

.file-picker-button.disabled {
  opacity: 0.62;
  pointer-events: none;
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.upload-errors {
  display: grid;
  gap: 6px;
}

.upload-errors div {
  border-left: 3px solid var(--danger);
  background: #fff6f4;
  color: #6f2520;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.35;
}

.document-list,
.column-list {
  display: grid;
  gap: 8px;
}

.document-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfa;
  padding: 9px 10px;
}

.document-row > div {
  min-width: 0;
}

.document-row strong,
.document-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.document-row small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.mini-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 760;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfa;
  padding: 8px 10px;
  color: var(--ink);
}

.check-row input {
  width: auto;
  min-height: 0;
}

.inline-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.tabular-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.export-status {
  border: 1px solid #c7ded5;
  border-radius: 8px;
  background: #f4fbf8;
  color: #17483f;
  padding: 9px 10px;
  display: grid;
  gap: 6px;
  font-size: 12px;
  line-height: 1.35;
}

.export-links {
  display: grid;
  gap: 6px;
}

.export-links .button {
  min-height: 34px;
  font-size: 12px;
}

.export-status a {
  color: #17483f;
  font-weight: 820;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tabular-results {
  min-width: 0;
  display: grid;
  gap: 14px;
  position: relative;
  z-index: 1;
  overflow: hidden;
  border: 1px solid rgba(222, 222, 216, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
  padding: 12px;
}

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

.tabular-summary div {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 32px rgba(20, 20, 18, 0.05);
  padding: 14px;
}

.tabular-summary strong {
  display: block;
  color: #17483f;
  font-size: 24px;
}

.tabular-summary span {
  color: var(--muted);
  font-size: 12px;
}

.review-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  max-height: min(62vh, 720px);
  overscroll-behavior: contain;
}

.review-table {
  width: max-content;
  min-width: 100%;
  border: 0;
  table-layout: fixed;
}

.review-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.review-table th:first-child,
.review-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  box-shadow: 1px 0 0 var(--line);
}

.review-table th:first-child {
  z-index: 3;
  background: #f9faf8;
}

.review-cell {
  width: 168px;
  min-width: 168px;
  max-width: 168px;
  cursor: pointer;
}

.review-table th:not(:first-child) {
  width: 168px;
  min-width: 168px;
  max-width: 168px;
}

.review-table td,
.review-table th {
  vertical-align: top;
}

.review-table td strong,
.cell-value {
  overflow-wrap: anywhere;
}

.review-cell:hover {
  background: #f3f8ff;
}

.review-cell.found {
  border-left: 3px solid #17483f;
}

.review-cell.missing {
  color: var(--muted);
  background: #fbfbfa;
}

.review-cell.high {
  border-left-color: var(--danger);
  background: #fff6f4;
}

.review-cell.medium {
  border-left-color: var(--warn);
  background: #fff9ee;
}

.cell-value {
  font-weight: 760;
  line-height: 1.35;
}

.cell-issue {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 4px;
}

.cell-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cell-meta span {
  border-radius: 999px;
  background: #ededea;
  color: var(--muted);
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 760;
}

.source-button {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #17483f;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
}

.source-panel-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.source-panel-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(24, 25, 24, 0.24);
  cursor: default;
  pointer-events: auto;
}

.cell-source-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(460px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(20, 20, 18, 0.24);
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  pointer-events: auto;
}

.source-panel-head {
  position: sticky;
  top: -16px;
  z-index: 1;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin: -16px -16px 2px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.icon-close {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f7f5;
  color: var(--ink);
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.icon-close:hover {
  background: #ecece8;
}

.source-status {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfa;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.source-status.found {
  border-color: #c7ded5;
  background: #f4fff9;
}

.source-status strong {
  color: #17201d;
}

.source-status span {
  color: var(--muted);
  font-size: 12px;
}

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

.source-section h4 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.finding-summary p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.source-quote {
  margin: 0;
  border-left: 4px solid #17483f;
  border-radius: 8px;
  background: #f7fbf9;
  padding: 12px 14px;
}

.source-quote p {
  margin: 0;
  line-height: 1.55;
}

.source-context,
.source-document-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfa;
  color: #30312f;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
}

.source-document-preview summary {
  cursor: pointer;
  color: #17483f;
  font-weight: 820;
}

.source-document-preview p {
  margin: 10px 0 0;
  white-space: pre-wrap;
}

.tabular-empty {
  min-height: 420px;
}

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

.storage-page {
  max-width: 1120px;
}

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

.storage-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  display: grid;
  gap: 18px;
  box-shadow: 0 10px 28px rgba(20, 20, 18, 0.04);
}

.storage-card.connected {
  border-color: #c7ded5;
  background: #fbfefd;
}

.storage-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.storage-card h3 {
  margin: 0 0 5px;
}

.storage-card p {
  margin: 0;
}

.drive-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #1f1f1d;
  color: #fff;
  font-weight: 800;
}

.storage-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.storage-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.storage-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.template-setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 14px;
  margin: 18px 0;
}

.template-setup-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.template-setup-card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.template-setup-card p,
.template-setup-card li {
  color: #3e3f3a;
  line-height: 1.45;
}

.template-setup-card ol {
  margin: 0;
  padding-left: 20px;
}

.template-path {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  border-radius: 8px;
  background: #eef6f3;
  color: #17483f;
  font-weight: 760;
}

.template-path span,
.template-path b {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}

.template-path b {
  border-radius: 999px;
  background: #fff;
  border: 1px solid #c7ded5;
  padding: 0 10px;
}

.template-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.template-workbench {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(420px, 1.05fr);
  gap: 16px;
  align-items: start;
  margin-top: 18px;
}

.template-builder,
.template-library {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: 0 10px 28px rgba(20, 20, 18, 0.04);
}

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

.template-builder-head h2 {
  margin: 0 0 5px;
  font-size: 22px;
}

.template-builder-head p {
  margin: 0;
}

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

.template-wide {
  grid-column: 1 / -1;
}

.template-wide textarea {
  min-height: 86px;
}

.template-wide:last-child textarea {
  min-height: 190px;
  font-family: inherit;
}

.template-card-list {
  display: grid;
  gap: 10px;
}

.template-library-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfbfa;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.template-library-card.active {
  border-color: #c7ded5;
  background: #f8fcfa;
}

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

.template-library-card-head p,
.template-library-card > p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #4f504b;
}

.section-subhead {
  margin: 24px 0 10px;
  font-size: 22px;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.admin-metric {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 3px;
}

.admin-metric strong {
  color: #17483f;
  font-size: 28px;
  line-height: 1;
}

.admin-metric span {
  font-weight: 780;
}

.admin-metric small {
  color: var(--muted);
  line-height: 1.3;
}

.admin-section {
  margin-top: 22px;
}

.admin-control-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 16px;
}

.admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.admin-section h2 {
  margin: 0;
  font-size: 22px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.admin-table {
  min-width: 980px;
  border: 0;
}

.admin-table th,
.admin-table td {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.admin-check-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.admin-checkbox {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
}

.admin-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: #111;
}

.admin-actions-cell {
  min-width: 260px;
}

.admin-actions-cell .button {
  margin: 2px 4px 2px 0;
}

.compact-segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f2f3f0;
}

.compact-segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.compact-segmented button.active {
  background: #111;
  color: #fff;
}

.compact-button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
}

.danger-button {
  border-color: #e0b9b6;
  color: #8f312b;
  background: #fff7f6;
}

.empty-doc.compact {
  min-height: 120px;
}

.storage-form .form-row:first-child,
.storage-form .form-row:nth-child(2) {
  grid-column: 1 / -1;
}

.storage-list {
  margin: 0;
  padding-left: 18px;
  color: #30312f;
  line-height: 1.5;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.table th {
  color: var(--muted);
  background: #f9faf8;
  font-weight: 760;
}

.table tr {
  cursor: pointer;
}

.table tbody tr:hover {
  background: #f3f4f1;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin: 18px 0;
}

.library-page-head {
  align-items: center;
}

.custom-skill-editor {
  margin: 18px 0 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(20, 20, 18, 0.06);
  display: grid;
  gap: 16px;
}

.custom-skill-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.custom-skill-editor-head h2,
.custom-skill-editor-head p {
  margin: 0;
}

.custom-skill-editor-head p {
  margin-top: 5px;
}

.custom-skill-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.custom-skill-wide {
  grid-column: 1 / -1;
}

.custom-skill-editor-actions,
.library-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.custom-skill-label {
  display: inline-flex;
  margin-left: 8px;
  border-radius: 999px;
  background: #e7efec;
  color: #17483f;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.library-actions .button {
  min-height: 30px;
}

.lab-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.test-result {
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.test-result pre {
  margin: 0;
  white-space: pre-wrap;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #20211f;
}

.note {
  border-left: 3px solid var(--warn);
  padding: 10px 12px;
  background: #fff7ec;
  color: #5d4428;
  line-height: 1.45;
}

@media (max-width: 1080px) {
  .app,
  .login,
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main {
    grid-template-rows: auto auto minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .topbar {
    gap: 10px;
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  .topbar .status-row {
    min-width: 0;
    flex-wrap: wrap;
  }

  .mobile-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: #fbfbfa;
  }

  .mobile-nav button {
    flex: 0 0 auto;
    border: 0;
    border-radius: 999px;
    background: #ededea;
    color: var(--muted);
    min-height: 34px;
    padding: 0 12px;
    font-weight: 760;
    font-size: 13px;
  }

  .mobile-nav button.active {
    background: #111;
    color: #fff;
  }

  .login-visual {
    display: none;
  }

  .workspace {
    grid-template-rows: minmax(520px, 1fr) auto;
    height: auto;
    overflow: visible;
  }

  .chat {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .section {
    width: 100%;
    min-width: 0;
  }

  .grid,
  .storage-grid,
  .template-setup-grid,
  .template-workbench,
  .workspace-template-card,
  .admin-summary,
  .tabular-shell,
  .tabular-summary,
  .workflow-ribbon,
  .intake-columns,
  .composer-controls,
  .workspace-template-controls,
  .template-form-grid,
  .custom-skill-form-grid,
  .send-row,
  .filters {
    grid-template-columns: 1fr;
  }

  .workflow-nav {
    align-items: stretch;
    flex-direction: column;
  }

  .workflow-nav-actions {
    width: 100%;
  }

  .workflow-nav-actions .button {
    flex: 1 1 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar > .status-row {
    width: 100%;
  }

  .section {
    padding: 18px 14px;
  }

  .page-head,
  .custom-skill-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .library-page-head .button,
  .custom-skill-editor-actions .button {
    width: 100%;
  }

  .custom-skill-editor {
    min-width: 0;
    padding: 14px;
  }

  .table {
    min-width: 720px;
  }
}
