:root {
  --paper: #fbfaf7;
  --panel: #fffefa;
  --ink: #0f0f0e;
  --muted: #665f56;
  --hairline: #d8d1c6;
  --soft: #f0ede7;
  --accent: #bd5537;
  --error: #a13d2d;
  --success: #4e6b55;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Helvetica Neue", Arial, "Pretendard", "Noto Sans KR", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 74px;
  padding: 0 32px;
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  font-family: "Bodoni 72", Didot, "Bodoni MT", "Times New Roman", serif;
  font-size: 37px;
  line-height: 1;
  letter-spacing: 0;
}

.header-actions,
.guest-actions,
.member-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 12px;
}

.guest-actions[hidden],
.member-actions[hidden] {
  display: none;
}

.join-button,
.logout-button {
  display: inline-grid;
  place-items: center;
  height: 28px;
  border: 0;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.join-button {
  width: 54px;
}

.logout-button {
  min-width: 64px;
  padding: 0 12px;
  border: 1px solid #0c0c0b;
  border-radius: 0;
  background: #0c0c0b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.member-nickname {
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  color: #1a1918;
  text-overflow: ellipsis;
  text-decoration: underline;
  text-underline-offset: 4px;
  white-space: nowrap;
}

.upload-select-page {
  padding: 50px clamp(24px, 4.5vw, 72px) 72px;
}

.upload-hero {
  margin-bottom: 46px;
}

.upload-hero p {
  margin: 0 0 17px;
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
}

.upload-hero h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Noto Serif KR", serif;
  font-size: clamp(56px, 6.2vw, 78px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: 0;
}

.upload-hero span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.upload-workspace {
  border: 1px solid var(--hairline);
  background: var(--panel);
  padding: 24px 32px 24px;
}

.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.workspace-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 34px;
}

.workspace-title span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.workspace-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.workspace-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 33px;
  margin-top: 28px;
}

.workspace-subhead p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.upload-message {
  min-height: 18px;
  text-align: right;
}

.upload-message.error {
  color: var(--error);
}

.upload-message.success {
  color: var(--success);
}

#image-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 48px 44px;
  margin-top: 20px;
}

.image-slot {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2.3 / 1;
  overflow: hidden;
  border: 1px solid #cfc8bd;
  background: var(--soft);
  transition:
    border-color 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

button.image-slot {
  padding: 0;
  cursor: pointer;
}

button.image-slot[draggable="true"] {
  cursor: grab;
}

button.image-slot.is-dragging {
  opacity: 0.46;
  cursor: grabbing;
  transform: scale(0.985);
}

button.image-slot.is-drag-over {
  border-color: var(--accent);
}

button.image-slot.is-drag-over::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  border: 2px solid var(--accent);
  background: rgba(189, 85, 55, 0.08);
  content: "";
  pointer-events: none;
}

.image-slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot-badge {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 12px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.empty-slot {
  display: grid;
  place-items: center;
  height: 100%;
}

.empty-slot::before,
.empty-slot::after {
  position: absolute;
  width: 38px;
  height: 1px;
  background: #9f968b;
  content: "";
}

.empty-slot::after {
  transform: rotate(90deg);
}

.slot-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.image-slot:hover .slot-actions,
.image-slot:focus-within .slot-actions {
  opacity: 1;
  transform: translateY(0);
}

.slot-action {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  background: rgba(15, 15, 14, 0.82);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
}

.workspace-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
}

.next-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(310px, 100%);
  height: 49px;
  padding: 0 20px 0 25px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.next-button:hover {
  border-color: #a7462d;
  background: #a7462d;
}

.next-button span {
  font-size: 28px;
  line-height: 1;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 42px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(17, 16, 14, 0.52);
  cursor: pointer;
}

.preview-frame {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1040px, 100%);
  max-height: calc(100dvh - 84px);
  border: 1px solid var(--hairline);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(22, 18, 15, 0.22);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid var(--hairline);
}

.preview-head p {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.preview-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.preview-close {
  min-width: 54px;
  height: 32px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
}

.preview-close:hover {
  background: var(--ink);
  color: #fff;
}

#preview-image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  background: #edeae4;
}

@media (max-width: 1180px) {
  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .site-header {
    height: 64px;
    padding: 0 18px;
  }

  .wordmark {
    font-size: 30px;
  }

  .login-link {
    display: none;
  }

  .header-actions,
  .guest-actions,
  .member-actions {
    gap: 12px;
  }

  .member-nickname {
    max-width: 95px;
  }

  .upload-select-page {
    padding: 38px 20px 56px;
  }

  .upload-hero {
    margin-bottom: 34px;
  }

  .upload-hero h1 {
    font-size: 48px;
  }

  .upload-workspace {
    padding: 30px 20px 22px;
  }

  .workspace-head,
  .workspace-subhead {
    align-items: flex-start;
    flex-direction: column;
  }

  .upload-message {
    text-align: left;
  }

  .image-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .slot-actions {
    opacity: 1;
    transform: none;
  }

  .image-preview-modal {
    padding: 18px;
  }

  .preview-frame {
    max-height: calc(100vh - 36px);
  }

  #preview-image {
    max-height: calc(100vh - 118px);
  }
}
