:root {
  color-scheme: light;
  --bg: #ffffff;
  --paper: #fbfaf8;
  --ink: #201f1d;
  --muted: #716c66;
  --soft: #9c958d;
  --line: #e8e2da;
  --line-strong: #d8d0c7;
  --red: #c8102e;
  --red-dark: #9e0d25;
  --blue: #315a76;
  --cream: #f4f0ea;
  --danger: #9b2433;
  --shadow: 0 18px 60px rgba(35, 31, 26, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

body.is-lightbox-open { overflow: hidden; }
button, input, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }

.view[hidden], .lightbox[hidden], .toast[hidden], .empty[hidden], .selection-panel[hidden] { display: none !important; }
.app-shell { min-height: 100vh; }

.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.portal {
  position: relative;
  width: min(1100px, 100%);
  min-height: min(720px, calc(100dvh - 56px));
  display: grid;
  grid-template-columns: minmax(120px, 0.78fr) minmax(280px, 1.28fr);
  align-items: center;
  gap: clamp(28px, 7vw, 92px);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #fff 0%, #fff 52%, var(--paper) 100%);
  box-shadow: var(--shadow);
  padding: clamp(24px, 6vw, 76px);
}

.portal__content {
  max-width: 620px;
  justify-self: center;
  text-align: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0;
}

.portal h1 {
  font-size: clamp(3rem, 7vw, 6.8rem);
  line-height: 0.94;
}

.portal__subline {
  margin: 18px auto 30px;
  max-width: 440px;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.16rem);
}

.login-form {
  width: min(420px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.login-form input,
.search input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0 14px;
  border-radius: 4px;
}

.login-form input:focus,
.search input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.10);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.button:hover { transform: translateY(-1px); border-color: var(--ink); }
.button--primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.button--primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.button--ghost { background: #fff; }

.hint {
  margin: 14px 0 0;
  color: var(--soft);
  font-size: 0.88rem;
}

.form-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 0.92rem;
}

.portal__footer {
  position: absolute;
  right: clamp(18px, 4vw, 36px);
  bottom: 18px;
  color: var(--soft);
  font-size: 0.86rem;
}

.flag {
  position: relative;
  display: block;
  background: var(--red);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.flag::before,
.flag::after,
.flag span::before,
.flag span::after {
  content: "";
  position: absolute;
  background: #fff;
}
.flag::before { left: 30%; top: 0; width: 12%; height: 100%; }
.flag::after { left: 0; top: 43%; width: 100%; height: 18%; }
.flag span::before { left: 34%; top: 0; width: 5%; height: 100%; background: var(--red); }
.flag span::after { left: 0; top: 48%; width: 100%; height: 8%; background: var(--red); }
.flag--large {
  width: min(340px, 28vw);
  aspect-ratio: 37 / 28;
  justify-self: center;
}
.flag--small {
  width: 42px;
  height: 30px;
  flex: 0 0 auto;
}

.portal-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, var(--safe-top)) clamp(18px, 4vw, 44px) 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}
.portal-header--sticky {
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.brand strong { display: block; font-size: 0.98rem; }
.brand small { display: block; color: var(--muted); font-size: 0.78rem; }
.brand--button {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page {
  width: min(1400px, calc(100% - clamp(20px, 5vw, 72px)));
  margin: 0 auto;
  padding: clamp(22px, 4vw, 46px) 0 72px;
}
.page--narrow { width: min(1100px, calc(100% - clamp(20px, 5vw, 72px))); }

.section-heading {
  margin-bottom: 24px;
}
.section-heading h2,
.album-summary h2 {
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 1;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 18px;
}

.album-card {
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  overflow: hidden;
  text-align: left;
}
.album-card__cover {
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, var(--cream), #fff);
  border-bottom: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.album-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.album-card__cover span {
  color: var(--muted);
  padding: 22px;
  text-align: center;
}
.album-card__body {
  padding: 18px;
  display: grid;
  gap: 9px;
}
.album-card h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 500;
}
.album-card p {
  margin: 0;
  color: var(--muted);
}
.album-card__meta {
  color: var(--blue);
  font-size: 0.9rem;
}

.album-hero {
  position: relative;
  min-height: clamp(310px, 52vw, 620px);
  border: 1px solid var(--line);
  background: var(--cream);
  overflow: hidden;
}
.album-hero img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  display: block;
  filter: saturate(0.96);
}
.album-hero__overlay {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(22px, 4vw, 46px);
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.58));
}
.album-hero__overlay h1 {
  font-size: clamp(2.6rem, 6vw, 6.4rem);
  line-height: 0.95;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
}
.album-hero__overlay span {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.38);
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
}

.album-summary {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin: 28px 0 18px;
}
.album-summary p {
  margin: 0 0 5px;
  color: var(--red);
  font-weight: 800;
}
.gallery-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.search { width: 210px; max-width: 100%; }
.search input { min-height: 42px; }

.selection-panel {
  margin: 0 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.status {
  min-height: 1.4em;
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 0.92rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: clamp(10px, 1.6vw, 18px);
}
.photo-tile {
  position: relative;
  display: block;
  min-width: 0;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper);
  overflow: hidden;
}
.photo-tile:nth-child(5n + 2) { aspect-ratio: 3 / 4; }
.photo-tile:nth-child(7n + 4) { aspect-ratio: 1 / 1; }
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.42s ease, filter 0.42s ease;
}
.photo-tile:hover img { transform: scale(1.035); filter: saturate(1.04); }
.photo-tile.is-selected::after {
  content: "Ausgewählt";
  position: absolute;
  right: 9px;
  bottom: 9px;
  padding: 5px 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
}
.selection-toggle {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.empty {
  border: 1px solid var(--line);
  padding: 32px;
  background: var(--paper);
  text-align: center;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  height: 100vh;
  height: 100dvh;
  background: #fff;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: var(--safe-top) 0 var(--safe-bottom);
  overflow: hidden;
}
.lightbox__top,
.lightbox__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-color: var(--line);
  background: #fff;
}
.lightbox__top {
  min-height: 72px;
  padding: 0 clamp(12px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
}
.lightbox__top strong { font-size: 0.98rem; }
.lightbox__bottom {
  min-height: 70px;
  padding: 8px clamp(10px, 3vw, 28px);
  border-top: 1px solid var(--line);
  justify-content: center;
}
.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 24px 64px;
}
.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  flex: 0 1 auto;
}
.icon-button,
.tool-button {
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}
.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.4rem;
}
.tool-button {
  padding: 0 14px;
  border-radius: 4px;
}
.tool-button.is-active,
.icon-button.is-active {
  border-color: var(--red);
  color: var(--red);
}
.nav-button {
  position: absolute;
  top: 50%;
  z-index: 110;
  transform: translateY(-50%);
  width: 44px;
  height: 58px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 2.4rem;
  line-height: 1;
}
.nav-button--prev { left: 12px; }
.nav-button--next { right: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 200;
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 24px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.noscript {
  position: fixed;
  inset: auto 16px 16px;
  padding: 16px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  z-index: 300;
}

@media (min-width: 1280px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); }
}

@media (min-width: 1600px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 760px) {
  .login-view { padding: 12px; }
  .portal {
    min-height: calc(100dvh - 24px);
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 28px 18px 54px;
  }
  .flag--large { width: min(210px, 68vw); }
  .portal h1 { font-size: clamp(3rem, 16vw, 4.7rem); }
  .login-form { grid-template-columns: 1fr; }
  .portal__footer { left: 18px; right: 18px; text-align: center; }

  .portal-header {
    min-height: 68px;
    padding-inline: 12px;
  }
  .brand small { display: none; }
  .brand strong { font-size: 0.9rem; }
  .flag--small { width: 34px; height: 24px; }
  .header-actions { gap: 6px; }
  .button { min-height: 38px; padding-inline: 10px; font-size: 0.86rem; }
  .page, .page--narrow { width: calc(100% - 18px); padding-top: 18px; }
  .album-grid { gap: 12px; }
  .album-hero { min-height: 320px; }
  .album-hero__overlay {
    display: grid;
    align-content: end;
    padding: 18px;
  }
  .album-hero__overlay h1 { font-size: clamp(2.5rem, 13vw, 4rem); }
  .album-summary {
    display: grid;
    margin-top: 20px;
  }
  .gallery-tools {
    justify-content: stretch;
  }
  .search { width: 100%; }
  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .photo-tile,
  .photo-tile:nth-child(5n + 2),
  .photo-tile:nth-child(7n + 4) {
    aspect-ratio: 1 / 1;
  }
  .selection-panel { align-items: stretch; display: grid; }
  .lightbox {
    height: 100dvh;
  }
  .lightbox__top { min-height: 56px; }
  .stage { padding: 8px 0; }
  .lightbox-image {
    max-width: 100vw;
    max-height: 100%;
  }
  .lightbox__bottom {
    min-height: 68px;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .tool-button { min-width: max-content; min-height: 42px; padding-inline: 12px; }
  .nav-button {
    top: 50%;
    bottom: auto;
    width: 42px;
    height: 46px;
    font-size: 2rem;
  }
  .nav-button--prev { left: 8px; }
  .nav-button--next { right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
