/* Pałac Umysłu — Material 3 Expressive.
 *
 * Dlaczego ten kierunek: pałac to pamięć z adresami, więc UI musi być **duże i dotykalne**
 * (duża typografia, duże promienie, wyraźne kontenery koloru), a nie tabelka telemetrii.
 * M3 Expressive daje trzy rzeczy, których potrzebuje telefon w kieszeni:
 *   1) typografię, którą widać bez okularów (display 44–57 px, tracking ujemny),
 *   2) kształt jako komunikat (karta → przytrzymanie → arkusz; pill → kwadrat w spoczynku),
 *   3) sprężystą animację (overshoot), która mówi „to jest twoje", a nie „trwa ładowanie".
 *
 * Twarde granice projektu (te same co panel /loop): zero fontów z sieci, zero @import,
 * zero obrazków z URL-a. Wszystko inline albo systemowe.
 *
 * Paleta: ciemna powierzchnia + osiem nasyconych kontenerów (jeden na locus). Kontener locus
 * jest JEGO kolorem także w scenie 3D — dlatego mapa miejsc czyta się jednym spojrzeniem.
 */

/* ---------------------------------------------------------------- tokeny M3 */
:root {
  /* powierzchnie */
  --surface: #0b0e14;
  --surface-1: #11151d;
  --surface-2: #171c26;
  --surface-3: #1e2431;
  --surface-4: #262e3d;
  --outline: #38414f;
  --outline-soft: #232a36;

  /* tekst */
  --on-surface: #e9eef7;
  --on-surface-variant: #a7b2c4;
  --on-surface-dim: #7b8798;

  /* role akcentu (jeden akcent główny = „zostaw myśl") */
  --primary: #cdf564;
  --on-primary: #1a2200;
  --primary-container: #38470a;
  --on-primary-container: #e4ffa3;
  --secondary-container: #1d3b46;
  --on-secondary-container: #b8ecff;
  --tertiary-container: #3a2a4d;
  --on-tertiary-container: #e7d3ff;
  --error: #ff8f85;
  --error-container: #4a1f1c;

  /* osiem loci = osiem kontenerów */
  --l-prog: #cdf564;
  --l-lustra: #7de2ff;
  --l-sensoryczna: #ff9e8a;
  --l-studnia: #a9a7ff;
  --l-biblioteka: #ffd48a;
  --l-wieza: #d9b8ff;
  --l-dziedziniec: #9cf0c8;
  --l-ogrod: #ffb3d1;

  /* kształt */
  --r-xs: 8px;
  --r-s: 12px;
  --r-m: 16px;
  --r-l: 22px;
  --r-xl: 28px;
  --r-xxl: 36px;
  --r-full: 999px;

  /* ruch: emphasized (M3) + sprężyna z overshootem */
  --ease-emph: cubic-bezier(0.2, 0, 0, 1);
  --ease-emph-out: cubic-bezier(0.05, 0.7, 0.1, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-soft: cubic-bezier(0.22, 1.4, 0.36, 1);
  --t-fast: 140ms;
  --t-mid: 260ms;
  --t-slow: 420ms;

  /* skala pisma (M3 expressive, przycięta do 430 px) */
  --f-display: 44px;
  --f-headline: 30px;
  --f-title: 21px;
  --f-body: 15px;
  --f-label: 13px;

  --gap: 14px;
  --pad: 18px;
}

/* ---------------------------------------------------------------- reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--f-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
  /* Zamszowa poświata pod powierzchnią — M3 tonal surface, nie gradient ozdobny. */
  background-image:
    radial-gradient(1100px 620px at 12% -8%, rgba(205, 245, 100, 0.09), transparent 62%),
    radial-gradient(900px 520px at 92% 4%, rgba(125, 226, 255, 0.08), transparent 60%);
  background-attachment: fixed;
}

h1, h2, h3, p, ol, ul, dl, figure {
  margin: 0;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

code, kbd {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--on-surface-variant);
}

.sr-only,
.aria-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- powłoka */
.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 14px calc(28px + env(safe-area-inset-bottom));
}

/* Górny pasek: M3 large app bar — tytuł display, pod nim jedno zdanie sensu. */
.top {
  padding: 26px 4px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand b {
  display: block;
  font-size: var(--f-display);
  line-height: 1.02;
  letter-spacing: -0.028em;
  font-weight: 800;
}

.brand b em {
  font-style: normal;
  color: var(--primary);
}

.brand span {
  display: block;
  margin-top: 6px;
  font-size: var(--f-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-surface-dim);
}

/* Chipy stanu: pill, tonalne, z kropką. Nie krzyczą — informują. */
.vitals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--outline-soft);
  background: var(--surface-2);
  color: var(--on-surface-variant);
  font-size: var(--f-label);
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease-emph), color var(--t-fast) var(--ease-emph),
    border-color var(--t-fast) var(--ease-emph), transform var(--t-mid) var(--spring);
}

.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  flex: none;
}

.chip[data-state="on"],
.chip[data-state="live"],
.chip[data-state="ok"] {
  background: var(--primary-container);
  border-color: transparent;
  color: var(--on-primary-container);
}

.chip[data-state="on"]::before,
.chip[data-state="live"]::before,
.chip[data-state="ok"]::before {
  background: var(--primary);
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(205, 245, 100, 0.18);
}

.chip[data-state="bad"],
.chip[data-state="pauza"] {
  background: var(--error-container);
  border-color: transparent;
  color: #ffc9c3;
}

.chip[data-state="off"] { opacity: 0.75; }

/* ---------------------------------------------------------------- siatka */
.wrap {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .wrap {
    /* Expressive = asymetria, nie dwie równe kolumny. */
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: start;
  }
  .col-a { grid-column: 1; }
  .col-b { grid-column: 2; }
}

.col-a,
.col-b {
  display: grid;
  gap: var(--gap);
  min-width: 0;
}

/* ---------------------------------------------------------------- karty M3 */
.card {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--outline-soft);
  border-radius: var(--r-xl);
  padding: var(--pad);
  overflow: hidden;
}

.card > h2 {
  font-size: var(--f-title);
  line-height: 1.2;
  letter-spacing: -0.012em;
  font-weight: 700;
  margin-bottom: 12px;
}

.card > h2 + .hint { margin-top: -6px; }

/* Karta „hero" — karta dnia. Ton pierwszy, duża liczba, jedno zdanie. */
.hero {
  background:
    radial-gradient(120% 140% at 88% -20%, rgba(205, 245, 100, 0.22), transparent 58%),
    linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border-color: rgba(205, 245, 100, 0.22);
  padding: 22px var(--pad) var(--pad);
}

.hero .kicker {
  display: block;
  font-size: var(--f-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 8px;
}

.hero .big {
  font-size: var(--f-display);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hero .big small {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--on-surface-variant);
  display: block;
  margin-top: 10px;
  line-height: 1.4;
  max-width: 44ch;
}

.hero .oldest {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--r-l);
  background: var(--surface-3);
  border-left: 3px solid var(--l-studnia);
}

.hero .oldest .lbl {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-surface-dim);
  display: block;
  margin-bottom: 5px;
}

.hero .oldest q {
  display: block;
  font-size: 17px;
  line-height: 1.35;
  quotes: "„" "”";
}

.hero .oldest .meta {
  margin-top: 7px;
  font-size: var(--f-label);
  color: var(--on-surface-dim);
}

/* ---------------------------------------------------------------- przyciski */
.btn {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--on-surface);
  appearance: none;
  border: 1px solid transparent;
  background: var(--btn-bg);
  color: var(--btn-fg);
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--r-full);
  font-size: var(--f-body);
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform var(--t-fast) var(--spring), background var(--t-fast) var(--ease-emph),
    border-radius var(--t-mid) var(--spring), box-shadow var(--t-mid) var(--ease-emph);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:hover { background: var(--surface-4); }

/* Squish: M3 Expressive zmienia kształt pod palcem, nie tylko kolor. */
.btn:active {
  transform: scale(0.955);
  border-radius: var(--r-m);
}

.btn:focus-visible,
.locus:focus-visible,
.tappable:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.btn.filled {
  --btn-bg: var(--primary);
  --btn-fg: var(--on-primary);
  box-shadow: 0 6px 22px -8px rgba(205, 245, 100, 0.7);
}

.btn.filled:hover { --btn-bg: #d8ff7a; }

.btn.tonal {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--on-surface);
  border-color: var(--outline-soft);
}

.btn.ghost {
  --btn-bg: transparent;
  --btn-fg: var(--on-surface-variant);
  border-color: var(--outline);
  min-height: 42px;
  padding: 0 16px;
  font-size: var(--f-label);
}

.btn.stop {
  --btn-bg: var(--error-container);
  --btn-fg: #ffd9d5;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Extended FAB — główna akcja produktu („przypomnij mi"). */
.fab {
  width: 100%;
  min-height: 62px;
  border-radius: var(--r-xxl);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.005em;
}

.fab .ico {
  font-size: 22px;
  line-height: 1;
}

/* ---------------------------------------------------------------- loci */
.loci-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.loci-head h2 {
  font-size: var(--f-headline);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 780;
}

.loci-head .totals {
  font-size: var(--f-label);
  color: var(--on-surface-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.loci-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 620px) {
  .loci-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.locus {
  --locus: var(--l-prog);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 132px;
  padding: 14px;
  text-align: left;
  border: 1px solid color-mix(in oklab, var(--locus) 30%, transparent);
  border-radius: var(--r-l);
  background:
    linear-gradient(160deg, color-mix(in oklab, var(--locus) 18%, var(--surface-2)), var(--surface-2) 72%);
  color: var(--on-surface);
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--t-mid) var(--spring), border-radius var(--t-mid) var(--spring),
    border-color var(--t-fast) var(--ease-emph), box-shadow var(--t-mid) var(--ease-emph);
  -webkit-tap-highlight-color: transparent;
}

.locus:hover {
  border-color: color-mix(in oklab, var(--locus) 62%, transparent);
  box-shadow: 0 12px 30px -18px color-mix(in oklab, var(--locus) 70%, transparent);
}

.locus:active {
  transform: scale(0.965) rotate(-0.4deg);
  border-radius: var(--r-m);
}

.locus .name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.locus .count {
  font-size: 34px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--locus);
  font-variant-numeric: tabular-nums;
  margin-top: auto;
}

.locus .count small {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--on-surface-dim);
  margin-left: 4px;
}

.locus .state {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-surface-dim);
}

/* Miejsce, którego liczb jeszcze nie znamy (brak sesji) — widoczne, ale nie udaje pomiaru. */
.locus[data-state="locked"] { opacity: 0.9; }
.locus[data-state="locked"] .count { color: var(--on-surface-dim); font-size: 26px; }

.locus[data-state="pusty"] { opacity: 0.72; }
.locus[data-state="pusty"] .count { color: var(--on-surface-dim); }

.locus[data-state="głodny"] {
  border-style: dashed;
  border-color: color-mix(in oklab, var(--locus) 55%, transparent);
}

.locus[data-state="głodny"] .state { color: #ffd48a; }

.locus[data-state="przeciążony"] {
  border-width: 2px;
  border-color: color-mix(in oklab, var(--error) 60%, transparent);
}

.locus[data-state="przeciążony"] .state { color: var(--error); }

/* Kropka „świeża myśl" — stan z plików, nie ozdoba. */
.locus .fresh {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--locus);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--locus) 22%, transparent);
  animation: pulse 2.4s var(--ease-emph) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------------------------------------------------------------- przypomnienie */
.recall-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.recall-item {
  background: var(--surface-2);
  border: 1px solid var(--outline-soft);
  border-radius: var(--r-l);
  padding: 14px 16px;
  animation: rise var(--t-slow) var(--spring-soft) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.recall-item .addr {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-surface-dim);
  margin-bottom: 7px;
}

.recall-item .addr i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--locus-color, var(--primary));
  display: inline-block;
}

.recall-item q {
  display: block;
  font-size: 19px;
  line-height: 1.34;
  letter-spacing: -0.008em;
  quotes: "„" "”";
}

.recall-item .why {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.why-chip {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: var(--r-full);
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.recall-item .score {
  float: right;
  font-size: 11px;
  color: var(--on-surface-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- arkusz zapisu */
.sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.66);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-mid) var(--ease-emph);
  z-index: 40;
}

.sheet-scrim[data-open="1"] {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  --locus-color: var(--primary);
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(560px, 100%);
  transform: translate(-50%, 108%);
  transition: transform var(--t-slow) var(--spring);
  background: var(--surface-2);
  border-radius: var(--r-xxl) var(--r-xxl) 0 0;
  border: 1px solid var(--outline);
  border-bottom: 0;
  padding: 12px 18px calc(20px + env(safe-area-inset-bottom));
  z-index: 41;
  box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, 0.8);
}

.sheet[data-open="1"] { transform: translate(-50%, 0); }

.sheet .grip {
  width: 42px;
  height: 5px;
  border-radius: var(--r-full);
  background: var(--outline);
  margin: 0 auto 14px;
}

.sheet h3 {
  font-size: var(--f-headline);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 780;
  color: var(--locus-color);
}

.sheet .hintline {
  font-size: var(--f-label);
  color: var(--on-surface-dim);
  margin: 6px 0 14px;
}

.sheet textarea {
  width: 100%;
  min-height: 108px;
  resize: none;
  padding: 14px 16px;
  border-radius: var(--r-l);
  border: 1px solid var(--outline);
  background: var(--surface-3);
  color: var(--on-surface);
  font-size: 17px;
  line-height: 1.4;
  transition: border-color var(--t-fast) var(--ease-emph), box-shadow var(--t-fast) var(--ease-emph);
}

.sheet textarea:focus {
  outline: none;
  border-color: var(--locus-color);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--locus-color) 22%, transparent);
}

.sheet .sheet-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.sheet .counter {
  font-size: var(--f-label);
  color: var(--on-surface-dim);
  font-variant-numeric: tabular-nums;
  margin-right: auto;
}

.sheet .counter[data-over="1"] { color: var(--error); font-weight: 700; }

/* -------------------------------------------------- zawartość miejsca (arkusz) */
.sheet-existing {
  max-height: 190px;
  overflow: auto;
  margin: 0 0 12px;
  padding-right: 4px;
}

.sheet-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 7px;
}

.sheet-list li {
  background: var(--surface-3);
  border-radius: var(--r-m);
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.35;
  border-left: 3px solid var(--locus-color, var(--primary));
  display: flex;
  gap: 9px;
  align-items: baseline;
}

.sheet-list li time {
  font-size: 11px;
  color: var(--on-surface-dim);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.sheet-list li.empty {
  border-left-color: var(--outline);
  color: var(--on-surface-dim);
  font-style: italic;
}

.inp-text { letter-spacing: 0; }

/* ---------------------------------------------------------------- scena */
.stage-card {
  padding: 0;
  overflow: hidden;
}

.stage-head {
  padding: 20px var(--pad) 6px;
}

.stage-head h1 {
  font-size: var(--f-headline);
  line-height: 1.1;
  letter-spacing: -0.022em;
  font-weight: 780;
}

.stage-head h1 em {
  font-style: normal;
  color: var(--secondary-container);
  background: var(--on-secondary-container);
  padding: 0 8px;
  border-radius: var(--r-s);
}

.stage-head .lead {
  margin-top: 7px;
  color: var(--on-surface-variant);
  font-size: 14px;
  max-width: 62ch;
}

.stage {
  position: relative;
  height: 300px;
  margin: 10px 0 0;
  touch-action: none;
}

@media (min-width: 700px) {
  .stage { height: 380px; }
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.fallback {
  margin: 0 var(--pad) 8px;
  padding: 12px 14px;
  border-radius: var(--r-l);
  background: var(--error-container);
  color: #ffd9d5;
  font-size: 14px;
}

.scene-keys {
  padding: 0 var(--pad) 10px;
  font-size: 12px;
  color: var(--on-surface-dim);
  line-height: 1.45;
}

/* Pasek nagrywania: pill z dużą kropką (M3 expressive „status orbs"). */
.rec-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 var(--pad) 14px;
  padding: 10px 12px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--outline-soft);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--on-surface-dim);
  flex: none;
  transition: background var(--t-fast) var(--ease-emph), box-shadow var(--t-fast) var(--ease-emph);
}

.dot[data-on="1"] {
  background: var(--primary);
  box-shadow: 0 0 0 5px rgba(205, 245, 100, 0.16);
  animation: pulse 1.8s var(--ease-emph) infinite;
}

.rec-text {
  font-size: var(--f-label);
  color: var(--on-surface-variant);
  margin-right: auto;
  font-variant-numeric: tabular-nums;
}

.warn {
  margin: 0 var(--pad) 16px;
  padding: 12px 14px;
  border-radius: var(--r-l);
  background: #4a3a12;
  color: #ffe4a3;
  font-size: 13px;
  line-height: 1.45;
}

/* ---------------------------------------------------------------- diagnostyka */
details.diag {
  background: var(--surface-1);
  border: 1px solid var(--outline-soft);
  border-radius: var(--r-xl);
  padding: 4px 4px 4px;
}

details.diag > summary {
  cursor: pointer;
  padding: 14px 16px;
  font-size: var(--f-title);
  font-weight: 700;
  letter-spacing: -0.01em;
  border-radius: var(--r-l);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--t-fast) var(--ease-emph);
}

details.diag > summary::-webkit-details-marker { display: none; }

details.diag > summary::before {
  content: "▸";
  color: var(--on-surface-dim);
  transition: transform var(--t-mid) var(--spring);
  display: inline-block;
}

details.diag[open] > summary::before { transform: rotate(90deg); }

details.diag > summary:hover { background: var(--surface-2); }

details.diag .diag-body {
  display: grid;
  gap: var(--gap);
  padding: 6px 8px 12px;
}

.diag .card {
  background: var(--surface-2);
}

/* ---------------------------------------------------------------- tabela sensorów */
.sensors {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.sensors th,
.sensors td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--outline-soft);
  vertical-align: top;
}

.sensors thead th {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-surface-dim);
  font-weight: 600;
}

.sensors tbody th {
  font-weight: 600;
  white-space: nowrap;
}

.sensors .wht {
  display: block;
  font-size: 11px;
  color: var(--on-surface-dim);
  font-weight: 400;
}

.sensors .val { color: var(--on-surface); }
.sensors .unit, .sensors .acc, .sensors .n { color: var(--on-surface-dim); white-space: nowrap; }

.st {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--surface-4);
  color: var(--on-surface-variant);
  white-space: nowrap;
}

.st[data-st="live"] { background: var(--primary-container); color: var(--on-primary-container); }
.st[data-st="denied"], .st[data-st="insecure"] { background: var(--error-container); color: #ffc9c3; }
.st[data-st="no_data"], .st[data-st="unsupported"] { background: #4a3a12; color: #ffe4a3; }

/* ---------------------------------------------------------------- drobne listy */
.stats {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0 0 12px;
}

.stats li {
  background: var(--surface-3);
  border-radius: var(--r-m);
  padding: 9px 12px;
  font-size: var(--f-label);
  color: var(--on-surface-dim);
}

.stats b {
  display: block;
  font-size: 22px;
  color: var(--on-surface);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.people {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.people li {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface-3);
  border-radius: var(--r-m);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--on-surface-variant);
}

.people li b { color: var(--on-surface); font-variant-numeric: tabular-nums; }

.events {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
  color: var(--on-surface-variant);
}

.events li {
  padding: 7px 10px;
  border-radius: var(--r-s);
  background: var(--surface-3);
  font-family: ui-monospace, Consolas, monospace;
}

.events li[data-kind="warn"] { background: #4a3a12; color: #ffe4a3; }
.events li[data-kind="bad"], .events li[data-kind="error"] { background: var(--error-container); color: #ffc9c3; }

.hint {
  font-size: var(--f-label);
  color: var(--on-surface-dim);
  line-height: 1.45;
}

.hint code { font-size: 0.9em; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lab {
  font-size: var(--f-label);
  color: var(--on-surface-variant);
  min-width: 78px;
}

.inp {
  flex: 1 1 130px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--outline);
  background: var(--surface-3);
  color: var(--on-surface);
  font-size: 16px;
  letter-spacing: 0.18em;
  transition: border-color var(--t-fast) var(--ease-emph), box-shadow var(--t-fast) var(--ease-emph);
}

.inp:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(205, 245, 100, 0.16);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: var(--f-label);
  color: var(--on-surface-variant);
  margin-top: 10px;
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

details.token-manual {
  margin-top: 12px;
}

details.token-manual > summary {
  cursor: pointer;
  font-size: var(--f-label);
  color: var(--on-surface-dim);
}

details.token-manual .row { margin-top: 10px; }

/* ---------------------------------------------------------------- dostępność */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Wąski ekran: górny pasek bez hero-paddingu, loci 2 kolumny, arkusz na całą szerokość. */
@media (max-width: 480px) {
  :root {
    --f-display: 38px;
    --f-headline: 26px;
    --pad: 15px;
  }
  .top { padding: 18px 2px 12px; }
  .locus { min-height: 120px; padding: 12px; }
  .locus .count { font-size: 30px; }
}
