:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --line: #d9dde5;
  --text: #171a21;
  --muted: #667085;
  --accent: #1769aa;
  --accent-dark: #0f4f82;
  --user: #e8f2ff;
  --agent: #ffffff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

html,
body {
  height: 100%;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #eef1f5;
  padding: 20px;
}

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

.mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

.brand p,
.status {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grow {
  min-height: 0;
  flex: 1;
}

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

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  outline: none;
  padding: 10px 12px;
}

textarea {
  resize: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

.row button,
.composer button,
.section-head button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-head h2,
.chat-head h2 {
  font-size: 16px;
}

.section-head button {
  width: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.sessions {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
}

.session-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.session-button.active {
  border-color: var(--accent);
  background: #f4f9ff;
}

.session-button strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 18px 24px;
}

.chat-head a {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.messages {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px;
}

.empty {
  margin: auto;
  max-width: 460px;
  color: var(--muted);
  text-align: center;
}

.message {
  max-width: min(760px, 82%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.5;
}

.message.user {
  align-self: flex-end;
  background: var(--user);
}

.message.agent {
  align-self: flex-start;
  background: var(--agent);
}

.message p,
.message ul,
.message ol,
.message pre,
.message blockquote {
  margin: 0 0 12px;
}

.message > :last-child {
  margin-bottom: 0;
}

.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
  margin: 14px 0 8px;
  line-height: 1.25;
}

.message h1 {
  font-size: 22px;
}

.message h2 {
  font-size: 19px;
}

.message h3 {
  font-size: 17px;
}

.message ul,
.message ol {
  padding-left: 22px;
}

.message li + li {
  margin-top: 5px;
}

.message code {
  border-radius: 5px;
  background: #eef2f6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 2px 5px;
}

.message pre {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101828;
  color: #f8fafc;
  padding: 12px;
}

.message pre code {
  display: block;
  background: transparent;
  color: inherit;
  padding: 0;
  white-space: pre;
}

.mermaid {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  margin: 12px 0;
  padding: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

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

.data-table th {
  background: #f8fafc;
  font-weight: 700;
}

.message a {
  color: var(--accent);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.message blockquote {
  border-left: 3px solid var(--line);
  color: var(--muted);
  padding-left: 12px;
}

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

.usage {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding-top: 8px;
}

.run-id {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  margin-top: 4px;
}

.feedback {
  display: grid;
  grid-template-columns: auto 34px 34px minmax(160px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding-top: 10px;
}

.feedback input {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
}

.feedback-thumb,
.feedback-submit {
  min-height: 34px;
  border-radius: 8px;
  background: #eef2f6;
  color: var(--text);
  padding: 0 10px;
}

.feedback-thumb {
  width: 34px;
  padding: 0;
}

.feedback-thumb:hover,
.feedback-submit:hover,
.feedback-thumb.selected {
  background: var(--accent);
  color: white;
}

.feedback-status {
  min-width: 42px;
}

.details-block {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.details-block summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.nested-details {
  margin-top: 8px;
}

.market-report {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.market-report h3,
.report-section h4 {
  margin: 0;
}

.market-report h3 {
  font-size: 16px;
}

.report-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.report-section h4 {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.report-section p,
.report-section ul {
  margin: 6px 0 0;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.client-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.client-row span {
  color: var(--accent);
  font-weight: 700;
}

.client-row p {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.details-block ol {
  margin: 10px 0 0;
  padding-left: 22px;
}

.details-block li {
  margin-bottom: 10px;
}

.details-block li p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 16px 24px;
}

.compose-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.attachments {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.file-button {
  display: inline-grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  white-space: nowrap;
}

.file-button:hover {
  border-color: var(--accent);
}

#files {
  display: none;
}

.file-list {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.file-chip {
  max-width: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef4fb;
  color: var(--text);
  font-size: 12px;
  padding: 5px 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer button {
  min-width: 92px;
}

.composer button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: 100dvh;
  }

  .sidebar {
    max-height: 38dvh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sessions {
    max-height: none;
  }

  .chat {
    height: 62dvh;
    min-height: 0;
  }

  .message {
    max-width: 100%;
  }

  .report-grid {
    grid-template-columns: 1fr;
  }

  .feedback {
    grid-template-columns: auto 34px 34px;
  }

  .feedback input,
  .feedback-submit,
  .feedback-status {
    grid-column: 1 / -1;
  }
}
