/* =========================================================
   감정트리 — Christmas Noir
   팔레트: 검정 · 회색 + 빨강 3톤(red / wine / rose)
   색은 전부 :root 변수에서만 바꿔주세요.
   ========================================================= */
:root {
  /* 무채색 */
  --black: #0b0b0c;
  --ink-900: #111113;
  --ink-800: #161618;
  --ink-700: #1e1e21;
  --ink-600: #2a2a2e;
  --ink-500: #3a3a3f;
  --gray-400: #6e6e73;
  --gray-300: #a1a1a6;
  --gray-200: #d4d4d8;
  --gray-100: #f2f2f4;

  /* 빨강 3톤 */
  --red: #c8102e;
  --wine: #7a0f1f;
  --rose: #e8475b;

  /* 역할 */
  --bg: var(--black);
  --surface: var(--ink-800);
  --surface-2: var(--ink-700);
  --line: var(--ink-600);
  --text: var(--gray-100);
  --text-sub: var(--gray-300);
  --text-faint: var(--gray-400);
  --accent: var(--red);
  --accent-soft: color-mix(in srgb, var(--red) 14%, transparent);

  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font-title: "Jua", "Gowun Dodum", sans-serif;
  --font-body: "Gowun Dodum", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: dark; scrollbar-color: var(--ink-500) var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.7;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.muted { color: var(--text-faint); font-family: var(--font-body); font-weight: 400; }
b, strong, h1, h2, h3, h4 { font-family: var(--font-title); font-weight: 400; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px; padding: 10px 20px; cursor: pointer;
  font-family: var(--font-title); font-weight: 400; font-size: 15px; transition: transform .15s var(--ease), background .2s, border-color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn--primary { background: var(--red); color: #fff; }
.btn--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 88%, #fff); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-sub); }
.btn--ghost:hover { border-color: var(--gray-400); color: var(--text); }
.btn--sm { padding: 7px 14px; font-size: 14px; }
.btn--lg { padding: 14px 28px; font-size: 16px; }
.btn--block { width: 100%; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: transparent; border: 0; color: var(--text-sub); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- 헤더 ---------- */
.header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.2) blur(14px); -webkit-backdrop-filter: saturate(1.2) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.header__inner { max-width: 1080px; margin: 0 auto; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-title); font-size: 19px; font-weight: 400; }
.logo__mark {
  width: 22px; height: 22px; background: url("/assets/favicon.svg") center/cover; border-radius: 6px;
}
.header__right { display: flex; align-items: center; gap: 12px; }
.dday { font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.text-btn { background: none; border: 0; padding: 6px 4px; cursor: pointer; font-size: 14px; color: var(--text-sub); }
.text-btn:hover { color: var(--text); }

/* ---------- 트리 씬 ---------- */
.scene {
  position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 50% 42%, #1d1d20 0%, transparent 70%),
    radial-gradient(ellipse 80% 40% at 50% 100%, #161618 0%, transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--line);
}
.snow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scene__inner { position: relative; max-width: 1080px; margin: 0 auto; padding: 56px 16px 48px; text-align: center; }
.eyebrow { margin: 0 0 10px; font-size: 12px; font-family: var(--font-title); font-weight: 400; letter-spacing: .18em; text-transform: uppercase; color: var(--rose); }
.hero__title {
  font-family: var(--font-title); font-weight: 400; font-size: clamp(28px, 6vw, 46px);
  line-height: 1.3; letter-spacing: -0.02em; margin: 0 0 14px;
}
.hero__desc { color: var(--text-sub); margin: 0 auto; max-width: 560px; }

.tree { position: relative; width: min(560px, 100%); margin: 28px auto 0; aspect-ratio: 600 / 720; }
.tree__img { width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.tree__ornaments { position: absolute; inset: 0; }

.ornament {
  position: absolute; width: 6.4%; padding: 0; border: 0; background: none; cursor: pointer;
  transform: translateX(-50%); transform-origin: 50% 0;
  display: flex; flex-direction: column; align-items: center;
  animation: sway 5s ease-in-out infinite; animation-delay: var(--delay, 0s);
}
.ornament::before { /* 걸이 실 */
  content: ""; width: 1px; height: 12px; background: linear-gradient(var(--gray-300), var(--gray-400)); opacity: .7;
}
.ornament .ornament-svg { width: 100%; height: auto; margin-top: -4px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.55)); transition: transform .3s var(--ease); }
.ornament:hover .ornament-svg, .ornament:focus-visible .ornament-svg { transform: scale(1.18); }
.ornament__count {
  position: absolute; right: -14%; bottom: 4%; min-width: 15px; height: 15px; padding: 0 3px;
  display: grid; place-items: center; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(11, 11, 12, .82); color: var(--gray-100); font-family: var(--font-title); font-size: 9.5px; line-height: 1;
  pointer-events: none;
}
.ornament:focus-visible { outline: none; }
.ornament.is-new { animation: drop-in .9s var(--ease) both, sway 5s ease-in-out .9s infinite; }
.ornament__tip {
  position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translate(-50%, 4px);
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .2s, transform .2s var(--ease);
  background: var(--gray-100); color: var(--black); font-size: 12px; font-family: var(--font-title); font-weight: 400;
  padding: 5px 10px; border-radius: 8px; box-shadow: var(--shadow); z-index: 2;
}
.ornament__tip span { color: var(--red); }
.ornament:hover .ornament__tip, .ornament:focus-visible .ornament__tip { opacity: 1; transform: translate(-50%, 0); }
.ornament:hover, .ornament:focus-visible { z-index: 3; animation-play-state: paused; }
@keyframes sway { 0%, 100% { rotate: -2.5deg; } 50% { rotate: 2.5deg; } }
@keyframes drop-in { 0% { opacity: 0; translate: 0 -40px; } 60% { opacity: 1; translate: 0 4px; } 100% { translate: 0 0; } }

.scene__footer { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 8px; }
.tree-count { margin: 0; color: var(--text-sub); font-size: 14px; }
.tree-count b { color: var(--text); font-size: 18px; font-family: var(--font-title); font-weight: 400; margin: 0 2px; }
.notice { margin: 0; font-size: 13px; color: var(--rose); }
.notice[hidden] { display: none; }

/* ---------- 게시판 ---------- */
.board { max-width: 1080px; margin: 0 auto; padding: 56px 16px 32px; }
.board__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-title { font-family: var(--font-title); font-size: 26px; font-weight: 400; margin: 0; letter-spacing: -0.02em; }
.board__count { margin: 0; color: var(--text-faint); font-size: 14px; }

.filters {
  display: flex; gap: 8px; margin: 0 -16px 22px; padding: 2px 16px 6px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-sub);
  border-radius: 999px; padding: 7px 14px 7px 10px; font-size: 14px; font-family: var(--font-title); font-weight: 400; cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.chip .ornament-svg { width: 18px; height: 18px; }
.chip:hover { border-color: var(--gray-400); color: var(--text); }
.chip.is-active { background: var(--red); border-color: var(--red); color: #fff; }
.chip--all { padding-left: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 12px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px; transition: border-color .2s;
}
.card:hover { border-color: var(--gray-400); }
.card__top { display: flex; align-items: center; gap: 12px; }
.card__orn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: var(--surface-2); border-radius: 12px; }
.card__orn .ornament-svg { width: 30px; height: 30px; }
.card__label { font-family: var(--font-title); font-weight: 400; font-size: 15px; color: var(--text); }
.card__who { font-size: 13px; color: var(--text-faint); }
.card__content {
  margin: 0; color: var(--gray-200); white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.card__stats { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-faint); margin-top: auto; }
.card__stats span { display: inline-flex; align-items: center; gap: 5px; }
.card__stats svg { width: 15px; height: 15px; }
.card__ai { margin-left: auto; color: var(--rose); }
.empty {
  grid-column: 1 / -1; text-align: center; color: var(--text-faint); padding: 56px 16px;
  border: 1px dashed var(--line); border-radius: var(--radius-lg);
}

/* ---------- 모달 ---------- */
.modal {
  border: 1px solid var(--line); padding: 0; border-radius: 24px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal--wide { width: min(680px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(5, 5, 6, .72); backdrop-filter: blur(4px); }
.modal[open] { animation: modal-in .3s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal__body:focus { outline: none; }
.modal__body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.modal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal__head .eyebrow { margin-bottom: 4px; }
.modal__title { font-family: var(--font-title); font-weight: 400; margin: 0; font-size: 24px; letter-spacing: -0.02em; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { font-family: var(--font-title); font-weight: 400; font-size: 14px; color: var(--gray-200); }
.field__help { margin: 0; font-size: 13px; color: var(--text-sub); min-height: 1.4em; }
.textarea-wrap { position: relative; display: block; }
.field__count { position: absolute; right: 12px; bottom: 10px; font-size: 12px; color: var(--text-faint); pointer-events: none; }
.input {
  width: 100%; border: 1px solid var(--line); background: var(--ink-900); border-radius: var(--radius);
  padding: 12px 14px; transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rose) 22%, transparent); }
textarea.input { resize: vertical; padding-bottom: 30px; min-height: 120px; display: block; }
.form-error { color: var(--rose); margin: -8px 0 0; font-size: 14px; min-height: 1.2em; }

/* 장식 고르기 */
.emotion-picker { display: flex; flex-direction: column; gap: 16px; }
.emotion-group__title { font-size: 12px; font-family: var(--font-title); font-weight: 400; letter-spacing: .06em; color: var(--text-faint); margin: 0 0 8px; }
.emotion-group__list { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.emo-option {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 9px;
  border: 1px solid var(--line); background: var(--ink-900); border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-family: var(--font-title); font-weight: 400; color: var(--text-sub); transition: border-color .2s, background .2s, color .2s, transform .15s var(--ease);
}
.emo-option .ornament-svg { width: 38px; height: 38px; transition: transform .3s var(--ease); }
.emo-option:hover { border-color: var(--gray-400); color: var(--text); }
.emo-option:hover .ornament-svg { transform: translateY(-2px) rotate(-4deg); }
.emo-option.is-active { border-color: var(--red); background: var(--accent-soft); color: var(--text); }

.field__help[hidden] { display: none; }
.custom-input { position: relative; display: block; }
.custom-input .input { padding-left: 48px; }
.custom-input__orn {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px;
  opacity: .35; filter: grayscale(1); transition: opacity .2s, filter .2s; pointer-events: none;
}
.custom-input__orn .ornament-svg { width: 100%; height: 100%; }
.custom-input__orn.is-active { opacity: 1; filter: none; }

/* 이용 방법 */
.modal--guide { width: min(440px, calc(100% - 24px)); }
.guide { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.guide__step { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--surface-2); border-radius: var(--radius); }
.guide__orn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; background: var(--ink-900); border-radius: 12px; }
.guide__orn .ornament-svg { width: 32px; height: 32px; }
.guide__title { margin: 0 0 2px; font-family: var(--font-title); font-weight: 400; display: flex; align-items: center; gap: 8px; }
.guide__title span { font-size: 12px; color: var(--rose); font-variant-numeric: tabular-nums; }
.guide__text { margin: 0; font-size: 14px; color: var(--text-sub); word-break: keep-all; }

/* 감정 묶음 목록 */
.group-list { display: flex; flex-direction: column; gap: 8px; max-height: min(52dvh, 460px); overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.group-item {
  display: flex; flex-direction: column; gap: 6px; text-align: left; cursor: pointer; width: 100%;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius); padding: 12px 14px;
  transition: border-color .2s;
}
.group-item:hover { border-color: var(--gray-400); }
.group-item__text {
  margin: 0; color: var(--gray-200); word-break: keep-all; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.group-item__meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-faint); }
.group-item__meta span { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.group-item__meta svg { width: 14px; height: 14px; }
.group-empty { margin: 8px 0; text-align: center; color: var(--text-faint); font-size: 14px; }

/* ---------- 상세 ---------- */
.post__head { display: flex; align-items: center; gap: 14px; }
.post__orn { width: 60px; height: 60px; flex: none; display: grid; place-items: center; background: var(--surface-2); border-radius: 18px; }
.post__orn .ornament-svg { width: 46px; height: 46px; }
.post__label { font-family: var(--font-title); font-size: 22px; font-weight: 400; margin: 0; }
.post__meta { color: var(--text-faint); font-size: 13px; }
.post__content { white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; margin: 0; font-size: 16px; line-height: 1.8; color: var(--gray-100); }

.reactions { display: flex; flex-wrap: wrap; gap: 8px; }
.reaction {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--ink-900); border-radius: 999px; padding: 8px 14px; cursor: pointer;
  font-size: 14px; color: var(--text-sub); transition: border-color .2s, color .2s, background .2s;
}
.reaction svg { width: 16px; height: 16px; }
.reaction:hover { border-color: var(--gray-400); color: var(--text); }
.reaction.is-mine { border-color: var(--red); background: var(--accent-soft); color: var(--text); }
.reaction.is-mine svg { color: var(--rose); }
.reaction__count { font-family: var(--font-title); font-weight: 400; color: var(--text); font-variant-numeric: tabular-nums; }
.reaction.pop svg { animation: pop .35s var(--ease); }
@keyframes pop { 50% { transform: scale(1.35); } }

.comments { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 20px; }
.comments__title { margin: 0; font-size: 15px; font-family: var(--font-title); font-weight: 400; }
.comments__title span { color: var(--text-faint); font-family: var(--font-title); font-weight: 400; margin-left: 4px; }
.comment { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; }
.comment__head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-faint); margin-bottom: 6px; gap: 8px; }
.comment__name { font-family: var(--font-title); font-weight: 400; color: var(--gray-200); display: inline-flex; align-items: center; gap: 6px; }
.comment__body { white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; margin: 0; font-size: 15px; color: var(--gray-200); }

.comment--ai { border-left: 2px solid var(--red); border-radius: 4px var(--radius) var(--radius) 4px; }
.santa-hat { width: 18px; height: 18px; flex: none; }
.ai-body .ai-sign { text-align: right; color: var(--text-sub); font-family: var(--font-title); margin-top: 2px; }
.ai-tag { font-size: 11px; font-family: var(--font-title); font-weight: 400; color: var(--text-faint); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; line-height: 18px; }
.ai-body { display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: var(--gray-200); }
.ai-body p { margin: 0; word-break: keep-all; overflow-wrap: anywhere; }
.ai-body .ai-tip { position: relative; padding-left: 14px; }
.ai-body .ai-tip::before { content: ""; position: absolute; left: 2px; top: .72em; width: 5px; height: 5px; border-radius: 50%; background: var(--rose); }
.ai-loading { display: flex; align-items: center; gap: 10px; color: var(--text-sub); margin: 0; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--rose); animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.link-btn { background: none; border: 0; color: var(--rose); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; margin-top: 10px; align-self: flex-start; }

.comment-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.comment-form__row { display: flex; gap: 8px; }
.comment-form__row .input { flex: 0 0 150px; }
.comment-form__row .btn { margin-left: auto; }
.comment-form textarea.input { min-height: 72px; padding-bottom: 12px; }

/* ---------- 푸터 / 토스트 ---------- */
.footer { border-top: 1px solid var(--line); padding: 28px 16px 40px; text-align: center; color: var(--text-faint); font-size: 13px; }
.footer p { margin: 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--gray-100); color: var(--black); font-family: var(--font-title); font-weight: 400; padding: 11px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s var(--ease); font-size: 14px;
  max-width: calc(100% - 32px); z-index: 100; box-shadow: var(--shadow);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 반응형 ---------- */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .scene__inner { padding: 36px 16px 36px; }
  .br-desktop { display: none; }
  .tree { margin-top: 18px; }
  .ornament { width: 7.4%; }
  .ornament__count { display: none; } /* 폰에선 장식이 작아서 숫자는 누르면 보이는 목록에서 */
  .ornament__tip { font-size: 11px; }
  .board { padding-top: 40px; }
  .cards { grid-template-columns: 1fr; }
  .modal:not(.modal--guide) { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 24px 24px 0 0; border-bottom: 0; }
  .modal__body { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .emotion-group__list { grid-template-columns: repeat(4, 1fr); }
  .header__right { gap: 8px; }
  .comment-form__row { flex-wrap: wrap; }
  .comment-form__row .input { flex: 1 1 100%; }
  .comment-form__row .btn { width: 100%; }
  .dday { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
