* { box-sizing: border-box; }

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #ececef;
  --border-hover: #dcdfe4;
  --text: #17181c;
  --text-sub: #6b7280;
  --text-mut: #9aa1ab;
  --accent: #2563eb;
  --accent-bg: #eaf1fe;
  --radius: 10px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }

/* ===== 상단바 ===== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.navbar .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.navbar .logo span { font-size: 1.3rem; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-actions a {
  font-size: 0.9rem;
  padding: 8px 14px;
  border-radius: var(--radius);
  color: var(--text-sub);
}
.nav-actions a.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}
.nav-actions a.primary:hover { background: #1d4ed8; }

/* ===== 본문 컨테이너 ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* ===== 홈 히어로 ===== */
.hero { text-align: center; margin-bottom: 32px; }
.hero h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; }
.hero p { font-size: 1.05rem; color: var(--text-sub); margin: 0 0 24px; }
.searchbar {
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-mut);
  font-size: 0.95rem;
}

/* ===== 메뉴 카드 그리드 ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.card {
  position: relative;
  display: block;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.06);
  border-color: var(--border-hover);
}
.card.featured { border: 2px solid var(--accent); }
.card .icon-box {
  width: 40px; height: 40px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 14px;
  background: var(--accent-bg);
}
.card h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 4px; color: var(--text); }
.card p { font-size: 0.88rem; color: var(--text-sub); margin: 0; }
.badge {
  position: absolute; top: 14px; right: 14px;
  font-size: 0.7rem; font-weight: 500;
  background: var(--accent-bg); color: var(--accent);
  padding: 4px 9px; border-radius: 20px;
}

/* ===== 폼 (로그인·회원가입) ===== */
.form-card {
  max-width: 400px;
  margin: 0 auto;
  background: var(--surface);
  padding: 36px 32px;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.04);
}
.form-card h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 24px; text-align: center; }
label { display: block; margin-bottom: 6px; font-size: 0.88rem; font-weight: 500; color: var(--text); }
input {
  width: 100%; padding: 12px 14px; margin-bottom: 18px;
  border: 1px solid var(--border-hover); border-radius: var(--radius);
  font-size: 1rem; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
button {
  width: 100%; padding: 13px; background: var(--text); color: #fff;
  border: none; border-radius: var(--radius); font-size: 1rem;
  font-weight: 600; cursor: pointer; transition: background 0.15s ease;
}
button:hover { background: #333; }
.form-footer { text-align: center; margin-top: 20px; color: var(--text-sub); font-size: 0.9rem; }

/* ===== 뒤로가기 링크 ===== */
.back-link { display: inline-block; margin-bottom: 20px; color: var(--text-mut); font-size: 0.9rem; }

/* ===== 빈 상태 ===== */
.empty-box {
  padding: 56px; text-align: center; color: var(--text-mut);
  background: var(--surface); border: 1px dashed var(--border-hover);
  border-radius: 16px;
}

/* ===== 모바일 ===== */
@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.6rem; }
  .container { padding: 28px 18px; }
}
textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.primary-btn {
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
}
.primary-btn:hover { background: #1d4ed8; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 16px;
}
.post-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.post-author { color: var(--text-mut); font-size: 0.85rem; }

.prompt-row { margin-bottom: 14px; }
.prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.prompt-label { font-size: 0.85rem; font-weight: 600; color: var(--text-sub); }
.copy-btn {
  width: auto;
  padding: 5px 12px;
  font-size: 0.8rem;
  background: var(--accent-bg);
  color: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.copy-btn:hover { background: #dbe7fd; }
.prompt-text {
  margin: 0;
  padding: 12px 14px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: "Consolas", "Monaco", monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: #1f2937;
}
.post-image {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  background: #f9fafb;
  border-radius: 12px;
  margin-bottom: 16px;
  display: block;
}
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.char-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.char-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.06);
  border-color: var(--border-hover);
}
.char-thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
}
.char-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: #f1f3f6;
}
.char-info { padding: 12px 14px; }
.delete-btn {
  width: auto;
  padding: 8px 16px;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.delete-btn:hover { background: #fee2e2; }
.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.author-link { text-decoration: none; }
.author-link:hover { color: var(--accent); text-decoration: underline; }

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.user-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.06);
  border-color: var(--border-hover);
}
.user-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.user-name { font-weight: 600; font-size: 1.05rem; margin-bottom: 2px; }
.bookmark-btn {
  width: auto;
  padding: 8px 18px;
  background: #fff;
  color: var(--text-sub);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.bookmark-btn:hover { background: #f9fafb; }
.bookmark-btn.active {
  background: #fffbeb;
  color: #d97706;
  border-color: #fcd34d;
}
.char-card { position: relative; }
.char-card-link { display: block; color: inherit; text-decoration: none; }
.mini-bookmark-form { position: absolute; top: 8px; right: 8px; margin: 0; }
.mini-bookmark {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: #9aa1ab;
}
.mini-bookmark:hover { background: #fff; }
.mini-bookmark.active { color: #d97706; background: #fffbeb; border-color: #fcd34d; }
.like-btn {
  display: inline-block;
  width: auto;
  padding: 8px 18px;
  background: #fff;
  color: var(--text-sub);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.like-btn.active { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

.sort-tab {
  display: inline-block;
  padding: 6px 14px;
  margin-right: 6px;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--text-sub);
  background: #fff;
  border: 1px solid var(--border);
}
.sort-tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  margin: 0;
  padding: 0;
}
.search-input:focus { box-shadow: none; }
.match-tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 8px;
  border-radius: 20px;
}
.danger-zone {
  margin-top: 48px;
  padding: 24px;
  border: 1px solid #fecaca;
  border-radius: 14px;
  background: #fef9f9;
  max-width: 400px;
}
.admin-badge {
  display: inline-block;
  padding: 4px 10px;
  background: #1a1a1a;
  color: #fff;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}