:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1e2528;
  --muted: #667276;
  --line: #d9dfda;
  --accent: #176b5d;
  --accent-strong: #0e4d43;
  --gold: #b98b2e;
  --danger: #a64235;
  --shadow: 0 18px 50px rgba(30, 37, 40, 0.10);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef2ed;
  padding: 28px;
}

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

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

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

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

.brand p,
.chat-header p,
.panel p,
.mode span,
.form-message {
  color: var(--muted);
}

.panel {
  margin-top: 18px;
}

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

.panel.muted {
  padding-top: 18px;
  border-top: 1px solid var(--line);
  line-height: 1.6;
}

.mode-list {
  display: grid;
  gap: 10px;
}

.mode {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
}

.mode strong,
.mode span {
  display: block;
}

.mode span {
  margin-top: 3px;
  font-size: 13px;
}

.mode.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.chat {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-width: 0;
  padding: 26px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
}

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

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: var(--panel);
  white-space: nowrap;
}

.status-pill.ready {
  color: var(--accent-strong);
  border-color: rgba(23, 107, 93, 0.35);
}

.login-box {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-box label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.inline-form,
.composer {
  display: flex;
  gap: 10px;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
}

input:focus {
  outline: 2px solid rgba(23, 107, 93, 0.22);
  border-color: var(--accent);
}

button {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

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

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.messages {
  overflow: auto;
  padding: 8px 0 20px;
}

.message {
  display: flex;
  gap: 12px;
  margin: 14px 0;
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  display: grid;
  flex: 0 0 36px;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #fff;
  background: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.message.assistant .avatar {
  background: var(--accent);
}

.bubble {
  max-width: min(820px, 88%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  line-height: 1.65;
}

.message.user .bubble {
  color: #fff;
  background: var(--accent);
}

.bubble pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.bubble code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #edf1ee;
}

.composer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.error {
  color: var(--danger);
}

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

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

  .mode-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .chat {
    min-height: 70vh;
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .mode-list,
  .inline-form,
  .composer {
    grid-template-columns: 1fr;
    display: grid;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .bubble {
    max-width: 100%;
  }
}
