:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-alt: #eef2f6;
  --border: #d9e0e8;
  --text: #182230;
  --muted: #667085;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
textarea,
input {
  font: inherit;
}

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

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-card label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 14px;
  font-weight: 650;
}

.login-card input {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.login-card button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.login-brand {
  margin-bottom: 8px;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #fbfcfe;
  padding: 24px;
  overflow-y: auto;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p,
.panel h2,
.chat-header h2,
.chat-header p {
  margin: 0;
}

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

.brand p,
.hint,
.chat-header p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.panel {
  padding: 18px 0;
  border-top: 1px solid var(--border);
}

.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #344054;
  margin-bottom: 12px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title-row h2 {
  margin-bottom: 0;
}

.icon-action {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.history-item {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item:hover,
.history-item.active {
  border-color: var(--border);
  background: var(--surface);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.quick-action {
  width: 100%;
  min-height: 42px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.quick-action:hover {
  border-color: var(--accent);
}

.chat-area {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 100vh;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.chat-header h2 {
  font-size: 20px;
}

.status {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-alt);
}

.status.busy {
  color: var(--accent-dark);
  border-color: #99d2c9;
  background: #e7f7f4;
}

.status.error {
  color: var(--danger);
  border-color: #f3b7b0;
  background: #fff0ee;
}

.messages {
  overflow-y: auto;
  padding: 28px 28px 120px;
}

.message {
  display: flex;
  margin-bottom: 16px;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(760px, 92%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
  line-height: 1.55;
}

.bubble h2,
.bubble h3,
.bubble p,
.bubble ul {
  margin: 0 0 12px;
}

.bubble h2 {
  font-size: 18px;
}

.bubble h3 {
  font-size: 15px;
}

.bubble ul {
  padding-left: 20px;
}

.bubble li {
  margin-bottom: 6px;
}

.bubble a {
  color: var(--accent-dark);
  font-weight: 650;
  text-decoration: none;
}

.bubble a:hover {
  text-decoration: underline;
}

.table-wrap {
  overflow-x: auto;
  margin: 10px 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.bubble th,
.bubble td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.bubble th {
  background: var(--surface-alt);
  color: #344054;
}

.message.user .bubble {
  background: #dff3ef;
  border-color: #b5ddd6;
}

.message.assistant .bubble {
  box-shadow: var(--shadow);
}

.composer-wrap {
  position: sticky;
  bottom: 0;
  padding: 18px 28px 24px;
  background: linear-gradient(180deg, rgba(247, 248, 251, 0), var(--surface) 32%);
}

.composer {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  max-width: 920px;
  margin: 0 auto;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.file-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 22px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

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

.file-button input {
  display: none;
}

.file-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 920px;
  margin: 10px auto 0;
}

.file-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 52px;
  max-height: 220px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
}

.composer textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.16);
  border-color: var(--accent);
}

.composer button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  min-height: 52px;
  padding: 0 18px;
}

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

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

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

  .chat-area {
    min-height: 70vh;
  }

  .chat-header,
  .composer-wrap {
    padding-left: 18px;
    padding-right: 18px;
  }

  .messages {
    padding: 18px;
  }

  .composer {
    grid-template-columns: 36px minmax(0, 1fr) auto;
  }

  .composer button {
    min-height: 52px;
    padding: 0 12px;
  }
}
