:root {
  --canvas: #0d1117;
  --panel: #131a23;
  --ink: #e6edf3;
  --muted: #8b98a5;
  --sage: #a8c4b0;
  --sage-dim: #365f4a;
  --hairline: #232d38;
  --bubble-user: #1d2b22;
  --bubble-bot: #161e28;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  font-size: 15px;
}
#app { display: flex; flex-direction: column; height: 100dvh; }
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  background: var(--panel);
}
#brand { font-weight: 700; letter-spacing: 0.5px; }
#brand .sage { color: var(--sage); }
#userline { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#settingsBtn {
  background: none; border: 1px solid var(--hairline); color: var(--ink);
  border-radius: 8px; font-size: 16px; padding: 6px 10px; cursor: pointer;
}
#chat { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 12px; border-radius: 10px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--bubble-user); border: 1px solid var(--sage-dim); }
.msg.bot { align-self: flex-start; background: var(--bubble-bot); border: 1px solid var(--hairline); }
.msg.system { align-self: center; color: var(--muted); font-size: 13px; background: none; }
.msg .pdfnote { color: var(--sage); font-weight: 600; }
#status {
  padding: 8px 14px; color: var(--sage); font-size: 13px;
  border-top: 1px solid var(--hairline); background: var(--panel);
}
#status.hidden, .hidden { display: none !important; }
#composer {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline); background: var(--panel);
}
#input {
  flex: 1; resize: none; background: var(--canvas); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 12px;
  font-size: 15px; font-family: inherit; max-height: 120px;
}
#sendBtn {
  background: var(--sage-dim); color: #fff; border: none; border-radius: 10px;
  padding: 0 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
#sendBtn:disabled { opacity: 0.5; cursor: default; }
#settings {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.sheet {
  background: var(--panel); border-top: 1px solid var(--hairline);
  border-radius: 16px 16px 0 0; padding: 18px; width: 100%; max-width: 520px;
  max-height: 88dvh; overflow-y: auto;
}
.sheet h2 { margin: 0 0 6px; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.field { display: block; margin: 12px 0; font-size: 14px; }
.field input[type="text"], .field input[type="password"] {
  display: block; width: 100%; margin-top: 6px; background: var(--canvas);
  color: var(--ink); border: 1px solid var(--hairline); border-radius: 8px;
  padding: 10px 12px; font-size: 15px;
}
.radios { display: flex; gap: 16px; margin-top: 8px; }
.radios label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.row { display: flex; gap: 10px; margin-top: 14px; }
.sheet button {
  background: var(--sage-dim); color: #fff; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.sheet button.ghost { background: none; border: 1px solid var(--hairline); color: var(--ink); }
#newSession { margin-top: 12px; width: 100%; }
