:root {
  color-scheme: light;
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-text: #14171a;
  --color-muted: #5b6470;
  --color-border: #d9dde2;
  --color-primary: #223164;
  --color-primary-hover: #182348;
  --color-accent: #dca028;
  --color-accent-hover: #c78e1e;
  --color-danger: #b3261e;
  --color-danger-bg: #fdecea;
  --focus-ring: 0 0 0 3px rgba(34, 49, 100, 0.45);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
.btn {
  font: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
}

.app-header-inner .logo {
  height: auto;
  width: auto;
  max-height: 40px;
  max-width: 160px;
  min-width: 0;
  justify-self: start;
}

@media (max-width: 560px) {
  .app-header-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 0.4rem;
  }

  .app-header-inner .logo {
    justify-self: center;
    max-height: 32px;
    max-width: 130px;
  }

  .header-actions {
    justify-self: center;
    width: 100%;
  }

  .header-actions .btn {
    width: 100%;
  }
}

.header-text {
  min-width: 0;
  text-align: center;
}

.app-header h1 {
  font-size: 1.1rem;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--color-primary);
}

.muted {
  color: var(--color-muted);
  font-size: 0.9rem;
  margin: 0.15rem 0 0;
}

.header-actions {
  justify-self: end;
}

.info-box {
  max-width: 1200px;
  margin: 1.25rem auto 0;
  padding: 1.25rem 1.5rem;
  background: #eaf0fb;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--color-text);
}

.info-box-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
}

.info-box[open] .info-box-title {
  margin-bottom: 0.75rem;
}

.info-box ul {
  margin: 0;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .info-box {
    margin: 1rem 0.75rem 0;
    padding: 1rem 1.1rem;
    font-size: 1rem;
  }
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

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

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
  text-decoration: none;
  width: 100%;
}

.btn-download:hover {
  background: #fdf3e2;
  border-color: var(--color-accent);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: #fdf3e2;
  border-color: var(--color-accent);
}

.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;
}

/* Login */

#login-view {
  display: flex;
  justify-content: center;
  padding-top: 3rem;
}

#login-view[hidden] {
  display: none;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card label {
  font-weight: 600;
}

.login-card input {
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 44px;
}

.error-message {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  margin: 0;
}

/* Folders (albums within an event) */

.categories-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.categories-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

.categories-select {
  display: none;
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 44px;
  background: var(--color-surface);
  color: var(--color-text);
}

@media (max-width: 600px) {
  .categories-bar {
    display: none;
  }

  .categories-select {
    display: block;
  }
}

.category-pill {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 40px;
}

.category-pill:hover {
  border-color: var(--color-accent);
}

.category-pill[aria-selected="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.categories-divider {
  width: 1px;
  align-self: stretch;
  background: var(--color-border);
  margin: 0.25rem 0.25rem;
}

/* Distinguishes "All Photos" (a computed view) from General/folders (real
   places to upload into) — same dashed treatment as the add-folder control,
   so it reads as a control rather than a peer of the folder pills. */
.category-pill-view {
  border-style: dashed;
  color: var(--color-primary);
}

.category-pill-view:hover {
  border-color: var(--color-accent);
}

.category-pill-view[aria-selected="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  border-style: solid;
  color: #fff;
}

.btn-add-folder {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  color: var(--color-primary);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  min-height: 40px;
}

.btn-add-folder:hover {
  border-color: var(--color-accent);
}

.add-folder-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.add-folder-form input {
  flex: 1;
  min-width: 160px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 40px;
}

/* Upload */

.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-muted);
  margin-top: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--color-accent);
  background: #fdf3e2;
  color: var(--color-primary);
}

.upload-progress {
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}

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

#upload-progress-label {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* Gallery grid */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 600px) {
  .photo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

.photo-card {
  margin: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.photo-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.photo-thumb img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--color-bg);
}

.photo-card figcaption {
  padding: 0.6rem 0.75rem 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.photo-card .filename {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-card .folder-name {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--color-primary);
}

.photo-card .folder-name[hidden] {
  display: none;
}

.photo-card .folder-icon {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.photo-card .upload-date {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.photo-card .btn-download {
  margin: 0.6rem 0.75rem 0.75rem;
  width: auto;
}

/* Footer */

.site-footer {
  max-width: 1200px;
  margin: 2rem auto 1.5rem;
  padding: 0 1.25rem;
  text-align: center;
}

.site-footer a {
  color: var(--color-muted);
  font-size: 0.9rem;
  text-decoration: underline;
}

.site-footer a:hover {
  color: var(--color-primary);
}

/* Terms & Conditions page */

.terms-page {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.25rem 2rem;
}

.terms-content {
  font-size: 1.05rem;
  line-height: 1.7;
}

.terms-content h2 {
  color: var(--color-primary);
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

.terms-content p {
  margin: 0 0 0.75rem;
}

/* Lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-figure {
  margin: 0;
  max-width: min(90vw, 1100px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.lightbox-image {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.lightbox-caption {
  color: #f2f3f5;
  font-size: 0.9rem;
  text-align: center;
}

.lightbox-btn {
  position: absolute;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 999px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

@media (max-width: 600px) {
  .lightbox-prev {
    left: 0.25rem;
  }
  .lightbox-next {
    right: 0.25rem;
  }
}
