/* Anton — iOS-čistý svetlý vzhľad s KAMIR oranžovou (tokeny podľa kamir.sk), dark mode cez systém */
:root {
  --bg: #F4F2EF;
  --surface: #FFFFFF;
  --surface-2: #FAF8F5;
  --ink: #1C1714;
  --ink-2: #4B4540;
  --muted: #7A736C;
  --line: #E8E3DD;
  --line-2: #F1EDE7;
  --brand: #E57E25;
  --brand-ink: #B85E12;
  --brand-soft: #FEF3E8;
  --ok: #15803D; --ok-soft: #E9F7EE;
  --warn: #B45309; --warn-soft: #FEF3E8;
  --danger: #DC2626; --danger-soft: #FDECEC;
  --user-bubble: #1C1714; --user-ink: #FFFFFF;
  --shadow: 0 1px 2px rgba(28,23,20,.06), 0 8px 24px -12px rgba(28,23,20,.18);
  --r: 16px; --r-lg: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 292px; --panel-w: 360px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131110; --surface: #1D1A17; --surface-2: #232019; --ink: #F3EFEA; --ink-2: #CFC7BF; --muted: #978F86;
    --line: #2E2925; --line-2: #262220; --brand: #F0904A; --brand-ink: #F5A66B; --brand-soft: #35261A;
    --ok: #4ADE80; --ok-soft: #12291C; --warn: #F5B36B; --warn-soft: #35261A; --danger: #F87171; --danger-soft: #3A1B1B;
    --user-bubble: #F0904A; --user-ink: #1C1714;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-ink); }
.hidden { display: none !important; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }

/* ── layout ── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr auto; height: 100dvh; width: 100%; }
.sidebar { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px 14px; gap: 14px; min-height: 0; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel { width: var(--panel-w); background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }

/* ── sidebar ── */
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.brand-mark, .empty-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 22px; letter-spacing: -.04em; flex: none; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 10px 18px; font-weight: 600; font-size: 14px; transition: transform .08s ease, background .15s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.thread-list { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -6px; padding: 0 6px; }
.thread-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.thread-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 12px; padding: 9px 10px; color: var(--ink); }
.thread-item:hover { background: var(--surface-2); }
.thread-item.active { background: var(--brand-soft); color: var(--brand-ink); }
.thread-item .t { flex: 1; min-width: 0; }
.thread-item .t-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item .t-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item.active .t-sub { color: var(--brand-ink); opacity: .8; }
.thread-item .t-chan { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }
.thread-item .spin { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: pulse 1s infinite; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-btn { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; border-radius: 12px; padding: 9px 10px; font-weight: 600; font-size: 14px; color: var(--ink-2); width: 100%; text-align: left; position: relative; }
.nav-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav-btn.active { background: var(--brand-soft); color: var(--brand-ink); }
.badge { margin-left: auto; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px 6px 0; margin-top: 6px; border-top: 1px solid var(--line-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--ink-2); flex: none; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pos { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.on { background: var(--brand-soft); color: var(--brand-ink); }

/* ── topbar ── */
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 5; }
.topbar-title { flex: 1; min-width: 0; font-weight: 800; font-size: 16px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.select-pill { appearance: none; -webkit-appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 28px 6px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237A736C' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; }

/* ── messages ── */
.messages { flex: 1; overflow-y: auto; padding: 20px 16px 8px; min-height: 0; }
.msg-wrap { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.day-sep { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 -2px; }
.msg { display: flex; gap: 10px; align-items: flex-end; }
.msg.user { flex-direction: row-reverse; }
.bubble { max-width: min(78%, 680px); padding: 11px 15px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user-bubble); color: var(--user-ink); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant .bubble { border-bottom-left-radius: 6px; }
.msg.system .bubble { background: var(--warn-soft); color: var(--warn); font-size: 13.5px; max-width: 100%; box-shadow: none; }
.msg-mark { width: 28px; height: 28px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 15px; flex: none; margin-bottom: 4px; }
.msg.user .msg-mark { display: none; }
.msg.system .msg-mark { visibility: hidden; }
.meta-line { font-size: 11.5px; color: var(--muted); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.activity { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.act { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 8px; animation: fadein .2s ease; }
.act .ic { width: 14px; height: 14px; }
.act.running .ic { color: var(--brand); }
.act.done { color: var(--muted); }
.stream-text { white-space: pre-wrap; }
.cursor { display: inline-block; width: 7px; height: 16px; background: var(--brand); border-radius: 2px; vertical-align: -3px; margin-left: 2px; animation: pulse .9s infinite; }
.thinking { display: inline-flex; gap: 4px; align-items: center; height: 16px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes fadein { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* markdown */
.md p { margin: 0 0 .7em; } .md p:last-child { margin-bottom: 0; }
.md h4 { font-size: 15px; font-weight: 800; margin: .8em 0 .35em; letter-spacing: -.01em; }
.md ul, .md ol { margin: .3em 0 .7em; padding-left: 1.3em; } .md li { margin: .15em 0; }
.md code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .05em .35em; }
.md pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; overflow-x: auto; margin: .5em 0; }
.md pre code { background: none; border: 0; padding: 0; font-size: 13px; }
.md blockquote { margin: .5em 0; padding: .2em .9em; border-left: 3px solid var(--brand); color: var(--ink-2); }
.md table { border-collapse: collapse; margin: .5em 0; font-size: 13.5px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); font-weight: 700; }
.md strong { font-weight: 700; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: .8em 0; }

/* empty state */
.empty { max-width: 640px; margin: 8vh auto 0; text-align: center; padding: 0 12px; }
.empty-mark { width: 56px; height: 56px; border-radius: 18px; font-size: 30px; margin: 0 auto 16px; }
.empty h1 { font-size: 30px; font-weight: 900; letter-spacing: -.03em; }
.empty p { color: var(--ink-2); margin: 10px 0 22px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); box-shadow: var(--shadow); }
.chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.empty-warn { margin-top: 22px; background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; text-align: left; }

/* composer */
.composer { padding: 8px 16px calc(12px + var(--safe-b)); }
.composer-box { max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow); }
.composer-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), var(--shadow); }
.composer textarea { flex: 1; border: 0; outline: 0; background: transparent; resize: none; max-height: 200px; padding: 8px 0; line-height: 1.45; font-size: 16px; }
.composer-actions { display: flex; align-items: center; gap: 2px; }
.send-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; transition: transform .08s; }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { background: var(--line); color: var(--muted); }
.send-btn.stop { background: var(--ink); color: var(--bg); }
.composer-hint { max-width: 820px; margin: 6px auto 0; font-size: 11.5px; color: var(--muted); text-align: center; min-height: 16px; }
.composer-hint .busy { color: var(--brand-ink); font-weight: 600; }

/* panel */
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 18px; font-weight: 800; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.card h3 { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.card h3 .ic { width: 16px; height: 16px; }
.card p { margin: 4px 0; font-size: 13.5px; color: var(--ink-2); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 2px 10px; }
.status.ok { color: var(--ok); background: var(--ok-soft); } .status.warn { color: var(--warn); background: var(--warn-soft); } .status.bad { color: var(--danger); background: var(--danger-soft); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); }
.input { border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; background: var(--surface); font-size: 16px; outline: 0; width: 100%; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 60px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--brand); color: #fff; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.switch input { appearance: none; width: 42px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--ok); } .switch input:checked::after { transform: translateX(16px); }
.mem-list { display: flex; flex-direction: column; gap: 6px; }
.mem { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; border-left: 4px solid var(--line); }
.mem.task { border-left-color: var(--brand); } .mem.reminder { border-left-color: var(--warn); } .mem.note { border-left-color: var(--muted); }
.mem.done { opacity: .55; } .mem.done .mem-title { text-decoration: line-through; }
.mem-check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); display: grid; place-items: center; flex: none; margin-top: 1px; color: transparent; }
.mem.done .mem-check { background: var(--ok); border-color: var(--ok); color: #fff; }
.mem-check .ic { width: 14px; height: 14px; stroke-width: 2.5; }
.mem-body { flex: 1; min-width: 0; }
.mem-title { font-weight: 600; font-size: 14px; }
.mem-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: pre-wrap; }
.mem-sub .due { font-weight: 700; color: var(--warn); } .mem-sub .due.over { color: var(--danger); }
.mem-del { opacity: 0; } .mem:hover .mem-del, .mem-del:focus-visible { opacity: 1; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; } .tbl th, .tbl td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line-2); } .tbl th { color: var(--muted); font-weight: 700; } .tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; } .kv b { color: var(--muted); font-weight: 600; }
.small { font-size: 12px; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.tabbar { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600; z-index: 40; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }
.only-mobile { display: none; }

/* prihlásenie (len pri priamom prístupe mimo domény MATRIXu) */
body.login-mode { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
body.login-mode .app { display: block; height: auto; width: min(100%, 380px); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px 24px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { font-size: 24px; font-weight: 900; letter-spacing: -.02em; }
.login-card .field { text-align: left; margin-top: 12px; }
.login-err { margin-top: 12px; background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 8px 12px; font-size: 13px; text-align: left; }

/* ── mobile ── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw, 340px); z-index: 36; transform: translateX(-104%); transition: transform .22s ease; box-shadow: var(--shadow); padding-bottom: calc(14px + var(--safe-b)); }
  .sidebar.open { transform: none; }
  .scrim { z-index: 34; }
  .panel { position: fixed; inset: 0; width: 100%; z-index: 25; border: 0; padding-bottom: calc(60px + var(--safe-b)); }
  .tabbar { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); z-index: 35; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 22px; padding: 6px; box-shadow: var(--shadow); }
  .tab { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 700; color: var(--muted); border-radius: 16px; padding: 6px 2px; }
  .tab.active { color: var(--brand-ink); background: var(--brand-soft); }
  .messages { padding: 14px 12px 8px; }
  .bubble { max-width: 88%; }
  .composer { padding-bottom: calc(76px + var(--safe-b)); }
  .empty { margin-top: 5vh; } .empty h1 { font-size: 26px; }
  .topbar-actions .icon-btn { display: none; }
  .mem-del { opacity: 1; }
}
