:root {
  --ink: #1f2322;
  --muted: #6d7370;
  --paper: #f6f6f4;
  --panel: #ffffff;
  --line: #e3e4e1;
  --accent: #2f5d62;
  --accent-soft: #eef3f2;
  --danger: #b3352b;
  --sans: 'Avenir Next', 'Helvetica Neue', system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: var(--paper); }

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body.lightbox-open { overflow: hidden; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3, p { margin-top: 0; }

/* ---------- shell / masthead ---------- */

.shell { width: min(1080px, calc(100% - 40px)); margin: auto; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
}
.storage-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}
.status-dot { width: 6px; height: 6px; background: #4a7c59; border-radius: 50%; }

.auth-nav { display: flex; align-items: center; gap: 18px; }
.auth-link {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  text-decoration: none;
}
.auth-link:hover { color: var(--ink); }

/* ---------- landing intro ---------- */

.intro { max-width: 620px; padding: 72px 0 64px; }
.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: lowercase;
}
h1 {
  margin-bottom: 20px;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.1;
}
h1 em { font-style: normal; }
.lede { max-width: 420px; margin: 0; color: var(--muted); }
.intro-link { margin-top: 28px; }
.intro-link a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  text-underline-offset: 3px;
}
.intro-link a:hover { text-decoration: underline; }

/* ---------- panels / cards ---------- */

.upload-panel { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.panel-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  text-transform: lowercase;
}
.panel-label span:last-child { color: var(--muted); }

.drop-zone {
  display: flex;
  min-height: 200px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 1px dashed rgba(31, 35, 34, .35);
  border-radius: 6px;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.drop-zone:hover, .drop-zone.is-dragging { background: var(--accent-soft); border-color: var(--accent); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-title { font-size: 16px; font-weight: 600; }
.drop-subtitle { margin-top: 6px; color: var(--muted); font-size: 13px; }
.drop-subtitle strong { color: var(--accent); font-weight: 600; }

.preview-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.preview-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: #e8e9e6; }
.preview-meta { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.preview-label { color: var(--muted); font-size: 12px; text-transform: lowercase; }
.preview-meta strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-meta span:last-child { margin: 0; color: var(--muted); font-size: 12px; }

/* ---------- buttons / messages ---------- */

.button {
  border: 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  transition: background-color .15s ease, color .15s ease;
}
.button:hover { opacity: .92; }
.button:disabled { cursor: wait; opacity: .55; }
.button-dark { padding: 10px 16px; color: #fff; background: var(--ink); }
.button-dark:hover { opacity: 1; background: #3a403d; }
.button span { margin-left: 8px; font-size: 14px; }

.message { min-height: 17px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.message.error { color: var(--danger); }
.message.success { color: #3d6b3f; }
.message.loading { color: var(--ink); }

/* ---------- embed links ---------- */

.embed-panel { margin-top: 48px; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.embed-filename { overflow: hidden; max-width: 240px; text-overflow: ellipsis; white-space: nowrap; }
.embed-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 14px; margin-top: 10px; }
.embed-label { color: var(--muted); font-size: 12px; text-transform: lowercase; }
.embed-input {
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-family: var(--sans);
  font-size: 13px;
}
.embed-input:focus { border-color: var(--accent); outline: none; }
.embed-copy { padding: 9px 14px; }

/* ---------- manage list ---------- */

.manage-section, .gallery-section { padding-top: 72px; }
.section-heading { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.section-heading .eyebrow { margin-bottom: 6px; }
h2 { margin-bottom: 0; font-size: clamp(22px, 3vw, 30px); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }

.manage-list { display: grid; gap: 12px; padding-top: 20px; }
.manage-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.manage-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: #e8e9e6; }
.manage-meta { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.manage-meta strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.manage-meta span { margin: 0; color: var(--muted); font-size: 12px; }
.manage-actions { display: flex; gap: 8px; }
.manage-action { padding: 8px 12px; }
.manage-delete { padding: 8px 12px; color: var(--danger); background: transparent; border: 1px solid rgba(179, 53, 43, .4); }
.manage-delete:hover { opacity: 1; color: #fff; background: var(--danger); }

/* ---------- gallery ---------- */

.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px 16px; padding-top: 20px; }
.image-trigger { display: block; width: 100%; padding: 0; border: 0; color: inherit; background: transparent; cursor: zoom-in; font: inherit; text-align: left; }
.image-frame {
  position: relative;
  aspect-ratio: 1 / 1.12;
  overflow: hidden;
  background: #e8e9e6;
  border-radius: 8px;
}
.image-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.image-number {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 7px;
  color: #fff;
  background: rgba(20, 24, 23, .55);
  border-radius: 4px;
  font-size: 11px;
}
.image-caption { display: flex; justify-content: space-between; gap: 10px; padding-top: 8px; color: var(--muted); font-size: 12px; }

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  min-height: 160px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(31, 35, 34, .3);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}
.empty-state span { font-size: 26px; }
.empty-state p { margin: 6px 0 0; font-size: 14px; }
.error-state span { color: var(--danger); }

/* ---------- lightbox ---------- */

.lightbox { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: clamp(16px, 4vw, 48px); color: #fff; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(20, 24, 23, .88); }
.lightbox-panel { position: relative; z-index: 1; display: flex; width: min(1120px, 100%); max-height: 100%; flex-direction: column; }
.lightbox-header { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 20px; padding-bottom: 12px; border-bottom: 1px solid rgba(255, 255, 255, .18); }
.lightbox-kicker, .lightbox-counter { margin: 0; font-size: 12px; color: rgba(255, 255, 255, .55); text-transform: lowercase; }
.lightbox-title { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lightbox-close {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 6px;
  color: #fff;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  transition: background-color .15s ease, color .15s ease;
}
.lightbox-close:hover { color: #1f2322; background: #fff; }
.lightbox-stage { position: relative; display: flex; min-height: 0; flex: 1; align-items: center; justify-content: center; gap: clamp(16px, 4vw, 40px); padding: 20px 0; }
.lightbox-image-wrap {
  position: relative;
  display: grid;
  width: min(860px, 100%);
  max-height: calc(100vh - 220px);
  min-height: 180px;
  place-items: center;
  overflow: hidden;
  background: rgba(255, 255, 255, .05);
  border-radius: 8px;
}
.lightbox-image { display: block; max-width: 100%; max-height: calc(100vh - 220px); object-fit: contain; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); }
.lightbox-image[hidden] { display: none; }
.lightbox-status { position: absolute; color: rgba(255, 255, 255, .7); font-size: 14px; }
.lightbox-status[hidden] { display: none; }
.lightbox-nav {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 6px;
  color: #fff;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  font-weight: 300;
  transition: background-color .15s ease, color .15s ease;
}
.lightbox-nav:hover { color: #1f2322; background: #fff; }
.lightbox-nav:disabled { cursor: default; opacity: .35; }
.lightbox-nav:disabled:hover { color: #fff; background: transparent; }
.lightbox-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .18); }
.lightbox-hint { color: rgba(255, 255, 255, .5); font-size: 12px; }
.lightbox-actions { display: flex; gap: 18px; }
.lightbox-actions a { color: #fff; font-size: 13px; text-decoration: none; text-underline-offset: 3px; }
.lightbox-actions a:hover { color: #9cc7cb; text-decoration: underline; }

/* ---------- auth / forms ---------- */

.login-intro { padding-bottom: 56px; }
.login-panel { max-width: 440px; }
.login-submit { width: 100%; margin-top: 4px; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; text-transform: lowercase; }
.field-optional { font-weight: 400; }
.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-family: var(--sans);
  font-size: 14px;
}
.field-input:focus { border-color: var(--accent); outline: none; }
.field-check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--muted); font-size: 13px; cursor: pointer; }
.import-textarea { min-height: 140px; resize: vertical; }

.admin-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 48px; }

.user-item { grid-template-columns: minmax(0, 1fr) auto auto; }
.user-ident { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  flex: none;
  place-items: center;
  color: #fff;
  background: var(--ink);
  border-radius: 50%;
  font-size: 15px;
  font-weight: 600;
}
.user-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.badge-admin { color: #fff; background: var(--accent); }
.badge-on { color: var(--accent); background: rgba(47, 93, 98, .12); }
.badge-off { color: var(--muted); background: #eceeec; }
.user-actions { flex-wrap: wrap; justify-content: flex-end; }

/* ---------- footer ---------- */

.footer {
  display: flex;
  justify-content: space-between;
  width: min(1080px, calc(100% - 40px));
  margin: 80px auto 0;
  padding: 18px 0 26px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .shell, .footer { width: min(100% - 30px, 600px); }
  .masthead { padding-top: 18px; }
  .storage-note { font-size: 11px; }
  .intro { padding: 56px 0 48px; }
  .upload-panel { padding: 16px; }
  .drop-zone { min-height: 170px; }
  .preview-row { grid-template-columns: 56px 1fr; }
  .preview-row img { width: 56px; height: 56px; }
  .preview-row .button { grid-column: 1 / -1; width: 100%; }
  .manage-section, .gallery-section { padding-top: 56px; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 20px 12px; }
  .embed-panel { padding: 16px; }
  .embed-row { grid-template-columns: 1fr auto; }
  .embed-label { display: none; }
  .manage-item { grid-template-columns: 56px 1fr; }
  .manage-thumb { width: 56px; height: 56px; }
  .manage-actions { grid-column: 1 / -1; }
  .user-item { grid-template-columns: 1fr; }
  .user-badges { grid-column: 1 / -1; }
  .admin-forms { grid-template-columns: 1fr; }
  .footer { margin-top: 60px; }
  .lightbox { padding: 16px; }
  .lightbox-header { gap: 10px; }
  .lightbox-stage { padding: 14px 0; }
  .lightbox-image-wrap { width: 100%; max-height: calc(100vh - 190px); }
  .lightbox-image { max-height: calc(100vh - 190px); }
  .lightbox-nav { position: absolute; z-index: 2; top: 50%; transform: translateY(-50%); }
  .lightbox-prev { left: 0; }
  .lightbox-next { right: 0; }
  .lightbox-footer { align-items: flex-start; flex-direction: column; }
  .lightbox-actions { width: 100%; justify-content: space-between; }
}
