@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg-1: #EDE9DE;
  --bg-2: #F6F3EA;
  --surface: #FFFFFF;
  --ink: #2B2A25;
  --ink-soft: #6B6A63;
  --accent: #2B303A;
  --glow: #E8A33D;
  --success: #4B7A57;
  --error: #B5533C;
  --border: rgba(43,42,37,0.10);
  --shadow: rgba(43,42,37,0.12);
  transition: background 0.6s ease;
}

[data-theme="night"] {
  --bg-1: #16223D;
  --bg-2: #223256;
  --surface: #223055;
  --ink: #F4EFE4;
  --ink-soft: #B9C0D6;
  --accent: #F0A94E;
  --glow: #F0A94E;
  --success: #7CAE8A;
  --error: #E08468;
  --border: rgba(244,239,228,0.12);
  --shadow: rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  overflow-x: hidden;
}

.phone {
  width: 380px;
  max-width: 100vw;
  min-height: 100vh;
  background: transparent;
  padding: 28px 24px 32px;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* Duży, bardzo delikatny znak marki wyśrodkowany za całym interfejsem —
   niezależny od .phone, żeby zostawał wyśrodkowany względem całego okna
   (telefon i laptop/desktop), nie tylko wąskiej kolumny aplikacji. */
.brand-watermark {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.brand-watermark img {
  width: min(60vmin, 560px);
  height: auto;
  opacity: 0.05;
}
[data-theme="night"] .brand-watermark img {
  opacity: 0.08;
  filter: invert(1);
}

.ambient-dot {
  position: fixed;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--glow);
  opacity: 0;
  transition: opacity 0.8s ease;
  box-shadow: 0 0 6px 1px var(--glow);
}
[data-theme="night"] .ambient-dot { opacity: 0.55; }
.d1 { top: 14%; left: 12%; }
.d2 { top: 22%; left: 82%; }
.d3 { top: 68%; left: 88%; }
.d4 { top: 78%; left: 8%; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 2;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  box-shadow: 0 2px 8px var(--shadow);
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent);
  transition: background 0.3s ease;
}
.dot.offline {
  background: var(--error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 25%, transparent);
}
.dot.connecting {
  background: var(--ink-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink-soft) 25%, transparent);
}

.theme-toggle {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  font-size: 18px;
  user-select: none;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 2;
  text-align: center;
}

.gate-wrap {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.gate-wrap.disabled { opacity: 0.4; pointer-events: none; }

.roofline {
  width: 210px;
  height: 6px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  margin: 0 auto 14px;
  opacity: 0.85;
}

svg.gate { display: block; }

.panel {
  transition: transform 0.55s cubic-bezier(.2,.9,.3,1.2);
  transform-origin: center;
}
.gate-wrap.open .panel-left { transform: translateX(-38px) rotateY(18deg); }
.gate-wrap.open .panel-right { transform: translateX(38px) rotateY(-18deg); }

.frame-glow {
  opacity: 0;
  transition: opacity 0.55s ease;
}
.gate-wrap.open .frame-glow { opacity: 1; }

.label {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-align: center;
}

.hint {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 6px;
}

.feedback {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: center;
  min-height: 18px;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.feedback.show { opacity: 1; }
.feedback.ok { color: var(--success); }
.feedback.err { color: var(--error); }

.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding-top: 18px;
  z-index: 2;
}

.key-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
  transition: background 0.2s ease;
}
.key-link:hover { background: var(--border); }

.brand-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 0 4px;
  z-index: 2;
  opacity: 0.5;
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand-icon { height: 15px; width: auto; display: block; }
.brand-wordmark { height: 10px; width: auto; display: block; }

/* Znaczki są czarne na przezroczystym tle — w trybie nocnym po prostu odwracamy jasność. */
[data-theme="night"] .brand-icon,
[data-theme="night"] .brand-wordmark {
  filter: invert(1);
}

.copyright {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.primary-btn {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: var(--bg-2);
}
[data-theme="night"] .primary-btn {
  color: var(--bg-1);
}

.key-box {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  word-break: break-all;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
  color: var(--ink);
}

/* bottom sheets */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 10;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 380px;
  max-width: 92vw;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 22px 22px 28px;
  transition: transform 0.4s cubic-bezier(.2,.9,.3,1.1);
  z-index: 11;
  box-shadow: 0 -10px 30px var(--shadow);
  max-height: 80vh;
  overflow-y: auto;
}
.sheet.show { transform: translate(-50%, 0); }

.sheet h3 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 19px;
  margin: 0 0 4px;
}
.sheet p.sub { color: var(--ink-soft); font-size: 12.5px; margin: 0 0 16px; }

.user-list { margin-bottom: 18px; }

.user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.user-row:last-of-type { border-bottom: none; }
.user-meta { display: flex; flex-direction: column; gap: 2px; }
.user-key { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-soft); }
.remove-btn {
  font-size: 12px; color: var(--error); background: none; border: none; cursor: pointer;
  font-family: 'Inter', sans-serif; font-weight: 500;
}

.add-user-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.add-user-form input {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--ink);
}
.add-user-form input::placeholder { color: var(--ink-soft); }

.sheet-close {
  display: block;
  margin: 18px auto 0;
  font-size: 13px;
  color: var(--ink-soft);
  background: none; border: none; cursor: pointer;
}
