:root {
  color-scheme: light dark;
  --bg: #f5f4ef;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d8d6cf;
  --accent: #1f5f53;
  --accent-text: #ffffff;
  --user: #e5efe9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111512;
    --surface: #1b211d;
    --text: #eef2ef;
    --muted: #a4aea7;
    --line: #354039;
    --accent: #77b5a2;
    --accent-text: #0f211b;
    --user: #26382f;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
  background: var(--surface);
  color: var(--text);
}

textarea {
  resize: vertical;
}

.shell {
  width: min(780px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(1.2rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom));
}

header,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 1.4rem;
  font-size: 1.8rem;
}

.eyebrow {
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.panel,
.message {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 1rem;
}

.login-panel {
  max-width: 440px;
}

form {
  display: grid;
  gap: 0.75rem;
}

nav {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.tab,
.quiet {
  background: transparent;
  color: var(--muted);
}

.tab {
  border-radius: 0;
  border-bottom: 2px solid transparent;
}

.tab.active {
  border-color: var(--accent);
  color: var(--text);
}

.messages {
  display: grid;
  gap: 0.75rem;
  min-height: 45vh;
  max-height: 65vh;
  overflow-y: auto;
  padding-bottom: 1rem;
}

.message {
  max-width: 88%;
}

.message.user {
  justify-self: end;
  background: var(--user);
}

.message p:last-child {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.sources {
  color: var(--muted);
  font-size: 0.78rem;
}

.composer {
  position: sticky;
  bottom: 0;
  grid-template-columns: 1fr auto;
  align-items: end;
  padding-top: 0.8rem;
  background: var(--bg);
}

pre {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.55;
}

#status {
  min-height: 1.5rem;
  margin-top: 1rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
