/* ────────────────────────────────────────────────────────────────────────
   Mika Galerie — Cooles, junges Design
   Kräftige Farben · Runde Ecken · Spielerische Typografie
   ──────────────────────────────────────────────────────────────────────── */

:root {
  --bg:         #eef4fb;
  --bg-card:    #ffffff;
  --header-bg:  #1565c0;
  --accent:     #1976d2;
  --accent-h:   #1251a3;
  --accent2:    #f5a623;
  --accent3:    #26c281;
  --text:       #1a2333;
  --text-dim:   #5a6a82;
  --danger:     #d94040;
  --border:     #c4d8f0;

  --shadow-card:  0 4px 18px rgba(30, 80, 160, .14), 0 1px 4px rgba(30,80,160,.08);
  --shadow-modal: 0 12px 60px rgba(20, 60, 140, .22);

  --radius:     18px;
  --radius-sm:  10px;
  --header-h:   68px;

  --font-fun:   'Trebuchet MS', 'Arial Rounded MT Bold', 'Nunito', sans-serif;
  --font-body:  -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; scroll-behavior: smooth; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ── Typography helpers ─────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--header-bg);
  box-shadow: 0 3px 12px rgba(20, 80, 180, .35);
  gap: 1rem;
}

.site-title {
  font-family: var(--font-fun);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 2px 0 rgba(0,0,0,.12);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1.2rem;
  border: none;
  background: #fff;
  color: var(--accent);
  font-family: var(--font-fun);
  font-size: .88rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  transition: background .2s, transform .15s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-add:hover, .btn-add:focus-visible {
  background: var(--accent2);
  color: #fff;
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(30, 100, 200, .35);
  outline: none;
}

.btn-logout {
  display: inline-block;
  padding: .45rem 1rem;
  border: 2px solid rgba(255,255,255,.7);
  background: transparent;
  color: #fff;
  font-family: var(--font-body);
  font-size: .8rem;
  border-radius: 999px;
  text-decoration: none;
  transition: background .2s, color .2s;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ═══════════════════════════════════════════════════════════════════════
   GALLERY GRID
   ═══════════════════════════════════════════════════════════════════════ */
main { min-height: calc(100vh - var(--header-h)); }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2rem 1.75rem;
  padding: 2.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Artwork card ────────────────────────────────────────────────────────── */
.artwork {
  cursor: pointer;
  list-style: none;
  transition: transform .25s ease, box-shadow .25s ease;
  border-radius: var(--radius);
}
.artwork:hover { transform: translateY(-6px) rotate(-1deg); }
.artwork:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.mat {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: .85rem .85rem 2.4rem;
  box-shadow: var(--shadow-card);
  position: relative;
  border: 2px solid var(--border);
}

.artwork img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #d0e8f8;
  border-radius: var(--radius-sm);
}

/* Caption */
.artwork-info {
  padding: .65rem 0 0;
  text-align: center;
}
.artwork-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.artwork-date {
  margin-top: .2rem;
  font-size: .72rem;
  color: var(--text-dim);
}

/* Delete button */
.artwork-delete {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,100,100,.85);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: .85rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s;
  z-index: 10;
}
.artwork:hover .artwork-delete,
.artwork:focus-within .artwork-delete { opacity: 1; }

/* ── Empty / loading / error states ────────────────────────────────────── */
.gallery-empty,
.gallery-loading,
.gallery-error {
  text-align: center;
  padding: 6rem 2rem;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1.8;
}
.gallery-empty { font-size: 1.1rem; }
.gallery-error { color: var(--danger); }

.load-more {
  display: flex;
  justify-content: center;
  padding: 2rem;
}
.btn-load-more {
  background: var(--accent2);
  border: none;
  color: var(--text);
  padding: .6rem 2rem;
  font-size: .9rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.btn-load-more:hover { background: #ffc233; transform: scale(1.04); }

/* ═══════════════════════════════════════════════════════════════════════
   LIGHTBOX
   ═══════════════════════════════════════════════════════════════════════ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(10, 30, 60, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .2s ease;
}
.lightbox[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(92vw, 1200px);
  max-height: 94dvh;
}

.lightbox-inner img {
  max-width: 100%;
  max-height: calc(94dvh - 80px);
  object-fit: contain;
  box-shadow: 0 16px 64px rgba(0,0,0,.6);
  display: block;
  border-radius: var(--radius-sm);
}

.lightbox-caption {
  text-align: center;
  padding-top: 1rem;
  font-size: .9rem;
  color: rgba(255,255,255,.75);
  font-style: italic;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  -webkit-tap-highlight-color: transparent;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { background: var(--accent2); }

.lightbox-close {
  top: 1rem; right: 1rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
}
.lightbox-prev,
.lightbox-next {
  top: 50%; transform: translateY(-50%);
  width: 44px; height: 54px;
  font-size: 1.8rem;
  padding-bottom: 2px;
}
.lightbox-prev { left: .5rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.lightbox-next { right: .5rem; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

.lightbox-prev[hidden],
.lightbox-next[hidden] { display: none; }

/* ═══════════════════════════════════════════════════════════════════════
   UPLOAD MODAL
   ═══════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(10, 40, 90, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .2s ease;
}
.modal-overlay[hidden] { display: none; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-modal);
  animation: slideUp .25s ease;
  padding: 1.5rem;
}
@media (min-width: 640px) {
  .modal { border-radius: var(--radius); }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-title {
  font-family: var(--font-fun);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: .25rem;
  line-height: 1;
  border-radius: 50%;
  transition: background .2s;
}
.modal-close:hover { background: #ddeeff; color: var(--accent); }

/* Drop zone */
.drop-zone {
  border: 3px dashed #90bce8;
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  line-height: 1.7;
  background: #f0f7ff;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #e0f0ff;
}
.drop-zone svg { margin-bottom: .75rem; opacity: .6; color: var(--accent); }
.drop-link { color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 600; }
.drop-hint { font-size: .75rem; margin-top: .3rem; opacity: .6; }

/* Preview grid */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: .5rem;
  margin-bottom: 1.25rem;
}
.preview-item {
  position: relative;
  aspect-ratio: 1;
  background: #d0e8f8;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.preview-remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 22px; height: 22px;
  background: rgba(255,60,100,.8);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: .7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Form fields */
.field-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text);
  margin-bottom: .4rem;
}
.field-optional { opacity: .55; font-weight: 400; }
.field-input {
  width: 100%;
  background: #f0f7ff;
  border: 2px solid #a8ccee;
  color: var(--text);
  padding: .65rem .85rem;
  font-family: var(--font-body);
  font-size: .95rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .2s;
  margin-bottom: 1.25rem;
}
.field-input:focus { border-color: var(--accent); background: #fff; }
.field-input::placeholder { color: var(--text-dim); opacity: .6; }

/* Progress */
.upload-progress { margin-bottom: 1rem; }
.progress-bar-track {
  height: 8px;
  background: #c8e0f8;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: .4rem;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px;
  transition: width .15s ease;
}
.progress-label {
  font-size: .78rem;
  color: var(--text-dim);
}

/* Modal action buttons */
.modal-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  padding-top: .5rem;
}
.btn-primary, .btn-secondary {
  padding: .65rem 1.5rem;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 999px;
  font-family: var(--font-fun);
  transition: all .2s;
}
.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  box-shadow: 0 3px 10px rgba(30, 100, 200, .35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-h);
  transform: scale(1.04);
}
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  border: 2px solid #b0ccee;
  color: var(--text-dim);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2px solid var(--accent);
  color: var(--text);
  padding: .75rem 1.75rem;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  z-index: 999;
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(30, 80, 180, .22);
  animation: fadeIn .2s ease;
}
.toast[hidden] { display: none; }
.toast.toast-error { border-color: var(--danger); color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #c8e0ff 0%, #e0f0ff 50%, #c8f0e0 100%);
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  padding: 1.5rem;
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: 0 8px 40px rgba(20, 60, 160, .18);
  text-align: center;
}

.login-logo {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: .5rem;
  display: block;
}

.login-title {
  font-family: var(--font-fun);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: .25rem;
}

.login-subtitle {
  font-size: .88rem;
  color: var(--text-dim);
  margin-bottom: 1.75rem;
}

.login-error {
  background: #fff0f0;
  border: 2px solid var(--danger);
  color: var(--danger);
  font-size: .85rem;
  padding: .65rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  text-align: left;
}

.login-card .field-label { text-align: left; }

.btn-login {
  width: 100%;
  margin-top: .5rem;
  font-size: 1rem;
  padding: .75rem;
  border-radius: 999px;
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem 1rem;
    padding: 1.5rem 1rem;
  }
  .mat { padding: .6rem .6rem 2rem; }
  .site-header { padding: 0 1rem; }
  .site-title { font-size: 1.2rem; }
}

@media (max-width: 380px) {
  .gallery {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem .75rem;
    padding: 1.25rem .75rem;
  }
}

