/* =====================================================================
   SECRET SANTA — style (mobile-first)
   Grafiki z Nano Banana Pro dojdą w etapie 5; do tego czasu tło i ozdoby
   są zrobione samym CSS.
   ===================================================================== */

:root {
  --pine-950: #0b2118;
  --pine-900: #10301f;
  --pine-700: #1d4a35;
  --pine-100: #e3efe7;
  --cream: #fbf6ec;
  --paper: #ffffff;
  --red: #b3261e;
  --red-dark: #8c1c16;
  --gold: #c9a14a;
  --ink: #1e2a24;
  --muted: #5c6b63;
  --line: #e4dccb;
  --danger-bg: #fdecea;
  --danger-ink: #8c1c16;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Josefin Sans", "Figtree", system-ui, sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--pine-950);
  /* delikatny "śnieg" + zielony gradient */
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.16) 0 2px, transparent 3px),
    radial-gradient(circle at 78% 9%, rgba(255, 255, 255, 0.12) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 42% 62%, rgba(255, 255, 255, 0.1) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 74%, rgba(255, 255, 255, 0.14) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 24% 88%, rgba(255, 255, 255, 0.1) 0 1.5px, transparent 2.5px),
    radial-gradient(ellipse at 50% -10%, var(--pine-700) 0%, var(--pine-900) 45%, var(--pine-950) 100%);
  background-size: 340px 340px, 280px 280px, 420px 420px, 300px 300px, 380px 380px, 100% 100%;
  background-attachment: fixed;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0;
}

p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

/* --- Stan ładowania: nic nie pokazujemy, dopóki nie sprawdzimy logowania --- */
body.is-loading > *:not(.loader) {
  visibility: hidden;
}

.loader {
  display: none;
  position: fixed;
  inset: 0;
  place-items: center;
}

body.is-loading .loader {
  display: grid;
}

.loader::after {
  content: "";
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fatal {
  margin: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-weight: 600;
}

/* --- Przyciski ------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--red-dark);
}

.btn-ghost {
  min-height: 44px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-block {
  width: 100%;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* --- Pola formularza ------------------------------------------------- */
.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 0.9rem;
  font-weight: 600;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font: inherit; /* 16px — iPhone nie powiększa strony przy wpisywaniu */
}

.input:focus {
  outline: none;
  border-color: var(--pine-700);
  box-shadow: 0 0 0 3px rgba(29, 74, 53, 0.18);
}

.input-group {
  position: relative;
}

.input-group .input {
  padding-right: 84px;
}

.input-addon {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  min-width: 72px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pine-700);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 0.95rem;
  font-weight: 500;
}

/* --- Ekran logowania ------------------------------------------------- */
.login-page {
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 22px 26px;
  border-radius: var(--radius);
  background: var(--cream);
  box-shadow: var(--shadow);
  border-top: 6px solid var(--red);
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 26px;
  text-align: center;
}

.brand-mark {
  width: 64px;
  height: 64px;
}

.login-brand h1 {
  font-size: 1.9rem;
  color: var(--pine-900);
}

.login-brand p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-hint {
  margin-top: 18px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}

/* --- Panele (uczestnik / admin) -------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 33, 24, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-brand .brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-user {
  display: block;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: grid;
  gap: 16px;
}

.page-narrow {
  max-width: 720px;
}

.card {
  padding: 20px 18px;
  border-radius: var(--radius);
  background: var(--cream);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card h2 {
  font-size: 1.35rem;
  color: var(--pine-900);
  margin-bottom: 8px;
}

.card p + p {
  margin-top: 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

a {
  color: var(--pine-700);
  font-weight: 500;
}

/* --- Dodatkowe przyciski --------------------------------------------- */
.btn-secondary {
  background: transparent;
  color: var(--pine-900);
  border: 1.5px solid var(--line);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(16, 48, 31, 0.06);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-dark);
}

.btn-link {
  min-height: 44px;
  padding: 8px 10px;
  margin: 0 0 0 -10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pine-700);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-link:hover {
  background: rgba(16, 48, 31, 0.07);
}

.btn-link-danger {
  color: var(--red);
  margin-left: 0;
}

/* --- Panel uczestnika: powitanie, odliczanie, budżet ----------------- */
.hero {
  color: #fff;
}

.hero h1 {
  font-size: 1.7rem;
  margin-bottom: 14px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stat {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.stat-label {
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.75);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.25;
  color: #f3dfa9;
}

.stat-sub {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
}

/* --- Lista prezentów ------------------------------------------------- */
.gift-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.gift {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.gift-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--pine-700);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.gift-body {
  flex: 1;
  min-width: 0;
}

.gift-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-top: 3px;
}

/* Pasek akcji prezentu: oddzielony linią, niżej i po prawej —
   żeby nie kliknąć "Edytuj" / "Usuń" przypadkiem przy czytaniu lub klikaniu linku */
.gift-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 14px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.gift-actions .btn-link {
  margin: 0;
}

.gift-actions .btn-link:last-child {
  margin-right: -10px;
}

.gift-empty {
  padding: 18px 14px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--muted);
}

.gift-form {
  display: grid;
  gap: 8px;
}

#gift-editor-slot .gift-form {
  margin-top: 10px;
  padding: 14px;
  border: 1.5px solid var(--pine-700);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.gift-form label {
  font-size: 0.9rem;
  font-weight: 600;
}

.gift-form textarea {
  resize: vertical;
  min-height: 128px; /* mieści całą podpowiedź także na wąskim telefonie */
}

.gift-form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gift-form-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Mniejsze przyciski w formularzu edycji prezentu
   oraz w oknach (edycja uczestnika, nowe hasło, potwierdzenia) */
.gift-form-buttons .btn,
.dialog-actions .btn {
  min-height: 38px;
  padding: 7px 14px;
  gap: 6px;
  font-size: 0.9rem;
  border-radius: 8px;
}

.gift-form-buttons .btn .icon,
.dialog-actions .btn .icon {
  width: 1.05em;
  height: 1.05em;
}

#add-gift {
  margin-top: 14px;
}

.note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--pine-100);
  color: var(--pine-900);
  font-size: 0.92rem;
}

/* --- Wylosowana osoba ------------------------------------------------ */
.card-reveal {
  border-top: 6px solid var(--red);
}

.reveal-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.card .reveal-name {
  font-size: 2rem;
  color: var(--red);
  margin: 2px 0 14px;
  overflow-wrap: anywhere;
}

.reveal-sub {
  font-weight: 600;
}

#assignment-body > .muted.small {
  margin: 16px 0 10px;
}

.confirmed {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--pine-100);
  color: var(--pine-900);
  font-weight: 600;
}

/* --- Powiadomienie (toast) ------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--pine-900);
  color: #fff;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: var(--red-dark);
  border-radius: var(--radius-sm);
}

/* --- Okno potwierdzenia ---------------------------------------------- */
.dialog {
  width: calc(100vw - 32px);
  max-width: 420px;
  padding: 22px 20px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(5, 16, 11, 0.65);
}

.dialog h2 {
  font-size: 1.3rem;
  color: var(--pine-900);
  margin-bottom: 8px;
}

.dialog p {
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* --- Panel admina: kafelki, zakładki --------------------------------- */
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  color: #fff;
}

.tiles .stat {
  padding: 12px 14px;
}

.tiles .stat-value {
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.tab {
  min-height: 44px;
  padding: 8px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.tab.is-active {
  background: var(--cream);
  color: var(--pine-900);
}

.tab-panel {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #fff;
}

.section-head h2 {
  font-size: 1.3rem;
}

.loading-text {
  color: rgba(255, 255, 255, 0.8);
}

/* --- Panel admina: uczestnicy ---------------------------------------- */
.people {
  display: grid;
  gap: 12px;
}

.person {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--cream);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.person-head {
  display: grid;
  gap: 8px;
}

.person-who {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
}

.person-name {
  font-size: 1.1rem;
  color: var(--pine-900);
  overflow-wrap: anywhere;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ece6d8;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
}

.chip-ok {
  background: #d9eedf;
  color: #14532d;
}

.chip-warn {
  background: #fbe8c8;
  color: #7a4a00;
}

.chip-gold {
  background: #f3e3b8;
  color: #5c4308;
}

.chip-muted {
  background: #e6e6e6;
  color: #4b4b4b;
}

.person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-small {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.9rem;
  background: var(--paper);
}

.btn-small-danger {
  color: var(--red);
}

.person-gifts {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Karta uczestnika bez odstępów siatki: odstęp nad listą prezentów siedzi
   w środku opakowania, więc przy wysokości 0 lista nie zajmuje ani piksela
   i rozwijanie zaczyna się dokładnie od zera, bez skoku. */
.person {
  display: block;
}

.person > .person-actions {
  margin-top: 12px;
}

.person-gifts-wrap {
  display: flow-root;
}

.person-gifts-wrap > .person-gifts {
  margin-top: 12px;
}

/* Strzałka w przycisku "Lista prezentów" — obraca się przy rozwinięciu */
.chevron {
  width: 8px;
  height: 8px;
  margin: -3px 2px 0 4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), margin 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-toggle[aria-expanded="true"] .chevron {
  transform: rotate(225deg);
  margin-top: 4px;
}

/* Podczas animacji wysokości wiersze siatki nie mogą się rozciągać —
   inaczej nagłówek karty (imię, login) "odjeżdża" i przeskakuje. */
.person,
#draw,
.login-form,
.dialog-form,
.dialog-form form {
  align-content: start;
}

.person-gifts .gift-list {
  margin-top: 0;
}

.gift-editor-slot .gift-form {
  padding: 14px;
  border: 1.5px solid var(--pine-700);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

/* --- Panel admina: losowanie ----------------------------------------- */
#draw {
  display: grid;
  gap: 12px;
}

#draw h2 {
  margin-bottom: 0;
}

#draw .note {
  margin-top: 0;
}

.steps {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.step {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.step-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--paper);
}

.step.is-done {
  color: var(--pine-900);
}

.step.is-done .step-num {
  background: var(--pine-700);
  border-color: var(--pine-700);
  color: #fff;
}

.draw-count {
  font-weight: 600;
}

.note-warn {
  background: #fbe8c8;
  color: #5f3a00;
}

.draw-actions {
  display: grid;
  gap: 8px;
}

.progress {
  height: 12px;
  border-radius: 999px;
  background: #e6dfcf;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--pine-700);
  transition: width 0.3s ease;
}

.pairs {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.pairs-hint {
  text-align: center;
}

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

.pair {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.pair-arrow {
  color: var(--red);
  font-weight: 700;
}

.pair .chip {
  margin-left: auto;
}

/* --- Panel admina: ustawienia i okna z formularzem -------------------- */
.settings-form {
  display: grid;
  gap: 16px;
  max-width: 520px;
}

.settings-form h2 {
  margin-bottom: 0;
}

.dialog-form form,
.dialog-form {
  display: grid;
  gap: 14px;
}

.dialog-form:not([open]) {
  display: none;
}

.dialog-form h2 {
  margin-bottom: 0;
}

.dialog-form .dialog-actions {
  margin-top: 4px;
}

.dialog-intro {
  font-size: 0.92rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 500;
  cursor: pointer;
}

.check input {
  width: 22px;
  height: 22px;
  accent-color: var(--pine-700);
}

.credentials {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

/* --- Większe ekrany -------------------------------------------------- */
@media (min-width: 760px) {
  .tiles {
    grid-template-columns: repeat(4, 1fr);
  }

  .tabs {
    max-width: 520px;
  }

  .person-head {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .draw-actions {
    grid-template-columns: auto auto;
    justify-content: start;
  }

  #tab-draw .card {
    max-width: 720px;
  }
}

@media (min-width: 480px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 640px) {
  .login-card {
    padding: 40px 36px 32px;
  }

  .page {
    padding: 28px 24px 64px;
    gap: 20px;
  }

  .card {
    padding: 26px 28px;
  }

  .topbar-inner {
    padding: 12px 24px;
  }
}

/* =====================================================================
   POLA DATY NA iPHONIE
   Safari na iOS nadaje polu daty własną minimalną szerokość i wygląd,
   przez co pole wychodziło poza kartę. Zdejmujemy systemowy wygląd
   i pozwalamy polu kurczyć się do szerokości karty.
   ===================================================================== */
.field,
.field > *,
.settings-form > * {
  min-width: 0;
}

.input[type="datetime-local"],
.input[type="date"],
.input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  line-height: 1.4;
}

.input[type="datetime-local"]::-webkit-date-and-time-value {
  text-align: left;
  min-height: 1.4em;
}

/* =====================================================================
   IKONY w przyciskach
   ===================================================================== */
.icon {
  flex: none;
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-link,
.tab,
.input-addon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-link .icon,
.input-addon .icon {
  width: 1.1em;
  height: 1.1em;
}

.btn-toggle .chevron {
  margin-left: 2px;
}

/* zakładki z ikonami muszą się mieścić także na wąskim telefonie */
.tab {
  padding-left: 4px;
  padding-right: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
}

@media (min-width: 480px) {
  .tab {
    font-size: 0.95rem;
    gap: 8px;
  }
}

/* Josefin Sans ma litery osadzone nieco wyżej — wyrównanie w pionie */
h1,
h2,
h3,
.topbar-title,
.stat-value {
  font-weight: 700;
  letter-spacing: 0.005em;
}

.stat-value {
  padding-top: 0.12em;
}

/* =====================================================================
   GRAFIKI — ilustracje i zimowy krajobraz
   ===================================================================== */

/* Krajobraz przyklejony do dołu okna, pod treścią; góra wtapia się w tło */
body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  height: clamp(140px, 20vw, 330px);
  /* Pas zawsze pokazuje pełną wysokość obrazka (drzewa i domki nie są ucinane),
     a na szerokich ekranach powtarza się w poziomie. Plik to krajobraz
     z dołączonym lustrzanym odbiciem, więc łączenia są niewidoczne. */
  background: url("../img/krajobraz.webp?v=6") left bottom / auto 100% repeat-x;
  /* sceneria zaczyna się na ok. 24% wysokości obrazka — wyżej jest samo niebo,
     które płynnie wtapia się w tło strony */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 20%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 20%);
  pointer-events: none;
  animation: fade-in 0.8s ease both;
}

/* miejsce na dole strony, żeby krajobraz było widać po przewinięciu do końca */
.page {
  padding-bottom: clamp(160px, 22vw, 360px);
}

.login-page {
  padding-bottom: clamp(90px, 16vw, 200px);
}

img.brand-mark {
  object-fit: contain;
}

.topbar-brand .brand-mark {
  width: 40px;
  height: 40px;
}

.login-art {
  width: 150px;
  height: auto;
  margin-bottom: -4px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-text {
  min-width: 0;
}

.hero .hero-text h1 {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.hero-sub {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
}

.hero-art {
  flex: none;
  width: 104px;
  height: auto;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}

.hero .stats {
  margin-top: 14px;
}

.gift-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.empty-art {
  width: 120px;
  height: auto;
}

.reveal-art {
  display: block;
  width: 150px;
  height: auto;
  margin: -4px auto 8px;
}

.card-reveal .reveal-label,
.card-reveal .reveal-name {
  text-align: center;
}

@media (min-width: 640px) {
  .login-art {
    width: 180px;
  }

  .hero-art {
    width: 150px;
  }

  .reveal-art {
    width: 180px;
  }

  .topbar-brand .brand-mark {
    width: 44px;
    height: 44px;
  }
}

/* =====================================================================
   PŁYNNOŚĆ — przejścia i animacje w całej aplikacji
   ===================================================================== */
:root {
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --fast: 0.18s;
}

/* Przejście między stronami (logowanie -> panel -> panel admina) */
@view-transition {
  navigation: auto;
}

/* Hover / focus / wciśnięcie */
.btn {
  transition: background-color var(--fast) ease, border-color var(--fast) ease,
    color var(--fast) ease, box-shadow var(--fast) ease, transform var(--fast) var(--ease),
    opacity var(--fast) ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
  box-shadow: none;
}

.btn-link,
.tab,
.input-addon,
a,
.chip {
  transition: background-color var(--fast) ease, color var(--fast) ease, box-shadow var(--fast) ease;
}

.tab:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.12);
}

.tab.is-active {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.input-addon:hover {
  background: rgba(16, 48, 31, 0.07);
}

.input {
  transition: border-color var(--fast) ease, box-shadow var(--fast) ease;
}

.gift,
.person,
.stat,
.pair {
  transition: border-color var(--fast) ease, box-shadow 0.25s ease, background-color var(--fast) ease;
}

.gift:hover,
.pair:hover {
  border-color: #cfc4ab;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
}

.person:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.26);
}

.step-num {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.progress-bar {
  transition: width 0.7s var(--ease);
}

/* Pojawianie się nowych elementów (rozwinięta lista, formularz, zakładka) */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* osobna nazwa animacji (pop-in), żeby odpalała się także na elementach,
   które mają już animację wejścia strony */
.anim-in,
body:not(.is-loading) .page > .anim-in {
  animation: pop-in 0.32s var(--ease) both;
}

/* Wejście strony po sprawdzeniu logowania */
body:not(.is-loading) .login-card,
body:not(.is-loading) .page > * {
  animation: fade-up 0.45s var(--ease) both;
}

body:not(.is-loading) .page > *:nth-child(2) {
  animation-delay: 0.06s;
}

body:not(.is-loading) .page > *:nth-child(3) {
  animation-delay: 0.12s;
}

body:not(.is-loading) .page > *:nth-child(4) {
  animation-delay: 0.18s;
}

body:not(.is-loading) .topbar {
  animation: fade-in 0.35s ease both;
}

body:not(.is-loading) .page > .tab-panel.anim-in {
  animation-duration: 0.28s;
  animation-delay: 0s;
}

/* Okna dialogowe: wejście i wyjście */
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes dialog-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.dialog[open] {
  animation: dialog-in 0.24s var(--ease) both;
}

.dialog[open]::backdrop {
  animation: fade-in 0.24s ease both;
}

.dialog.is-closing {
  animation: dialog-out 0.17s ease both;
}

.dialog.is-closing::backdrop {
  animation: fade-out 0.17s ease both;
}

/* Osoby, które wyłączyły animacje w systemie, dostają wersję bez ruchu */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  .dialog::backdrop {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }

  .loader::after {
    animation-duration: 2.5s !important;
  }

  @view-transition {
    navigation: none;
  }
}
