:root {
  --bg: #fbf6ef;
  --bg-elevated: #ffffff;
  --text: #2b2420;
  --text-muted: #8a7f73;
  --border: #ece2d4;
  --accent: #ff7a4d;
  --accent-2: #ffb238;
  --accent-contrast: #ffffff;
  --danger: #d1584f;
  --route-color: #2f8fd1;
  --tip-color: #e0972a;
  --info-color: #8a5fd6;
  --radius: 18px;
  --radius-lg: 24px;
  --shadow: 0 4px 16px rgba(60, 40, 20, 0.08);
}

:root[data-theme="dark"] {
  --bg: #1b1714;
  --bg-elevated: #262019;
  --text: #f3ece3;
  --text-muted: #b0a396;
  --border: #3a322a;
  --accent: #ff8a5e;
  --accent-2: #ffc457;
  --accent-contrast: #241005;
  --danger: #e58079;
  --route-color: #6fb6ea;
  --tip-color: #f0b558;
  --info-color: #b79bef;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { min-width: 320px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font-family: inherit; }

.loading-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 닉네임 게이트 ---------- */

.nickname-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--accent) 0%, var(--bg) 55%);
  padding: 24px;
  z-index: 90;
}

.nickname-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 36px 26px 30px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.nickname-emoji { font-size: 2.6rem; margin-bottom: 6px; }
.nickname-card h1 { margin: 0 0 10px; font-size: 1.3rem; }
.nickname-card p { color: var(--text-muted); font-size: 0.88rem; line-height: 1.5; margin: 0 0 20px; }
.nickname-card form { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 레이아웃 ---------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 66px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.app-title { font-weight: 900; }
.app-user { font-size: 0.85rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.view-container {
  flex: 1;
  padding: 14px 12px 90px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- 아바타 ---------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- 하단 탭 + FAB ---------- */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 9px 2px 8px;
  font-size: 1.15rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tab-btn span { font-size: 0.68rem; }
.tab-btn.active { color: var(--accent); font-weight: 700; }

.fab-write {
  position: fixed;
  right: 18px;
  bottom: 78px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.4rem;
  box-shadow: 0 6px 18px rgba(255, 122, 77, 0.45);
  z-index: 15;
  cursor: pointer;
}

/* ---------- 버튼/폼 ---------- */

.btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 15px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.btn-block { width: 100%; }
.btn-ghost { background: none; border-color: transparent; }
.btn-sm { padding: 5px 8px; font-size: 0.8rem; }
.btn-danger { color: var(--danger); border-color: var(--danger); }

.form-control {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 0.85rem; margin-bottom: 10px; }
.alert-error { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

.section-title { font-weight: 900; font-size: 1.05rem; margin: 4px 0 12px; }

/* ---------- 홈 피드 ---------- */

.upcoming-card {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.upcoming-card .uc-label { font-size: 0.75rem; opacity: 0.85; font-weight: 700; }
.upcoming-card .uc-title { font-size: 1.05rem; font-weight: 900; margin: 4px 0 2px; }
.upcoming-card .uc-sub { font-size: 0.82rem; opacity: 0.9; }

.filter-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active { background: var(--text); color: var(--bg-elevated); border-color: var(--text); font-weight: 700; }

.tag-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
  margin-left: auto;
}

.tag-route { background: var(--route-color); }
.tag-tip { background: var(--tip-color); }
.tag-info { background: var(--info-color); }

/* ---------- Day/일정 ---------- */

.day-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}

.day-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.day-card-title { display: flex; flex-direction: column; }
.day-label { font-size: 1rem; }
.day-date, .day-desc { font-size: 0.78rem; color: var(--text-muted); }

.day-items { padding: 4px 15px 12px; }

.item-card { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.item-card:last-child { border-bottom: none; }

.item-time { flex: 0 0 52px; font-weight: 700; color: var(--accent); font-size: 0.85rem; padding-top: 2px; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 700; }
.item-location a { color: var(--accent); font-size: 0.85rem; text-decoration: none; }
.item-memo { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; white-space: pre-wrap; }
.item-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.item-images { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.item-images img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.item-actions { display: flex; flex-direction: column; gap: 2px; }

.add-day-btn { display: block; margin: 4px auto 20px; }

/* ---------- 피드 카드 ---------- */

.post-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px;
  margin-bottom: 12px;
  cursor: pointer;
}

.post-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.post-card-who { display: flex; flex-direction: column; line-height: 1.2; }
.post-author { font-size: 0.85rem; }
.post-time { font-size: 0.72rem; color: var(--text-muted); }

.post-title { margin: 0 0 4px; font-size: 1rem; }
.post-excerpt { margin: 0; font-size: 0.88rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.post-thumb img { width: 100%; max-height: 160px; object-fit: cover; border-radius: 12px; margin-top: 8px; }
.post-card-footer { margin-top: 8px; font-size: 0.78rem; color: var(--text-muted); }

/* ---------- 상세 ---------- */

.detail-who { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.detail-body { white-space: pre-wrap; line-height: 1.55; margin: 12px 0; }
.detail-images { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.detail-images img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; }

.comment-list { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.comment { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 0.85rem; }
.comment-main { flex: 1; }
.comment-author { margin-right: 6px; }
.comment-time { color: var(--text-muted); font-size: 0.72rem; }
.comment-body { margin: 3px 0 0; white-space: pre-wrap; }

.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; }

/* ---------- 멤버 ---------- */

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.member-row .member-name { font-weight: 700; }
.member-row .member-since { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }

/* ---------- 공통 ---------- */

.empty-state { text-align: center; color: var(--text-muted); padding: 44px 10px; font-size: 0.9rem; line-height: 1.6; }
.empty-state .ee-emoji { font-size: 2rem; display: block; margin-bottom: 8px; }

.toast-container {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: translateY(0); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 10, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 80;
}

.modal-sheet {
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-sheet h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }

.write-sheet-options { display: flex; flex-direction: column; gap: 8px; }
.write-sheet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.write-sheet-option .wso-emoji { font-size: 1.3rem; }
.write-sheet-option .wso-desc { font-weight: 400; font-size: 0.78rem; color: var(--text-muted); display: block; }
