:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --ink: #1c1915;
  --muted: #6d655c;
  --line: #e4ddd2;
  --accent: #0f6e56;
  --accent-ink: #ffffff;
  --danger: #9f2d2d;
  --user: #e7f3ee;
  --shadow: 0 10px 30px rgba(28, 25, 21, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 12px;
  cursor: pointer;
}

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

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.hidden { display: none !important; }

.error { min-height: 1.2em; color: var(--danger); margin: 8px 0 0; }

.meta, .eyebrow { color: var(--muted); margin: 0; }
.eyebrow { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }

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

.login-card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 { margin: 8px 0; font-size: 28px; }
.lead { color: var(--muted); }

label { display: block; margin: 16px 0 6px; font-weight: 600; }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  resize: vertical;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.side {
  border-right: 1px solid var(--line);
  background: var(--paper);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-head, .top, .composer-row, .context {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.sessions {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
}

.sessions button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px;
}

.sessions button.active { background: var(--user); }

.sessions small { display: block; color: var(--muted); }

.main {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 100vh;
  padding: 16px 20px 12px;
  gap: 12px;
}

.top h1 { margin: 0; font-size: 22px; }

.modes { display: flex; flex-wrap: wrap; gap: 6px; }

.modes button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.modes button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.context {
  align-items: end;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.context label { margin: 0 0 6px; }
.context textarea { flex: 1; }

.thread {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.bubble {
  max-width: 820px;
  border-radius: 12px;
  padding: 12px 14px;
  white-space: pre-wrap;
  background: var(--paper);
  border: 1px solid var(--line);
}

.bubble.user { background: var(--user); margin-left: auto; }

.bubble header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.bubble header button {
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.composer textarea { min-height: 76px; }

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

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .sessions { max-height: 180px; }
  .context, .composer-row, .top { flex-direction: column; align-items: stretch; }
}
