:root {
  --bg: #0f1115;
  --bg-card: #1a1d24;
  --bg-card-hover: #22262f;
  --text: #f2f3f5;
  --text-dim: #9aa0ac;
  --accent: #6c8cff;
  --border: #2a2e37;
  --radius: 14px;
  --maxw: 1200px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", Roboto, Helvetica, Arial, sans-serif;
}

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

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 20px 80px;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10;
}

header.top .brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

header.top nav a {
  color: var(--text-dim);
  font-size: 14px;
  margin-left: 20px;
  transition: color 0.15s;
}
header.top nav a:hover { color: var(--text); }

h1 { font-size: 26px; margin: 28px 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 18px; color: var(--text-dim); font-weight: 500; margin: 0 0 28px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px;
  margin-top: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  display: block;
  cursor: pointer;
}
.card:hover {
  background: var(--bg-card-hover);
  border-color: #3a3f4b;
  transform: translateY(-3px);
}

.card .thumb {
  width: 100%;
  aspect-ratio: 10 / 16;
  object-fit: contain;
  background: #14161b;
  display: block;
}

.card .thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
}

.card .label {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
}

.card .label .sub {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 4px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 8px;
}
.back-link:hover { color: var(--text); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  background: #14161b;
  cursor: zoom-in;
  border: 1px solid var(--border);
  transition: opacity 0.15s;
}
.photo-grid img:hover { opacity: 0.85; }

.empty {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 40px;
  text-align: center;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

/* Admin */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.panel h3 { margin: 0 0 16px; font-size: 16px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  background: #11131a;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
}

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.88; }
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button.danger {
  background: #e5484d;
}

.thumb-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.thumb-picker img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
}
.thumb-picker img.selected {
  border-color: var(--accent);
}

.project-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.project-row:last-child { border-bottom: none; }
.project-row img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: #11131a;
}
.project-row .meta { flex: 1; }
.project-row .meta .name { font-weight: 600; font-size: 14px; }
.project-row .meta .dir { font-size: 12px; color: var(--text-dim); }
.project-row .actions { display: flex; gap: 8px; }

.drag-handle {
  cursor: grab;
  font-size: 18px;
  line-height: 1;
  color: var(--text-dim);
  padding: 0 2px;
  user-select: none;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

.project-row.dragging {
  opacity: 0.4;
}

.msg {
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}
.msg.error { color: #ff8a8a; }
.msg.success { color: #7bd88f; }

.login-box {
  max-width: 360px;
  margin: 80px auto;
  text-align: center;
}
.login-box .panel { text-align: left; }

/* 모바일 레이아웃 */
@media (max-width: 600px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .photo-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .photo-grid img {
    border-radius: 6px;
  }
}
