:root {
  --bg: #f7f7f5; --panel: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e4e3df;
  --accent: #1f5c4a; --accent-soft: #e6efe9; --mark: #fff1b8; --danger: #a33;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161716; --panel: #1f201f; --text: #ecebe6; --muted: #9c9b95; --line: #333431;
          --accent: #7fc4a8; --accent-soft: #23342d; --mark: #5a4b12; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 9px 14px; background: var(--accent); color: #fff; }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.icon { background: transparent; color: var(--muted); font-size: 22px; padding: 0 6px; }
button.link { background: none; color: var(--muted); padding: 4px 8px; border: 1px solid var(--line); font-size: 13px; }
button.link:hover { color: var(--text); }
button.link.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
textarea { resize: vertical; }

/* login */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; max-width: 420px; width: 100%; }
.login-box h1 { margin: 0 0 6px; font-size: 24px; }
.login-box form { display: grid; gap: 10px; margin-top: 18px; }
.login-box label { font-size: 13px; color: var(--muted); }
.msg { color: var(--danger); min-height: 1em; }

/* layout */
#app { height: 100%; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 24px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 650; }
.beta { font-size: 11px; font-weight: 500; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 10px; margin-left: 6px; }
nav { display: flex; gap: 4px; }
nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 8px; }
nav a.active { color: var(--text); background: var(--bg); }
.user { margin-left: auto; font-size: 13px; color: var(--muted); }
main { flex: 1; min-height: 0; }
.tab { height: 100%; }

/* klausti */
#tab-klausti { display: flex; }
.history { width: 240px; border-right: 1px solid var(--line); padding: 14px; overflow-y: auto; flex-shrink: 0; }
.history button { width: 100%; margin-bottom: 12px; }
.h-item { display: block; padding: 7px 8px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-item:hover, .h-item.active { background: var(--panel); }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0 20px 10px; }
#thread { flex: 1; overflow-y: auto; padding-top: 20px; }
.welcome { max-width: 720px; margin: 8vh auto 0; }
.welcome h2 { margin: 0 0 4px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.examples .ex { background: var(--panel); color: var(--text); border: 1px solid var(--line); text-align: left; font-size: 14px; }
.ask { display: flex; gap: 8px; max-width: 820px; width: 100%; margin: 10px auto 4px; }
.ask button { align-self: flex-end; }
.turn { max-width: 820px; margin: 0 auto 26px; }
.q { font-weight: 600; margin-bottom: 10px; }
.a { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.a p { margin: 0 0 10px; } .a ul { margin: 0 0 10px; padding-left: 20px; }
.a .typing { color: var(--muted); }
.cite { display: inline-block; font-size: 11px; line-height: 1; padding: 3px 5px; margin: 0 1px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); cursor: pointer; vertical-align: 1px; }
.srcs { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.src { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; cursor: pointer; color: var(--muted); background: var(--bg); }
.src:hover { color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.letter { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; white-space: pre-wrap; }
.comment-box { display: flex; gap: 6px; margin-top: 8px; }

.source-panel { width: 420px; border-left: 1px solid var(--line); background: var(--panel); padding: 16px; overflow-y: auto; flex-shrink: 0; }
.sp-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.sp-text { white-space: pre-wrap; margin: 12px 0; font-size: 14px; }

/* šaltiniai */
.browse { display: flex; height: 100%; }
.browse-left { width: 380px; border-right: 1px solid var(--line); padding: 14px; overflow-y: auto; flex-shrink: 0; }
.filters { display: flex; gap: 6px; margin: 8px 0 12px; }
.browse-right { flex: 1; overflow-y: auto; padding: 20px 28px; }
.s-group { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 4px; }
.s-item { display: block; padding: 7px 8px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; }
.s-item:hover, .s-item.active { background: var(--panel); }
.s-item small { display: block; color: var(--muted); }
.doc-head h2 { margin: 0 0 4px; }
.art { border-bottom: 1px solid var(--line); padding: 14px 0; }
.art h4 { margin: 0 0 6px; }
.art .t { white-space: pre-wrap; font-size: 14px; }
.art details { font-size: 12px; color: var(--muted); margin-top: 6px; }
mark { background: var(--mark); color: inherit; }
.toc { columns: 2; font-size: 13px; margin: 10px 0 16px; }
.toc a { display: block; }

.changes { max-width: 760px; margin: 0 auto; padding: 24px 20px; }
.ch { padding: 10px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 900px) {
  .history { display: none; }
  .source-panel { position: fixed; inset: 0; width: auto; z-index: 10; }
  .browse { flex-direction: column; } .browse-left { width: auto; border-right: 0; max-height: 45vh; }
  header { gap: 10px; flex-wrap: wrap; padding: 8px 16px; } .user { display: none; }
  .chat { padding: 0 16px 8px; }
}
