:root {
  --bg: #e9eef2; --panel: #ffffff; --text: #1b2430; --muted: #66727f; --line: #d6dde4;
  --me: #dcf5c8; --me-line: #c3e6a8; --bot: #ffffff; --bot-line: #dfe5ea;
  --accent: #2f7dbd; --accent-ink: #ffffff; --chip: #f2f5f8; --sys: #f6f1df; --sys-ink: #6b5a1e;
  --ok: #2e8b4a; --bad: #b8432f; --shadow: 0 1px 1px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11171d; --panel: #1a222a; --text: #e6ebf0; --muted: #94a1ae; --line: #2a343e;
    --me: #2b4a2a; --me-line: #355a33; --bot: #1f2830; --bot-line: #2b3640;
    --accent: #5aa3dd; --accent-ink: #0d1318; --chip: #222c35; --sys: #3a3420; --sys-ink: #e6d9a6;
    --ok: #63c27e; --bad: #e57a66; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #11171d; --panel: #1a222a; --text: #e6ebf0; --muted: #94a1ae; --line: #2a343e;
  --me: #2b4a2a; --me-line: #355a33; --bot: #1f2830; --bot-line: #2b3640;
  --accent: #5aa3dd; --accent-ink: #0d1318; --chip: #222c35; --sys: #3a3420; --sys-ink: #e6d9a6;
  --ok: #63c27e; --bad: #e57a66; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; color: var(--text); padding: 6px 10px; border: 1px solid var(--line); }
button.link { background: none; color: var(--accent); padding: 4px 0; text-decoration: underline; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); min-height: 1.2em; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

/* prisijungimas */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; padding: 28px 22px; box-shadow: var(--shadow); }
.card h1 { margin: 6px 0 4px; font-size: 24px; }
.card .logo { font-size: 36px; }
.card form button[type=submit] { width: 100%; margin-top: 14px; }
.msgpage { max-width: 520px; margin: 60px auto; padding: 0 16px; }

/* programa */
.app { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px;
       background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who #me { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }
.body { flex: 1; display: flex; min-height: 0; }
.days { width: 240px; flex: none; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 8px; }
.day { display: block; width: 100%; text-align: left; background: none; color: var(--text); border-radius: 10px; padding: 8px 10px; margin: 2px 0; }
.day:hover { background: var(--chip); }
.day.on { background: var(--accent); color: var(--accent-ink); }
.day .d1 { font-weight: 600; font-size: 14px; }
.day .d2 { font-size: 12px; opacity: .85; }
.chatwrap { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dayhead { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.dayhead .dt { flex: 1; text-align: center; }
#day-title { font-weight: 650; }
.help { margin: 0 0 4px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.partial { margin: 0 0 6px; padding: 8px 12px; background: var(--sys); color: var(--sys-ink); border-radius: 12px; font-size: 13px; }
.chat { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px 40px; display: flex; flex-direction: column; gap: 6px; }
.empty { text-align: center; color: var(--muted); margin-top: 40px; }

.row { display: flex; }
.row.in { justify-content: flex-end; }
.row.sys { justify-content: center; }
.bubble { max-width: min(560px, 86%); padding: 7px 10px 5px; border-radius: 14px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.in .bubble { background: var(--me); border: 1px solid var(--me-line); border-bottom-right-radius: 4px; }
.out .bubble { background: var(--bot); border: 1px solid var(--bot-line); border-bottom-left-radius: 4px; }
.txt { white-space: pre-wrap; }
.meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: rgba(0,0,0,.06); margin-bottom: 4px; }
.tag.late { background: var(--sys); color: var(--sys-ink); }
.press { font-size: 14px; }
.kb { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.kb .kbr { display: flex; gap: 4px; }
.kb span { flex: 1; text-align: center; font-size: 13px; padding: 6px 4px; border-radius: 8px; background: var(--chip); border: 1px solid var(--line); }
.toast { font-size: 13px; padding: 4px 12px; border-radius: 999px; background: var(--chip); color: var(--muted); max-width: 90%; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px; }
.grid.one { grid-template-columns: 1fr; }
.grid img { width: 100%; height: 100%; max-height: 360px; object-fit: cover; border-radius: 8px; cursor: zoom-in; display: block; background: var(--chip); }
.grid.one img { object-fit: contain; max-height: 420px; }
.audio audio { width: 260px; max-width: 100%; display: block; }
.tr { font-size: 14px; font-style: italic; color: var(--muted); margin-top: 4px; white-space: pre-wrap; }
.nofile { font-size: 14px; color: var(--muted); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: grid; place-items: center; z-index: 20; cursor: zoom-out; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 10; padding: 16px; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--panel); border-radius: 16px; padding: 16px 18px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { font-size: 19px; margin: 0; }
.sheet h3 { font-size: 16px; margin: 18px 0 0; }
.u { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.u .n { font-weight: 600; }
.u .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.u .acts button { font-size: 13px; padding: 6px 10px; }
.add button[type=submit] { margin-top: 12px; }
.newlink { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--sys); color: var(--sys-ink); }
.linkrow { display: flex; gap: 6px; }
.linkrow input { font-size: 13px; }

@media (max-width: 860px) {
  .body { flex-direction: column; }
  .days { width: auto; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 16px; flex: none; }
  .day { width: auto; flex: none; margin: 0; padding: 6px 10px; text-align: center; background: var(--chip); }
  .day .d2 { white-space: nowrap; }
  .brand span { display: none; }
  .bubble { max-width: 90%; }
}
