@import url("https://fonts.googleapis.com/css2?family=Nanum+Gothic:wght@700&display=swap");

:root {
  color-scheme: light;
  --app-bg: #f3f6fa;
  --app-ink: #111827;
  --app-muted: #667085;
  --app-line: #dbe3ee;
  --app-surface: rgba(255, 255, 255, 0.9);
  --app-surface-solid: #ffffff;
  --app-elevated: #ffffff;
  --app-primary: #0f766e;
  --app-primary-dark: #115e59;
  --app-soft: #eef6f5;
  --app-accent: #f59e0b;
  --app-danger: #e11d48;
  --app-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  --app-shadow-strong: 0 22px 58px rgba(15, 23, 42, 0.13);
  --app-page-bg:
    linear-gradient(180deg, #fbfcfe 0, var(--app-bg) 390px),
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(245, 158, 11, 0.1), transparent 31%);
  --app-header-bg: rgba(255, 255, 255, 0.84);
  --app-stage-bg:
    linear-gradient(135deg, rgba(12, 18, 32, 0.99), rgba(31, 41, 55, 0.98)),
    linear-gradient(45deg, rgba(20, 184, 166, 0.1), transparent 42%);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #0b1120;
  --app-ink: #edf2f7;
  --app-muted: #a8b3c7;
  --app-line: #263244;
  --app-surface: rgba(17, 24, 39, 0.86);
  --app-surface-solid: #111827;
  --app-elevated: #162033;
  --app-primary: #2dd4bf;
  --app-primary-dark: #14b8a6;
  --app-soft: rgba(45, 212, 191, 0.12);
  --app-accent: #fbbf24;
  --app-danger: #fb7185;
  --app-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  --app-shadow-strong: 0 24px 70px rgba(0, 0, 0, 0.48);
  --app-page-bg:
    linear-gradient(180deg, #0b1120 0, #111827 410px),
    linear-gradient(135deg, rgba(45, 212, 191, 0.16), transparent 38%),
    linear-gradient(225deg, rgba(251, 191, 36, 0.1), transparent 32%);
  --app-header-bg: rgba(17, 24, 39, 0.82);
  --app-stage-bg:
    linear-gradient(135deg, rgba(3, 7, 18, 0.99), rgba(15, 23, 42, 0.98)),
    linear-gradient(45deg, rgba(45, 212, 191, 0.12), transparent 42%);
}

body {
  background: var(--app-page-bg);
  color: var(--app-ink);
  font-family: "Nanum Gothic", Arial, sans-serif;
  font-weight: 700;
}

body.preview-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.app-header {
  backdrop-filter: blur(18px);
  background: var(--app-header-bg) !important;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-title-block h1 {
  letter-spacing: 0;
}

.app-brand-chip {
  align-items: center;
  background: var(--app-surface-solid);
  border: 1px solid rgba(219, 227, 238, 0.9);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
  color: var(--app-ink);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
  padding: 5px 10px 5px 5px;
}

.app-brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--app-primary), #14b8a6);
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-button {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  min-height: 34px;
}

.theme-icon-button {
  align-items: center;
  background: var(--app-surface-solid);
  border: 1px solid var(--app-line);
  border-radius: 999px;
  color: var(--app-ink);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 16px;
  height: 36px;
  justify-content: center;
  padding: 0;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
  width: 36px;
}

.theme-icon-button:hover {
  background: var(--app-primary);
  border-color: var(--app-primary);
  color: #ffffff;
  transform: translateY(-1px);
}

.admin-icon-button {
  color: var(--app-primary);
}

.admin-icon-button:hover {
  background: var(--app-primary);
  border-color: var(--app-primary);
  color: #ffffff;
}

html[data-theme="dark"] .theme-icon-button {
  background: #1f2937;
  border-color: #516178;
  color: #e5edf8;
}

html[data-theme="dark"] .admin-icon-button {
  color: #5eead4;
}

html[data-theme="dark"] .theme-icon-button:hover {
  background: #5eead4;
  border-color: #5eead4;
  color: #061018;
}

.btn-primary,
.btn-success {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary-dark);
  --bs-btn-hover-border-color: var(--app-primary-dark);
  --bs-btn-active-bg: var(--app-primary-dark);
  --bs-btn-active-border-color: var(--app-primary-dark);
}

.btn {
  font-weight: 700;
}

.btn-outline-primary {
  --bs-btn-color: var(--app-primary);
  --bs-btn-border-color: rgba(15, 118, 110, 0.38);
  --bs-btn-hover-bg: var(--app-primary);
  --bs-btn-hover-border-color: var(--app-primary);
}

.form-control {
  background-color: var(--app-surface-solid);
  border-color: var(--app-line);
  color: var(--app-ink);
}

.form-control:focus {
  background-color: var(--app-surface-solid);
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--app-primary) 18%, transparent);
  color: var(--app-ink);
}

.form-control[readonly] {
  background-color: color-mix(in srgb, var(--app-surface-solid) 88%, var(--app-bg));
}

.text-secondary {
  color: var(--app-muted) !important;
}

.text-bg-light,
.badge.text-bg-light {
  background-color: var(--app-surface-solid) !important;
  color: var(--app-ink) !important;
}

.border {
  border-color: var(--app-line) !important;
}

html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-primary {
  --bs-btn-color: #e5edf8;
  --bs-btn-border-color: #516178;
  --bs-btn-hover-color: #061018;
  --bs-btn-hover-bg: #5eead4;
  --bs-btn-hover-border-color: #5eead4;
  --bs-btn-active-color: #061018;
  --bs-btn-active-bg: #2dd4bf;
  --bs-btn-active-border-color: #2dd4bf;
  background-color: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-success {
  --bs-btn-color: #061018;
  --bs-btn-bg: #5eead4;
  --bs-btn-border-color: #5eead4;
  --bs-btn-hover-color: #061018;
  --bs-btn-hover-bg: #99f6e4;
  --bs-btn-hover-border-color: #99f6e4;
  --bs-btn-active-color: #061018;
  --bs-btn-active-bg: #2dd4bf;
  --bs-btn-active-border-color: #2dd4bf;
}

html[data-theme="dark"] .btn-light {
  --bs-btn-color: #e5edf8;
  --bs-btn-bg: #1f2937;
  --bs-btn-border-color: #3b4a60;
  --bs-btn-hover-color: #061018;
  --bs-btn-hover-bg: #5eead4;
  --bs-btn-hover-border-color: #5eead4;
}

html[data-theme="dark"] .text-success {
  color: #5eead4 !important;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6 {
  color: #ffffff;
}

html[data-theme="dark"] .text-danger,
html[data-theme="dark"] .text-bg-danger-subtle {
  color: #fda4af !important;
}

html[data-theme="dark"] .text-bg-danger-subtle {
  background-color: rgba(251, 113, 133, 0.14) !important;
}

html[data-theme="dark"] .border-danger-subtle {
  border-color: rgba(251, 113, 133, 0.38) !important;
}

.upload-card,
.gallery-section,
#adminPanel {
  background: var(--app-surface) !important;
  border: 1px solid rgba(219, 227, 238, 0.9) !important;
  border-radius: 16px;
  box-shadow: var(--app-shadow) !important;
  contain: layout paint;
  overflow: hidden;
}

.gallery-section > .card-body,
.upload-card > .card-body,
#adminPanel > .card-body {
  position: relative;
}

.dropzone {
  align-items: center;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--app-surface-solid) 92%, transparent), color-mix(in srgb, var(--app-bg) 88%, transparent)),
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 42%),
    linear-gradient(225deg, rgba(245, 158, 11, 0.08), transparent 38%);
  border: 1px dashed #aebccd;
  border-radius: 14px;
  display: grid;
  gap: 10px;
  justify-items: center;
  min-height: 250px;
  padding: 30px 20px;
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.dropzone:hover,
.dropzone.dragover {
  background:
    linear-gradient(180deg, var(--app-surface-solid), var(--app-soft)),
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent);
  border-color: var(--app-primary);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.18);
  transform: translateY(-2px);
}

.upload-icon {
  align-items: center;
  background: linear-gradient(135deg, var(--app-primary), #14b8a6);
  border-radius: 16px;
  box-shadow: 0 16px 30px rgba(15, 118, 110, 0.22);
  color: #ffffff;
  display: inline-flex;
  font-size: 34px;
  height: 64px;
  justify-content: center;
  width: 64px;
}

.result-card {
  align-items: center;
  background: linear-gradient(135deg, var(--app-soft), var(--app-surface-solid)) !important;
  border: 1px solid rgba(15, 118, 110, 0.14) !important;
  border-radius: 14px;
  display: grid;
  gap: 16px;
  grid-template-columns: 160px minmax(0, 1fr);
}

.result-card img {
  aspect-ratio: 1;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
  cursor: zoom-in;
  object-fit: cover;
  width: 100%;
}

.result-card img.is-animated-image {
  transform: translateZ(0);
}

.admin-login {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 240px) auto;
}

.gallery-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.image-card {
  border: 1px solid rgba(219, 227, 238, 0.85) !important;
  border-radius: 14px;
  content-visibility: auto;
  contain-intrinsic-size: 260px 340px;
  overflow: hidden;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.image-card:hover {
  border-color: rgba(15, 118, 110, 0.24) !important;
  box-shadow: var(--app-shadow-strong) !important;
  transform: translateY(-3px);
}

.image-thumb {
  background:
    linear-gradient(135deg, var(--app-bg), var(--app-surface-solid)),
    linear-gradient(45deg, rgba(15, 118, 110, 0.08), transparent);
  border: 0;
  cursor: zoom-in;
  display: block;
  overflow: hidden;
  padding: 0;
  text-align: inherit;
  width: 100%;
}

.image-thumb img {
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
  transition: filter 180ms ease, transform 180ms ease;
  width: 100%;
}

.image-card:hover .image-thumb img {
  filter: saturate(1.06) contrast(1.02);
  transform: scale(1.03);
}

.image-card.is-gif-card {
  transform: translateZ(0);
}

.image-card.is-gif-card:hover {
  transform: translateY(-1px);
}

.image-card.is-gif-card .image-thumb img,
.image-card.is-gif-card:hover .image-thumb img {
  filter: none;
  transform: none;
  transition: none;
}

.image-card .card-body {
  background: var(--app-surface-solid);
}

.image-card .badge {
  font-weight: 800;
}

.empty-state {
  align-items: center;
  background: color-mix(in srgb, var(--app-surface-solid) 72%, transparent);
  border: 1px dashed #b8c4d4;
  border-radius: 12px;
  color: var(--app-muted);
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
  justify-content: center;
  min-height: 120px;
  padding: 18px;
}

.empty-state .bi {
  font-size: 22px;
}

.viewer-body {
  background: var(--app-page-bg);
}

.viewer-page {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 18px;
}

.viewer-card {
  background: var(--app-surface);
  border: 1px solid rgba(219, 227, 238, 0.92);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 1060px;
  padding: 14px;
  width: 100%;
}

.viewer-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 2px 2px 0;
}

.viewer-brand {
  align-items: center;
  color: var(--app-ink);
  display: inline-flex;
  font-size: 15px;
  font-weight: 800;
  gap: 8px;
  text-decoration: none;
}

.viewer-brand-icon {
  align-items: center;
  background: linear-gradient(135deg, var(--app-primary), #14b8a6);
  border-radius: 10px;
  color: #ffffff;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.viewer-meta {
  align-items: center;
  color: var(--app-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 10px;
  justify-content: flex-end;
}

.viewer-meta span {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  white-space: nowrap;
}

.viewer-theme-button {
  height: 32px;
  width: 32px;
}

.viewer-title-row {
  align-items: end;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 0 2px;
}

.viewer-title-row h1 {
  color: var(--app-ink);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  margin: 0;
  overflow-wrap: anywhere;
}

.viewer-kicker {
  color: var(--app-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.viewer-pill {
  align-items: center;
  background: var(--app-soft);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  color: var(--app-primary-dark);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
  padding: 6px 10px;
}

.viewer-stage {
  align-items: center;
  background: var(--app-stage-bg);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: grid;
  min-height: min(68vh, 680px);
  overflow: hidden;
  padding: 12px;
  place-items: center;
}

.viewer-stage img {
  border-radius: 10px;
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
  display: block;
  max-height: calc(100vh - 210px);
  max-width: 100%;
  object-fit: contain;
  transform: translateZ(0);
}

.viewer-stage.is-gif-stage img {
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.viewer-button {
  align-items: center;
  background: var(--app-surface-solid);
  border: 1px solid var(--app-line);
  border-radius: 10px;
  color: var(--app-ink);
  display: inline-flex;
  font-size: 14px;
  font-weight: 700;
  gap: 7px;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

html[data-theme="dark"] .viewer-button {
  background: #1f2937;
  border-color: #516178;
  color: #e5edf8;
}

.viewer-button:hover {
  background: var(--app-elevated);
  border-color: #b8c4d4;
  color: var(--app-ink);
  transform: translateY(-1px);
}

.viewer-button-primary {
  background: linear-gradient(135deg, var(--app-primary), #14b8a6);
  border-color: var(--app-primary);
  color: #ffffff;
}

html[data-theme="dark"] .viewer-button-primary {
  background: linear-gradient(135deg, #5eead4, #22d3ee);
  border-color: #5eead4;
  color: #061018;
}

html[data-theme="dark"] .viewer-button:hover,
html[data-theme="dark"] .viewer-theme-button:hover {
  background: #5eead4;
  border-color: #5eead4;
  color: #061018;
}

.viewer-button-primary:hover {
  background: var(--app-primary-dark);
  border-color: var(--app-primary-dark);
  color: #ffffff;
}

html[data-theme="dark"] .viewer-button-primary:hover {
  background: #99f6e4;
  border-color: #99f6e4;
  color: #061018;
}

.preview-layer {
  align-items: center;
  backdrop-filter: blur(8px);
  background: rgba(15, 23, 42, 0.76);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 50;
}

.preview-dialog {
  background: var(--app-surface-solid);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 16px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  contain: layout paint;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 36px);
  max-width: 1100px;
  overflow: hidden;
  width: min(100%, 1100px);
}

.preview-header {
  align-items: center;
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
}

.preview-body {
  background: var(--app-stage-bg);
  display: grid;
  min-height: 260px;
  overflow: auto;
  padding: 14px;
  place-items: center;
  position: relative;
}

.preview-body img {
  border-radius: 10px;
  cursor: zoom-in;
  display: block;
  max-height: calc(100vh - 220px);
  max-width: 100%;
  object-fit: contain;
  touch-action: none;
  transform-origin: center;
  transition: transform 120ms ease;
  user-select: none;
  will-change: transform;
}

.preview-body.is-gif-preview img {
  transition: none;
}

.preview-body.is-zoomed img {
  cursor: grab;
}

.preview-body.is-dragging img {
  cursor: grabbing;
  transition: none;
}

.preview-tools {
  align-items: center;
  background: color-mix(in srgb, var(--app-surface-solid) 92%, transparent);
  border: 1px solid rgba(219, 227, 238, 0.95);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18);
  display: flex;
  gap: 6px;
  left: 50%;
  padding: 6px;
  position: absolute;
  top: 12px;
  transform: translateX(-50%);
  z-index: 2;
}

html[data-theme="dark"] .preview-tools {
  background: rgba(17, 24, 39, 0.94);
  border-color: #516178;
}

.preview-tools .btn {
  align-items: center;
  display: inline-flex;
  gap: 4px;
  min-height: 32px;
  white-space: nowrap;
}

.preview-zoom-label {
  color: var(--app-ink);
  font-size: 13px;
  font-weight: 700;
  min-width: 44px;
  text-align: center;
}

.preview-footer {
  background: var(--app-surface-solid);
  border-top: 1px solid var(--app-line);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  padding: 12px 16px;
}

.toast-message {
  background: rgba(16, 24, 40, 0.96);
  border-radius: 8px;
  bottom: 18px;
  color: #ffffff;
  left: 50%;
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: 140ms ease;
  z-index: 30;
}

.toast-message.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 720px) {
  body {
    background:
      linear-gradient(180deg, #fbfcfe 0, var(--app-bg) 300px),
      linear-gradient(145deg, rgba(15, 118, 110, 0.1), transparent 42%);
  }

  .app-header {
    backdrop-filter: none;
    position: static;
  }

  .app-title-block h1 {
    font-size: 22px;
    line-height: 1.25;
  }

  .app-title-block p {
    font-size: 14px;
  }

  .header-actions {
    display: flex;
    justify-content: flex-end;
    width: 100%;
  }

  .header-actions .btn {
    justify-content: center;
  }

  .upload-card,
  .gallery-section,
  #adminPanel {
    border-radius: 13px;
  }

  .dropzone {
    min-height: 210px;
    padding: 24px 14px;
  }

  .upload-icon {
    border-radius: 14px;
    font-size: 28px;
    height: 56px;
    width: 56px;
  }

  .result-card,
  .admin-login {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .image-card {
    border-radius: 12px;
  }

  .input-group {
    display: grid;
    gap: 8px;
  }

  .input-group > .form-control,
  .input-group > .btn {
    border-radius: 0.375rem !important;
    width: 100%;
  }

  .preview-layer {
    align-items: end;
    backdrop-filter: none;
    padding: 8px;
  }

  .viewer-page {
    align-items: stretch;
    padding: 8px;
  }

  .viewer-card {
    border-radius: 14px;
    gap: 10px;
    padding: 10px;
  }

  .viewer-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .viewer-meta {
    justify-content: flex-start;
  }

  .viewer-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .viewer-title-row h1 {
    font-size: 18px;
  }

  .viewer-stage {
    min-height: 56vh;
    padding: 8px;
  }

  .viewer-stage img {
    max-height: calc(100vh - 250px);
  }

  .viewer-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .viewer-button {
    width: 100%;
  }

  .preview-dialog {
    border-radius: 12px;
    max-height: calc(100vh - 16px);
  }

  .preview-body {
    min-height: 220px;
    padding: 58px 10px 10px;
  }

  .preview-body img {
    max-height: calc(100vh - 260px);
  }

  .preview-tools {
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100% - 20px);
    top: 10px;
    width: max-content;
  }

  .preview-tools .btn {
    font-size: 12px;
    min-height: 30px;
    padding: 4px 7px;
  }

  .preview-zoom-label {
    font-size: 12px;
    min-width: 40px;
  }

  .preview-footer {
    grid-template-columns: 1fr 1fr;
    padding: 10px;
  }

  .preview-footer .form-control {
    grid-column: 1 / -1;
  }

  .preview-footer .btn {
    width: 100%;
  }
}
