/* Triki Pilot — ciemny motyw, telefon-first */
:root {
  --bg: #0d0f12;
  --card: #171a1f;
  --line: #2a2f37;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #3ddc84;
  --warn: #f5b942;
  --err: #ff5c5c;
  --blue: #5ea2ff;
  --orange: #ff9f43;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
.page {
  max-width: 640px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
}
h1 { font-size: 24px; margin: 4px 0 8px; }
h2 { font-size: 17px; margin: 0 0 10px; }
a { color: var(--blue); }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.card.warn { border-color: var(--warn); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
  appearance: none; border: 0; border-radius: 12px; cursor: pointer;
  background: #2b313a; color: var(--text); font: inherit; font-weight: 600;
  min-height: 48px; padding: 10px 16px;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #062b16; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn[hidden] { display: none; }
.btn.grow { flex: 1 1 auto; }
.spacer { flex: 1; }
.links { display: grid; gap: 8px; }
.links a { display: block; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); font-weight: 600; }
.links a span { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }

/* status */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status[data-state="connecting"]::before { background: var(--warn); }
.status[data-state="connected"]::before { background: var(--accent); }
.status[data-state="disconnected"]::before { background: var(--err); }

/* live dane */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cell { background: #0f1216; border-radius: 10px; padding: 8px; min-width: 0; }
.cell small { display: block; color: var(--muted); font-size: 12px; }
.cell b { font: 600 17px/1.3 ui-monospace, Menlo, monospace; white-space: nowrap; }
.cell.pressed { background: #123a24; }
.big-gesture { font-size: 26px; font-weight: 700; min-height: 40px; text-align: center; }
canvas { width: 100%; height: 160px; display: block; background: #0f1216; border-radius: 10px; }
.legend { font-size: 13px; color: var(--muted); }
.legend .p { color: var(--blue); } .legend .r { color: var(--orange); }

/* log */
.log, .raw {
  font: 12px/1.4 ui-monospace, Menlo, monospace; background: #0a0c0f; border-radius: 10px;
  padding: 8px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.log-warn { color: var(--warn); } .log-error { color: var(--err); } .log-ok { color: var(--accent); }

/* ustawienia */
details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.set-row { display: grid; gap: 4px; margin: 10px 0; font-size: 15px; }
.set-row.set-check { grid-template-columns: 1fr auto; align-items: center; }
.set-row input[type=range] { width: 100%; }
.set-row input[type=checkbox] { width: 24px; height: 24px; }
select, textarea {
  font: inherit; color: var(--text); background: #0f1216; border: 1px solid var(--line); border-radius: 10px; padding: 10px; width: 100%;
}
textarea { min-height: 110px; font-size: 14px; }
textarea.code { font: 12px/1.3 ui-monospace, Menlo, monospace; min-height: 90px; }
ol.steps { padding-left: 22px; } ol.steps li { margin: 8px 0; }
code { background: #0f1216; padding: 1px 5px; border-radius: 6px; font-size: 14px; }

/* --- odtwarzacz --- */
body.player { height: 100dvh; overflow: hidden; }
.player-wrap { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(6px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 6px calc(10px + env(safe-area-inset-left));
}
.topbar .pos { font-weight: 700; font-variant-numeric: tabular-nums; }
.topbar .spacer { flex: 1; }
.stage { flex: 1; position: relative; background: #000; min-height: 0; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage .empty { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; color: var(--muted); }
.controls {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; touch-action: pan-x;
  padding: 8px calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
}
.controls .btn { min-height: 56px; font-size: 22px; }
.toast {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, .8); color: #fff; font-size: 24px; font-weight: 700;
  padding: 12px 20px; border-radius: 14px; pointer-events: none; opacity: 0; transition: opacity .2s; z-index: 10;
}
.toast.show { opacity: 1; }
.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto;
}
.sheet[hidden] { display: none; }
.queue-list { list-style: none; padding: 0; margin: 8px 0 0; max-height: 200px; overflow: auto; font: 13px ui-monospace, Menlo, monospace; }
.queue-list li { padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.queue-list li.cur { background: #123a24; }
.queue-list li.bad { color: var(--err); }
.row + .row { margin-top: 8px; }
.stage .empty[hidden] { display: none; }
