/* ===== CSS Variables & Reset ===== */
:root {
  --primary: #7C5CFC;
  --primary-light: #A78BFA;
  --primary-bg: #F3F0FF;
  --accent-pink: #F472B6;
  --accent-yellow: #FBBF24;
  --accent-mint: #34D399;
  --accent-blue: #60A5FA;
  --accent-orange: #FB923C;
  --bg: #FAFAFE;
  --bg-card: #FFFFFF;
  --bg-dark: #1E1B2E;
  --text: #1E1B2E;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --shadow: 0 2px 12px rgba(124,92,252,0.08);
  --shadow-lg: 0 8px 32px rgba(124,92,252,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-full: 999px;
  --tab-height: 64px;
  --header-height: 56px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { border: none; background: none; cursor: pointer; font: inherit; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
input, textarea, select { font: inherit; border: none; outline: none; }

/* ===== Layout ===== */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,250,254,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-light);
}

.header-logo {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions { display: flex; gap: 8px; }

.header-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  font-size: 18px;
  transition: var(--transition);
  position: relative;
}

.header-btn:hover { transform: scale(1.08); }

.badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 18px; height: 18px;
  background: var(--accent-pink);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

/* ===== Bottom Tab Bar ===== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--tab-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid var(--border-light);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  min-width: 56px;
  transition: var(--transition);
}

.tab-item .tab-icon {
  font-size: 24px;
  transition: var(--transition);
}

.tab-item .tab-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-light);
  transition: var(--transition);
}

.tab-item.active .tab-icon { color: var(--primary); }
.tab-item.active .tab-label { color: var(--primary); font-weight: 700; }

/* ===== Page Content ===== */
.page {
  display: none;
  padding: 16px 20px;
  padding-bottom: calc(var(--tab-height) + 24px);
  animation: fadeIn 0.3s ease;
}

.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Section Titles ===== */
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title .more {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-lg); }

.card-gradient {
  background: linear-gradient(135deg, var(--primary), var(--accent-pink));
  color: #fff;
}

.card-gradient .card-subtitle { color: rgba(255,255,255,0.8); }

/* ===== Emotion Mood Selector ===== */
.mood-selector {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}

.mood-selector::-webkit-scrollbar { display: none; }

.mood-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.mood-chip:hover, .mood-chip.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}

.mood-chip .emoji { font-size: 18px; }

/* ===== Room Preview ===== */
.room-preview {
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/10;
  background: linear-gradient(180deg, #2D1B69 0%, #1a1145 60%, #0d0a24 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.room-preview .room-objects {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.room-object {
  position: absolute;
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.room-preview .room-message {
  position: relative;
  z-index: 2;
  color: #fff;
  text-align: center;
  padding: 20px;
}

.room-preview .room-message h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.room-preview .room-message p {
  font-size: 13px;
  opacity: 0.8;
}

.room-preview .room-mood-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  color: #fff;
  font-weight: 600;
}

/* ===== Horizontal Scroll List ===== */
.h-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
}

.h-scroll::-webkit-scrollbar { display: none; }

/* ===== Friend Room Cards ===== */
.friend-room {
  flex-shrink: 0;
  width: 130px;
  text-align: center;
  cursor: pointer;
}

.friend-room .room-thumb {
  width: 130px;
  height: 90px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  position: relative;
}

.friend-room .friend-name {
  font-size: 13px;
  font-weight: 600;
}

.friend-room .friend-mood {
  font-size: 11px;
  color: var(--text-light);
}

.online-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px; height: 8px;
  background: var(--accent-mint);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
}

/* ===== Trace Items ===== */
.trace-list { display: flex; flex-direction: column; gap: 10px; }

.trace-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.trace-avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.trace-content { flex: 1; min-width: 0; }
.trace-content .trace-name { font-size: 13px; font-weight: 600; }
.trace-content .trace-text { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trace-time { font-size: 11px; color: var(--text-light); flex-shrink: 0; }

/* ===== Club Cards ===== */
.club-card {
  flex-shrink: 0;
  width: 200px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
}

.club-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.club-card .club-emoji { font-size: 32px; margin-bottom: 8px; }
.club-card .club-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.club-card .club-desc { font-size: 11px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.4; }
.club-card .club-members { font-size: 11px; color: var(--text-light); }

/* ===== My Room Page ===== */
.room-full {
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  min-height: 280px;
  background: linear-gradient(180deg, #2D1B69 0%, #1a1145 50%, #0d0a24 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  padding: 30px 20px;
}

.room-full .room-objects {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.room-full .room-center {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff;
}

.room-full .room-center .avatar-large {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-pink));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 12px;
  box-shadow: 0 4px 20px rgba(124,92,252,0.4);
}

.room-full .room-center .room-nickname {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.room-full .room-center .room-today-msg {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 16px;
}

.room-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.room-action-btn {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.room-action-btn:hover { background: rgba(255,255,255,0.25); }

/* ===== Emotion Post ===== */
.emotion-post {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.emotion-post .post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.emotion-post .post-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.emotion-post .post-meta { flex: 1; }
.emotion-post .post-name { font-size: 13px; font-weight: 600; }
.emotion-post .post-time { font-size: 11px; color: var(--text-light); }
.emotion-post .post-body { font-size: 14px; line-height: 1.6; margin-bottom: 10px; }

.emotion-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.emotion-tag {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

/* ===== Visitor / Trace Grid ===== */
.visitor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.visitor-item {
  text-align: center;
  cursor: pointer;
}

.visitor-item .visitor-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin: 0 auto 6px;
}

.visitor-item .visitor-name { font-size: 11px; font-weight: 600; }
.visitor-item .visitor-time { font-size: 10px; color: var(--text-light); }

/* ===== Sticker Grid (방 꾸미기) ===== */
.decor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.decor-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}

.decor-item:hover, .decor-item.selected {
  border-color: var(--primary);
  background: #fff;
}

.decor-item .decor-emoji { font-size: 28px; }
.decor-item .decor-label { font-size: 10px; color: var(--text-secondary); }

/* ===== Visit Page ===== */
.visit-room-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.visit-room-card:hover { transform: translateX(4px); }

.visit-room-thumb {
  width: 80px;
  height: 56px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.visit-room-info { flex: 1; min-width: 0; }
.visit-room-info .vr-name { font-size: 14px; font-weight: 600; }
.visit-room-info .vr-mood { font-size: 12px; color: var(--text-secondary); }
.visit-room-info .vr-time { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ===== Club Page ===== */
.club-full-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.club-full-card:hover { box-shadow: var(--shadow-lg); }

.club-full-card .club-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.club-full-card .club-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}

.club-full-card .club-title { font-size: 15px; font-weight: 700; }
.club-full-card .club-sub { font-size: 12px; color: var(--text-secondary); }
.club-full-card .club-body { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 10px; }

.club-full-card .club-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-light);
}

.club-tag {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-bg);
  color: var(--primary);
}

/* ===== My Page ===== */
.profile-card {
  text-align: center;
  padding: 24px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-pink));
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  margin: 0 auto 12px;
  box-shadow: 0 4px 20px rgba(124,92,252,0.3);
}

.profile-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.profile-bio { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
}

.profile-stat { text-align: center; }
.profile-stat .stat-num { font-size: 18px; font-weight: 700; color: var(--primary); }
.profile-stat .stat-label { font-size: 11px; color: var(--text-light); }

.menu-list { margin-bottom: 16px; }

.menu-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 0 6px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  cursor: pointer;
  transition: var(--transition);
}

.menu-item:hover { background: var(--primary-bg); }

.menu-item .menu-icon { font-size: 20px; width: 28px; text-align: center; }
.menu-item .menu-text { flex: 1; font-size: 14px; font-weight: 500; }
.menu-item .menu-arrow { color: var(--text-light); font-size: 14px; }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent-pink));
  color: #fff;
  box-shadow: 0 4px 16px rgba(124,92,252,0.3);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,92,252,0.4); }

.btn-secondary {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 8px 16px; font-size: 12px; }
.btn-block { width: 100%; }

/* ===== Form Elements ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  transition: var(--transition);
}

.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,92,252,0.1); }

textarea.form-input { resize: none; min-height: 80px; }

/* ===== AI Play Card ===== */
.ai-play-card {
  background: linear-gradient(135deg, #1E1B2E 0%, #2D1B69 100%);
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  margin-bottom: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.ai-play-card:hover { transform: scale(1.01); }
.ai-play-card .ai-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.ai-play-card .ai-desc { font-size: 12px; opacity: 0.7; }
.ai-play-card .ai-icon { font-size: 36px; margin-bottom: 8px; }

/* ===== Sub page header ===== */
.sub-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.sub-header .back-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.sub-header h2 { font-size: 18px; font-weight: 700; }

/* ===== Tab Pills ===== */
.tab-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-pills::-webkit-scrollbar { display: none; }

.tab-pill {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
}

.tab-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== Trace sticker picker ===== */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.sticker-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}

.sticker-item:hover, .sticker-item.selected {
  border-color: var(--primary);
  transform: scale(1.1);
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; }

/* ===== Color utility ===== */
.bg-purple { background: linear-gradient(135deg, #7C5CFC22, #A78BFA22); }
.bg-pink { background: linear-gradient(135deg, #F472B622, #EC489922); }
.bg-blue { background: linear-gradient(135deg, #60A5FA22, #3B82F622); }
.bg-mint { background: linear-gradient(135deg, #34D39922, #10B98122); }
.bg-yellow { background: linear-gradient(135deg, #FBBF2422, #F59E0B22); }
.bg-orange { background: linear-gradient(135deg, #FB923C22, #F9731622); }
.bg-night { background: linear-gradient(180deg, #2D1B69, #1a1145); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== Responsive desktop ===== */
@media (min-width: 768px) {
  .app {
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    box-shadow: 0 0 60px rgba(0,0,0,0.06);
  }
}
