:root {
  color-scheme: light;
  --canvas: #f8f9f8;
  --paper: #ffffff;
  --ink: #1e2421;
  --muted: #66716b;
  --line: #dce2de;
  --line-strong: #bbc7c0;
  --green: #177353;
  --green-soft: #e8f4ed;
  --blue: #286789;
  --blue-soft: #eaf2f6;
  --coral: #ba5944;
  --coral-soft: #fbefec;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--canvas);
}

body {
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

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

button,
label {
  cursor: pointer;
}

button:focus-visible,
label:focus-within,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

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

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  border-right: 1px solid var(--line);
  background: #f2f5f3;
}

.sidebar-top,
.section-title-row,
.workspace-topbar,
.topbar-actions,
.composer-toolbar,
.composer-tools,
.composer-actions,
.utility-heading,
.file-chip,
.source-row,
.activity-row,
.settings-list div {
  display: flex;
  align-items: center;
}

.sidebar-top {
  min-height: 42px;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #8eb7a4;
  border-radius: 5px;
  color: var(--green);
  background: var(--paper);
  font-size: 11px;
  font-weight: 800;
}

.brand-name {
  color: #25342d;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.12;
}

.icon-button,
.send-button {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: var(--ink);
  background: #e1e8e3;
  outline: none;
}

.sidebar-close,
.sidebar-toggle {
  display: none;
}

.primary-nav,
.secondary-nav {
  display: grid;
  gap: 3px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  color: #3d4641;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.nav-item:hover,
.nav-item:focus-visible {
  color: var(--ink);
  background: #e5ebe7;
  outline: none;
}

.nav-item.active {
  color: var(--ink);
  background: #dfe7e2;
}

.nav-icon {
  width: 21px;
  height: 21px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #aebbb4;
  border-radius: 3px;
  color: #4d5c54;
  background: var(--paper);
  font-size: 10px;
  font-weight: 800;
}

.nav-item.active .nav-icon {
  border-color: var(--green);
  color: var(--green);
}

.recent-section {
  flex: 1;
  min-height: 142px;
  margin-top: 24px;
  padding: 0 8px;
}

.section-title-row {
  justify-content: space-between;
}

.sidebar-label,
.view-kicker,
.empty-eyebrow,
.utility-caption {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.recent-sessions {
  display: grid;
  gap: 3px;
  margin-top: 8px;
}

.recent-session {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.recent-session:hover,
.recent-session:focus-visible,
.recent-session.active {
  color: var(--ink);
  background: #e5ebe7;
  outline: none;
}

.recent-session-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.recent-session-time {
  padding-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.secondary-nav {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sidebar-version {
  margin: 14px 8px 0;
  color: var(--muted);
  font-size: 11px;
}

.workspace-main {
  width: min(100%, 1260px);
  min-height: 100vh;
  display: grid;
  grid-template-rows: 86px minmax(0, 1fr);
  margin: 0 auto;
  padding: 0 42px;
}

.workspace-topbar {
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.workspace-topbar h1,
.utility-heading h2,
.future-view h2,
.settings-view h2,
.empty-state h2 {
  margin: 0;
  color: #171c19;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: 0;
}

.workspace-topbar h1 {
  margin-top: 3px;
  font-size: 22px;
}

.topbar-actions {
  gap: 12px;
}

.run-state {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.workspace-view {
  min-width: 0;
}

.chat-view {
  min-height: calc(100vh - 86px);
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto;
}

.chat-history {
  min-height: 0;
  max-height: calc(100vh - 310px);
  overflow-y: auto;
  padding: 38px 0 24px;
  scrollbar-gutter: stable;
}

.empty-state {
  min-height: 390px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.empty-eyebrow {
  margin-bottom: 14px;
  color: var(--green);
}

.empty-state h2 {
  max-width: 700px;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1.04;
}

.empty-copy {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.chat-message {
  width: min(82%, 800px);
  margin-bottom: 29px;
}

.chat-message.user {
  margin-left: auto;
}

.message-label,
.message-meta {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.message-label {
  margin-bottom: 7px;
  font-weight: 750;
}

.chat-message.user .message-label {
  text-align: right;
}

.message-body {
  overflow-wrap: anywhere;
  padding: 13px 15px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.chat-message.user .message-body {
  border: 1px solid #c4dace;
  border-radius: 6px;
  background: var(--green-soft);
}

.chat-message.assistant .message-body {
  border-left: 3px solid var(--blue);
  background: var(--paper);
}

.message-meta {
  margin-top: 8px;
  line-height: 1.45;
}

.message-references {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
}

.message-references summary {
  cursor: pointer;
  font-weight: 700;
}

.reference-list {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.chat-form {
  padding: 16px 0 24px;
  border-top: 1px solid var(--line);
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}

.file-list:empty {
  display: none;
}

.file-chip {
  max-width: min(100%, 356px);
  gap: 7px;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.file-size {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.remove-file {
  width: 22px;
  height: 22px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 15px;
}

.remove-file:hover,
.remove-file:focus-visible {
  color: var(--coral);
  background: var(--coral-soft);
  outline: none;
}

.composer {
  min-height: 164px;
  display: grid;
  grid-template-rows: minmax(94px, 1fr) auto;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--paper);
  box-shadow: 0 10px 24px rgba(25, 39, 31, 0.06);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.composer:focus-within,
.composer.dragging {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 115, 83, 0.12), 0 10px 24px rgba(25, 39, 31, 0.06);
}

.composer textarea {
  width: 100%;
  min-height: 94px;
  max-height: 220px;
  padding: 18px 19px 6px;
  resize: vertical;
  border: 0;
  color: var(--ink);
  background: transparent;
  outline: none;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: #8b9690;
}

.composer-toolbar {
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 11px;
}

.composer-tools,
.composer-actions {
  gap: 7px;
}

.composer-select,
.model-select,
.attach-button,
.outline-button {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #47524c;
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}

.composer-select:hover,
.model-select:hover,
.attach-button:hover,
.outline-button:hover,
.composer-select:focus-within,
.model-select:focus-within,
.attach-button:focus-within,
.outline-button:focus-within {
  border-color: var(--line);
  color: var(--ink);
  background: #f5f7f6;
  outline: none;
}

.composer-select select,
.model-select select {
  min-width: 0;
  max-width: 148px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  outline: none;
  font: inherit;
}

.composer-select select {
  width: 56px;
}

.attach-button input,
#file-input {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.model-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a5afa9;
}

.model-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 3px #ddf0e6;
}

.model-dot.offline {
  background: var(--coral);
  box-shadow: 0 0 0 3px #f9e2dc;
}

.send-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--paper);
  background: var(--green);
  font-size: 19px;
  font-weight: 800;
}

.send-button:hover,
.send-button:focus-visible {
  background: #0f5e43;
  outline: none;
}

.send-button:disabled {
  color: #8b9690;
  background: #e4e9e6;
  cursor: not-allowed;
}

.form-footer {
  min-height: 23px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 2px 0;
}

.form-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.form-error {
  color: var(--coral) !important;
}

.utility-view {
  width: min(100%, 880px);
  padding: 48px 0;
}

.utility-heading {
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.utility-heading h2,
.future-view h2,
.settings-view h2 {
  margin-top: 5px;
  font-size: 30px;
}

.outline-button {
  border-color: var(--line-strong);
  background: var(--paper);
}

.source-list,
.activity-list,
.settings-list {
  margin-top: 22px;
}

.source-row {
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.source-row strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.source-row span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.pending-source strong::before {
  content: "PENDING ";
  color: var(--blue);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.empty-utility,
.future-status {
  margin: 22px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.source-caption {
  margin-top: 30px;
}

.activity-list {
  display: grid;
}

.activity-row {
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.activity-marker {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--blue);
}

.activity-row div {
  display: grid;
  gap: 3px;
}

.activity-row strong {
  font-size: 13px;
}

.activity-row span:not(.activity-marker) {
  color: var(--muted);
  font-size: 11px;
}

.future-view {
  max-width: 680px;
}

.future-view .future-status {
  width: fit-content;
  padding: 9px 12px;
  border-left: 3px solid var(--coral);
  background: var(--coral-soft);
}

.settings-list {
  display: grid;
  margin-bottom: 0;
  padding: 0;
}

.settings-list div {
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.settings-list dt {
  color: var(--muted);
  font-size: 12px;
}

.settings-list dd {
  margin: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 650;
}

.visually-hidden {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    width: min(300px, calc(100vw - 36px));
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    transform: translateX(-105%);
    box-shadow: 12px 0 28px rgba(25, 39, 31, 0.14);
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close,
  .sidebar-toggle {
    display: grid;
  }

  .workspace-main {
    min-height: 100vh;
    padding: 0 24px;
  }
}

@media (max-width: 620px) {
  .workspace-main {
    grid-template-rows: 74px minmax(0, 1fr);
    padding: 0 16px;
  }

  .workspace-topbar {
    gap: 12px;
  }

  .workspace-topbar h1 {
    font-size: 20px;
  }

  .view-kicker {
    font-size: 9px;
  }

  .run-state {
    display: none;
  }

  .chat-view {
    min-height: calc(100vh - 74px);
  }

  .chat-history {
    max-height: calc(100vh - 290px);
    padding-top: 26px;
  }

  .empty-state {
    min-height: 310px;
  }

  .empty-state h2 {
    font-size: 34px;
  }

  .empty-copy {
    max-width: 290px;
    font-size: 14px;
  }

  .chat-message {
    width: 94%;
  }

  .composer-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .composer-actions {
    width: 100%;
    justify-content: space-between;
  }

  .model-select select {
    max-width: 220px;
  }

  .form-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .utility-view {
    padding-top: 34px;
  }

  .utility-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-row,
  .settings-list div {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .settings-list dd {
    text-align: left;
  }
}
