:root {
  --bg: #f5f7fa; --surface: #ffffff; --ink: #0b1b33; --ink-2: #4a5872; --line: #e1e6ee;
  --accent: #1fa463; --accent-ink: #ffffff; --accent-soft: #e6f6ee;
  --warn: #b45309; --warn-soft: #fef3e2; --bad: #b42318; --bad-soft: #fdecea;
  --navy: #0b1b33; --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a1220; --surface: #121c2e; --ink: #e8edf5; --ink-2: #9aa7bd; --line: #24324a;
    --accent-soft: #10331f; --warn-soft: #3a2a10; --bad-soft: #3a1512; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: inherit; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: var(--navy); color: #fff; }
.brand { text-decoration: none; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
#nav { display: flex; gap: 14px; font-size: 14px; }
#nav a { text-decoration: none; opacity: .85; } #nav a:hover { opacity: 1; }
main { max-width: 980px; margin: 0 auto; padding: 20px 16px 120px; }
.pad { padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 4px; } h2 { font-size: 17px; margin: 24px 0 10px; } h3 { font-size: 15px; margin: 0 0 4px; }
.muted { color: var(--ink-2); } .small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.list > * + * { margin-top: 8px; }
.card.link { text-decoration: none; display: block; }
.card.link:hover { border-color: var(--accent); }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--ink); font: inherit; }
textarea { min-height: 90px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: default; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tabs button { white-space: nowrap; flex: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--ink-2); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); }
.pill.grey { background: var(--line); }
.meter { display: inline-flex; gap: 2px; vertical-align: middle; }
.meter i { width: 8px; height: 8px; border-radius: 2px; background: var(--line); }
.meter i.on { background: var(--accent); }
.modes { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.mode { text-align: left; display: block; padding: 14px; min-height: 0; font-weight: 400; }
.mode b { display: block; font-size: 15px; margin-bottom: 2px; }
.mode.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px;
  font-weight: 400; margin: 6px 0; cursor: pointer; }
.check input { margin-top: 4px; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* czat */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 2px; }
.msg.them { background: var(--surface); border: 1px solid var(--line); align-self: flex-start; }
.msg.me { background: var(--accent); color: #fff; align-self: flex-end; }
.msg.me .who { color: rgba(255,255,255,.8); }
.msg.hint { background: var(--warn-soft); border: 1px dashed var(--warn); align-self: stretch; max-width: 100%; }
.typing { color: var(--ink-2); font-size: 13px; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); z-index: 5; }
.composer .inner { max-width: 980px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; flex: 1; }
.mic { width: 52px; height: 52px; border-radius: 50%; padding: 0; font-size: 22px; flex: none; }
.mic.live { background: var(--bad); border-color: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(180,35,24,.15); } }
@media (prefers-reduced-motion: reduce) { .mic.live { animation: none; } }
.drive { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 30px 10px; text-align: center; }
.drive .big { width: 160px; height: 160px; border-radius: 50%; font-size: 48px; }
.drive .status { font-size: 18px; font-weight: 600; min-height: 28px; }
.drive .last { font-size: 17px; max-width: 600px; }

/* debrief */
.score { font-size: 44px; font-weight: 800; line-height: 1; }
.debrief ul { margin: 6px 0 0; padding-left: 18px; }
.fix { border-left: 3px solid var(--bad); padding: 6px 10px; background: var(--bad-soft); border-radius: 6px; margin: 6px 0; }
.better { border-left: 3px solid var(--accent); padding: 6px 10px; background: var(--accent-soft); border-radius: 6px; margin: 6px 0; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 50; }
#toast.on { opacity: 1; }
#toast.err { background: var(--bad); }
.empty { text-align: center; padding: 30px 16px; }
@media (max-width: 600px) { h1 { font-size: 19px; } .msg { max-width: 94%; } .brand b { display: none; } #nav { gap: 10px; font-size: 13px; } }

.pill.warn { background: var(--warn-soft); color: var(--warn); }
.brief h2 { font-size: 15px; margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); }
.brief h3 { margin-top: 10px; }
.brief ul { margin: 0; padding-left: 18px; }
.brief .qa { padding: 6px 0; border-bottom: 1px solid var(--line); }
.brief .src { color: var(--ink-2); font-size: 12px; }
@media print {
  .top, .tabs, .noprint, #toast, .composer, a.small.muted { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; } main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
}
.card.link.row { display: flex; }

@media (max-width: 600px) {
  .top { padding: 8px 12px; } #nav a { white-space: nowrap; } #nav #logout { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.stack tr:first-child { display: none; }
  table.stack td { border: 0; padding: 2px 0; }
  table.stack td:first-child { grid-column: 1 / -1; }
  table.stack td.row { grid-column: 1 / -1; }
}
@media (max-width: 600px) { .tabs { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); scrollbar-width: none; } }

[hidden] { display: none !important; }
#bform, #pform { scroll-margin-top: 70px; }

/* rozmowa grupowa: rola przy imieniu i kolor osoby */
.msg .who .role { font-weight: 400; }
.msg.them.p0 { border-left: 3px solid #1fa463; } .msg.them.p1 { border-left: 3px solid #3b82f6; }
.msg.them.p2 { border-left: 3px solid #d97706; } .msg.them.p3 { border-left: 3px solid #a855f7; }
.msg.them.p4 { border-left: 3px solid #e11d48; } .msg.them.p5 { border-left: 3px solid #0891b2; }

.radio { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink-2); margin-right: 8px; vertical-align: -2px; }
.radio.on { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }

/* załączniki */
.atts { max-width: 980px; margin: 0 auto 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.atts:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 4px 4px 10px; border-radius: 99px; background: var(--accent-soft); }
.chip.muted { padding-right: 10px; }
.chip button { min-height: 40px; width: 40px; padding: 0; border-radius: 50%; border: 0; background: transparent; }
.msg .att { margin-top: 6px; font-size: 13px; } .msg .att summary { cursor: pointer; }
.msg .att div { white-space: pre-wrap; max-height: 240px; overflow: auto; margin-top: 4px; opacity: .9; }
