:root {
  --bg: #0b0d12; --panel: #141821; --panel2: #1c2130; --line: #2a3142;
  --fg: #e8ebf2; --muted: #8b93a7; --accent: #3b82f6; --ok: #22c55e;
  --warn: #f59e0b; --urgent: #ef4444; --info: #38bdf8; --wait: #a78bfa;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 10px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { border-color: #7f1d1d; color: #fca5a5; }
button.icon { background: transparent; border: 0; padding: 6px 8px; font-size: 18px; }
button.big { width: 100%; padding: 14px; font-size: 18px; }
input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; outline: none; }
input:focus { border-color: var(--accent); }
.view { height: 100%; }
[hidden] { display: none !important; }

/* logowanie */
#login { display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: grid; gap: 14px; }
.card h1 { margin: 0; text-align: center; font-size: 22px; }
.card label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.logo { font-size: 40px; text-align: center; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details label { margin-top: 8px; }
.err { color: #fca5a5; min-height: 1em; margin: 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.hint a { color: var(--info); }

/* główny układ */
#main { display: flex; flex-direction: column; height: 100dvh; }
.top { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 12px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top strong { flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talknow { flex: 1; text-align: right; color: var(--ok); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--urgent); flex: none; }
.dot.on { background: var(--ok); }
.dot.half { background: var(--warn); }

.banner { padding: 10px 14px; text-align: center; font-weight: 600; cursor: pointer; }
.banner.warn { background: #78350f; }
.toast { position: fixed; left: 12px; right: 12px; top: calc(56px + var(--safe-t)); z-index: 20; background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); border-radius: 12px; padding: 10px 14px; box-shadow: 0 8px 24px #0008; cursor: pointer; }
.toast.urgent { background: #450a0a; border-color: var(--urgent); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); white-space: nowrap; }
.tab::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 8px; vertical-align: middle; }
.tab[aria-selected="true"] { color: var(--fg); border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
.tab.muted { opacity: .55; }
.tab .badge { margin-left: 6px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.tab .badge.urgent { background: var(--urgent); }
.tab.talking { animation: pulse 1s infinite; border-color: var(--ok); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 35%, transparent); } }

.feed { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.empty { margin: auto; color: var(--muted); text-align: center; }
.msg { flex: none; min-width: 0; max-width: 88%; align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.msg.mine { align-self: flex-end; background: #172554; border-color: #1e3a8a; }
.msg .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.msg .who { color: var(--fg); font-weight: 600; }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg.quick { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; }
.msg.quick .text { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; padding: 3px 12px; border-radius: 999px; font-weight: 700; background: color-mix(in srgb, var(--t) 22%, transparent); color: var(--t); border: 1px solid var(--t); }
.msg.urgent { background: #450a0a; border-color: var(--urgent); }
.msg.voice { background: transparent; border-style: dashed; color: var(--muted); font-size: 14px; }
.msg.system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 13px; }
.tone-ok { --t: var(--ok); } .tone-warn { --t: var(--warn); } .tone-urgent { --t: var(--urgent); }
.tone-info { --t: var(--info); } .tone-wait { --t: var(--wait); }

.bottom { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 10px calc(8px + var(--safe-b)); display: grid; gap: 8px; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.quick button { min-width: 0; border-radius: 12px; padding: 8px 6px; font-size: 14px; line-height: 1.2; white-space: normal; font-weight: 600; color: var(--t); border-color: color-mix(in srgb, var(--t) 60%, transparent); background: color-mix(in srgb, var(--t) 12%, transparent); }
.quick button:active { transform: scale(.96); }
.composer { display: flex; gap: 8px; }
.composer button { flex: none; width: 52px; }
.pttrow { display: flex; gap: 8px; }
.ptt { flex: 1; min-height: 76px; border-radius: 16px; border: 2px solid #334155; background: #111827; display: grid; place-content: center; gap: 2px; user-select: none; -webkit-user-select: none; touch-action: none; }
.ptt-l1 { font-size: 18px; font-weight: 700; }
.ptt-l2 { font-size: 13px; color: var(--muted); }
.ptt.live { background: #14532d; border-color: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 35%, transparent); }
.ptt.live .ptt-l2 { color: #bbf7d0; }
.ptt:disabled { opacity: .5; }
.pttlock { flex: none; width: 64px; border-radius: 16px; font-size: 22px; }
.pttlock[aria-pressed="true"] { background: #14532d; border-color: var(--ok); }

/* panel */
.sheet { position: fixed; inset: 0; background: #000a; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; background: var(--panel); border-radius: 18px 18px 0 0; border: 1px solid var(--line); padding: 16px 16px calc(16px + var(--safe-b)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.checklist, .switch { display: grid; gap: 4px; }
.checklist label, .switch { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.checklist input, .switch input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.checklist .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.row { display: flex; gap: 8px; margin-top: 12px; }
.me { color: var(--muted); margin: 8px 0 0; }
.people-sum { color: var(--muted); font-size: 14px; margin: 6px 0 4px; }
.pgroup { margin-top: 14px; }
.pgroup h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 15px; }
.pgroup h4::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.pgroup h4 small { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12px; }
.people { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.people li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel2); border-radius: 10px; border-left: 3px solid var(--c, transparent); }
.people .nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.people .here { font-size: 12px; color: var(--muted); }
.pbadge { flex: none; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pbadge.can { color: #93c5fd; border-color: #1e3a8a; }
.pbadge.live { color: #052e16; background: var(--ok); border-color: var(--ok); font-weight: 700; animation: pulse 1s infinite; }

@media (min-width: 900px) {
  .feed { padding: 16px 24px; }
  .msg { max-width: 70%; }
}
.msg.voice .stt { font-style: italic; opacity: .75; }
.msg.voice .text { color: var(--fg); font-size: 16px; margin-top: 2px; }

/* logowanie z obsady Planning Center */
.lead { margin: 0; font-weight: 600; }
.roster { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 46dvh; overflow-y: auto; }
.roster button { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 10px 12px; }
.roster .rn { font-weight: 600; }
.roster .rt { grid-column: 1; font-size: 12px; color: var(--muted); }
.roster .pbadge { grid-column: 2; grid-row: 1 / span 2; }
.roster .you { color: var(--info); font-weight: 400; font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--info); padding: 4px 0; text-align: left; }

/* pasek planu */
.planbar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: #10151f; padding: 8px 12px; }
.planbar .pl-now { font-weight: 700; }
.planbar .pl-next, .planbar .pl-muted { color: var(--muted); font-size: 13px; }
.planbar .live { background: var(--urgent); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-right: 4px; letter-spacing: .05em; }
.planlist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; }
.planlist li { padding: 8px 10px; border-radius: 10px; background: var(--panel2); cursor: default; }
.planlist li[data-iid] { cursor: pointer; }
.planlist li.ph { background: transparent; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 12px 2px 2px; }
.planlist li.cur { background: #14532d; border: 1px solid var(--ok); }
.planlist .pt { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.planlist .pm { color: var(--muted); font-weight: 400; font-size: 13px; white-space: nowrap; }
.planlist .pd { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: pre-wrap; }
