@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&display=swap');

:root {
  --color-bg: #fdfdf8;
  --color-bg-alt: #f4f0e4;
  --color-bg-bounce: #f8f6ee;
  --color-card-bg: #ffffff;
  --color-accent: #6f7d43;
  --color-accent-dark: #56612f;
  --color-rust: #b0664a;
  --color-text: #2c2c22;
  --color-border: #a4af80;
  --color-completed-text: #ffffff;
  --color-stripe: rgba(111, 125, 67, 0.08);

  --pico-font-family: 'Cormorant Garamond', Georgia, serif !important;
  --pico-background-color: var(--color-bg) !important;
  --pico-color: var(--color-text) !important;
  --pico-primary: var(--color-accent) !important;
  --pico-primary-background: var(--color-accent) !important;
  --pico-primary-border: var(--color-accent) !important;
  --pico-primary-hover: var(--color-accent-dark) !important;
  --pico-primary-hover-background: var(--color-accent-dark) !important;
  --pico-primary-hover-border: var(--color-accent-dark) !important;
  --pico-primary-inverse: #fff !important;
  --pico-h1-color: var(--color-text) !important;
  --pico-h2-color: var(--color-text) !important;
  --pico-h3-color: var(--color-text) !important;
  --pico-form-element-background-color: var(--color-card-bg) !important;
  --pico-form-element-border-color: var(--color-border) !important;
  --pico-form-element-color: var(--color-text) !important;
  --pico-table-border-color: var(--color-border) !important;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #201e18;
    --color-bg-alt: #171510;
    --color-bg-bounce: #1b1914;
    --color-card-bg: #29271f;
    --color-accent: #9caf6a;
    --color-accent-dark: #7d8f57;
    --color-rust: #d0876a;
    --color-text: #ece8da;
    --color-border: #5b5940;
    --color-completed-text: #201e18;
    --color-stripe: rgba(156, 175, 106, 0.10);
  }
}

/* ręczny przełącznik motywu (localStorage) nadpisuje ustawienia systemowe -
   selektor z atrybutem ma wyższą specyficzność niż zwykły :root, więc
   wygrywa niezależnie od kolejności w pliku */
:root[data-theme="dark"] {
  --color-bg: #201e18;
  --color-bg-alt: #171510;
  --color-bg-bounce: #1b1914;
  --color-card-bg: #29271f;
  --color-accent: #9caf6a;
  --color-accent-dark: #7d8f57;
  --color-rust: #d0876a;
  --color-text: #ece8da;
  --color-border: #5b5940;
  --color-completed-text: #201e18;
  --color-stripe: rgba(156, 175, 106, 0.10);
}

:root[data-theme="light"] {
  --color-bg: #fdfdf8;
  --color-bg-alt: #f4f0e4;
  --color-bg-bounce: #f8f6ee;
  --color-card-bg: #ffffff;
  --color-accent: #6f7d43;
  --color-accent-dark: #56612f;
  --color-rust: #b0664a;
  --color-text: #2c2c22;
  --color-border: #a4af80;
  --color-stripe: rgba(111, 125, 67, 0.08);
  --color-completed-text: #ffffff;
}

html,
body {
  background-color: var(--color-bg-bounce);
  background-image:
    linear-gradient(to bottom, var(--color-bg-bounce), transparent 100px),
    linear-gradient(to top, var(--color-bg-bounce), transparent 100px),
    radial-gradient(ellipse at top, var(--color-bg) 0%, var(--color-bg-alt) 100%),
    radial-gradient(420px circle at 8% -5%, rgba(111, 125, 67, 0.16), transparent 60%),
    radial-gradient(380px circle at 105% 12%, rgba(176, 102, 74, 0.11), transparent 55%),
    radial-gradient(420px circle at 50% 105%, rgba(111, 125, 67, 0.12), transparent 55%);
  background-repeat: no-repeat;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
}

@media (prefers-color-scheme: dark) {
  html,
  body {
    background-image:
      linear-gradient(to bottom, var(--color-bg-bounce), transparent 100px),
      linear-gradient(to top, var(--color-bg-bounce), transparent 100px),
      radial-gradient(ellipse at top, var(--color-bg) 0%, var(--color-bg-alt) 100%),
      radial-gradient(420px circle at 8% -5%, rgba(156, 175, 106, 0.10), transparent 60%),
      radial-gradient(380px circle at 105% 12%, rgba(208, 135, 106, 0.08), transparent 55%),
      radial-gradient(420px circle at 50% 105%, rgba(156, 175, 106, 0.08), transparent 55%);
  }
}

.frame {
  position: relative;
  z-index: 0;
  max-width: 640px;
  margin: 1.5rem auto;
  padding: 2.5rem 1.75rem;
  background: var(--color-card-bg);
  border: 1.5px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 4px 32px rgba(40, 35, 20, 0.08), 0 1px 3px rgba(40, 35, 20, 0.06);
  animation: frame-enter 0.6s ease-out;
}

input[type="text"],
input[type="number"],
input[type="file"],
select,
textarea {
  box-shadow: inset 0 1px 3px rgba(40, 35, 20, 0.06);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  box-shadow: inset 0 1px 3px rgba(40, 35, 20, 0.06), 0 0 0 3px rgba(111, 125, 67, 0.18);
}

@media (prefers-color-scheme: dark) {
  input[type="text"],
  input[type="number"],
  input[type="file"],
  select,
  textarea {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
  }

  input[type="text"]:focus,
  input[type="number"]:focus,
  select:focus,
  textarea:focus {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(156, 175, 106, 0.22);
  }
}

@media (prefers-color-scheme: dark) {
  .frame {
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

@keyframes frame-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .frame {
    animation: none;
  }

  .list-row.htmx-swapping,
  .table-scroll tr.htmx-swapping,
  .photo-tile.htmx-swapping {
    transition: none;
  }
}

.frame-wide {
  max-width: 900px;
}

.table-scroll {
  overflow-x: auto;
}

.corner-sprig {
  position: absolute;
  width: 34px;
  height: 84px;
  color: var(--color-accent);
  opacity: 0.55;
  pointer-events: none;
  z-index: -1;
}

.corner-sprig--tl {
  top: 8px;
  left: 8px;
}

.corner-sprig--br {
  bottom: 8px;
  right: 8px;
  transform: rotate(180deg);
}

.corner-sprig--big.corner-sprig--tl {
  width: 68.05px;
  height: 168.03px;
  top: -19px;
  transform: rotate(45deg);
}

.corner-sprig--big.corner-sprig--br {
  width: 68.05px;
  height: 168.03px;
  bottom: -19px;
  transform: rotate(225deg);
}

.bg-botanical {
  position: fixed;
  width: 220px;
  color: var(--color-accent);
  opacity: 0.14;
  pointer-events: none;
  z-index: 0;
}

.bg-botanical--tl,
.bg-botanical--br {
  height: 403px;
}

.bg-botanical--tr,
.bg-botanical--bl {
  height: 487px;
}

.bg-botanical--tl,
.bg-botanical--tr,
.bg-botanical--bl,
.bg-botanical--br {
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%);
  mask-image: linear-gradient(to bottom, transparent, black 15%);
}

.bg-botanical--tl {
  top: -30px;
  left: -50px;
  transform: rotate(-12deg);
}

.bg-botanical--tr {
  top: -60px;
  right: -40px;
  transform: rotate(15deg) scaleX(-1);
}

.bg-botanical--bl {
  bottom: -50px;
  left: -40px;
  transform: rotate(-8deg) scaleY(-1);
}

.bg-botanical--br {
  bottom: -30px;
  right: -50px;
  transform: rotate(10deg) scaleX(-1) scaleY(-1);
}

.bg-botanical--ml,
.bg-botanical--mr {
  top: 50%;
  width: 170px;
  height: 195px;
  opacity: 0.1;
}

.bg-botanical--ml {
  left: -70px;
  transform: translateY(-50%) rotate(-20deg);
}

.bg-botanical--mr {
  right: -70px;
  transform: translateY(-50%) rotate(160deg);
}

@media (max-width: 700px) {
  .bg-botanical {
    width: 130px;
    opacity: 0.1;
  }

  .bg-botanical--tl,
  .bg-botanical--br {
    height: 238px;
  }

  .bg-botanical--tr,
  .bg-botanical--bl {
    height: 288px;
  }

  .bg-botanical--ml,
  .bg-botanical--mr {
    width: 100px;
    height: 115px;
    opacity: 0.08;
  }
}

@media (max-width: 480px) {
  .corner-sprig {
    width: 24px;
    height: 59px;
    opacity: 0.4;
  }

  .corner-sprig--big.corner-sprig--tl {
    width: 48.02px;
    height: 118.43px;
    top: -14px;
  }

  .corner-sprig--big.corner-sprig--br {
    width: 48.02px;
    height: 118.43px;
    bottom: -14px;
  }

  .frame {
    padding: 1.5rem 0.65rem;
  }

  .admin-logout-form {
    top: 1rem;
    right: 0.85rem;
  }

  .status-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .ranking-title {
    font-size: 1.3rem;
  }

  .ranking-card {
    padding: 0.85rem 0.7rem;
  }

  .ranking-table {
    font-size: 0.8rem;
  }

  .ranking-table td {
    padding: 0.45rem 0.4rem;
  }

  .ranking-table .rank-num {
    width: 1.4rem;
  }

  .ranking-table .rank-value {
    width: 4rem;
  }

  .ranking-table--duration .rank-value {
    width: 6.5rem;
  }
}

@media (max-width: 400px) {
  .bingo-cell {
    font-size: 0.74rem;
    padding: 0.2rem;
  }

  .bingo-grid {
    gap: 0.2rem;
  }
}

.eyebrow {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.95rem;
  color: var(--color-text);
  margin: 0;
}

.board-code-label {
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  opacity: 0.65;
  margin: 0.5rem 0 0;
}

.title {
  text-align: center;
  font-style: italic;
  font-weight: 600;
  color: var(--color-accent);
  font-size: 2.4rem;
  margin: 0.25rem 0 1rem;
}

.gallery-subtitle {
  text-align: center;
  font-size: 1rem;
  opacity: 0.7;
  margin: -0.5rem 0 1.25rem;
}

.gallery-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.75rem 0 1.5rem;
}

.gallery-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.95rem;
  color: var(--color-text);
  text-decoration: none;
  background: var(--color-card-bg);
}

.gallery-toggle-btn:hover {
  border-color: var(--color-accent);
}

.gallery-toggle-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  font-weight: 600;
}

.gallery-group-heading {
  font-style: italic;
  color: var(--color-accent);
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
}

.gallery-group-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.5rem 0;
  opacity: 0.6;
}

.gallery-sentinel {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1rem 0;
}

.gallery-sentinel .hint {
  margin: 0;
}

.board-hint {
  text-align: center;
  font-size: 1rem;
  opacity: 0.75;
  margin: 0 0 1rem;
}

.flourish {
  display: block;
  width: 6rem;
  height: 0.9rem;
  margin: 0.25rem auto 2rem;
  color: var(--color-accent);
}

.form-error {
  text-align: center;
  color: var(--color-rust);
}

.intro {
  text-align: center;
  font-size: 1.05rem;
  margin-bottom: 1.75rem;
}

.btn-return-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  margin-bottom: 0.5rem;
}

.btn-return-board svg {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.divider-text {
  text-align: center;
  font-size: 0.9rem;
  font-style: italic;
  opacity: 0.7;
  margin: 1.25rem 0;
}

.bingo-banner {
  text-align: center;
  background: var(--color-accent);
  color: var(--color-completed-text);
  padding: 0.6rem 1rem;
  border-radius: 12px;
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.bingo-grid-wrap {
  position: relative;
}

.bingo-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.bingo-lines line {
  stroke: var(--color-accent-dark);
  stroke-width: 1.1;
  stroke-linecap: round;
}

.bingo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.3rem;
}

.bingo-cell {
  aspect-ratio: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.15;
  padding: 0.3rem;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: 9px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(40, 35, 20, 0.07);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.bingo-cell:active {
  transform: scale(0.95);
}

.bingo-cell.completed {
  box-shadow: 0 3px 12px rgba(111, 125, 67, 0.3);
}

@media (prefers-color-scheme: dark) {
  .bingo-cell {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }

  .bingo-cell.completed {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
  }
}

.bingo-cell label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.bingo-cell.completed {
  background-color: var(--color-accent);
  color: var(--color-completed-text);
  cursor: pointer;
}

.bingo-cell .cell-button {
  all: unset;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  font: inherit;
  color: inherit;
  text-align: center;
  cursor: pointer;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Chromium wymusza własną logikę rozmiaru dla <dialog> w "top layer", która
   ignoruje autorskie width/max-width na samym elemencie dialog niezależnie
   od specyficzności CSS - dlatego dialog staje się przezroczystą warstwą
   centrującą (flex), a cały wygląd karty przenosimy na .dialog-inner */
.photo-dialog:not([open]) {
  display: none !important;
}

.photo-dialog[open] {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: none !important;
  padding: 0 !important;
  background: transparent !important;
  color: var(--color-text) !important;
}

.photo-dialog::backdrop {
  background: rgba(20, 18, 12, 0.55);
}

.dialog-inner {
  position: relative;
  box-sizing: border-box;
  width: 88vw;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-card-bg);
}

.photo-dialog img {
  display: block;
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  background: #000;
  border-radius: 9px;
  margin-bottom: 1rem;
}

.dialog-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
}

.dialog-meta > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--color-border);
}

.dialog-meta > div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.dialog-meta dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.65;
  white-space: nowrap;
}

.dialog-meta dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

.dialog-close {
  all: unset;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  background: rgba(20, 18, 12, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  z-index: 1;
}

.dialog-close svg {
  width: 1.125rem;
  height: 1.125rem;
}

.dialog-close:hover {
  background: rgba(20, 18, 12, 0.9);
}

@media (hover: hover) and (pointer: fine) {
  .lightbox-media .dialog-close,
  .lightbox-media .lightbox-download-icon,
  .lightbox-media .lightbox-delete-icon {
    opacity: 0.35;
    transition: opacity 0.15s ease;
  }

  .lightbox-media:hover .dialog-close,
  .lightbox-media:hover .lightbox-download-icon,
  .lightbox-media:hover .lightbox-delete-icon,
  .lightbox-media .dialog-close:focus-visible,
  .lightbox-media .lightbox-download-icon:focus-visible,
  .lightbox-media .lightbox-delete-icon:focus-visible {
    opacity: 1;
  }
}

.app-dialog-message {
  margin: 0 0 1.2rem;
  padding-right: 1.6rem;
  line-height: 1.5;
}

.dialog-loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(20, 18, 12, 0.35);
  z-index: 5;
}

.dialog-loading-overlay.htmx-request {
  display: flex;
}

.dialog-loading-overlay .dialog-spinner {
  width: 2em;
  height: 2em;
  margin-right: 0;
  border-width: 3px;
}

.dialog-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 0.5rem;
  vertical-align: -0.15em;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: dialog-spin 0.8s linear infinite;
}

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

.dialog-actions {
  display: flex;
  gap: 0.6rem;
}

.dialog-actions > * {
  margin: 0;
  flex: 1;
}

.dialog-actions-stack {
  flex-direction: column;
}

.dialog-actions-stack > * {
  flex: none;
}

.no-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  aspect-ratio: 4 / 3;
  border-radius: 9px;
  background: var(--color-bg-alt);
  color: var(--color-accent);
  font-size: 2rem;
  margin-bottom: 1rem;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  border: 1px solid transparent;
  box-sizing: border-box;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active,
button:active,
[role="button"]:active {
  transform: scale(0.97);
}

button,
[role="button"],
.btn-primary,
.btn-danger {
  box-shadow: 0 2px 10px rgba(40, 35, 20, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  button,
  [role="button"],
  .btn-primary,
  .btn-danger {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  }
}

.btn-outline {
  background: transparent;
  border-color: var(--color-accent);
  color: var(--color-accent);
}

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

.btn-danger {
  flex: 1;
  background: var(--color-rust);
  border-color: var(--color-rust);
  color: #fff;
}

.signature {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.signature .hint {
  font-size: 1rem;
  font-style: italic;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.signature-form {
  display: flex;
  gap: 0.5rem;
}

.signature-form input {
  margin-bottom: 0;
}

.signature-form button {
  width: auto;
  margin-bottom: 0;
  white-space: nowrap;
}

.signature + .board-hint {
  margin-top: 1.25rem;
}

table {
  border: 1px solid var(--color-border);
}

thead th {
  border-bottom: 1px solid var(--color-border);
}

td, th {
  border-color: var(--color-border) !important;
}

.site-footer {
  max-width: 640px;
  margin: 1.5rem auto 2rem;
  text-align: center;
  color: var(--color-text);
  opacity: 0.7;
}

.site-footer .flourish {
  width: 4.5rem;
  margin-bottom: 0.75rem;
}

.site-footer p {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin: 0;
}

.site-footer-credit {
  margin-top: 0.5rem !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-style: italic;
  font-size: 0.85rem !important;
}

.theme-switch {
  margin-top: 1rem !important;
  text-align: right;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 0.8rem !important;
  opacity: 0.75;
}

.theme-switch-btn {
  all: unset;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  cursor: pointer;
  text-decoration: underline;
  color: var(--color-text);
}

.theme-switch-btn.active {
  cursor: default;
  pointer-events: none;
  text-decoration: none;
  font-weight: 700;
  color: var(--color-accent);
}

.site-nav {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.site-nav-logo {
  text-align: center;
  text-decoration: none;
  font-style: italic;
  font-weight: 600;
  font-size: 2rem;
  color: var(--color-accent);
  line-height: 1.2;
}

.site-nav-logo .amp {
  font-style: normal;
}

.site-nav-logo-sub {
  display: block;
  font-style: normal;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-text);
}

.site-nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
}

.site-nav-links a {
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text);
  text-decoration: none;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid transparent;
}

.site-nav-links a:hover {
  color: var(--color-accent);
}

.site-nav-links a.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  text-align: center;
  padding: 1rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg-alt);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--color-accent);
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-logout-form {
  position: absolute;
  top: 1.75rem;
  right: 1.75rem;
  z-index: 1;
  margin: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem !important;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  flex: none;
}

.icon-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.icon-btn:hover {
  background: var(--color-bg-alt);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.admin-nav-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.admin-nav-grid > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.admin-nav-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  padding: 1.25rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg-alt);
  color: var(--color-text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.admin-nav-card:hover,
.admin-nav-card:focus-visible {
  border-color: var(--color-accent);
  color: var(--color-text);
  transform: translateY(-1px);
}

.admin-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  color: var(--color-accent);
}

.admin-nav-icon svg {
  width: 1.4rem;
  height: 1.4rem;
}

.admin-nav-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.admin-nav-subtitle {
  font-size: 0.78rem;
  color: var(--color-text);
  opacity: 0.75;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.status-pill--gray {
  background: var(--color-bg-alt);
  border-color: var(--color-border);
  color: var(--color-text);
  opacity: 0.75;
}

.status-pill--amber {
  background: rgba(176, 102, 74, 0.12);
  border-color: var(--color-rust);
  color: var(--color-rust);
}

.status-pill--blue {
  background: rgba(70, 110, 160, 0.12);
  border-color: #466ea0;
  color: #466ea0;
}

.status-pill--green {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-completed-text);
}

.status-pill--red {
  background: var(--color-rust);
  border-color: var(--color-rust);
  color: var(--color-completed-text);
}

.provider-card {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--provider-color, var(--color-border));
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  background: var(--color-bg-alt);
}

.provider-card > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.6rem;
  cursor: pointer;
}

.provider-card[open] > summary {
  margin-bottom: 0.75rem;
}

.provider-card-summary-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.provider-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  color: var(--provider-color, var(--color-accent));
  flex: none;
}

.provider-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.provider-card-title {
  font-size: 1.2rem;
  font-weight: 600;
  flex: 1;
  min-width: 8rem;
}

.backup-instructions summary {
  cursor: pointer;
  color: var(--color-accent);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.backup-config-form-wrapper {
  margin-top: 0.75rem;
}

.settings-form label {
  display: block;
  max-width: 320px;
  margin-bottom: 0.25rem;
}

.settings-hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  opacity: 0.7;
}

.settings-save-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.settings-save-row button {
  width: auto;
}

.settings-saved {
  color: var(--color-accent);
  font-weight: 600;
  animation: settings-saved-fade 2.5s ease forwards;
}

@keyframes settings-saved-fade {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; }
}

.danger-zone {
  border: 1.5px solid var(--color-rust);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: rgba(176, 102, 74, 0.06);
}

.danger-zone h2 {
  color: var(--color-rust);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.danger-zone h2 svg {
  width: 1.2rem;
  height: 1.2rem;
}

.btn-compact,
.btn-delete-board {
  box-sizing: border-box;
  width: auto !important;
  height: 1.9rem;
  margin: 0;
  padding: 0 0.6rem;
  font-size: 0.8rem;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-delete-board {
  background: transparent;
  border: 1px solid var(--color-rust);
  color: var(--color-rust);
}

.btn-reset-app {
  display: block;
  width: 100%;
  background: transparent;
  border: 1.5px solid var(--color-rust);
  color: var(--color-rust);
  font-weight: 600;
}

.ranking-title {
  text-align: center;
  font-style: italic;
  font-weight: 600;
  color: var(--color-accent);
  font-size: 1.6rem;
  margin: 0 0 1.25rem;
}

.ranking-card {
  padding: 1.1rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: 0 2px 14px rgba(40, 35, 20, 0.05);
}

.ranking-card h3 {
  margin-top: 0;
}

.ranking-card:last-child {
  margin-bottom: 0;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0;
}

.ranking-table tr:nth-child(even) {
  background: var(--color-stripe);
}

.ranking-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

.ranking-table tr:last-child td {
  border-bottom: none;
}

.ranking-table .rank-num {
  width: 1.75rem;
  font-weight: 600;
  color: var(--color-accent);
  text-align: center;
}

.ranking-table .rank-name {
  overflow-wrap: break-word;
  word-break: break-word;
}

.ranking-table .rank-value {
  width: 5rem;
  font-weight: 600;
  color: var(--color-accent);
  white-space: nowrap;
  text-align: right;
}

.ranking-table--duration .rank-value {
  width: 7.5rem;
  font-size: 0.85em;
}

.gallery-upload-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.upload-trigger {
  display: block;
  width: 100%;
}

.file-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  color: var(--color-text);
  background: var(--color-card-bg);
  box-sizing: border-box;
}

.upload-hint {
  font-size: 0.85rem;
  text-align: center;
  opacity: 0.6;
  margin: 0.35rem 0 0;
}

.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.upload-progress-track {
  width: 100%;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-accent);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.upload-progress-text {
  font-size: 0.85rem;
  text-align: center;
  opacity: 0.75;
  margin: 0;
}

.upload-progress-bar--indeterminate {
  width: 40%;
  animation: upload-progress-indeterminate 1.1s ease-in-out infinite;
}

@keyframes upload-progress-indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.photo-tile {
  margin: 0;
}

.photo-tile.htmx-swapping {
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.photo-tile img,
.photo-tile video {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

.photo-tile-trigger {
  all: unset;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  position: relative;
  display: block;
  width: 100%;
  cursor: pointer;
}

.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border-radius: 50%;
  font-size: 0.8rem;
  padding-left: 0.15rem;
  pointer-events: none;
}


.lightbox-inner {
  max-width: min(90vw, 700px);
  padding: 1rem;
}

.lightbox-inner img,
.lightbox-inner video {
  display: block;
  width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 10px;
  background: #000;
  margin-bottom: 0.75rem;
}

.lightbox-nav-row {
  display: flex;
  gap: 0.6rem;
  margin: -0.25rem 0 0.75rem;
}

.lightbox-nav-btn {
  all: unset;
  flex: 1;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  padding: 0.5rem 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-bg);
  background: var(--color-accent);
  border-radius: 10px;
  cursor: pointer;
}

.nav-arrow-icon {
  width: 0.85em;
  height: 0.85em;
  flex-shrink: 0;
  stroke-width: 2.5;
}

.lightbox-nav-btn:hover {
  background: var(--color-accent-dark);
}

.lightbox-media {
  position: relative;
}

.lightbox-download-icon {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(20, 18, 12, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  cursor: pointer;
  z-index: 1;
}

.lightbox-download-icon svg {
  width: 1.125rem;
  height: 1.125rem;
}

.lightbox-download-icon:hover {
  background: rgba(20, 18, 12, 0.9);
}

.lightbox-delete-icon {
  all: unset;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  position: absolute;
  bottom: 0.6rem;
  right: 3.1rem;
  z-index: 1;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(20, 18, 12, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  cursor: pointer;
}

.lightbox-delete-icon svg {
  width: 1.125rem;
  height: 1.125rem;
}

.lightbox-delete-icon:hover {
  background: rgba(20, 18, 12, 0.9);
}

.lightbox-delete-icon--solo {
  right: 0.6rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 1rem 0 2rem;
}

.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.85rem;
}

.pagination-arrow svg {
  width: 0.85em;
  height: 0.85em;
  stroke-width: 2.5;
}

.pagination a.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.admin-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.admin-filter-form input,
.admin-filter-form select,
.admin-filter-form button {
  margin-bottom: 0;
  width: auto;
}

.admin-filter-form input[type="text"] {
  flex: 1;
  min-width: 160px;
}

.content-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.content-links a,
.content-links button {
  flex: 1;
  min-width: 200px;
  text-align: center;
}

.content-links--stacked {
  flex-direction: column;
}

.content-links--stacked > a,
.content-links--stacked > button {
  flex: none;
  width: 100%;
  min-width: 0;
}

.list-rows {
  display: flex;
  flex-direction: column;
  margin: 0 0 1rem;
}

.list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.list-row.htmx-swapping,
.table-scroll tr.htmx-swapping {
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.list-row:last-child {
  border-bottom: none;
}

.list-row .inline-edit-form {
  flex: 1 1 240px;
  min-width: 0;
}

.inline-edit-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.inline-edit-form input {
  flex: 3 1 100px;
  min-width: 90px;
  margin-bottom: 0;
}

.inline-edit-form button {
  margin-bottom: 0;
}

.gender-toggle {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  box-sizing: border-box;
  height: 1.9rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-alt);
  overflow: hidden;
}

.gender-toggle::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: calc(50% - 1px);
  height: calc(100% - 2px);
  border-radius: 999px;
  background: var(--color-accent);
  transition: transform 0.2s ease;
}

.gender-toggle:has(input[value="f"]:checked)::before {
  transform: translateX(100%);
}

.gender-toggle input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.gender-toggle label {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.gender-toggle input[type="radio"]:checked + label {
  color: #fff;
}

.gender-toggle input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.gender-toggle-icon {
  display: none;
  font-size: 0.95rem;
  line-height: 1;
}

@media (max-width: 480px) {
  .gender-toggle label {
    padding: 0 0.5rem;
  }

  .gender-toggle-text {
    display: none;
  }

  .gender-toggle-icon {
    display: inline;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gender-toggle::before {
    transition: none;
  }
}

.list-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.list-meta-row .hint {
  margin: 0;
}

.per-page-form {
  margin: 0;
}

.per-page-form label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.per-page-form select {
  width: auto;
  margin-bottom: 0;
}

.backup-setup-steps {
  padding-left: 1.25rem;
  margin-bottom: 1.25rem;
}

.backup-setup-steps li {
  margin-bottom: 0.75rem;
}

.backup-copy-value {
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-alt);
  border-radius: 8px;
  overflow-x: auto;
}

.backup-config-form label {
  display: block;
  margin-bottom: 0.75rem;
}

.provider-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
}

.provider-card-actions form {
  margin: 0;
}

.provider-card-actions button {
  width: auto;
  margin-bottom: 0;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.status-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.6rem;
  margin: 1rem 0;
}

.status-summary-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.7rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg-alt);
  text-decoration: none;
  color: var(--color-text);
  text-align: center;
}

.status-summary-tile.active {
  border-color: var(--color-accent);
  background: var(--color-stripe);
}

.status-summary-value {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-accent);
}

.status-summary-label {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  opacity: 0.8;
  overflow-wrap: break-word;
  hyphens: auto;
}

.file-status-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.file-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-alt);
}

.file-status-main {
  min-width: 0;
  flex: 1 1 12rem;
}

.file-status-label {
  font-weight: 600;
  overflow-wrap: break-word;
}

.file-status-meta {
  font-size: 0.8rem;
  opacity: 0.75;
}

.file-status-side {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

.file-status-side form {
  margin: 0;
}

.file-status-side button {
  width: auto;
  margin-bottom: 0;
}

.file-status-error {
  flex-basis: 100%;
  font-size: 0.78rem;
  color: var(--color-rust);
  opacity: 0.85;
}

.app-dialog-message p {
  margin: 0;
}

.test-result--ok {
  color: var(--color-accent);
}

.test-result--fail {
  color: var(--color-rust);
}

