:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #222632;
  --text: #f3f4f6;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-text: #ffffff;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --cand: #34d399;
  --recr: #60a5fa;
  --border: #2d3240;
  --panel-bg: rgba(14, 16, 21, 0.96);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  --fs-answer: 17px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #111318;
  --muted: #5b6474;
  --border: #d9dde5;
  --panel-bg: rgba(255, 255, 255, 0.97);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(64px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 17px; margin: 18px 0 6px; }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { white-space: nowrap; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.chip.demo { background: #3b2f0b; color: var(--warn); }
.chip.live { background: #0d3326; color: var(--ok); }

main { padding: 4px 16px 16px; max-width: 720px; margin: 0 auto; }
.tab { padding-bottom: 40vh; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
label { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
label > textarea, label > input, label > select { margin-top: 4px; }
textarea, input, select {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; color: var(--text); font-size: 16px; /* 16px = brak auto-zoomu na iOS */
}
textarea { resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 14px; }
.check input { width: auto; margin-top: 3px; }
.check.inline { margin: 0; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.row input { flex: 1 1 140px; width: auto; }
.row select { width: auto; }

button { border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: 0.45; }
.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.secondary { background: var(--surface-2); color: var(--text); }
.mini { background: transparent; color: var(--muted); padding: 6px 8px; min-width: 36px; min-height: 36px; }
.big { flex: 1; min-height: 48px; font-size: 16px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tabs button { background: transparent; color: var(--muted); border-radius: 0; padding: 14px 4px; font-size: 13px; }
.tabs button.active { color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }

.sentences li { margin: 6px 0; font-size: 16px; }
.meter { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
#cal-meter { height: 100%; width: 0; background: var(--ok); transition: width 60ms linear; }
.result { white-space: pre-wrap; color: var(--muted); font-size: 13px; }

.demo { border: 1px dashed var(--border); border-radius: 12px; padding: 4px 10px; margin: 8px 0; }
.transcript { list-style: none; padding: 0; margin: 8px 0; }
.transcript li {
  padding: 8px 10px; margin: 6px 0; border-radius: 10px; background: var(--surface);
  border-left: 3px solid var(--border); cursor: pointer;
}
.transcript li.candidate { border-left-color: var(--cand); }
.transcript li.recruiter { border-left-color: var(--recr); }
.transcript .who { font-size: 11px; color: var(--muted); display: block; }
.transcript li.q .who::after { content: " · pytanie"; color: var(--warn); }
.partial { color: var(--muted); font-style: italic; min-height: 1.4em; }
.log pre { white-space: pre-wrap; font-size: 12px; color: var(--muted); max-height: 200px; overflow: auto; }

.train-q { font-size: 18px; font-weight: 600; }

.gate {
  margin: 12px 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--accent);
}
.gate p { margin: 4px 0; }

/* ---------- Pływający panel ---------- */
.panel {
  position: fixed; z-index: 20; left: 8px; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; height: 42vh; min-height: 220px;
  display: flex; flex-direction: column; background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.panel.tall { height: 72vh; }
.panel.dragged { margin: 0; right: auto; width: min(560px, calc(100vw - 16px)); }
.panel-head {
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 4px 8px; touch-action: none; cursor: grab;
  border-bottom: 1px solid var(--border);
}
.seg { display: flex; flex: 1; background: var(--surface-2); border-radius: 10px; padding: 2px; }
.seg button { flex: 1; background: transparent; color: var(--muted); padding: 6px 4px; font-size: 13px; border-radius: 8px; }
.seg button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.panel-q { padding: 6px 12px 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body {
  flex: 1; overflow-y: auto; padding: 6px 12px 10px; font-size: var(--fs-answer); line-height: 1.4;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.panel-body p { margin: 4px 0; }
.panel-body ul { margin: 4px 0; padding-left: 18px; }
.panel-body li { margin: 3px 0; }
.panel-body .lead { font-weight: 600; }
.panel-body pre {
  background: var(--surface-2); border-radius: 8px; padding: 8px; overflow-x: auto; font-size: 13px; line-height: 1.35;
}
.panel-body code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.panel-meta { padding: 0 12px 4px; font-size: 11px; color: var(--muted); min-height: 15px; }
.panel-foot { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--border); align-items: center; }
.panel-foot .secondary { padding: 10px; }
.cursor::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.bubble {
  position: fixed; z-index: 21; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); box-shadow: var(--shadow); padding: 0;
  touch-action: none;
}
.bubble span { display: block; width: 14px; height: 14px; border-radius: 50%; margin: auto; background: #fff; opacity: 0.6; }
.bubble.new span { background: var(--warn); opacity: 1; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.5); } }

@media (prefers-reduced-motion: reduce) {
  .cursor::after, .bubble.new span { animation: none; }
}
