:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --panel: #ffffff;
  --ink: #161616;
  --muted: #6f6b63;
  --line: #ded8cc;
  --accent: #be4b2d;
  --accent-dark: #82341f;
  --shadow: 0 18px 60px rgba(18, 16, 13, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 48px);
  background: rgba(247, 244, 238, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

.photo-card:focus-visible,
.album-card:focus-visible,
.lightbox button:focus-visible,
.lightbox a:focus-visible {
  outline: 3px solid rgba(190, 75, 45, 0.35);
  outline-offset: 3px;
}

main {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 36px) 48px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: clamp(8px, 1.2vw, 16px);
}

.photo-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #e7e0d4;
  cursor: zoom-in;
}

.photo-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease, filter 180ms ease;
}

.photo-card:hover img {
  transform: scale(1.035);
  filter: saturate(1.05) contrast(1.02);
}

[hidden] {
  display: none !important;
}

.topbar__titles {
  min-width: 0;
}

.back-link {
  display: inline-block;
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
}

.back-link:hover {
  color: var(--accent);
}

.topbar__meta {
  flex-shrink: 0;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.message {
  margin: 48px 0;
  color: var(--muted);
  font-size: 17px;
  text-align: center;
}

.progress {
  margin: 0 0 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.progress__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 10px;
  font-size: 15px;
}

.progress__head span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress__bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee7da;
}

.progress__fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 300ms ease;
}

.progress__note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.progress.is-error {
  border-color: #e6b8a9;
  background: #fbefea;
}

.albums {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: clamp(12px, 2vw, 24px);
}

.album-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.album-card[href]:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(18, 16, 13, 0.12);
}

.album-card__cover {
  display: block;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #e7e0d4;
}

.album-card__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-card__body {
  display: block;
  padding: 14px 16px 16px;
}

.album-card__name {
  display: block;
  margin-bottom: 4px;
  font-size: 19px;
  font-weight: 750;
  line-height: 1.25;
}

.album-card__meta {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.album-card.is-pending {
  cursor: default;
}

.album-card.is-pending .album-card__cover {
  background: repeating-linear-gradient(-45deg, #e7e0d4 0 12px, #ede7dc 12px 24px);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3e3dc;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 84px;
  grid-template-rows: 1fr;
  align-items: center;
  padding: 24px;
  background: rgba(10, 10, 10, 0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  width: 100%;
  height: calc(100vh - 48px);
  margin: 0;
}

.lightbox__figure img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 110px);
  max-height: calc(100dvh - 110px);
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: var(--shadow);
  user-select: none;
}

.lightbox__figure figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  min-height: 44px;
  padding-top: 10px;
  color: #e9e2d6;
  font-size: 14px;
  font-weight: 650;
}

.lightbox__download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  text-decoration: none;
}

.lightbox__download:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox__download span {
  color: #cfc7b9;
  font-weight: 500;
}

.lightbox button {
  border: 0;
  color: #fff;
  cursor: pointer;
}

.lightbox__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 34px;
  line-height: 1;
}

.lightbox__nav {
  z-index: 1;
  width: 58px;
  height: 86px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 64px;
  line-height: 0.8;
}

.lightbox__nav:hover,
.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lightbox__nav--prev {
  justify-self: start;
}

.lightbox__nav--next {
  justify-self: end;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    padding: 14px 12px;
  }

  h1 {
    font-size: 28px;
  }

  main {
    padding: 12px 8px 32px;
  }

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .lightbox {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .lightbox__figure {
    height: calc(100vh - 28px);
  }

  .lightbox__figure img {
    max-height: calc(100vh - 100px);
    max-height: calc(100dvh - 100px);
  }

  .lightbox__nav {
    position: absolute;
    top: 50%;
    width: 48px;
    height: 72px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.16);
    font-size: 52px;
  }

  .lightbox__nav--prev {
    left: 8px;
  }

  .lightbox__nav--next {
    right: 8px;
  }
}

@media (min-width: 1280px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  }
}

/* ---------- panel ---------- */

.panel-main {
  width: min(980px, 100%);
}

.topbar__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar a.button--ghost {
  text-decoration: none;
}

.notice {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 15px;
  line-height: 1.5;
}

.notice p {
  margin: 0;
}

.notice p + p,
.notice form {
  margin-top: 8px;
}

.notice--ok {
  border-color: #b9d8b5;
  background: #f1f8ef;
}

.notice--error {
  border-color: #e6b8a9;
  background: #fbefea;
}

.notice--inline-error {
  color: var(--accent-dark);
}

.panel-field {
  display: block;
}

.panel-field > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.panel-field input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(190, 75, 45, 0.2);
}

.panel-section {
  margin: 0 0 22px;
}

.panel-section h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.panel-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.panel-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.panel-row.is-hidden {
  background: #faf8f4;
}

.panel-row.is-hidden .panel-row__cover {
  opacity: 0.45;
}

.panel-row__cover {
  display: block;
  width: 104px;
  height: 78px;
  border-radius: 6px;
  background: #e7e0d4;
  object-fit: cover;
}

.panel-row__meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.panel-row__meta a {
  color: var(--accent-dark);
}

.panel-row details {
  margin-top: 6px;
  font-size: 13px;
}

.panel-row details ul {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.panel-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.panel-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.panel-row__move {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.icon-button {
  width: 36px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.button {
  display: inline-block;
  padding: 11px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
}

.button--ghost {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent-dark);
  font-size: 14px;
}

.button--ghost:hover {
  background: #fff;
  color: var(--accent);
}

.panel-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding: 18px 0 14px;
  background: linear-gradient(rgba(247, 244, 238, 0), var(--bg) 45%);
}

.login-card {
  width: min(380px, 100%);
  margin: 10vh auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0 0 16px;
  font-size: 22px;
}

.login-card .button {
  width: 100%;
  margin-top: 14px;
}

.login-card .notice {
  margin-bottom: 14px;
}

@media (max-width: 640px) {
  .panel-row {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
  }

  .panel-row__cover {
    width: 72px;
    height: 54px;
  }

  .panel-toggle,
  .panel-row__move {
    grid-column: 2;
  }

  .panel-row__move {
    flex-direction: row;
  }
}

/* ---------- nagłówek z logo ---------- */

.topbar__start {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.5vw, 28px);
  min-width: 0;
}

.brand {
  display: block;
  flex-shrink: 0;
  line-height: 0;
}

.brand img {
  display: block;
  width: auto;
  height: 60px;
}

.topbar__start .topbar__titles {
  padding-left: clamp(14px, 2.5vw, 28px);
  border-left: 1px solid var(--line);
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .topbar__start {
    gap: 12px;
  }

  .brand img {
    height: 40px;
  }

  .topbar__start .topbar__titles {
    padding-left: 12px;
  }

  .topbar__meta {
    flex-basis: 100%;
    font-size: 13px;
  }

  .topbar__meta:empty {
    display: none;
  }

  .topbar__actions {
    flex-basis: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .brand img {
    height: 34px;
  }

  h1 {
    font-size: 24px;
  }

  .back-link {
    margin-bottom: 3px;
    font-size: 12px;
  }
}

/* ---------- panel: adresy i linki ---------- */

.panel-row__fields {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.panel-row__fields .panel-row__meta {
  margin: 0;
}

.slug-field {
  display: flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.slug-field:focus-within {
  border-color: var(--accent);
  outline: 3px solid rgba(190, 75, 45, 0.2);
}

.slug-field__prefix {
  display: flex;
  align-items: center;
  max-width: 45%;
  padding: 0 4px 0 12px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
  direction: rtl;
}

.panel-field .slug-field input {
  flex: 1;
  min-width: 80px;
  padding-left: 0;
  border: 0;
  outline: 0;
}

.slug-field .button--small {
  margin: 4px;
}

.slug-hint {
  color: var(--accent-dark);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.link-button:hover {
  color: var(--accent);
}

.button--small {
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.button--danger {
  background: #a3261b;
}

.button--danger:hover {
  background: #7d1b13;
}

.panel-back {
  margin: 0 0 14px;
  font-weight: 700;
}

.panel-back a {
  color: var(--accent-dark);
  text-decoration: none;
}

/* ---------- panel: zdjęcia galerii ---------- */

.photo-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 650;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.photo-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: #e7e0d4;
  cursor: grab;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.photo-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.photo-tile--placeholder {
  border: 2px dashed var(--accent);
  background: rgba(190, 75, 45, 0.08);
}

.photo-tile.is-dragging {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  opacity: 0.92;
  pointer-events: none;
  cursor: grabbing;
}

.photo-tile.is-moved {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

body.is-dragging-photo {
  cursor: grabbing;
  user-select: none;
}

.photo-tile__number,
.photo-tile__cover,
.photo-tile__trashed {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(22, 22, 22, 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.photo-tile__cover {
  display: none;
  top: auto;
  bottom: 6px;
  background: var(--accent);
}

.photo-tile.is-cover .photo-tile__cover {
  display: block;
}

.photo-tile__trashed {
  display: none;
  top: 50%;
  left: 50%;
  background: #a3261b;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

.photo-tile.is-trashed img {
  filter: grayscale(1);
  opacity: 0.35;
}

.photo-tile.is-trashed .photo-tile__trashed {
  display: block;
}

.photo-tile__actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}

.photo-tile__button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.photo-tile__button:hover {
  background: #fff;
  color: var(--accent);
}

.photo-tile.is-trashed .photo-tile__button--trash {
  background: #a3261b;
  color: #fff;
}

.panel-actions--photos {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.save-status {
  color: var(--accent-dark);
  font-weight: 700;
}

.trash {
  margin-top: 28px;
}

.trash-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 4px 16px;
  margin: 10px 0 14px;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.trash-list label {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.trash__empty {
  margin-top: 12px;
}
