:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1e2329;
  --muted: #68717d;
  --line: #d9dee6;
  --blue: #2863c7;
  --blue-dark: #1d4f9f;
  --green: #227653;
  --red: #b42318;
  --amber: #8a5a00;
  --shadow: 0 10px 28px rgba(30, 35, 41, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
textarea,
a {
  font: inherit;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: #fbfbfc;
  padding: 22px;
  overflow: hidden;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #1f2a44;
  color: #ffffff;
  font-weight: 800;
}

.brand h1,
.topbar h2,
.empty-state h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.eyebrow,
.empty-state p,
.meta,
.step-message {
  color: var(--muted);
}

.brand p {
  margin: 2px 0 0;
  font-size: 13px;
}

.sidebar-row,
.topbar,
.composer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-row h2 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.icon-button,
.docs-link,
.composer button,
.new-chat-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 34px;
  height: 34px;
  font-weight: 700;
}

.new-chat-button {
  min-height: 38px;
  font-weight: 800;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.history-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.history-item:hover {
  border-color: #9aa7b8;
}

.history-item.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 99, 199, 0.14);
}

.history-item strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

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

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 18px 24px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 22px;
}

.docs-link {
  padding: 9px 12px;
  text-decoration: none;
}

.conversation {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 28px clamp(18px, 4vw, 56px) 24px;
}

.empty-state {
  max-width: 620px;
  margin: auto;
  text-align: center;
}

.empty-state h3 {
  font-size: 28px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.prompt-grid button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.prompt-grid button:hover {
  border-color: #9aa7b8;
}

.message,
.step-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.message {
  max-width: min(760px, 92%);
  padding: 14px 16px;
}

.message.user {
  align-self: flex-end;
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.message.agent {
  align-self: flex-start;
}

.message.error {
  align-self: flex-start;
  border-color: #f3b4ad;
  background: #fff4f2;
}

.message p,
.step-card p,
.result-card p {
  margin: 8px 0 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user .meta,
.message.user p {
  color: #ffffff;
}

.message a,
.step-card a {
  color: var(--blue-dark);
  font-weight: 700;
}

.message.user a {
  color: #ffffff;
}

.meta {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.steps {
  display: grid;
  gap: 10px;
  width: min(760px, 92%);
  align-self: flex-start;
}

.step-card {
  padding: 14px;
  box-shadow: none;
}

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.step-title {
  font-weight: 700;
}

.badge {
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #e9f6ef;
  color: var(--green);
}

.badge.warn {
  background: #fff4d8;
  color: var(--amber);
}

pre {
  overflow-x: auto;
  border-radius: 8px;
  background: #161a22;
  color: #f5f7fb;
  padding: 12px;
  white-space: pre-wrap;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  border-top: 1px solid var(--line);
  background: rgba(246, 247, 249, 0.94);
  padding: 14px clamp(18px, 4vw, 56px) 18px;
  backdrop-filter: blur(12px);
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: min(860px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px;
  box-shadow: var(--shadow);
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 180px;
  resize: none;
  border: 0;
  border-radius: 6px;
  padding: 10px 8px;
  color: var(--text);
  line-height: 1.45;
  outline: none;
}

.composer textarea:focus {
  outline: none;
}

.composer-inner:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 99, 199, 0.15), var(--shadow);
}

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 92px;
  height: 42px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.send-button:hover {
  background: var(--blue-dark);
}

.send-button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.send-icon {
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
}

.send-button.is-loading .send-icon {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.loading-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.loading-dot {
  width: 16px;
  height: 16px;
  border: 2px solid #c9d4e5;
  border-top-color: var(--blue);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.search-results {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.browser-action-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.browser-action-card span {
  color: var(--muted);
  font-size: 13px;
}

.browser-action-card a {
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  padding: 8px 10px;
  text-decoration: none;
}

.search-result {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
  text-decoration: none;
}

.search-result strong {
  display: block;
  color: var(--text);
}

.search-result span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    overflow: auto;
  }

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

  .history-list {
    max-height: 180px;
  }

  .workspace {
    min-height: calc(100vh - 230px);
  }

  .topbar,
  .composer-inner {
    align-items: stretch;
    flex-direction: column;
  }

  .docs-link,
  .send-button {
    width: 100%;
    text-align: center;
  }

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