:root {
  color-scheme: light dark;
  --bg: #f6f7f4; --surface: #ffffff; --soft: #eceee8; --text: #1d211c;
  --muted: #62695f; --line: #d9ddd4; --accent: #24614a; --on-accent: #ffffff;
  --warn-bg: #fbf3df; --warn-text: #66500f; --error: #a62f25;
  --mark-bg: #ffe89a; --mark-text: #2b2400;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141714; --surface: #1c201c; --soft: #272c27; --text: #eaede6;
    --muted: #a3aa9f; --line: #343a33; --accent: #7fcdaa; --on-accent: #10231a;
    --warn-bg: #30290f; --warn-text: #ecd98f; --error: #f09a90;
    --mark-bg: #6b5a14; --mark-text: #fff6d2;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1 { margin: 0; font-size: 1.4rem; }
h2 { margin: 0; font-size: .95rem; }
p { margin: 0; }
button, select, textarea { font: inherit; color: inherit; }
button { border: 0; border-radius: 8px; padding: .65rem 1rem; background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: var(--soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: 100dvh; }
.panel { display: flex; flex-direction: column; gap: .9rem; padding: 1.25rem; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); }
.muted { color: var(--muted); font-size: .9rem; }
.drop { display: grid; gap: .15rem; padding: 1.1rem; text-align: center; border: 1.5px dashed var(--line); border-radius: 10px; cursor: pointer; }
.drop:hover, .drop:focus-within { border-color: var(--accent); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.status { min-height: 1.3em; font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.status.error { color: var(--error); }
.documents { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.documents li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .55rem; background: var(--soft); border-radius: 7px; font-size: .9rem; }
.documents span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.documents button { flex: none; padding: .1rem .45rem; background: transparent; color: var(--muted); font-size: 1.1rem; }
.documents .none { background: transparent; padding: 0; color: var(--muted); }
.field { display: grid; gap: .25rem; font-size: .88rem; color: var(--muted); }
.field select { width: 100%; padding: .45rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.notice { padding: .7rem; font-size: .8rem; line-height: 1.4; color: var(--warn-text); background: var(--warn-bg); border-radius: 8px; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 820px; margin: 0 auto; padding: 1.5rem 1.25rem; overflow-y: auto; }
.empty { margin: auto; text-align: center; }
.message { max-width: 88%; padding: .7rem .95rem; border-radius: 12px; overflow-wrap: anywhere; }
.message.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); white-space: pre-wrap; }
.message.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.message.error { color: var(--error); }
.answer { display: grid; gap: .6rem; }
.answer ul, .answer ol { display: grid; gap: .35rem; margin: 0; padding-left: 1.3rem; }
.answer .heading { font-weight: 700; }
.answer code { padding: .05rem .3rem; background: var(--soft); border-radius: 4px; font-size: .9em; }
details { margin-top: .6rem; font-size: .86rem; color: var(--muted); }
summary { cursor: pointer; font-weight: 600; }
.source { margin-top: .5rem; padding: .55rem; background: var(--soft); border-radius: 7px; }
.source.cited { border-left: 3px solid var(--accent); }
.source b { display: block; margin-bottom: .2rem; color: var(--text); }
.passage { white-space: pre-wrap; }
mark { padding: .05rem .15rem; color: var(--mark-text); background: var(--mark-bg); border-radius: 3px; }
.composer { display: flex; align-items: flex-end; gap: .6rem; width: 100%; max-width: 820px; margin: 0 auto; padding: .75rem 1.25rem 1.1rem; }
.composer textarea { flex: 1; min-width: 0; max-height: 160px; padding: .65rem .8rem; resize: none; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
@media (max-width: 760px) {
  .shell { display: flex; flex-direction: column; height: auto; min-height: 100dvh; }
  .panel { padding: 1rem 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat { min-height: 70dvh; }
  .messages { padding: 1rem 16px; }
  .composer { position: sticky; bottom: 0; padding: .6rem 16px .8rem; background: var(--bg); }
}
