:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel2: #1a2230;
  --border: #232c3a;
  --text: #e8eef6;
  --muted: #8b98a9;
  --accent: #4cc38a;
  --accent2: #58a6ff;
  --danger: #ff7b72;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px;
  gap: 8px;
}

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 12px;
}

.brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }

.orb {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: #08130d; font-weight: 800; font-size: 15px;
  flex-shrink: 0;
  transition: box-shadow .3s;
}
.orb.thinking { animation: think 1s ease-in-out infinite; box-shadow: 0 0 14px rgba(76,195,138,.7); }
@keyframes think {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.brand-name { font-weight: 700; letter-spacing: 2px; font-size: 15px; }
.brand-state { color: var(--muted); font-size: 11px; }

.net { display: flex; gap: 8px; }
.net-box {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  text-align: center;
}
.net-box b { display: block; font-size: 14px; color: var(--accent); }
.net-box span { font-size: 10px; color: var(--muted); }

.icon-btn {
  background: var(--panel2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 10px;
  width: 36px; height: 36px; font-size: 15px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent2); }

/* czat */
.chat {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  min-height: 0;
}

.messages {
  flex: 1; overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.row { display: flex; gap: 8px; align-items: flex-end; }
.row.user { flex-direction: row-reverse; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  flex-shrink: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.avatar.bot { background: var(--accent); color: #08130d; }
.avatar.user { background: #39445a; color: #fff; }

.msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop .16s ease-out;
}
.msg.user { background: #2b5fd9; border-bottom-right-radius: 4px; }
.msg.bot { background: var(--panel2); border-bottom-left-radius: 4px; }

@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.genimg {
  width: 100%; max-width: 300px;
  border-radius: 10px;
  margin: 8px 0;
  display: block;
  cursor: zoom-in;
  border: 1px solid var(--border);
  animation: pop .25s ease-out;
}

.msg pre {
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px; margin: 8px 0;
  overflow-x: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px; line-height: 1.5;
  color: #9fe8c0; white-space: pre;
}

.code-tools { display: flex; gap: 6px; margin-top: 6px; }
.ctool {
  background: var(--panel); border: 1px solid var(--border);
  color: var(--muted); border-radius: 7px;
  font-size: 11px; padding: 3px 9px; cursor: pointer;
}
.ctool:hover { color: var(--text); border-color: var(--accent); }

.msg a { color: var(--accent2); }

.meta { display: flex; gap: 6px; margin-top: 7px; align-items: center; flex-wrap: wrap; }
.vote {
  background: none; border: 1px solid var(--border);
  color: var(--muted); border-radius: 7px;
  font-size: 11px; cursor: pointer; padding: 2px 8px;
}
.vote:hover { color: var(--text); border-color: var(--accent); }
.vote.done { opacity: .3; pointer-events: none; }

details.think { margin-top: 7px; font-size: 11.5px; color: var(--muted); }
details.think summary { cursor: pointer; user-select: none; }
details.think ul { margin: 5px 0 0 15px; }
details.think li { margin: 2px 0; }

.typing {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 16px 6px;
  color: var(--muted); font-size: 12px;
}
.dots { display: flex; gap: 4px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.1s infinite; }
.dots span:nth-child(2) { animation-delay: .18s; }
.dots span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.hidden { display: none !important; }

.chat-form {
  display: flex; gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
}
#chat-input {
  flex: 1; min-width: 0;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px; /* >=16px = iOS nie zoomuje */
  outline: none;
}
#chat-input:focus { border-color: var(--accent); }
.chat-form button {
  background: var(--accent); color: #08130d;
  border: none; border-radius: 12px;
  padding: 0 18px; font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.chat-form button:disabled { opacity: .4; cursor: not-allowed; }

.foot {
  text-align: center;
  font-size: 11px; color: var(--muted);
  padding: 2px 0 6px;
}
.foot a { color: var(--muted); }

/* modale */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 8, 12, .7);
  display: grid; place-items: center;
  padding: 14px;
  animation: fade .2s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  max-width: 420px; width: 100%;
  max-height: 88dvh; overflow-y: auto;
  animation: pop .2s ease-out;
}
.modal h2 { font-size: 16px; margin-bottom: 10px; }
.modal p, .modal li { font-size: 13.5px; line-height: 1.55; }
.modal ul { margin: 8px 0 0 17px; }
.modal a { color: var(--accent2); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.btn {
  background: var(--accent); color: #08130d;
  border: none; border-radius: 9px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn.ghost { background: none; color: var(--muted); border: 1px solid var(--border); font-weight: 400; }
.small { color: var(--muted); font-size: 12.5px !important; margin-top: 8px; }

.captcha-q {
  font-family: ui-monospace, monospace;
  font-size: 22px; letter-spacing: 4px;
  background: var(--panel2); border-radius: 8px;
  padding: 12px; text-align: center;
  margin: 10px 0; user-select: none;
}
#captcha-a, #report-text {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px; font-size: 15px;
  outline: none; resize: vertical;
}
#captcha-a:focus, #report-text:focus { border-color: var(--accent); }
.check { display: flex; gap: 7px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 8px; }
.err { color: var(--danger); font-size: 12.5px; margin-top: 8px; }

/* legal pages */
.legal {
  max-width: 720px; margin: 0 auto;
  padding: 24px 16px 60px;
  overflow-y: auto; height: 100dvh;
}
.legal h1 { font-size: 22px; margin-bottom: 14px; }
.legal h2 { font-size: 16px; margin: 18px 0 8px; color: var(--accent); }
.legal p, .legal li { font-size: 14px; line-height: 1.65; color: var(--text); }
.legal ul { margin: 6px 0 6px 18px; }
.legal .small { color: var(--muted); font-size: 12px; margin-top: 24px; }
.legal a { color: var(--accent2); }


/* pobieranie modelu */
.dl {
  padding: 8px 16px 10px;
  background: var(--panel2);
  border-top: 1px solid var(--border);
}
.dl-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.dl-bar {
  height: 10px; border-radius: 6px; overflow: hidden;
  background: rgba(255,255,255,.08);
}
.dl-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width .3s;
}
.dl-text { font-size: 11px; color: var(--muted); margin-top: 4px; }
.net-box b.lm-on { color: var(--accent); }
