/* ==========================================================================
   Spojrzenie – wspólny system wyglądu
   --u  : jednostka wielkości (ustawiana przez każde okno)
   --fs : skala napisów (ustawienie użytkownika)
   ========================================================================== */
:root {
  --u: 1vh;
  --fs: 1;
  --radius: calc(var(--u) * 1.9);
  --gap: calc(var(--u) * 0.9);
  --font: "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Motywy ---------- */
body, body.theme-dark {
  --bg: #0a0f17;
  --bg-2: #0e1520;
  --surface: #131b28;
  --key: #1a2333;
  --key-2: #202b3e;
  --key-hover: #25324a;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef2fa;
  --muted: #8794ad;
  --faint: #5d6a83;
  --accent: #5b8cff;
  --accent-strong: #3f73f0;
  --accent-soft: rgba(91, 140, 255, 0.16);
  --fill: linear-gradient(0deg, rgba(91, 140, 255, 0.62), rgba(91, 140, 255, 0.34));
  --ok: #2fd4a3;
  --ok-strong: #17a982;
  --warn: #ffb547;
  --danger: #ff5f6d;
  --danger-strong: #e23c4c;
  --gaze: #ffc400;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.045) inset, 0 2px 6px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}
body.theme-light {
  --bg: #e9edf4;
  --bg-2: #f1f4f9;
  --surface: #f7f9fc;
  --key: #ffffff;
  --key-2: #f4f7fc;
  --key-hover: #eaf1ff;
  --border: rgba(20, 30, 60, 0.10);
  --border-strong: rgba(20, 30, 60, 0.2);
  --text: #111a2b;
  --muted: #56627a;
  --faint: #8a95aa;
  --accent: #2f6fe8;
  --accent-strong: #1f5bd0;
  --accent-soft: rgba(47, 111, 232, 0.12);
  --fill: linear-gradient(0deg, rgba(47, 111, 232, 0.42), rgba(47, 111, 232, 0.2));
  --ok: #0f9e78;
  --ok-strong: #0b8463;
  --warn: #b86e00;
  --danger: #d6293b;
  --danger-strong: #b81d2e;
  --gaze: #e09b00;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08), 0 2px 8px rgba(20, 30, 60, 0.06);
  color-scheme: light;
}
/* Wysoki kontrast – dla słabszego wzroku */
body.theme-contrast {
  --bg: #000;
  --bg-2: #000;
  --surface: #000;
  --key: #000;
  --key-2: #0a0a0a;
  --key-hover: #1a1a00;
  --border: #9a9a9a;
  --border-strong: #fff;
  --text: #fff;
  --muted: #e6e6e6;
  --faint: #bdbdbd;
  --accent: #ffd400;
  --accent-strong: #ffd400;
  --accent-soft: rgba(255, 212, 0, 0.2);
  --fill: linear-gradient(0deg, rgba(255, 212, 0, 0.75), rgba(255, 212, 0, 0.45));
  --ok: #00ff9c;
  --ok-strong: #00c97b;
  --warn: #ffb000;
  --danger: #ff4d4d;
  --danger-strong: #ff2b2b;
  --gaze: #00e5ff;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font); user-select: none; cursor: default;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* ---------- Ikony ---------- */
svg.i { width: 1em; height: 1em; display: block; flex: none; }

/* ---------- Klawisz ---------- */
.key {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--key); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 0.5);
  text-align: center; min-width: 0; min-height: 0;
  padding: calc(var(--u) * 0.5) calc(var(--u) * 0.8);
  font-size: calc(var(--u) * 4.4 * var(--fs)); font-weight: 600; line-height: 1.08; letter-spacing: -0.005em;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .16s var(--ease), box-shadow .16s var(--ease), color .16s;
  --p: 0;
}
/* wypełnianie się pod wzrokiem */
.key::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--fill);
  transform-origin: bottom; transform: scaleY(var(--p));
  border-radius: inherit;
}
.key > * { pointer-events: none; }
.key .ico { font-size: 1.25em; line-height: 0; opacity: .95; }
.key .lbl { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key .sub { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: max(0.6em, calc(var(--u) * 2.5)); font-weight: 500; color: var(--muted); }
.key.wrap .lbl { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; line-height: 1.15; }
.key.row { flex-direction: row; gap: calc(var(--u) * 1); }
.key.row .ico { font-size: 1.15em; }
.key.left { align-items: flex-start; text-align: left; padding-left: calc(var(--u) * 2); }

/* rozmiary */
.key.xl { font-size: calc(var(--u) * 7.2 * var(--fs)); font-weight: 500; }
.key.lg { font-size: calc(var(--u) * 5.4 * var(--fs)); }
.key.sm { font-size: calc(var(--u) * 3.6 * var(--fs)); }
.key.xs { font-size: calc(var(--u) * 3.0 * var(--fs)); }

/* stany */
.key.hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 calc(var(--u) * 0.35) var(--accent-soft), inset 0 0 0 1px var(--accent);
  background: var(--key-hover);
}
.key.fired { transform: scale(0.965); background: var(--accent); color: #fff; border-color: var(--accent); }
body.theme-contrast .key.fired { color: #000; }
.key.on { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.key.on .sub { color: rgba(255, 255, 255, .82); }
body.theme-contrast .key.on { color: #000; }
body.theme-contrast .key.on .sub { color: #000; }
body.theme-contrast .key.primary, body.theme-contrast .key.success { color: #000; }
body.theme-contrast .key.primary .sub, body.theme-contrast .key.success .sub { color: #000; }
body.theme-contrast .key.hover { background: #222200; }
.key.primary { background: var(--accent-strong); border-color: transparent; color: #fff; }
.key.primary .sub { color: rgba(255, 255, 255, .82); }
.key.success { background: var(--ok-strong); border-color: transparent; color: #fff; }
.key.success .sub { color: rgba(255, 255, 255, .85); }
.key.danger { background: var(--danger-strong); border-color: transparent; color: #fff; }
.key.danger .sub { color: rgba(255, 255, 255, .85); }
.key.soft { background: var(--key-2); }
.key.ghost { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); box-shadow: none; font-weight: 500; }
.key.info { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); font-weight: 500; }
.key.disabled { opacity: .32; }
.key.value { background: var(--surface); border-style: dashed; box-shadow: none; }
.key.marked { outline: calc(var(--u) * 0.35) dashed var(--danger); outline-offset: calc(var(--u) * -0.6); }
.key .badge {
  position: absolute; top: calc(var(--u) * 0.7); right: calc(var(--u) * 0.7); font-size: .5em;
  background: var(--danger); color: #fff; border-radius: 999px; padding: .15em .55em; font-weight: 700;
}

/* ---------- Kropka wzroku ---------- */
.gaze-dot {
  position: fixed; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 3px solid var(--gaze); background: color-mix(in srgb, var(--gaze) 22%, transparent);
  pointer-events: none; z-index: 1000; display: none;
}
body.showdot .gaze-dot.visible { display: block; }

/* ---------- Komunikat ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--u) * 2); transform: translateX(-50%); z-index: 900;
  background: var(--text); color: var(--bg); padding: calc(var(--u) * 1.2) calc(var(--u) * 3);
  border-radius: 999px; font-size: calc(var(--u) * 3.4); font-weight: 600;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35); white-space: nowrap;
  animation: toastIn .25s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
