:root {
  --bg: #161618;
  --panel: #1e1f22;
  --panel-2: #26282c;
  --line: #34363b;
  --text: #ececee;
  --muted: #9a9ca3;
  --accent: #e9a45c;
  --accent-ink: #1d1409;
  --user: #3b3550;
  --danger: #e5645f;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3a3c42; border-radius: 6px; border: 2px solid var(--bg); }

/* ---- układ ---- */
.shell { display: flex; height: 100dvh; }
.side {
  width: 220px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand svg { color: var(--accent); }
.nav {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); background: none; border: 0; text-align: left; width: 100%;
}
.nav:hover { background: var(--panel-2); color: var(--text); }
.nav.on { background: var(--panel-2); color: var(--text); }
.nav svg, .ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; color: var(--text); }
.me:hover { background: var(--panel-2); }
main { flex: 1; min-width: 0; overflow-y: auto; }
.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.page.narrow { max-width: 720px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* ---- awatary ---- */
.av { border-radius: 50%; object-fit: cover; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; background: #555; }
.av.sq { border-radius: 12px; }

/* ---- przyciski i pola ---- */
.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; display: inline-flex; align-items: center; gap: 8px; line-height: 1.2;
}
.btn:hover { border-color: #53565d; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 6px; border-radius: 8px; display: inline-grid; place-items: center; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
.icon-btn.on { color: var(--accent); }
.field { display: block; margin: 14px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field > small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.check { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pill { font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); }
.err { color: var(--danger); font-size: 14px; margin: 8px 0; min-height: 1em; }

/* ---- odkrywanie ---- */
.search { position: relative; flex: 1; min-width: 200px; }
.search input { padding-left: 40px; border-radius: 999px; }
.search svg { position: absolute; left: 13px; top: 11px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ccard {
  display: flex; gap: 14px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  text-align: left; width: 100%; align-items: flex-start;
}
.ccard:hover { background: var(--panel-2); }
.ccard .t { min-width: 0; }
.ccard b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard p { margin: 2px 0 6px; color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ccard .meta { font-size: 12px; color: var(--muted); }
.strip { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.strip button { background: none; border: 0; width: 84px; flex: none; text-align: center; font-size: 12.5px; color: var(--muted); }
.strip button span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 6px; }
.strip button:hover { color: var(--text); }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; }

/* ---- strona postaci ---- */
.hero { display: flex; gap: 22px; align-items: flex-start; }
.hero h1 { margin-top: 4px; }
.quote { background: var(--panel); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; }

/* ---- czat ---- */
.chatmain { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.chathead { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chathead .who { min-width: 0; flex: 1; }
.chathead b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.faces { display: flex; }
.faces .av { border: 2px solid var(--panel); margin-left: -10px; }
.faces .av:first-child { margin-left: 0; }
.msgs { flex: 1; overflow-y: auto; padding: 20px 16px; }
.msgs-in { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; }
.msg .body { min-width: 0; max-width: calc(100% - 52px); }
.msg .name { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.msg.user { flex-direction: row-reverse; }
.msg.user .body { text-align: right; }
.bubble { display: inline-block; text-align: left; background: var(--panel-2); border-radius: 18px; border-top-left-radius: 6px; padding: 10px 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user); border-radius: 18px; border-top-right-radius: 6px; }
.bubble em { color: #c9c3da; font-style: italic; }
.msg.pinned .bubble { box-shadow: 0 0 0 1px var(--accent); }
.tools { display: flex; align-items: center; gap: 2px; margin-top: 4px; opacity: .55; min-height: 30px; }
.msg.user .tools { justify-content: flex-end; }
.msg:hover .tools, .tools.show { opacity: 1; }
.tools .icon-btn { padding: 4px; }
.tools .ico { width: 17px; height: 17px; }
.swipe { display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); margin-right: 6px; }
.dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.editbox { width: min(640px, 100%); }
.composer { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); }
.composer-in { max-width: 820px; margin: 0 auto; }
.chips { display: flex; gap: 8px; margin-bottom: 8px; overflow-x: auto; }
.chips .btn { white-space: nowrap; }
.inputbar { display: flex; gap: 8px; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 6px 6px 6px 16px; }
.inputbar:focus-within { border-color: var(--accent); }
.inputbar textarea { border: 0; background: none; min-height: 0; height: 28px; max-height: 180px; padding: 6px 0; resize: none; border-radius: 0; }
.send { background: var(--accent); color: var(--accent-ink); border: 0; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.send:disabled { opacity: .4; }
.send.stop { background: var(--panel-2); color: var(--text); }
.note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---- okna i komunikaty ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; width: min(520px, 100%); max-height: 88dvh; overflow-y: auto; }
.modal h3 { margin: 0 0 8px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 10px; cursor: pointer; }
.pick:hover { background: var(--panel-2); }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #2d2f34; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.4); max-width: 90vw; }
.toast.bad { border-color: var(--danger); }

/* ---- logowanie ---- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.tabs { display: flex; gap: 6px; margin: 16px 0 4px; background: var(--bg); padding: 4px; border-radius: 999px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 999px; color: var(--muted); }
.tabs button.on { background: var(--panel-2); color: var(--text); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* ---- telefon ---- */
@media (max-width: 760px) {
  .shell { flex-direction: column-reverse; }
  .side { width: auto; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); overflow-x: auto; justify-content: space-around; }
  .brand, .spacer, .me .nm { display: none; }
  .nav { flex-direction: column; gap: 2px; padding: 6px 10px; font-size: 11px; width: auto; flex: none; }
  .page { padding: 18px 14px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .hero { flex-direction: column; }
  .chatmain { height: 100%; }
  main { min-height: 0; }
  .msg .body { max-width: calc(100% - 44px); }
  .tools { opacity: 1; }
}
