:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #172033;
  --muted: #667085;
  --line: #d7deea;
  --accent: #0f8b8d;
  --accent-2: #d9480f;
  --button: #172033;
  --button-text: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
  padding: 0 14px;
  cursor: pointer;
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
}

button.active-action {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent);
}

button.stop-button {
  min-height: 32px;
  background: var(--accent-2);
  padding: 0 12px;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  min-height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
}

.topbar p,
.eyebrow,
.meta,
#statusLabel {
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--surface-2);
  color: var(--text);
}

.chat-list {
  height: calc(100vh - 134px);
  overflow: auto;
  padding: 8px;
}

.search-shell {
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--line);
}

.source-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.source-button,
.full-button {
  width: 100%;
}

.full-button {
  margin-top: 8px;
}

.search-shell input {
  width: 100%;
}

.chat-row {
  width: 100%;
  min-height: 62px;
  display: block;
  text-align: left;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
}

.chat-row:hover,
.chat-row.active {
  background: var(--surface-2);
}

.chat-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.meta {
  display: block;
  margin-top: 4px;
}

.empty-state {
  padding: 18px 10px;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 14px;
  padding: 18px;
}

.workspace-header,
.actions,
.ask-panel,
.digest-panel,
.answer-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-header {
  justify-content: space-between;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

select,
input {
  min-height: 40px;
  padding: 0 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  padding: 12px;
}

.ask-panel {
  align-items: stretch;
}

.ask-panel button {
  min-width: 96px;
}

.digest-panel {
  flex-wrap: wrap;
}

.digest-panel label {
  font-size: 14px;
  font-weight: 700;
}

.answer-shell {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.answer-header {
  justify-content: space-between;
  min-height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.answer-output {
  padding: 16px;
  overflow: auto;
  font-size: 15px;
  line-height: 1.6;
}

.answer-output h1,
.answer-output h2,
.answer-output h3 {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.25;
}

.answer-output p {
  margin: 0 0 10px;
}

.answer-output ul,
.answer-output ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.answer-output li {
  margin: 7px 0;
}

.answer-output strong {
  font-weight: 800;
}

.answer-output code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-2);
}

.answer-output table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 14px;
  font-size: 14px;
}

.answer-output th,
.answer-output td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.answer-output th {
  background: var(--surface-2);
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-list {
    height: auto;
    max-height: 260px;
  }

  .workspace-header,
  .ask-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}
