:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2330;
  --border: #2a2f3d;
  --text: #e7ebf3;
  --muted: #8a93a6;
  --accent: #ff5577;
  --accent-2: #7c5cff;
}

* { 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, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}

header.site .logo {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

header.site nav {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

header.site nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: all .15s ease;
}
header.site nav a:hover { color: var(--text); background: var(--panel-2); }
header.site nav a.active {
  color: var(--text);
  background: var(--panel-2);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

h1.page-title {
  margin: 8px 0 4px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 14px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { border-color: #3a4055; background: var(--panel-2); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: white;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* 로그인 영역 */
.auth-area {
  display: flex;
  align-items: center;
  gap: 10px;
}
.auth-area .me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.auth-area .avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}
.auth-area .me-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 삭제 버튼 */
.del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 9px;
  margin-left: 6px;
  font-size: 14px;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.del-btn:hover {
  color: #ff9aa0;
  border-color: rgba(229, 72, 77, 0.5);
  background: rgba(229, 72, 77, 0.1);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 9px;
  margin-left: 6px;
  font-size: 14px;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.share-btn:hover {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.6);
  background: rgba(124, 92, 255, 0.12);
}

/* 공유 모달 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-title {
  margin: 0 0 18px;
  font-size: 18px;
  color: var(--text);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); border-color: #3a4055; }
.qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  padding: 12px;
  width: 200px;
  height: 200px;
  background: #fff;
  border-radius: 12px;
}
.qr-box img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.qr-fail { color: #555; font-size: 13px; }
.share-url {
  display: flex;
  gap: 8px;
}
.share-url-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
}
.share-url-input:focus { outline: none; border-color: #3a4055; }

/* 안내 배너 */
.notice {
  margin: 0 0 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.35);
  color: #ff9aa0;
  font-size: 14px;
  font-weight: 600;
}

.chip {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  cursor: pointer;
}
.chip.active { color: var(--text); background: var(--panel-2); border-color: #3a4055; }

/* Pagination */
.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 28px 0 8px;
}
.page-btn {
  min-width: 38px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  cursor: pointer;
}
.page-btn:hover:not(:disabled) { color: var(--text); border-color: #3a4055; background: var(--panel-2); }
.page-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}
.page-btn:disabled { opacity: .4; cursor: default; }
.page-ellipsis { color: var(--muted); padding: 0 4px; }

/* Gallery grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-2px); border-color: #3a4055; }

.card .preview {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--panel-2);
  overflow: hidden;
}
.card .preview iframe {
  position: absolute;
  inset: 0;
  width: 200%;
  height: 200%;
  border: 0;
  transform: scale(0.5);
  transform-origin: top left;
  pointer-events: none;
}
.card .preview .scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 60%, rgba(0,0,0,0.6));
  pointer-events: none;
}
.card .preview .open-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
  color: white;
  font-weight: 600;
  opacity: 0;
  transition: opacity .15s ease;
}
.card:hover .preview .open-hint { opacity: 1; }
.card .preview .private-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.85);
  color: white;
  font-weight: 700;
}

.card .meta {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.card .meta .info { min-width: 0; }
.card .card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.card .card-actions .del-btn,
.card .card-actions .share-btn { margin-left: 0; }
.card .meta .title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .meta .author {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s ease;
  user-select: none;
}
.like-btn:hover { border-color: #3a4055; }
.like-btn.liked {
  background: rgba(255, 85, 119, 0.15);
  border-color: rgba(255, 85, 119, 0.5);
  color: var(--accent);
}
.like-btn .heart {
  display: inline-block;
  transition: transform .2s ease;
}
.like-btn.liked .heart { transform: scale(1.15); }

/* Upload form */
.upload-card {
  max-width: 560px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input[type=text] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  font-size: 14px;
  border-radius: 10px;
  outline: none;
}
.field input[type=text]:focus { border-color: var(--accent-2); }

.drop {
  border: 2px dashed var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.drop:hover, .drop.dragover { border-color: var(--accent-2); color: var(--text); }
.drop strong { color: var(--text); }
.drop .filename { color: var(--text); font-weight: 600; word-break: break-all; }

.error { color: #ff7f8e; font-size: 13px; margin-top: 8px; min-height: 18px; }

/* Ranking */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .12s ease;
}
.rank-row:hover { border-color: #3a4055; }
.rank-row .rank {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.04em;
  color: var(--muted);
  text-align: center;
}
.rank-row.top-1 .rank { color: #ffd166; }
.rank-row.top-2 .rank { color: #cfd6e4; }
.rank-row.top-3 .rank { color: #d39064; }
.rank-row .info { min-width: 0; }
.rank-row .info .title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-row .info .author { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rank-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rank-actions .del-btn,
.rank-actions .share-btn { margin-left: 0; }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

/* ── 웹앱 갤러리 확장 스타일 ───────────────────────────── */
.btn.kakao,
.btn.primary.kakao {
  background: #FEE500;
  color: #191600;
  border-color: #FEE500;
}
.btn.kakao:hover { background: #f5dd00; }

.file-list {
  margin-top: 10px;
  max-height: 200px;
  overflow: auto;
  border: 1px solid rgba(128,128,128,.25);
  border-radius: 10px;
  padding: 6px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.file-row {
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-row.entry {
  background: rgba(46,160,67,.15);
  color: #2ea043;
  font-weight: 600;
}
