/* LocaNoto web interface. One file, no framework, light and dark. */
:root {
  --accent: #2f5d8a;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --border: #dde2e8;
  --ok: #1f7a4d;
  --bad: #b42318;
  --warn-bg: #fff6e5;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2129;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --border: #2c3440;
    --ok: #4cc38a;
    --bad: #f97066;
    --warn-bg: #3a2e14;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.error { color: var(--bad); }
.warn { background: var(--warn-bg); padding: .5rem .75rem; border-radius: 6px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; }

/* top bar */
.top {
  display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.tabs { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.tabs a {
  padding: .35rem .7rem; border-radius: 6px; color: var(--muted);
  text-decoration: none;
}
.tabs a.on, .tabs a:hover { background: var(--bg); color: var(--text); }
.who { color: var(--muted); }

/* layout */
main.page { padding: 1.5rem; max-width: 1000px; width: 100%; margin: 0 auto; }
main.login { display: grid; place-items: center; flex: 1; padding: 1rem; }
main.chat { display: flex; flex: 1; min-height: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.card.narrow { width: 100%; max-width: 380px; }

/* forms */
label { display: block; margin: .5rem 0; color: var(--muted); font-size: .9rem; }
label.check { display: flex; gap: .4rem; align-items: center; color: var(--text); }
input, select, textarea, button, .button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: .45rem .6rem;
}
label input, label select { display: block; width: 100%; margin-top: .2rem; }
textarea { width: 100%; resize: vertical; }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
.button.wide, button.wide { width: 100%; text-align: center; }
form.inline { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: .25rem 0; }
form.inline.wide { display: flex; }
form.inline.wide input { flex: 1; min-width: 8rem; }
.busy { opacity: .6; pointer-events: none; }
.or { text-align: center; color: var(--muted); }
fieldset { border: 1px solid var(--border); border-radius: 6px; margin: .5rem 0; }

/* chat */
.sidebar {
  width: 260px; flex-shrink: 0; overflow-y: auto; padding: 1rem;
  border-right: 1px solid var(--border); background: var(--surface);
}
.chats { list-style: none; padding: 0; margin: 1rem 0 0; }
.chats li a {
  display: block; padding: .4rem .5rem; border-radius: 6px; color: var(--text);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chats li.on a, .chats li a:hover { background: var(--bg); }
.conversation { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: .5rem 1rem; border-bottom: 1px solid var(--border); display: flex; gap: .5rem; flex-wrap: wrap; }
.messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.msg { max-width: 860px; width: 100%; margin: 0 auto; }
.msg.user .bubble {
  background: var(--accent); color: #fff; padding: .6rem .9rem;
  border-radius: var(--radius); margin-left: auto; max-width: 80%; width: fit-content;
  white-space: pre-wrap;
}
.msg.user .images { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .4rem; }
.msg.user .images img { max-height: 120px; border-radius: 6px; }
.msg.assistant .answer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .6rem 1rem;
}
.answer.streaming { white-space: pre-wrap; }
.answer table { border-collapse: collapse; }
.answer td, .answer th { border: 1px solid var(--border); padding: .25rem .5rem; }
.answer pre { overflow-x: auto; background: var(--bg); padding: .5rem; border-radius: 6px; }
.status { font-size: .85rem; margin-bottom: .3rem; }
details.sources { margin-top: .5rem; }
details.sources summary { cursor: pointer; color: var(--muted); }
.source { border-left: 3px solid var(--border); padding-left: .75rem; margin: .75rem 0; }
.source-head { font-weight: 600; }
.source blockquote {
  margin: .3rem 0; color: var(--muted); white-space: pre-wrap;
  max-height: 12em; overflow-y: auto;
}
.source img { max-width: 100%; border: 1px solid var(--border); }
.draft { border: 1px solid var(--accent); border-radius: var(--radius); padding: .75rem; margin-top: .5rem; }
.draft .arg pre { white-space: pre-wrap; background: var(--bg); padding: .4rem; border-radius: 6px; }
.draft .preview { font-weight: 600; margin: .4rem 0; }
.feedback button { border: 0; background: none; padding: .1rem .3rem; }
.composer { border-top: 1px solid var(--border); padding: .75rem 1rem; background: var(--surface); }
.composer-row { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }
.composer-row .options { flex: 1; }
.composer-row .options summary { cursor: pointer; color: var(--muted); }

/* documents, web */
table.files { width: 100%; border-collapse: collapse; }
table.files td { padding: .35rem .25rem; border-top: 1px solid var(--border); vertical-align: middle; }
td.actions { text-align: right; }
.upload { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.upload label { margin: 0; display: flex; gap: .3rem; align-items: center; white-space: nowrap; }
.upload label.check input { width: auto; }
.upload label select { display: inline-block; width: auto; margin: 0; }
.hit p { margin: .4rem 0; }
pre.pagetext { white-space: pre-wrap; max-height: 420px; overflow-y: auto; background: var(--bg); padding: .75rem; border-radius: 6px; }
pre.status { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); padding: .75rem; border-radius: 6px; }

/* admin */
.subnav { display: flex; gap: .25rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; font-size: .9rem; }
.pill { display: inline-block; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .6rem; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }

/* toast */
#toast {
  position: fixed; right: 1rem; bottom: 1rem; max-width: 420px; padding: .6rem 1rem;
  border-radius: 8px; background: var(--text); color: var(--bg);
  opacity: 0; transform: translateY(8px); transition: all .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 720px) {
  .top { gap: .5rem; }
  .who { margin-left: auto; }
  .tabs { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; }
  main.chat { flex-direction: column; }
  .sidebar { width: auto; max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--border); }
  main.page { padding: 1rem; }
}
