/* ── Custom properties ── */
:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666666;
  --border: #d0d0d0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --drop-zone-bg: #f0f4ff;
  --drop-zone-active: #dbeafe;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --btn-text: #ffffff;
  --overlay: rgba(0, 0, 0, 0.6);
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --duration: 0.15s;
  --font-base: 0.9375rem;
  --font-sm: 0.875rem;
  --font-xs: 0.8125rem;
}

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

body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.site-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
}

.site-nav {
  display: flex;
  gap: 1rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-left: auto;
}

.nav-link--active {
  text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent);
}

.nav-link--active::before {
  content: "[";
}
.nav-link--active::after {
  content: "]";
}

/* ── Main ── */
main {
  flex: 1;
  padding: 2rem 1rem;
}

.main--centered {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Footer ── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-sm);
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card__title {
  font-size: 1.5rem;
}

/* ── Banners ── */
.banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
}

.banner--success {
  background: var(--success-bg);
  color: var(--success-text);
}

.banner--error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* ── Upload section ── */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.upload-section__heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--drop-zone-bg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition:
    background var(--duration),
    border-color var(--duration);
}

.drop-zone--active {
  background: var(--drop-zone-active);
  border-color: var(--accent);
}

.drop-zone__label {
  color: var(--text-muted);
  font-size: var(--font-base);
}

.drop-zone__input {
  font-size: var(--font-sm);
  color: var(--text);
}

/* ── URL row ── */
.url-row {
  display: flex;
  gap: 0.5rem;
}

.url-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-base);
}

.url-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── Login form ── */
.login-card {
  max-width: 380px;
  width: 100%;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: var(--font-sm);
  font-weight: 500;
}

.form-input {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-base);
  width: 100%;
}

.form-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-btn {
  width: 100%;
  padding: 0.625rem 1.25rem;
  justify-content: center;
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: var(--accent);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  line-height: 1.5;
  cursor: pointer;
  transition: background var(--duration);
  white-space: nowrap;
}

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

.btn--small {
  padding: 0.3rem 0.75rem;
  font-size: var(--font-sm);
}

.btn--danger {
  background: var(--danger);
}

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

.btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  align-items: center;
  justify-content: center;
}

.modal-backdrop:target {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  max-width: 20rem;
  text-align: center;
}

.modal__body {
  margin: 0 0 1.25rem;
}

.modal__form {
  display: inline-flex;
}

.modal__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ── Gallery grid ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  padding: 0;
}

.gallery-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--duration);
}

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

.gallery-card__link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
}

.gallery-card__select {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--duration);
  cursor: pointer;
}

.gallery-card:hover .gallery-card__select {
  opacity: 1;
}

.gallery-card--selected .gallery-card__select {
  opacity: 1;
}

.gallery-card--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

#bulk-toolbar:not([hidden]) {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#bulk-modal:not([hidden]) {
  display: flex;
}

.gallery-card__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.gallery-card__date {
  padding: 0.5rem 0.75rem;
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.gallery-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 1rem;
}

/* ── Image detail ── */
.image-detail {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.image-detail__link {
  display: flex;
  justify-content: center;
}

.image-detail__img {
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
  cursor: zoom-in;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .card {
    padding: 1.25rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .url-row {
    flex-direction: column;
  }

  .header-actions {
    gap: 0.5rem;
  }

  .header-actions .btn {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-sm);
  }
}

/* ── Dark mode ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --surface: #1e1e1e;
    --text: #e5e5e5;
    --text-muted: #999999;
    --border: #333333;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --success-bg: #14532d;
    --success-text: #bbf7d0;
    --error-bg: #7f1d1d;
    --error-text: #fecaca;
    --drop-zone-bg: #1e2a3a;
    --drop-zone-active: #1e3a5f;
  }
}
