:root {
  --paper: #fffaf3;
  --panel: #fffefd;
  --ink: #22272c;
  --muted: #72706b;
  --line: #ded6ca;
  --green: #214c3b;
  --green-2: #386a52;
  --rose: #c87e79;
  --soft: #f5eee4;
  --success: #e7f1e8;
  --shadow: 0 18px 70px rgba(58, 43, 32, 0.12);
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(200, 126, 121, 0.14), transparent 26rem),
    linear-gradient(135deg, var(--paper) 0%, color-mix(in srgb, var(--paper) 86%, var(--soft)) 100%);
  font-family: var(--font-body);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 24px;
  height: 100svh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 8px 4px 22px;
}

.brand-mark {
  width: 74px;
  height: 74px;
  border: 1px solid rgba(33, 76, 59, 0.18);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.45);
}

.brand-mark span {
  width: 38px;
  height: 46px;
  display: block;
  border-left: 3px solid #c8bba7;
  border-radius: 50% 0 0 50%;
  transform: rotate(22deg);
  position: relative;
}

.brand-mark span::before,
.brand-mark span::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 14px;
  border: 2px solid #c8bba7;
  border-left: 0;
  border-radius: 50%;
  left: 7px;
}

.brand-mark span::before {
  top: 4px;
  transform: rotate(-32deg);
}

.brand-mark span::after {
  bottom: 7px;
  transform: rotate(24deg);
}

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

h1 {
  color: var(--green);
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 500;
  line-height: 1;
}

.topbar p {
  margin-top: 8px;
  color: var(--rose);
  font-size: 1.05rem;
  font-weight: 700;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--green);
  display: grid;
  place-items: center;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-link {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 750;
  text-decoration: none;
}

.admin-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.access-panel {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 253, 0.78);
  box-shadow: var(--shadow);
  padding: 34px;
}

.access-panel h2 {
  color: var(--green);
  font-family: var(--font-heading);
  font-size: clamp(1.9rem, 5vw, 3rem);
  font-weight: 500;
}

.access-panel p {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.6;
}

.workspace {
  min-height: 0;
  height: auto;
  display: grid;
  grid-template-columns: 35% 65%;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 254, 253, 0.8);
  box-shadow: var(--shadow);
}

.mobile-tabs {
  display: none;
}

.upload-panel,
.gallery-panel {
  background: rgba(255, 254, 253, 0.72);
  min-height: 0;
  overflow: auto;
}

.upload-panel {
  border-right: 1px solid var(--line);
  padding: 34px 24px;
}

.gallery-panel {
  padding: 34px 28px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border-bottom: 1px solid #e4ddd4;
  margin-bottom: 32px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 8px 16px;
  font-weight: 700;
  border-bottom: 4px solid transparent;
}

.tab.active {
  color: var(--ink);
  border-color: var(--green);
}

.upload-form {
  display: grid;
  gap: 18px;
}

.name-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

.name-field input {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
}

.intro-card {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.intro-card h2 {
  color: var(--green);
  font-family: var(--font-heading);
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 500;
  line-height: 1.08;
}

.intro-card p {
  color: var(--muted);
  line-height: 1.55;
}

.hero-photo {
  min-height: 190px;
  border-radius: 8px;
  background-position: center;
  background-size: cover;
  border: 1px solid var(--line);
}

.drop-zone {
  min-height: 310px;
  border: 2px dashed #d5c7b6;
  border-radius: 8px;
  background: rgba(250, 245, 237, 0.62);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.drop-zone.dragover {
  border-color: var(--green);
  background: #eef5ef;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.camera-mark {
  width: 144px;
  height: 144px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 18px 38px rgba(33, 76, 59, 0.24);
}

.camera-mark svg {
  width: 58px;
  height: 58px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.drop-zone strong {
  font-size: 1.35rem;
}

.drop-zone small {
  color: var(--muted);
  font-size: 1rem;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  color: var(--muted);
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.secondary-button,
.primary-button {
  min-height: 54px;
  border-radius: 8px;
  padding: 0 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-weight: 750;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.secondary-button.small {
  min-height: 42px;
  font-size: 0.92rem;
}

.queue {
  display: grid;
  gap: 10px;
}

.queue-item,
.success-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 82px;
  border: 1px solid #e5ddd3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.queue-item img {
  width: 58px;
  height: 58px;
  border-radius: 6px;
  object-fit: cover;
}

.queue-item small {
  color: var(--muted);
}

.progress {
  height: 7px;
  margin-top: 8px;
  border-radius: 999px;
  background: #dedbd5;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  background: var(--green);
}

.success-card {
  grid-template-columns: auto 1fr;
  background: var(--success);
  border-color: #cbdccf;
}

.success-icon {
  width: 42px;
  height: 42px;
  border: 2px solid #1f7a42;
  color: #1f7a42;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
}

.privacy-note {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.gallery-head h2 {
  display: inline;
  font-size: 1.85rem;
  line-height: 1;
}

.gallery-head span {
  margin-left: 8px;
  color: var(--muted);
}

.masonry {
  columns: 3 230px;
  column-gap: 8px;
}

.photo-card {
  position: relative;
  break-inside: avoid;
  margin: 0 0 8px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--soft);
}

.photo-open {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  display: block;
  position: relative;
}

.photo-card img {
  display: block;
  width: 100%;
  min-height: 160px;
  object-fit: cover;
}

.photo-open span {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  min-height: 28px;
  border-radius: 8px;
  padding: 6px 9px;
  background: rgba(34, 39, 44, 0.72);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 750;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.photo-open:hover span,
.photo-open:focus-visible span {
  opacity: 1;
  transform: translateY(0);
}

.delete-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: rgba(34, 39, 44, 0.78);
  color: #fff;
  display: none;
}

.admin-mode .delete-button {
  display: grid;
  place-items: center;
}

.empty-state,
.guest-gate {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.72);
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.empty-state h3,
.guest-gate h3 {
  color: var(--ink);
  margin-bottom: 8px;
}

.pin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 16px;
}

.pin-row input {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
}

.viewer-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow: visible;
}

.viewer-dialog::backdrop {
  background: rgba(34, 39, 44, 0.34);
  backdrop-filter: blur(4px);
}

.dialog-card {
  position: relative;
  width: min(92vw, 430px);
  border-radius: 8px;
  padding: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow-x: hidden;
}

.admin-card {
  width: min(100%, 980px);
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.admin-page {
  min-height: 100svh;
  padding: 24px;
  display: grid;
  place-items: start center;
  background:
    radial-gradient(circle at 20% 0%, rgba(200, 126, 121, 0.14), transparent 26rem),
    linear-gradient(135deg, var(--paper) 0%, color-mix(in srgb, var(--paper) 86%, var(--soft)) 100%);
}

.dialog-card h2 {
  color: var(--green);
  margin-bottom: 8px;
}

.dialog-card p,
.qr-box a {
  color: var(--muted);
}

.admin-login,
.admin-area {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.admin-login label,
.admin-area label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.palette-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 0;
  background: rgba(255, 255, 255, 0.58);
}

.palette-field legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.palette-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.palette-options label {
  display: block;
  cursor: pointer;
}

.palette-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.palette-options span {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

.palette-options input:checked + span {
  border-color: var(--green);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 18%, transparent);
}

.palette-options i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--swatch);
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex: 0 0 auto;
}

.theme-customizer {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.theme-customizer label {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 750;
}

.theme-customizer input[type="color"] {
  width: 38px;
  min-height: 34px;
  height: 34px;
  padding: 2px;
  border: 0;
  background: transparent;
}

.theme-customizer select {
  min-width: 120px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.admin-login input,
.admin-area input,
.admin-area textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  background: #fff;
  color: var(--ink);
}

.admin-area textarea {
  min-height: 112px;
  resize: vertical;
}

.admin-actions,
.branding-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.branding-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.branding-box h3 {
  margin-bottom: 4px;
}

.branding-box input {
  max-width: 280px;
  background: transparent;
}

.favicon-admin {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.favicon-admin img {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
  padding: 6px;
}

.favicon-admin input {
  max-width: 260px;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.qr-box {
  margin-top: 20px;
  display: grid;
  gap: 10px;
  justify-items: start;
}

.qr-box img {
  width: min(100%, 260px);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.qr-box a {
  overflow-wrap: anywhere;
}

.viewer-dialog {
  width: 100dvw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
}

.viewer-dialog::backdrop {
  background: rgba(18, 22, 24, 0.88);
}

.viewer-frame {
  width: 100dvw;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  padding: 18px 84px 22px;
  position: relative;
  background: rgba(18, 22, 24, 0.92);
  touch-action: pan-y;
  overflow: hidden;
}

.viewer-frame img {
  max-width: 100%;
  max-height: calc(100dvh - 104px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.36);
  will-change: transform, opacity;
  transition: transform 0.23s cubic-bezier(0.2, 0.75, 0.25, 1), opacity 0.23s ease;
}

.viewer-frame img.is-dragging {
  transition: none;
}

.viewer-frame img.slide-left {
  transform: translateX(-130%) scale(0.96);
  opacity: 0;
}

.viewer-frame img.slide-right {
  transform: translateX(130%) scale(0.96);
  opacity: 0;
}

.viewer-frame img.enter-left {
  transform: translateX(-130%) scale(0.96);
  opacity: 0;
}

.viewer-frame img.enter-right {
  transform: translateX(130%) scale(0.96);
  opacity: 0;
}

.viewer-close,
.viewer-nav {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: grid;
  place-items: center;
}

.viewer-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
}

.viewer-close svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  width: 52px;
  height: 62px;
  transform: translateY(-50%);
}

.viewer-nav:disabled {
  opacity: 0.35;
}

.viewer-nav svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viewer-nav.previous {
  left: 22px;
}

.viewer-nav.next {
  right: 22px;
}

.viewer-meta {
  position: static;
  transform: none;
  margin-top: 12px;
  min-width: min(92vw, 420px);
  border-radius: 8px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  backdrop-filter: blur(8px);
}

.viewer-meta span {
  color: rgba(255, 255, 255, 0.72);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(8px);
  min-width: min(92vw, 340px);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 14px 16px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 12px;
    display: block;
    height: auto;
    min-height: 100svh;
    overflow: visible;
  }

  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    padding: 4px 0 12px;
  }

  .brand-mark {
    width: 50px;
    height: 50px;
  }

  h1 {
    font-size: 1.9rem;
  }

  .topbar p {
    font-size: 0.9rem;
    margin-top: 4px;
  }

  .admin-link {
    min-height: 40px;
    padding: 0 12px;
  }

  .workspace {
    display: block;
    height: auto;
    min-height: auto;
  }

  .mobile-tabs {
    position: sticky;
    top: 0;
    z-index: 8;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 0;
    padding: 14px 18px 0;
    border-bottom: 1px solid #e4ddd4;
    background: rgba(255, 254, 253, 0.96);
  }

  .upload-panel > .tabs {
    display: none;
  }

  .upload-panel,
  .gallery-panel {
    padding: 18px;
    border-right: 0;
    overflow: visible;
  }

  .upload-panel {
    border-bottom: 0;
  }

  .upload-panel.hide-mobile,
  .gallery-panel.hide-mobile {
    display: none;
  }

  .intro-card {
    margin-bottom: 18px;
    padding-bottom: 18px;
  }

  .drop-zone {
    min-height: 230px;
  }

  .camera-mark {
    width: 116px;
    height: 116px;
  }

  .gallery-head {
    align-items: flex-start;
  }

  .head-actions {
    display: none;
  }

  .masonry {
    columns: 2 145px;
  }

  .viewer-frame {
    padding: 64px 14px 16px;
  }

  .viewer-frame img {
    max-height: calc(100dvh - 150px);
  }

  .viewer-nav {
    top: auto;
    bottom: 18px;
    width: 48px;
    height: 48px;
    transform: none;
  }

  .viewer-nav.previous {
    left: 14px;
  }

  .viewer-nav.next {
    right: 14px;
  }

  .viewer-meta {
    min-width: auto;
    width: calc(100vw - 144px);
    padding: 10px 12px;
  }

  .admin-grid,
  .admin-actions,
  .branding-box,
  .palette-options,
  .theme-customizer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dialog-card {
    padding: 20px;
  }

  .admin-card {
    width: 100%;
    max-height: none;
  }

  .branding-box input {
    max-width: none;
  }

  .favicon-admin {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .brand-mark {
    display: none;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  h1 {
    font-size: 1.65rem;
  }

  .admin-link span {
    display: none;
  }

  .admin-link {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .mobile-tabs {
    padding: 12px 14px 0;
  }

  .upload-panel,
  .gallery-panel {
    padding: 14px;
  }

  .drop-zone {
    min-height: 210px;
  }

  .camera-mark {
    width: 98px;
    height: 98px;
  }

  .camera-mark svg {
    width: 46px;
    height: 46px;
  }

  .masonry {
    columns: 1;
  }

  .photo-card img {
    min-height: 220px;
  }

  .pin-row {
    grid-template-columns: 1fr;
  }

  .dialog-card {
    padding: 16px;
  }

  .viewer-close {
    top: 12px;
    right: 12px;
  }

  .admin-page {
    padding: 10px;
  }
}
