/* =========================================================
   KIOSK OCENY OBIADÓW — układ, tokeny, komponenty
   Efekty "kinowe" (glow, sweep, animacje) są w cinematic.css
   ========================================================= */

:root {
  /* tło i powierzchnie */
  --bg: #06080c;
  --bg-2: #0a0e14;
  --panel: #0d131a;
  --panel-2: #121b24;
  --panel-3: #18232e;
  --line: rgba(150, 185, 205, .14);
  --line-strong: rgba(150, 185, 205, .30);

  /* tekst (kontrast > 4.5:1 na --panel) */
  --text: #eaf1f5;
  --muted: #9fb1bd;
  --dim: #6c7f8c;

  /* akcenty */
  --cyan: #3be4ff;
  --cyan-deep: #0aa6c4;
  --olive: #7d9b45;
  --lime: #b9f24b;
  --amber: #ffb83f;
  --red: #ff5b4f;

  /* tony przycisków ocen */
  --good-1: #9de34a; --good-2: #4f8f1f; --good-edge: #2c5410;
  --ok-1:   #ffc95a; --ok-2:   #d8871a; --ok-edge:   #7a4808;
  --bad-1:  #ff7a66; --bad-2:  #c62f25; --bad-edge:  #6d140f;
  --steel-1:#3a4a57; --steel-2:#24313b; --steel-edge:#111920;
  --send-1: #4cf0ff; --send-2: #0b9fbf; --send-edge: #05526a;
  --ready-1:#c4f75a; --ready-2:#4f9a1c; --ready-edge:#24500c; --ready-glow: rgba(157,227,74,.75);
  --sel-ring: #ffffff;
  --spark: #3be4ff;          /* kolor cząsteczek wybuchu */
  --need: #ff5b4f;           /* brakujące pole */
  --guide: rgba(59,228,255,.55); /* pulsowanie "następny krok" */
  --input-bg: #081118;
  --track-1: #071016; --track-2: #0c1820;
  --thumb-1: #2a3d4a; --thumb-2: #1a2832;

  /* skala */
  --r: clamp(12px, 1.4vw, 20px);
  --r-sm: clamp(8px, .9vw, 12px);
  --gap: clamp(8px, 1.2vw, 18px);
  --pad: clamp(10px, 1.4vw, 22px);
  --touch: clamp(64px, 9vh, 104px);   /* minimalna wysokość celu dotykowego: 64px */

  --font: "Bahnschrift", "DIN Alternate", "Barlow Semi Condensed", "Roboto Condensed",
          "Arial Narrow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "tnum" 1;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

/* ===== szkielet ekranu ===== */
.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--gap);
  padding: var(--pad);
  padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
}

/* ===== pasek górny ===== */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: var(--gap);
}
.brand { display: flex; align-items: center; gap: clamp(8px, 1vw, 14px); min-width: 0; }
.brand-mark {
  width: clamp(10px, 1vw, 14px);
  height: clamp(34px, 5vh, 52px);
  background: linear-gradient(var(--lime), var(--olive));
  clip-path: polygon(0 0, 100% 12%, 100% 88%, 0 100%);
  flex: none;
}
.brand-txt { min-width: 0; }
.brand-kicker {
  display: block;
  font-family: var(--mono);
  font-size: clamp(11px, 1.05vw, 14px);
  letter-spacing: .18em;
  color: var(--cyan);
  text-transform: uppercase;
}
.brand h1 {
  font-size: clamp(20px, 2.8vw, 40px);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* status karty */
.card-status {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1vw, 16px);
  min-height: clamp(56px, 8vh, 84px);
  padding: 0 clamp(14px, 1.6vw, 26px) 0 clamp(8px, .8vw, 12px);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(59,228,255,.10), rgba(59,228,255,.03));
  border: 1px solid rgba(59,228,255,.35);
  text-align: left;
}
.nfc-ring {
  display: grid; place-items: center;
  width: clamp(42px, 6vh, 64px); aspect-ratio: 1;
  border-radius: 50%;
  color: var(--cyan);
  background: radial-gradient(circle, rgba(59,228,255,.22), rgba(59,228,255,.04) 70%);
  border: 2px solid rgba(59,228,255,.55);
  flex: none;
}
.nfc-ring svg { width: 58%; height: 58%; }
.card-status-txt { display: grid; line-height: 1.1; }
.card-status-txt strong { font-size: clamp(15px, 1.7vw, 24px); letter-spacing: .06em; }
.card-status-txt small { font-size: clamp(11px, 1.05vw, 15px); color: var(--muted); }

.round-tools { display: flex; gap: clamp(6px, .8vw, 12px); }
.round-btn {
  width: clamp(48px, 6.4vh, 64px); aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: radial-gradient(circle at 35% 30%, var(--panel-3), var(--panel));
  border: 1px solid var(--line-strong);
  box-shadow: 0 4px 0 #04070a, 0 8px 18px rgba(0,0,0,.45);
  transition: transform .1s var(--ease-out), color .2s, box-shadow .1s;
}
.round-btn svg { width: 46%; height: 46%; }
.round-btn:hover { color: var(--text); }
.round-btn:active { transform: translateY(3px) scale(.96); box-shadow: 0 1px 0 #04070a, 0 3px 8px rgba(0,0,0,.4); }
.round-btn.is-on { color: var(--lime); border-color: rgba(185,242,75,.6); }

/* ===== karty posiłków ===== */
.meals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  min-height: 0;
}
.meal {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(64px, 1fr) auto auto;
  gap: clamp(5px, 1vh, 14px);
  min-height: 0;
  padding: var(--pad);
  border-radius: var(--r);
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 30%),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 20px 50px rgba(0,0,0,.45);
  overflow: hidden;
}
/* stałe rzędy — ukrycie podpowiedzi (.rate-label) na niskich ekranach nie przesuwa układu */
.meal > .meal-head { grid-row: 1; }
.meal > .rate-label { grid-row: 2; }
.meal > .rate { grid-row: 3; }
.meal > .tri[data-key="przyprawa"] { grid-row: 4; }
.meal > .tri[data-key="solonosc"] { grid-row: 5; }
.tri { align-content: start; }
.meal-head { display: flex; align-items: center; gap: clamp(10px, 1.2vw, 18px); min-height: 0; }
.meal-icon {
  width: clamp(54px, 9vh, 108px); aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,.55));
}
.meal-icon svg { width: 100%; height: 100%; display: block; }
.meal-title { min-width: 0; display: grid; gap: 4px; }
.meal-title h2 {
  font-size: clamp(22px, calc(1.6vw + 1.9vh), 50px);
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1;
  text-transform: uppercase;
}

/* gwiazdki */
.stars { display: flex; align-items: center; gap: clamp(6px, .8vw, 12px); }
.stars-row { display: flex; gap: clamp(2px, .3vw, 5px); }
.star { width: clamp(18px, 2.2vw, 30px); aspect-ratio: 1; display: block; }
.star-bg { fill: rgba(255,255,255,.08); stroke: color-mix(in srgb, var(--amber) 55%, transparent); }
.star-fg { fill: var(--amber); filter: drop-shadow(0 0 4px color-mix(in srgb, var(--amber) 60%, transparent)); }
.stars-num {
  font-family: var(--mono);
  font-size: clamp(14px, 1.6vw, 22px);
  font-weight: 700;
  color: var(--amber);
}

/* przyciski oceny */
.rate {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(6px, .8vw, 12px);
  min-height: 0;
}

/* przełącznik trzystanowy ("przesuwak") */
.tri { display: grid; grid-template-rows: auto auto; gap: clamp(3px, .6vh, 8px); min-height: 0; }
.tri-label {
  font-size: clamp(12px, calc(.7vw + .8vh), 20px);
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--muted);
  text-transform: uppercase;
}
.tri-track {
  --pos: 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: clamp(48px, 7.2vh, 88px);
  border-radius: var(--r-sm);
  background: linear-gradient(180deg, var(--track-1), var(--track-2));
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 3px 10px rgba(0,0,0,.65);
  touch-action: none;
  overflow: hidden;
}
.tri-thumb {
  position: absolute;
  top: 4px; bottom: 4px;
  left: calc(4px + var(--pos) * (100% - 8px) / 3);
  width: calc((100% - 8px) / 3);
  border-radius: calc(var(--r-sm) - 3px);
  background: linear-gradient(180deg, var(--thumb-1), var(--thumb-2));
  border: 1px solid rgba(59,228,255,.55);
  box-shadow: 0 4px 0 #050b10, 0 0 22px rgba(59,228,255,.28), inset 0 1px 0 rgba(255,255,255,.15);
  transition: left .28s var(--ease-spring), border-color .2s, box-shadow .2s;
  pointer-events: none;
}
.tri-track[data-pos="0"] .tri-thumb,
.tri-track[data-pos="2"] .tri-thumb {
  border-color: rgba(255,184,63,.75);
  box-shadow: 0 4px 0 #050b10, 0 0 24px rgba(255,184,63,.3), inset 0 1px 0 rgba(255,255,255,.15);
}
.tri-track button {
  position: relative;
  z-index: 1;
  font-size: clamp(12px, calc(.7vw + .75vh), 21px);
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--dim);
  transition: color .2s;
}
.tri-track button.on { color: var(--text); }
.tri-track[data-pos="0"] button.on,
.tri-track[data-pos="2"] button.on { color: var(--amber); }

/* ===== dok: komentarz | klasa | WYŚLIJ ===== */
.dock {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(200px, .8fr);
  gap: var(--gap);
  align-items: stretch;
}
.comment {
  display: grid;
  gap: clamp(4px, .6vh, 8px);
  padding: clamp(8px, 1vh, 14px) var(--pad);
  border-radius: var(--r);
  background: var(--panel);
  border: 1px solid var(--line);
}
.comment-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.comment-tools { display: flex; align-items: center; gap: 10px; }
.comment-head label {
  font-size: clamp(13px, 1.4vw, 19px);
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.counter { font-family: var(--mono); font-size: clamp(12px, 1.1vw, 15px); color: var(--dim); }
.counter.warn { color: var(--amber); }
.counter.full { color: var(--red); }
.comment-row { display: grid; }
.comment textarea {
  width: 100%;
  min-height: clamp(56px, 7.4vh, 80px);
  max-height: clamp(56px, 7.4vh, 80px);
  resize: none;
  padding: clamp(8px, 1vh, 12px) clamp(10px, 1vw, 14px);
  border-radius: var(--r-sm);
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--line-strong);
  font: inherit;
  font-size: clamp(15px, calc(.7vw + .9vh), 21px);
  line-height: 1.3;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color .2s, box-shadow .2s;
}
.comment textarea::placeholder { color: var(--dim); }
.comment textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(59,228,255,.18); }
.kb-toggle { --depth: 3px; display: flex; align-items: center; gap: 6px; min-height: 44px; height: 44px; align-self: center; padding: 0 12px; font-size: clamp(11px, 1vw, 14px); letter-spacing: .08em; }
.kb-toggle svg { width: clamp(18px, 1.6vw, 24px); height: auto; }

/* pasek akcji: na dużych ekranach nie istnieje w układzie (dzieci są w siatce .dock) */
.action-bar { display: contents; }

/* ===== WYBÓR KLASY ===== */
.klasa {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(4px, .6vh, 8px);
  padding: clamp(8px, 1vh, 14px) clamp(8px, 1vw, 14px);
  border-radius: var(--r);
  background: var(--panel);
  border: 1px solid var(--line);
  min-width: 0;
}
.klasa-label {
  font-size: clamp(13px, 1.4vw, 19px);
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.klasa-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(5px, .6vw, 10px); }
.klasa-btn {
  --depth: 5px;
  min-height: clamp(56px, 7.4vh, 84px);
  display: grid; place-content: center; justify-items: center;
  gap: 1px;
  padding: 0 2px;
  overflow: visible;           /* fala wybuchu wychodzi poza przycisk */
}
.klasa-btn b { font-size: clamp(22px, calc(1.2vw + 1.6vh), 40px); line-height: .95; font-weight: 900; position: relative; z-index: 2; }
.klasa-btn span { font-size: clamp(9px, calc(.45vw + .55vh), 13px); letter-spacing: .16em; opacity: .85; }
.klasa-row.has-choice .klasa-btn:not(.sel) { filter: saturate(.4) brightness(.6); }
.klasa-btn.sel {
  --c1: var(--send-1); --c2: var(--send-2); --edge: var(--send-edge); --ink: #02161d;
  transform: translateY(2px);
  box-shadow: 0 calc(var(--depth) - 2px) 0 var(--edge), 0 0 0 3px var(--sel-ring), 0 0 28px 2px color-mix(in srgb, var(--c1) 60%, transparent), inset 0 2px 0 rgba(255,255,255,.35);
}

/* ===== WYŚLIJ ===== */
.send-zone { position: relative; display: grid; min-width: 0; }
/* .send-bite niesie cień i zielony puls; sam przycisk dostaje maskę "nadgryzienia",
   więc wycięcie jest czyste, a krawędź 3D jest ramką dolną (ramka zostaje w obrębie maski) */
.send-bite { position: relative; display: grid; }
.send-bite::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  border-radius: var(--r-sm);
  box-shadow: 0 12px 22px rgba(0,0,0,.5);
}
.send {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  align-content: center;
  align-items: center;
  column-gap: 12px;
  row-gap: 3px;
  padding: 0 clamp(14px, 1.6vw, 26px);
  min-height: var(--touch);
  text-align: left;
}
.send-lock { grid-row: span 3; width: clamp(24px, 2.6vw, 36px); display: grid; }
.send-lock svg { width: 100%; height: auto; }
.send-txt { font-size: clamp(22px, 3vw, 44px); font-weight: 800; letter-spacing: .12em; line-height: 1; }
.send-hint { font-size: clamp(11px, 1vw, 14px); letter-spacing: .04em; opacity: .9; min-height: 1.2em; }
.send-progress { display: none; gap: 4px; position: relative; z-index: 2; }
.send-progress i { flex: 1; height: 5px; border-radius: 3px; background: rgba(255,255,255,.18); transition: background .3s, box-shadow .3s; }
.send-progress i.done { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.send:not(:disabled) .send-lock { display: none; }
.send:not(:disabled) { grid-template-columns: 1fr; text-align: center; }
.send:not(:disabled) .send-progress { display: flex; }
/* gotowy do wysłania */
.send-zone.ready .send { --c1: var(--ready-1); --c2: var(--ready-2); --edge: var(--ready-edge); --ink: #0c1a03; }
.send-zone.ready .send-progress { display: none; }
.send-zone .send {
  z-index: 1;
  border-bottom: var(--depth) solid var(--edge);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.28), inset 0 -3px 0 rgba(0,0,0,.18);
}
.send-zone .send:active:not(:disabled), .send-zone .send.pressed:not(:disabled) {
  transform: translateY(3px) scale(.99);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.2), inset 0 0 26px rgba(255,255,255,.3);
}
.send-zone .send:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--cyan), inset 0 2px 0 rgba(255,255,255,.28); }
.send-zone .send:disabled { border-bottom-color: #0a0f13; }

/* ===== kroki: "następny krok" i brakujące pola ===== */
.step { position: relative; border-radius: var(--r-sm); }
.need-msg {
  position: absolute; left: 50%; top: 0; z-index: 5;
  transform: translate(-50%, -60%);
  padding: 3px 10px; border-radius: 6px;
  font-size: clamp(11px, 1vw, 14px); font-weight: 800; letter-spacing: .08em; white-space: nowrap;
  color: #fff; background: var(--need);
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
  pointer-events: none;
}

/* warstwa efektów */
.fx { position: fixed; inset: 0; z-index: 58; pointer-events: none; overflow: hidden; }
.fx .p { position: absolute; left: 0; top: 0; width: 7px; height: 7px; border-radius: 2px; background: var(--spark); box-shadow: 0 0 10px var(--spark); }
.fx .ring { position: absolute; left: 0; top: 0; border-radius: 14px; border: 3px solid var(--spark); box-shadow: 0 0 22px var(--spark), inset 0 0 18px var(--spark); }
.fx .crumb { position: absolute; left: 0; top: 0; width: 6px; height: 5px; border-radius: 1px 3px 2px 3px; background: var(--ready-1); }

/* ===== status czytnika ===== */
.reader-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font-family: var(--mono); font-size: clamp(10px, .9vw, 12px); letter-spacing: .14em;
  color: var(--muted); border: 1px solid var(--line-strong); background: var(--panel);
  white-space: nowrap;
}
.reader-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.reader-chip[data-state="ok"] { color: var(--lime); border-color: color-mix(in srgb, var(--lime) 45%, transparent); }
.reader-chip[data-state="ok"] i { background: var(--lime); }
.reader-chip[data-state="error"] { color: var(--red); border-color: color-mix(in srgb, var(--red) 55%, transparent); }
.reader-chip[data-state="error"] i { background: var(--red); }

.brand-desc { font-size: clamp(12px, 1.1vw, 16px); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.rate-label { font-size: clamp(13px, calc(.6vw + .9vh), 20px); font-weight: 700; color: var(--text); opacity: .9; letter-spacing: .02em; }

/* ===== przycisk 3D (wspólny) ===== */
.btn3d {
  --c1: var(--steel-1); --c2: var(--steel-2); --edge: var(--steel-edge); --ink: var(--text);
  --depth: clamp(5px, .8vh, 8px);
  position: relative;
  isolation: isolate;
  min-height: 64px;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(14px, calc(.85vw + .95vh), 28px);
  letter-spacing: .02em;
  line-height: 1.1;
  background: linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow:
    0 var(--depth) 0 var(--edge),
    0 calc(var(--depth) + 8px) 20px rgba(0,0,0,.5),
    inset 0 2px 0 rgba(255,255,255,.28),
    inset 0 -3px 0 rgba(0,0,0,.18);
  transform: translateY(0);
  transition: transform .09s var(--ease-out), box-shadow .09s var(--ease-out), filter .2s, opacity .2s;
  overflow: hidden;
}
.btn3d > span { position: relative; z-index: 2; }
.btn3d:hover:not(:disabled) { filter: brightness(1.08); }
.btn3d:active:not(:disabled), .btn3d.pressed:not(:disabled) {
  transform: translateY(calc(var(--depth) - 1px)) scale(.985);
  box-shadow:
    0 1px 0 var(--edge),
    0 4px 10px rgba(0,0,0,.45),
    inset 0 2px 0 rgba(255,255,255,.2),
    inset 0 0 24px rgba(255,255,255,.25);
  filter: brightness(1.2);
}
.btn3d:disabled {
  --c1: #1f2a33; --c2: #151d24; --edge: #0a0f13; --ink: var(--muted);
  border: 1px dashed rgba(159,177,189,.35);
}

.tone-good  { --c1: var(--good-1);  --c2: var(--good-2);  --edge: var(--good-edge); --ink: #0b1504; }
.tone-ok    { --c1: var(--ok-1);    --c2: var(--ok-2);    --edge: var(--ok-edge);   --ink: #1e1102; }
.tone-bad   { --c1: var(--bad-1);   --c2: var(--bad-2);   --edge: var(--bad-edge);  --ink: #fff; }
.tone-steel { --c1: var(--steel-1); --c2: var(--steel-2); --edge: var(--steel-edge); --ink: var(--text); }
.tone-send  { --c1: var(--send-1);  --c2: var(--send-2);  --edge: var(--send-edge); --ink: #02161d; }

/* wybór oceny: pozostałe przygasają */
.rate.has-choice .btn3d:not(.sel) { filter: saturate(.35) brightness(.55); }
.rate .btn3d.sel {
  transform: translateY(2px);
  box-shadow:
    0 calc(var(--depth) - 2px) 0 var(--edge),
    0 0 0 3px var(--sel-ring),
    0 0 34px 4px color-mix(in srgb, var(--c1) 70%, transparent),
    inset 0 2px 0 rgba(255,255,255,.35);
}

/* ===== klawiatura ekranowa ===== */
.keyboard {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 60dvh;
  z-index: 40;
  padding: var(--pad);
  padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #0f1820, #070b10);
  border-top: 1px solid rgba(59,228,255,.45);
  box-shadow: 0 -20px 60px rgba(0,0,0,.6), 0 -1px 24px rgba(59,228,255,.15);
  transform: translateY(105%);
  transition: transform .38s var(--ease-out);
}
.keyboard.show { transform: translateY(0); }
.kb-rows { height: 100%; display: grid; grid-template-rows: repeat(5, 1fr); gap: clamp(6px, .9vh, 12px); }
.kb-row { display: flex; gap: clamp(5px, .7vw, 10px); justify-content: center; min-height: 0; }
.kb-row .btn3d { flex: 1; min-height: 0; font-size: clamp(16px, 2.4vw, 32px); padding: 0; }
.kb-row .w15 { flex: 1.5; } .kb-row .w2 { flex: 2; } .kb-row .w5 { flex: 5; }
.kb-row .small { font-size: clamp(12px, 1.5vw, 20px); letter-spacing: .08em; }
.kb-row .btn3d.lit { --c1: #4b6576; --c2: #2c3e4a; }

/* tryb pisania: wstęga COMMENTS nad klawiaturą (css/cinematic.css → WSTĘGA) */

/* klawiatura w pionie i na telefonie: klawisze KWADRATOWE.
   Rozmiar klawisza = mniejsza z wartości: 1/10 szerokości ekranu albo 1/4 dostępnej wysokości. */
@media (max-aspect-ratio: 1/1), (max-width: 900px), (max-height: 520px) {
  .keyboard {
    --kgap: clamp(4px, 1.2vw, 9px);
    --key: min(calc((100vw - 2 * var(--pad) - 9 * var(--kgap)) / 10), calc((58dvh - 2 * var(--pad) - 3 * var(--kgap)) / 4));
    height: auto;
  }
  .kb-rows {
    height: auto;
    grid-template-rows: none !important;
    grid-auto-rows: var(--key);
    gap: var(--kgap);
    max-width: calc(10 * var(--key) + 9 * var(--kgap));
    margin: 0 auto;
  }
  .kb-row { gap: var(--kgap); }
  .kb-row .btn3d { flex: 0 0 var(--key); width: var(--key); height: var(--key); font-size: calc(var(--key) * .44); --depth: clamp(3px, calc(var(--key) * .08), 6px); }
  .kb-row .btn3d.w15 { flex: 1 1 calc(var(--key) * 1.5); width: auto; }
  .kb-row .btn3d.w2  { flex: 1 1 calc(var(--key) * 2);   width: auto; }
  .kb-row .btn3d.w5  { flex: 1 1 calc(var(--key) * 5);   width: auto; }
  .kb-row .small { font-size: clamp(10px, calc(var(--key) * .24), 18px); letter-spacing: .04em; }
}

/* ===== komunikaty ===== */
.toast, .alert {
  position: fixed;
  left: 50%; top: 50%;
  z-index: 60;
  transform: translate(-50%, -50%) scale(.85);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  border-radius: var(--r);
  transition: opacity .25s, transform .4s var(--ease-spring);
}
.toast {
  display: grid; justify-items: center; gap: clamp(10px, 2vh, 22px);
  padding: clamp(24px, 5vh, 56px) clamp(32px, 6vw, 90px);
  background: radial-gradient(ellipse at 50% 0%, rgba(185,242,75,.22), transparent 70%), #0b141a;
  border: 2px solid var(--lime);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 80px rgba(185,242,75,.35), 0 30px 80px rgba(0,0,0,.6);
}
.toast-ring { width: clamp(56px, 9vh, 96px); color: var(--lime); }
.toast-ring svg { width: 100%; height: auto; }
.toast p { font-size: clamp(26px, 4.4vw, 64px); font-weight: 800; letter-spacing: .02em; }
.alert {
  padding: clamp(18px, 3vh, 34px) clamp(26px, 4vw, 56px);
  background: #1a0d0c;
  border: 2px solid var(--red);
  box-shadow: 0 0 60px rgba(255,91,79,.35);
  max-width: min(90vw, 760px);
}
.alert p { font-size: clamp(18px, 2.6vw, 34px); font-weight: 700; }
.alert.info { background: #0b151b; border-color: var(--cyan); box-shadow: 0 0 60px rgba(59,228,255,.3); }
.toast.show, .alert.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.demo-ribbon {
  position: fixed; left: 50%; bottom: 0; z-index: 30;
  transform: translate(-50%, 100%);
  padding: 4px 18px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .14em;
  color: #1a2405; background: var(--lime);
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform .3s var(--ease-out);
}
/* tryb testowy (panel → Karty i głosowanie → wiele głosów z jednej karty) */
.test-ribbon {
  position: fixed; top: 0; left: 50%; z-index: 30; transform: translate(-50%, -100%);
  padding: 2px 14px 3px; border-radius: 0 0 8px 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; white-space: nowrap;
  color: #1d1500; background: var(--amber); opacity: .92;
  transition: transform .3s var(--ease-out); pointer-events: none;
  max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
body.multi-vote .test-ribbon { transform: translate(-50%, 0); }
body.kb-open .test-ribbon { display: none; }
body.demo .demo-ribbon { transform: translate(-50%, 0); }

/* ===== responsywność ===== */
/* pion / wąsko: karty jedna nad drugą, dok w trzech rzędach */
@media (max-aspect-ratio: 1/1), (max-width: 760px) {
  .meals { grid-template-columns: 1fr; }
  .meal-icon { width: clamp(46px, 6vh, 84px); }
  .tri-track { min-height: clamp(44px, 5vh, 72px); }
  .dock { grid-template-columns: 1fr; gap: clamp(8px, 1vh, 14px); }
  .klasa { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto; align-items: center; column-gap: 12px; }
  .klasa-btn { min-height: clamp(56px, 6vh, 76px); }
  .send { min-height: clamp(64px, 7.5vh, 96px); }
  .brand-desc { display: none; }
}
/* tablet w pionie (szerszy niż telefon): komentarz | klasa obok siebie, WYŚLIJ pod spodem */
@media (max-aspect-ratio: 1/1) and (min-width: 561px) {
  .dock { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .send-zone { grid-column: 1 / -1; }
  .klasa { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .comment textarea { min-height: 0; max-height: none; height: 100%; }
  .comment { grid-template-rows: auto minmax(0, 1fr); }
  .comment-row { min-height: 56px; }
  .brand h1 { white-space: normal; line-height: 1.08; font-size: clamp(18px, 2.8vw, 34px); }
  .tri-track { min-height: clamp(42px, 4.4vh, 64px); }
  .meal { grid-template-rows: auto auto minmax(60px, 1fr) auto auto; }
}
/* laptop / tablet poziomo przy węższym ekranie: klasa i WYŚLIJ obok siebie pod komentarzem */
@media (min-aspect-ratio: 1/1) and (max-width: 1100px) {
  .dock { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .comment { grid-column: 1 / -1; }
  .meal { grid-template-rows: auto auto minmax(56px, 1fr) auto auto; }
}
/* niski ekran poziomo (laptop, telefon poziomo) */
@media (max-height: 760px) and (min-aspect-ratio: 1/1) {
  .brand-desc { display: none; }
  .rate-label { display: none; }
}
@media (max-height: 560px) and (min-aspect-ratio: 1/1) {
  .meal-icon { width: 44px; }
  .meal-title h2 { font-size: 20px; }
  .tri-label { font-size: 11px; }
  .card-status-txt small { display: none; }
}
/* bardzo niski ekran (telefon poziomo): przewijanie zamiast ucinania */
@media (max-height: 520px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .meals { min-height: 0; }
  .meal { grid-template-rows: auto auto 76px auto auto; }
}
/* telefon w pionie: pasek górny w dwóch rzędach, przewijanie zamiast ucinania */
@media (max-width: 560px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto; }
  .meal { gap: 6px; padding: 10px; grid-template-rows: auto auto 64px auto auto; }
  .meal-icon { width: 46px; }
  .rate-label { font-size: 13px; }
  .tri { grid-template-columns: 30% 1fr; grid-template-rows: auto; align-items: center; gap: 8px; }
  .tri-label { font-size: 11px; letter-spacing: .06em; }
  .tri-track { min-height: 46px; }
  .tri-track button { font-size: 11px; }
  .clock-day { display: none; }
  .topbar { grid-template-columns: 1fr auto; }
  .reader-chip { display: none; }
  .card-status { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .brand h1 { font-size: 18px; }
  .rate .btn3d { font-size: 13px; }
  .kb-toggle span { display: none; }
  .kb-toggle { width: 52px; justify-content: center; padding: 0; }
  .brand h1 { white-space: normal; letter-spacing: 0; line-height: 1.1; }
  .klasa { grid-template-columns: 1fr; }
  .klasa-btn { min-height: 58px; }
  .dock { padding-bottom: 6px; }
  body.demo .app { padding-bottom: 40px; }
}
@media (max-width: 900px) { .reader-chip span { display: none; } .reader-chip { padding: 8px; } }

/* ===== niski tablet poziomo (np. 1024×600): komentarz | klasa | WYŚLIJ w jednym rzędzie ===== */
@media (min-aspect-ratio: 1/1) and (max-height: 700px) and (min-height: 521px) {
  .dock { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(170px, .75fr); }
  .comment { grid-column: auto; padding: 8px 12px; gap: 4px; }
  .comment textarea { min-height: 44px; max-height: 44px; font-size: 15px; padding: 8px 10px; }
  .kb-toggle span { display: none; }
  .kb-toggle { width: 52px; padding: 0; justify-content: center; }
  .klasa { padding: 8px 10px; }
  .klasa-btn { min-height: 50px; }
  .send { min-height: 64px; }
  .send-txt { font-size: 26px; }
  .app { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .meal { gap: 5px; padding: 10px 12px; grid-template-rows: auto auto minmax(52px, 1fr) auto auto; }
  .meal-icon { width: 42px; }
  .meal-title h2 { font-size: 22px; }
  .tri { gap: 2px; }
  .tri-label { font-size: 11px; }
  .tri-track { min-height: 40px; }
  .tri-track button { font-size: 12px; }
  .card-status { min-height: 52px; }
  .nfc-ring { width: 40px; }
}

/* ===== telefon: klasa + WYŚLIJ w pasku przyklejonym do dołu ekranu ===== */
@media (max-width: 560px) {
  .action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    display: grid; gap: 8px;
    padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 88%, transparent), var(--panel));
    border-top: 1px solid var(--line-strong);
    box-shadow: 0 -14px 34px rgba(0,0,0,.55);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  }
  .action-bar .klasa {
    grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto; align-items: center; column-gap: 10px;
    padding: 0; background: none; border: 0; box-shadow: none;
  }
  .action-bar .klasa-label { font-size: 12px; letter-spacing: .08em; max-width: 5.5em; line-height: 1.15; }
  .action-bar .klasa-btn { min-height: 50px; }
  .action-bar .klasa-btn b { font-size: 22px; }
  .action-bar .klasa-btn span { font-size: 9px; }
  .action-bar .send { min-height: 56px; }
  .action-bar .send-txt { font-size: 24px; }
  /* animacja wejścia z transform tworzy kontekst dla position:fixed — na telefonie ją wyłączamy */
  .app .dock { animation: none; }
  .app { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }
  body.demo .app { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }
  body.demo .action-bar { padding-bottom: calc(34px + env(safe-area-inset-bottom)); }
  body.kb-open .action-bar { display: none; }
}
/* telefon poziomo: klasa i WYŚLIJ w jednym rzędzie na dole */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; align-items: center;
    padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: var(--panel); border-top: 1px solid var(--line-strong); box-shadow: 0 -14px 34px rgba(0,0,0,.55);
  }
  .action-bar .klasa { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto; align-items: center; column-gap: 10px; padding: 0; background: none; border: 0; box-shadow: none; }
  .action-bar .klasa-label { font-size: 12px; max-width: 5.5em; line-height: 1.15; }
  .action-bar .klasa-btn { min-height: 48px; }
  .action-bar .send { min-height: 52px; }
  .action-bar .send-txt { font-size: 22px; }
  .action-bar .send-zone { grid-column: auto; }
  .app .dock { animation: none; }
  .app { padding-bottom: 84px; }
  body.kb-open .action-bar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* czytnik niepodłączony / błąd: sama kropka bez napisu (aplikacja działa głównie na telefonach bez czytnika); opis w podpowiedzi */
.reader-chip:not([data-state="ok"]) { padding: 8px; background: none; border-color: transparent; box-shadow: none; }
.reader-chip:not([data-state="ok"]) span { display: none; }
.reader-chip[data-state="error"] i { width: 12px; height: 12px; box-shadow: 0 0 10px color-mix(in srgb, var(--red) 70%, transparent); }
