:root {
  color-scheme: light;
  --ink: #18201e;
  --muted: #66716d;
  --paper: #f7f4ed;
  --panel: #fffdf8;
  --line: #dcd8cd;
  --green: #1f5f4a;
  --green-dark: #164638;
  --green-soft: #e2eee7;
  --ochre: #c87832;
  --danger: #9e3d34;
  --danger-soft: #f9e9e5;
  --shadow: 0 16px 44px rgb(40 50 46 / 9%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, rgb(200 120 50 / 8%), transparent 25rem),
    var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--green);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--ochre);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.85rem;
  transform: translateY(-200%);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--green-dark);
  font-weight: 750;
}

.skip-link:focus {
  transform: translateY(0);
}

.noscript,
.notice {
  margin: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel);
}

.notice.error {
  border-color: #e4b8b0;
  background: var(--danger-soft);
  color: var(--danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wordmark {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  color: var(--ink);
  font-size: 0.91rem;
  font-weight: 760;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.wordmark-mark {
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  place-items: center;
  border-radius: 0.65rem 0.65rem 0.2rem;
  background: var(--green);
  color: white;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card {
  width: min(100%, 34rem);
  padding: clamp(1.5rem, 5vw, 3.5rem);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  background: rgb(255 253 248 / 94%);
  box-shadow: var(--shadow);
}

.auth-card .wordmark {
  margin-bottom: 3rem;
}

.auth-card h1 {
  max-width: 12ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 7vw, 3.65rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.98;
}

.lede {
  max-width: 47ch;
  margin: 1.25rem 0 1.75rem;
  color: var(--muted);
}

.sign-in-slot,
.rm-clerk-root,
.rm-clerk-card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.sign-in-slot {
  min-height: 3.5rem;
}

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

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) auto minmax(10rem, 1fr);
  gap: 1rem;
  align-items: center;
  min-height: 4.6rem;
  padding: 0.7rem clamp(1rem, 3vw, 2.3rem);
  border-bottom: 1px solid var(--line);
  background: rgb(247 244 237 / 92%);
  backdrop-filter: blur(16px);
}

.topnav {
  display: flex;
  gap: 0.2rem;
  align-items: center;
}

.topnav a {
  padding: 0.55rem 0.75rem;
  border-radius: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.topnav a:hover,
.topnav a.active {
  background: var(--green-soft);
  color: var(--green-dark);
}

.account {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
}

.user-label {
  max-width: 15rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: center;
  min-height: 2.45rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 760;
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button.quiet {
  border-color: var(--line);
  background: var(--panel);
}

.button.quiet:hover:not(:disabled) {
  border-color: #bdb8ab;
  background: white;
}

.button.primary {
  min-width: 7.3rem;
  background: var(--green);
  color: white;
}

.button.primary:hover:not(:disabled) {
  background: var(--green-dark);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 23rem);
  min-height: calc(100vh - 4.6rem);
}

.conversation {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: clamp(1rem, 3vw, 2.25rem);
}

.conversation-head {
  display: flex;
  gap: 2rem;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 0.35rem;
}

.conversation-head h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.thread-tools {
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
}

.field {
  display: grid;
  gap: 0.3rem;
}

.field > span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.field input,
.field select {
  min-height: 2.45rem;
  padding: 0.45rem 2rem 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--panel);
}

.field.compact select {
  max-width: 14rem;
}

.policy,
.status {
  min-height: 1.25rem;
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.status.error {
  color: var(--danger);
}

.local-auth {
  display: flex;
  gap: 1rem;
  align-items: end;
  margin-top: 0.8rem;
  padding: 0.8rem;
  border: 1px dashed #b8b2a5;
  border-radius: 0.75rem;
  background: #fff9e8;
}

.local-auth p {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.messages {
  flex: 1;
  min-height: 23rem;
  max-height: calc(100vh - 18.5rem);
  margin: 1rem 0;
  padding: 1rem 0.2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.empty-state {
  display: grid;
  max-width: 35rem;
  min-height: 20rem;
  margin: 0 auto;
  place-content: center;
  text-align: center;
}

.empty-mark {
  display: grid;
  width: 3.2rem;
  height: 3.2rem;
  margin: 0 auto 1rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ochre);
  font-size: 1.4rem;
}

.empty-state h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 500;
}

.empty-state p {
  max-width: 46ch;
  margin: 0.65rem auto 0;
  color: var(--muted);
}

.empty-hint {
  max-width: 52ch;
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

.message,
.action-card,
.notice-card {
  width: fit-content;
  max-width: min(48rem, 86%);
  margin: 0.7rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.95rem;
  background: var(--panel);
  box-shadow: 0 8px 20px rgb(40 50 46 / 4%);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.user {
  margin-left: auto;
  border-color: #c9d9d0;
  background: var(--green-soft);
}

.message.assistant {
  border-top-left-radius: 0.3rem;
}

.message.error {
  border-color: #e4b8b0;
  background: var(--danger-soft);
  color: var(--danger);
}

.citations {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: normal;
}

.citations strong {
  color: var(--ink);
}

.citations ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

.action-card {
  border-color: #b9cfc3;
  background: #f1f7f3;
  white-space: normal;
}

.action-card.governed-handoff {
  width: min(52rem, 96%);
  max-width: 52rem;
  padding: 0;
  overflow: hidden;
  border-color: #a9c5b7;
  border-radius: 1.15rem;
  background: var(--panel);
  box-shadow: 0 20px 48px rgb(31 95 74 / 13%);
}

.action-card h3 {
  margin: 0;
  color: var(--green-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 600;
}

.action-card p {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.handoff-head {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.15rem 1.2rem 1rem;
  background:
    radial-gradient(circle at 100% 0, rgb(200 120 50 / 13%), transparent 13rem),
    linear-gradient(135deg, #e5f1e9 0%, #f3f7ef 68%, #fbf3e8 100%);
}

.handoff-eyebrow {
  margin: 0 0 0.3rem !important;
  color: var(--green) !important;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.handoff-status {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.38rem;
  align-items: center;
  min-height: 1.9rem;
  padding: 0.35rem 0.62rem;
  border: 1px solid rgb(31 95 74 / 22%);
  border-radius: 999px;
  background: rgb(255 253 248 / 82%);
  color: var(--green-dark);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.handoff-status::before {
  width: 0.48rem;
  height: 0.48rem;
  border: 2px solid var(--green);
  border-radius: 50%;
  content: "";
}

.handoff-description {
  max-width: 58ch;
  margin: 0 !important;
  padding: 0.95rem 1.2rem 0;
  color: var(--ink) !important;
  font-size: 0.86rem;
}

.handoff-path-label {
  margin: 0 !important;
  padding: 1rem 1.2rem 0;
  color: var(--muted) !important;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.handoff-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 0.85rem 1.2rem 1.2rem;
  list-style: none;
}

.handoff-step {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 0.55rem;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.handoff-step:not(:last-child)::after {
  position: absolute;
  z-index: 0;
  top: 1rem;
  left: calc(50% + 1.2rem);
  width: calc(100% - 2.4rem);
  height: 2px;
  background: var(--line);
  content: "";
}

.handoff-step.complete:not(:last-child)::after {
  background: #8fb7a2;
}

.handoff-step-marker {
  position: relative;
  z-index: 1;
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid #d3d6d2;
  border-radius: 50%;
  background: var(--panel);
  color: #7a827e;
  font-size: 0.72rem;
  font-weight: 850;
}

.handoff-step.complete .handoff-step-marker {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.handoff-step.next .handoff-step-marker {
  border-color: var(--ochre);
  background: #fff8ed;
  color: #a35d22;
  box-shadow: 0 0 0 4px rgb(200 120 50 / 13%);
}

.handoff-step-copy {
  display: grid;
  gap: 0.05rem;
}

.handoff-step-copy strong {
  color: inherit;
  font-size: 0.74rem;
  line-height: 1.3;
}

.handoff-step-copy small {
  color: inherit;
  font-size: 0.66rem;
}

.handoff-step.complete {
  color: var(--green-dark);
}

.handoff-step.next {
  color: #9a571f;
}

/* A refused proposal, not a proposal: ochre rather than the action green, so
   the advisor can tell at a glance that nothing was recorded. */
.notice-card {
  border-color: #e3c9a8;
  background: #fbf3e8;
  white-space: normal;
}

.notice-card h3 {
  margin: 0;
  color: var(--ochre);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 600;
}

.notice-card p {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.notice-card .notice-hint {
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px solid #ecd9be;
  color: var(--ink);
}

.action-result {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid #cfddd5;
  font-size: 0.78rem;
}

.handoff-result {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 1rem 1.2rem 1.2rem;
  border-top: 1px solid #dce5df;
  background: #f7faf7;
}

.handoff-guidance {
  max-width: 72ch;
  margin: 0 !important;
  color: var(--muted) !important;
  font-size: 0.74rem;
}

.safe-link {
  display: inline-block;
  margin-top: 0.35rem;
  font-weight: 750;
}

.safe-link.action-cta {
  display: flex;
  width: 100%;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.65rem 0.9rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.7rem;
  background: var(--green);
  color: white;
  font-size: 0.78rem;
  text-decoration: none;
}

.safe-link.action-cta:hover {
  background: var(--green-dark);
}

.composer {
  display: grid;
  gap: 0.7rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.composer-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}

.composer-row textarea {
  width: 100%;
  min-height: 2.65rem;
  max-height: 12rem;
  padding: 0.55rem 0.65rem;
  resize: vertical;
  border: 0;
  background: transparent;
}

.attachment-button {
  display: grid;
  flex: 0 0 2.65rem;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--panel);
  cursor: pointer;
  font-size: 1.1rem;
}

.attachment-button:hover:not(:disabled),
.attachment-button[aria-expanded="true"] {
  border-color: #9fbaa9;
  background: var(--green-soft);
}

.compact-button {
  min-height: 2rem;
  padding: 0.35rem 0.6rem;
}

.document-selection {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.65rem;
  border: 1px solid #b9cfc3;
  border-radius: 0.7rem;
  background: #f1f7f3;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.document-intake {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.document-intake-head,
.document-intake-actions {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

.document-intake-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  font-weight: 550;
}

.document-intake-copy,
.document-intake-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.document-intake-status.error {
  color: var(--danger);
}

.destination-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.destination-fields select {
  width: 100%;
}

.document-dropzone {
  display: grid;
  width: 100%;
  min-height: 7rem;
  padding: 1rem;
  place-items: center;
  border: 1px dashed #9faaa5;
  border-radius: 0.8rem;
  background: #fbfaf5;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.document-dropzone > span {
  color: var(--ochre);
  font-size: 1.45rem;
}

.document-dropzone small {
  color: var(--muted);
  font-size: 0.72rem;
}

.document-dropzone.dragover {
  border-color: var(--green);
  background: var(--green-soft);
}

.document-dropzone:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.document-file-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.document-file-list li {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: #fbfaf5;
  font-size: 0.76rem;
}

.document-file-state {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}

.document-file-state.ready {
  color: var(--green);
}

.document-file-state.failed {
  color: var(--danger);
}

.document-receipt {
  padding: 0.8rem;
  border: 1px solid #b9cfc3;
  border-radius: 0.75rem;
  background: #f1f7f3;
}

.document-receipt h3 {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
}

.document-receipt dl {
  display: grid;
  gap: 0.3rem;
  margin: 0;
}

.document-receipt dl > div {
  display: grid;
  grid-template-columns: minmax(5rem, 0.25fr) minmax(0, 1fr);
  gap: 0.6rem;
}

.document-receipt dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}

.document-receipt dd {
  margin: 0;
  overflow-wrap: anywhere;
  font: 0.7rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.runtime {
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 1.8rem);
  border-left: 1px solid var(--line);
  background: rgb(255 253 248 / 68%);
}

.runtime-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.runtime h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 500;
}

.live-dot {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.live-dot::before {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #2f8f69;
  content: "";
}

.runtime-intro,
.events-empty {
  color: var(--muted);
  font-size: 0.78rem;
}

.events {
  display: grid;
  gap: 0.55rem;
  margin-top: 1.15rem;
}

.event {
  display: grid;
  gap: 0.25rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--panel);
}

.event strong {
  font-size: 0.76rem;
}

.event code {
  overflow-wrap: anywhere;
  color: var(--muted);
  font: 0.68rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .topnav {
    justify-content: center;
    overflow-x: auto;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 19rem;
  }

  .conversation-head,
  .thread-tools {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr auto;
  }

  .topnav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    order: 3;
  }

  .user-label {
    display: none;
  }

  .workspace {
    display: block;
  }

  .messages {
    max-height: none;
  }

  .runtime {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .auth-screen {
    padding: 0.75rem;
  }

  .auth-card {
    padding: 1.35rem;
  }

  .conversation,
  .runtime {
    padding: 1rem;
  }

  .thread-tools,
  .local-auth,
  .composer-row,
  .destination-fields,
  .document-intake-head,
  .document-intake-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .destination-fields {
    grid-template-columns: 1fr;
  }

  .document-selection {
    align-items: stretch;
    flex-direction: column;
  }

  .field.compact select,
  .message,
  .action-card,
  .notice-card {
    max-width: 100%;
  }

  .action-card.governed-handoff {
    width: 100%;
  }

  .handoff-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .handoff-steps {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .handoff-step {
    min-height: 3.9rem;
    grid-template-columns: 2rem minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    justify-items: stretch;
    text-align: left;
  }

  .handoff-step:not(:last-child)::after {
    top: 2rem;
    left: 0.95rem;
    width: 2px;
    height: calc(100% - 0.2rem);
  }

  .button.primary {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
