:root {
  color-scheme: light;
  --bg: #f4efe4;
  --panel: rgba(255, 252, 246, 0.88);
  --panel-strong: #fffaf0;
  --ink: #1e1b18;
  --muted: #655c53;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --line: rgba(30, 27, 24, 0.1);
  --user: #d9efe7;
  --assistant: #fff6db;
  --shadow: 0 18px 60px rgba(47, 37, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(202, 138, 4, 0.18), transparent 30%),
    linear-gradient(135deg, #f7f2e8 0%, #efe7d8 55%, #f9f5ec 100%);
}

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

.sidebar,
.chat-area {
  padding: 28px;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.55);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 0.95;
}

.sidebar-copy {
  color: var(--muted);
  line-height: 1.6;
  max-width: 36ch;
}

.panel {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

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

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

textarea {
  width: 100%;
  border: 1px solid rgba(30, 27, 24, 0.14);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  line-height: 1.55;
  resize: vertical;
  background: #fffdf9;
  color: var(--ink);
}

select {
  width: 100%;
  border: 1px solid rgba(30, 27, 24, 0.14);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  line-height: 1.4;
  background: #fffdf9;
  color: var(--ink);
}

#systemPrompt {
  min-height: 340px;
}

.panel-note {
  margin: 10px 2px 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  color: var(--muted);
}

.status-row strong {
  color: var(--ink);
}

.chat-area {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 22px;
}

.chat-log {
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 251, 245, 0.72);
  box-shadow: var(--shadow);
}

.message {
  max-width: min(920px, 100%);
  margin-bottom: 18px;
  padding: 18px 20px;
  border-radius: 22px;
  border: 1px solid var(--line);
}

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

.message.assistant {
  margin-right: auto;
  background: var(--assistant);
}

.message-role {
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-content {
  white-space: pre-wrap;
  line-height: 1.7;
}

.composer {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: white;
}

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

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

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

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

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

  #systemPrompt {
    min-height: 220px;
  }
}
