/* === NotebookLM Visual Builder === */
:root {
  --bg-primary: #09090b;
  --bg-secondary: #18181b;
  --bg-card: #27272a;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --border: #3f3f46;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --danger: #ef4444;
  --success: #22c55e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* === HEADER === */
.header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(9,9,11,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 16px; height: 48px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff;
}
.logo-text h1 { font-size: 14px; font-weight: 700; }
.logo-text p { font-size: 9px; color: var(--text-muted); }

.btn-open {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: var(--accent);
  color: #fff; border: none; border-radius: 20px;
  font-size: 12px; font-weight: 700; cursor: pointer;
  text-decoration: none;
}
.btn-open:hover { background: var(--accent-hover); }

/* === HEADER RIGHT (lang + button) === */
.header-right {
  display: flex; align-items: center; gap: 8px;
}
.lang-switcher {
  display: flex; gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 2px;
}
.lang-btn {
  padding: 3px 8px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  font-size: 10px; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.lang-btn:hover { color: var(--text-primary); }
.lang-btn.active {
  background: var(--accent); color: #fff;
}

/* === HERO === */
.hero { padding: 24px 16px; text-align: center; }
.hero h2 { font-size: 22px; font-weight: 900; }
.hero .gradient-text {
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* === TOOLBAR === */
.toolbar {
  max-width: 1280px; margin: 0 auto;
  padding: 0 16px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.search-wrap {
  position: relative; flex: 0 0 auto; width: 200px;
}
.search-wrap svg {
  position: absolute; left: 8px; top: 50%;
  transform: translateY(-50%); width: 14px; height: 14px;
  color: var(--text-muted); pointer-events: none;
}
.search-input {
  width: 100%; padding: 6px 10px 6px 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-size: 12px; outline: none;
}
.search-input:focus { border-color: var(--accent); }

.btn-add {
  padding: 6px 12px; background: var(--success);
  color: #fff; border: none; border-radius: 8px;
  font-size: 11px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.btn-add:hover { opacity: 0.9; }

.btn-export, .btn-import {
  padding: 6px 10px; background: var(--bg-card);
  color: var(--text-secondary); border: 1px solid var(--border);
  border-radius: 8px; font-size: 11px; cursor: pointer;
}
.btn-export:hover, .btn-import:hover { background: var(--border); }

/* === CATEGORIES (반응형 - flex-wrap) === */
.categories {
  max-width: 1280px; margin: 0 auto;
  padding: 0 16px 12px;
}
.cat-list {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.cat-btn {
  padding: 5px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
  white-space: nowrap; border: none; cursor: pointer;
  background: var(--bg-secondary); color: var(--text-muted);
  transition: all 0.15s;
}
.cat-btn:hover { color: var(--text-primary); background: var(--bg-card); }
.cat-btn.active { background: #fff; color: #000; }
.cat-count { opacity: 0.6; margin-left: 2px; }

/* === TEMPLATE GRID === */
.grid-container {
  max-width: 1280px; margin: 0 auto; padding: 0 16px 32px;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}

/* === TEMPLATE CARD === */
.template-card {
  cursor: pointer; border: none; background: none;
  text-align: left; padding: 0; width: 100%;
  transition: transform 0.15s;
}
.template-card:hover { transform: scale(1.03); }

.thumb {
  position: relative; width: 100%;
  aspect-ratio: 16/9; border-radius: 10px;
  overflow: hidden;
}
.thumb-bg { width: 100%; height: 100%; position: relative; }

/* 썸네일 오버레이 */
.thumb-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex; flex-direction: column; gap: 2px;
}
.thumb-name {
  font-size: 10px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.thumb-mood {
  font-size: 8px; color: rgba(255,255,255,0.75);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 컬러 팔레트 도트 */
.color-dots {
  position: absolute; top: 6px; right: 6px;
  display: flex; gap: 3px;
}
.color-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.5);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* 폰트 라벨 */
.thumb-font {
  position: absolute; top: 6px; left: 6px;
  font-size: 7px; padding: 1px 5px;
  background: rgba(0,0,0,0.5); color: #fff;
  border-radius: 4px; backdrop-filter: blur(4px);
}

/* 카드 하단 정보 */
.card-info { margin-top: 6px; padding: 0 2px; }
.card-info h3 {
  font-size: 12px; font-weight: 700;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.template-card:hover .card-info h3 { color: var(--accent); }
.card-info .cat-label {
  font-size: 9px; color: var(--text-muted);
}

/* CRUD 버튼 (카드 위) */
.card-actions {
  position: absolute; top: 4px; left: 4px;
  display: none; gap: 3px; z-index: 5;
}
.template-card:hover .card-actions { display: flex; }
.card-action-btn {
  width: 22px; height: 22px; border-radius: 6px;
  border: none; font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.btn-edit-card {
  background: rgba(59,130,246,0.8); color: #fff;
}
.btn-delete-card {
  background: rgba(239,68,68,0.8); color: #fff;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center; padding: 48px 0;
  color: var(--text-muted); font-size: 12px;
}
.empty-state svg { width: 32px; height: 32px; margin-bottom: 8px; opacity: 0.4; }

/* === MODAL OVERLAY === */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.85);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.active { display: flex; }

/* === PROMPT MODAL === */
.prompt-modal {
  width: 100%; max-width: 640px; max-height: 90vh;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 16px; display: flex; flex-direction: column;
  overflow: hidden;
}
.prompt-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.prompt-header-info { display: flex; align-items: center; gap: 12px; }
.prompt-color-box {
  width: 40px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border);
}
.prompt-header-info h3 { font-size: 14px; font-weight: 700; }
.prompt-header-info span { font-size: 11px; color: var(--text-muted); }
.btn-close {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-card); color: #fff;
  border: none; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-close:hover { background: var(--border); }

.prompt-body {
  flex: 1; padding: 16px; overflow-y: auto;
}
.prompt-textarea {
  width: 100%; height: 100%; min-height: 300px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
  font-family: monospace; font-size: 12px;
  line-height: 1.6; resize: none; outline: none;
}

.prompt-footer {
  padding: 16px; border-top: 1px solid var(--border);
}
.btn-copy {
  width: 100%; padding: 14px;
  border-radius: 12px; border: none;
  font-size: 14px; font-weight: 700; cursor: pointer;
  background: #fff; color: #000;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-copy.copied { background: var(--success); color: #fff; }
.btn-copy:hover { opacity: 0.9; }

/* === CRUD MODAL (추가/수정) === */
.crud-modal {
  width: 100%; max-width: 560px; max-height: 90vh;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 16px; overflow-y: auto;
}
.crud-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.crud-header h3 { font-size: 16px; font-weight: 700; }
.crud-body { padding: 16px; }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-size: 13px; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
}
.form-group textarea { min-height: 60px; resize: vertical; }

.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.color-preview {
  display: flex; gap: 8px; margin-top: 6px;
}
.color-preview-box {
  width: 40px; height: 30px; border-radius: 6px;
  border: 1px solid var(--border);
}

.crud-footer {
  padding: 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}
.btn-save {
  flex: 1; padding: 12px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 10px;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-save:hover { background: var(--accent-hover); }
.btn-cancel {
  padding: 12px 20px;
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; cursor: pointer;
}
.btn-cancel:hover { background: var(--border); }

/* === DELETE CONFIRM === */
.delete-modal {
  width: 100%; max-width: 380px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 24px;
  text-align: center;
}
.delete-modal h3 { font-size: 16px; margin-bottom: 8px; }
.delete-modal p { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.delete-actions { display: flex; gap: 8px; justify-content: center; }
.btn-delete-confirm {
  padding: 10px 24px; background: var(--danger);
  color: #fff; border: none; border-radius: 10px;
  font-weight: 700; cursor: pointer;
}
.btn-delete-cancel {
  padding: 10px 24px; background: var(--bg-card);
  color: var(--text-secondary); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
}

/* === FOOTER === */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  padding: 24px 16px; text-align: center;
}
.footer-link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--bg-card);
  color: var(--text-secondary); border-radius: 8px;
  text-decoration: none; font-size: 13px;
  margin-bottom: 12px;
}
.footer-link:hover { background: var(--border); }
.footer-notice {
  font-size: 10px; color: var(--text-muted);
  max-width: 640px; margin: 0 auto; line-height: 1.6;
}

/* === TOAST === */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card); color: var(--text-primary);
  padding: 10px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: transform 0.3s; z-index: 100;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .hero h2 { font-size: 18px; }
  .template-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .search-wrap { width: 160px; }
  .toolbar { gap: 6px; }
}
@media (max-width: 480px) {
  .template-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .search-wrap { width: 100%; order: -1; }
  .toolbar { flex-wrap: wrap; }
  .btn-export, .btn-import { font-size: 10px; padding: 5px 8px; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* === file input hide === */
#importFile { display: none; }

/* === AUTH AREA === */
.auth-area {
  display: flex; align-items: center; gap: 6px;
}
.btn-auth {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text-secondary);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.btn-auth:hover { border-color: var(--accent); color: var(--text-primary); }
.btn-auth.btn-register {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-auth.btn-register:hover { background: var(--accent-hover); }
.auth-nickname {
  color: var(--text-primary); font-size: 11px; font-weight: 600;
}
.auth-admin-badge {
  padding: 1px 5px; border-radius: 4px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
}
.btn-logout {
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 5px;
  background: transparent; color: var(--text-muted);
  font-size: 10px; cursor: pointer; transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* === AUTH MODAL === */
.auth-modal {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 12px; width: 360px; max-width: 90vw;
}
.auth-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.auth-modal-header h3 { font-size: 16px; font-weight: 700; }
.auth-modal-body { padding: 20px; }
.auth-modal-body .form-group { margin-bottom: 12px; }
.auth-modal-body label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 4px;
}
.auth-modal-body input {
  width: 100%; padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-primary); font-size: 13px;
  transition: border-color 0.15s;
}
.auth-modal-body input:focus {
  outline: none; border-color: var(--accent);
}
.auth-error {
  color: var(--danger); font-size: 11px; min-height: 16px; margin-top: 4px;
}
.auth-modal-footer {
  padding: 0 20px 20px; text-align: center;
}
.auth-modal-footer .btn-save {
  width: 100%; padding: 10px; margin-bottom: 10px;
}
.auth-switch {
  font-size: 11px; color: var(--text-muted);
}
.auth-switch a {
  color: var(--accent); text-decoration: none; font-weight: 600;
}
.auth-switch a:hover { text-decoration: underline; }

/* === CONTRIBUTOR BADGE === */
.contributor-badge {
  display: inline-block; margin-top: 2px;
  padding: 1px 6px; border-radius: 4px;
  background: rgba(139,92,246,0.15); color: var(--accent);
  font-size: 9px; font-weight: 600;
}

/* 대기중 배지 */
.status-pending {
  display: inline-block; margin-top: 2px;
  padding: 1px 6px; border-radius: 4px;
  background: rgba(234,179,8,0.2); color: #eab308;
  font-size: 9px; font-weight: 700;
}

/* 대기중 카드 테두리 */
.card-pending { border: 1px dashed rgba(234,179,8,0.4); }

/* 승인 버튼 (초록) */
.btn-approve-card { background: rgba(34,197,94,0.8); color: #fff; }
.btn-approve-card:hover { background: rgba(34,197,94,1); }

/* 승인대기 카테고리 탭 */
.cat-btn-pending { border-color: #eab308; color: #eab308; }
.cat-btn-pending .cat-count { background: rgba(234,179,8,0.2); color: #eab308; }
