/* 부엉이장 디자인 v2: 마법학교 기숙사의 오래된 양피지 편지 느낌
   색은 맨 위 :root 에서 한 번에 바꿀 수 있어요. */
@import url("https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&family=Song+Myung&display=swap");

:root {
  --night: #1f1a2e;        /* 바깥 밤하늘 */
  --night-2: #2c2440;
  --parchment: #f3e6c8;    /* 양피지 */
  --parchment-2: #e9d6ac;
  --ink: #3b2a1e;          /* 잉크 */
  --muted: #7d6650;        /* 흐린 잉크 */
  --line: #cdb48a;         /* 선 */
  --gold: #c9a24a;         /* 금박 */
  --gold-soft: #f0dfa8;
  --wax: #8e2a2a;          /* 봉랍(빨간 왁스) */
  --wax-dark: #5e1a1a;
  --danger: #a3302a;
  --radius: 6px;
  --title: "Song Myung", "Gowun Batang", serif;
}

* { box-sizing: border-box; }

body {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  font-family: "Gowun Batang", "Nanum Myeongjo", serif;
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--ink);
  background-color: var(--night);
  /* 별이 뜬 밤하늘 */
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(255,240,200,.8), transparent),
    radial-gradient(1px 1px at 70% 10%, rgba(255,240,200,.7), transparent),
    radial-gradient(1.5px 1.5px at 85% 60%, rgba(255,240,200,.6), transparent),
    radial-gradient(1px 1px at 40% 80%, rgba(255,240,200,.6), transparent),
    radial-gradient(1px 1px at 10% 90%, rgba(255,240,200,.5), transparent),
    radial-gradient(ellipse at top, var(--night-2), var(--night) 70%);
  background-size: 260px 260px, 300px 300px, 340px 340px, 280px 280px, 320px 320px, 100% 100%;
  background-attachment: fixed;
}

a { color: var(--wax); text-decoration-color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--wax-dark); }

h1, h2 { font-family: var(--title); font-weight: 400; line-height: 1.3; margin: 0 0 12px; color: var(--ink); }
h1 { font-size: 2.2rem; letter-spacing: 0.02em; }
h1::after {
  content: "";
  display: block;
  width: 72px;
  height: 2px;
  margin-top: 10px;
  background: linear-gradient(90deg, var(--gold), transparent);
}
h2 { font-size: 1.45rem; margin-top: 30px; }
h2::before { content: "✦ "; color: var(--gold); font-size: 0.9em; }

/* ---------- 상단 메뉴 (금박 띠) ---------- */
#nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  margin-bottom: 26px;
  background: linear-gradient(#2a2238, #1c1728);
  border: 1px solid var(--gold);
  outline: 1px solid rgba(201,162,74,.35);
  outline-offset: 3px;
  border-radius: var(--radius);
}
#nav a {
  color: var(--gold-soft);
  text-decoration: none;
  padding: 2px 12px;
  border-radius: 4px;
  font-size: 0.95rem;
}
#nav a:hover { color: #fff3cf; background: rgba(201,162,74,.15); }
#nav a:first-child { font-family: var(--title); font-size: 1.25rem; color: var(--gold); }
#nav a:first-child::before { content: "🦉 "; }
#nav #logout { margin-left: auto; color: #a99a7a; }

/* ---------- 본문 양피지 ---------- */
#app {
  position: relative;
  padding: 40px 36px 40px;
  border-radius: 3px;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(255,250,235,.7), transparent 45%),
    radial-gradient(ellipse at 85% 90%, rgba(170,130,70,.25), transparent 50%),
    radial-gradient(ellipse at center, var(--parchment) 55%, var(--parchment-2) 100%);
  box-shadow:
    inset 0 0 60px rgba(140,100,50,.35),
    inset 0 0 6px rgba(120,80,40,.4),
    0 12px 40px rgba(0,0,0,.45);
}
/* 안쪽 이중 테두리 */
#app::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(160,120,60,.45);
  outline: 1px solid rgba(160,120,60,.25);
  outline-offset: -5px;
  pointer-events: none;
}
/* 봉랍 도장 */
#app::before {
  content: "🦉";
  position: absolute;
  top: -22px;
  right: 30px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b8443f, var(--wax) 55%, var(--wax-dark));
  box-shadow: 0 0 0 4px rgba(142,42,42,.35), 0 3px 8px rgba(0,0,0,.4), inset 0 0 0 3px rgba(0,0,0,.15);
  filter: saturate(.9);
  z-index: 1;
}

/* ---------- 폼 ---------- */
form { display: grid; gap: 10px; margin: 14px 0; }
input, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"]):not([type="file"]), textarea {
  width: 100%;
  padding: 8px 4px;
  border: none;
  border-bottom: 1.5px solid var(--line);
  border-radius: 0;
  background: transparent;
  outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus { border-color: var(--wax); background: rgba(255,250,235,.45); }
input::placeholder, textarea::placeholder { color: #a48c6c; }
textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 30px;
  padding: 0 6px !important;
  border: 1px solid var(--line) !important;
  background-color: rgba(255,250,235,.35);
  background-image: repeating-linear-gradient(transparent 0 29px, rgba(160,120,60,.3) 29px 30px);
  background-attachment: local;
}
label { color: var(--muted); font-size: 0.95rem; }
input[type="file"] { display: block; margin-top: 6px; font-size: 0.9rem; }
input[type="file"]::file-selector-button {
  font: inherit;
  border: 1px dashed var(--muted);
  background: rgba(255,250,235,.5);
  color: var(--ink);
  border-radius: 4px;
  padding: 3px 12px;
  margin-right: 10px;
  cursor: pointer;
}

/* 봉랍처럼 생긴 기본 버튼 */
button {
  cursor: pointer;
  justify-self: start;
  border: 1px solid var(--wax-dark);
  border-radius: 4px;
  padding: 7px 22px;
  background: linear-gradient(#9b3330, var(--wax-dark));
  color: var(--gold-soft);
  font-family: var(--title);
  font-size: 1.02rem;
  letter-spacing: .05em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 2px 4px rgba(60,20,10,.35);
  transition: transform .1s, filter .1s;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }

/* 작은 보조 버튼 (수정/삭제 등) */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.actions button, .actions a {
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0;
  padding: 1px 10px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: none;
  text-decoration: none;
}
.actions button:hover, .actions a:hover { background: rgba(255,250,235,.6); color: var(--ink); filter: none; }
#delete-post:hover, [data-act^="delete"]:hover, [data-act="remove-member"]:hover {
  color: var(--danger); border-color: var(--danger);
}
.actions input { flex: 1; min-width: 0; font-size: 0.85rem; }

/* ---------- 공통 ---------- */
.post-body, .comment-body, .bio { white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 0.88rem; }
.meta a { color: var(--muted); }
.error { color: var(--danger); font-size: 0.9rem; margin: 0; }
.error:empty, .progress:empty { display: none; }
code { background: rgba(201,162,74,.25); padding: 1px 6px; border-radius: 3px; font-size: 0.9em; }

/* 목록 (일기 목록, 멤버, 쓴 글 등) — 편지 봉투 */
.list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 0; }
.list li {
  position: relative;
  padding: 14px 6px 14px 34px;
  border-bottom: 1px dashed var(--line);
  transition: background .15s;
}
.list li::before {
  content: "✉\FE0E";
  position: absolute;
  left: 6px;
  top: 14px;
  color: var(--wax);
  font-size: 1.05rem;
}
.list li:hover { background: rgba(255,250,235,.45); }
.list li > a:first-child { font-family: var(--title); font-size: 1.2rem; text-decoration: none; color: var(--ink); }
.list li > a:first-child:hover { color: var(--wax); }
.list li > span.meta {
  display: inline-block;
  font-style: normal;
  border: 1px solid var(--gold);
  color: #8a6a22;
  background: rgba(240,223,168,.5);
  padding: 0 8px;
  border-radius: 3px;
  font-size: 0.75rem;
  margin-left: 6px;
  vertical-align: 2px;
}

/* 글 화면 */
article > .meta { margin-bottom: 18px; }
article .post-body { font-size: 1.07rem; margin: 18px 0; line-height: 1.95; }
#app > p:first-of-type > a[href="#/new"] {
  display: inline-block;
  text-decoration: none;
  font-family: var(--title);
  color: var(--wax);
  border: 1px solid var(--wax);
  border-radius: 3px;
  padding: 2px 14px;
}
#app > p:first-of-type > a[href="#/new"]::before { content: "✒\FE0E  "; }
#app > p:first-of-type > a[href="#/new"]:hover { background: rgba(142,42,42,.08); }

/* 사진 — 낡은 사진처럼 */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 16px 0; }
.photos:has(> .photo:only-child) { grid-template-columns: 1fr; }
.photo {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  background: #d9c59c;
  border: 7px solid #fbf4e2;
  border-bottom-width: 22px;
  box-shadow: 0 3px 10px rgba(60,40,20,.35);
  filter: sepia(.25) contrast(1.02);
  min-height: 80px;
  display: block;
  transition: filter .2s, transform .2s;
}
.photo:hover { filter: none; transform: rotate(0deg) scale(1.02); }
.photos > .photo:not(:only-child) { aspect-ratio: 1; }
.photos > .photo:nth-child(odd):not(:only-child) { transform: rotate(-1.5deg); }
.photos > .photo:nth-child(even) { transform: rotate(1.2deg); }
.photo-pick { display: grid; gap: 4px; justify-items: start; font-size: 0.85rem; }
.photo-pick .photo { max-height: 140px; aspect-ratio: 1; border-bottom-width: 7px; }

/* 반응 */
.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 8px; align-items: center; }
.reaction, .reaction-add {
  font-family: inherit;
  letter-spacing: 0;
  border: 1px solid var(--line);
  background: rgba(255,250,235,.5);
  color: var(--ink);
  border-radius: 999px;
  padding: 1px 12px;
  font-size: 0.92rem;
  box-shadow: none;
}
.reaction:hover, .reaction-add:hover { border-color: var(--gold); filter: none; }
.reaction.mine { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 2px rgba(201,162,74,.25); }
.reaction-add { color: var(--muted); border-style: dashed; }
.reaction-picker {
  display: flex; flex-wrap: wrap; gap: 2px; width: 100%;
  padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: rgba(255,250,235,.6);
}
.reaction-picker[hidden] { display: none; }
.reaction-picker button {
  border: none; background: none; box-shadow: none; font-size: 1.35em; padding: 2px 6px; border-radius: 4px;
}
.reaction-picker button:hover { background: rgba(201,162,74,.2); }
.reaction-picker button.mine { background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }

/* 댓글 — 덧붙인 쪽지 */
section { margin-top: 28px; padding-top: 6px; position: relative; }
section::before {
  content: "─── ✦ ───";
  display: block;
  text-align: center;
  color: var(--gold);
  letter-spacing: .2em;
  margin-bottom: 6px;
}
.comment {
  padding: 10px 14px;
  margin: 12px 0;
  background: rgba(255,250,235,.5);
  border: 1px solid rgba(160,120,60,.3);
  border-left: 3px solid var(--wax);
  border-radius: 2px;
}
.comment .actions { margin-top: 4px; }
.comment .actions:empty { display: none; }
#comment textarea { min-height: 92px; }

/* 처음 오는 사람용 로그인/가입 화면 */
#login, #signup { max-width: 360px; }

/* ---------- 휴대폰 ---------- */
@media (max-width: 560px) {
  body { padding: 14px 12px 40px; }
  #nav a { padding: 2px 8px; }
  #app { padding: 34px 20px 28px; }
  #app::after { inset: 6px; }
  h1 { font-size: 1.85rem; }
  .photos { grid-template-columns: repeat(2, 1fr); }
}

/* 프로필 사진 (원형) */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 28px; height: 28px; margin-right: 6px; vertical-align: middle;
  border-radius: 50%; overflow: hidden; background: var(--gold-soft); color: var(--ink);
  font-weight: 600; font-size: 0.8rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 96px; height: 96px; font-size: 2rem; margin: 0 0 8px; }
.avatar-edit { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* 사진 자르기 창 */
.cropper { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(20, 15, 30, .7); }
.cropper-panel { display: grid; gap: 10px; width: min(100%, 320px); padding: 18px; background: var(--parchment); border: 1px solid var(--line); border-radius: var(--radius); }
.cropper-stage { position: relative; width: 280px; height: 280px; max-width: 100%; justify-self: center; }
.cropper-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.cropper-stage canvas:active { cursor: grabbing; }
.cropper-mask { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 200px rgba(20, 15, 30, .55); outline: 2px solid var(--gold); }
.cropper-stage { overflow: hidden; }
.cropper label { display: grid; grid-template-columns: 3em 1fr; align-items: center; gap: 8px; }
.cropper .actions { justify-content: center; flex-wrap: wrap; }

/* 답글 */
.replies { margin-left: 28px; }
.replies:empty { display: none; }
.comment.reply { margin: 8px 0; }
.comment.deleted { opacity: .7; }
.reply-form { margin: 0 0 12px 28px; }
.reply-form[hidden] { display: none; }
.reply-form textarea { min-height: 72px; }
.comment-reactions { margin: 6px 0 2px; }

/* ---------- 홈 화면: 게시판 두 칸 + 오른쪽 캘린더/날씨 ---------- */
body.home { max-width: 1160px; }
body.home #nav { max-width: 760px; margin-left: auto; margin-right: auto; }
body.home #app { padding: 0; background: none; box-shadow: none; }
body.home #app::before, body.home #app::after { display: none; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 26px; align-items: start; }
.home-main { display: grid; gap: 44px; }
.home-side { display: grid; gap: 22px; }

/* 양피지 카드 (본문 양피지와 같은 느낌) */
.home-card, .side-card {
  position: relative;
  border-radius: 3px;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(255,250,235,.7), transparent 45%),
    radial-gradient(ellipse at 85% 90%, rgba(170,130,70,.25), transparent 50%),
    radial-gradient(ellipse at center, var(--parchment) 55%, var(--parchment-2) 100%);
  box-shadow: inset 0 0 60px rgba(140,100,50,.35), inset 0 0 6px rgba(120,80,40,.4), 0 12px 40px rgba(0,0,0,.45);
}
.home-card { padding: 40px 36px; }
.side-card { padding: 22px 20px 20px; }
.home-card::after, .side-card::after {
  content: ""; position: absolute; inset: 10px; pointer-events: none;
  border: 1px solid rgba(160,120,60,.45); outline: 1px solid rgba(160,120,60,.25); outline-offset: -5px;
}
.side-card::after { inset: 7px; }
.home-card::before {
  content: "🦉"; position: absolute; top: -22px; right: 30px; width: 52px; height: 52px;
  display: grid; place-items: center; font-size: 22px; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle at 35% 30%, #b8443f, var(--wax) 55%, var(--wax-dark));
  box-shadow: 0 0 0 4px rgba(142,42,42,.35), 0 3px 8px rgba(0,0,0,.4), inset 0 0 0 3px rgba(0,0,0,.15);
}
.side-card h2 { margin: 0 0 10px; font-size: 1.2rem; }
a.new-post {
  display: inline-block; text-decoration: none; font-family: var(--title); color: var(--wax);
  border: 1px solid var(--wax); border-radius: 3px; padding: 2px 14px;
}
a.new-post::before { content: "✒\FE0E  "; }
a.new-post:hover { background: rgba(142,42,42,.08); }
.category-label { margin: 0 0 4px; color: var(--gold); letter-spacing: .05em; }

/* 캘린더 */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-title { font-family: var(--title); font-size: 1.1rem; }
.cal-head button { border: none; background: none; box-shadow: none; font-size: 1.3rem; color: var(--wax); padding: 0 10px; cursor: pointer; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-week { text-align: center; font-size: 0.75rem; color: var(--muted); padding-bottom: 4px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.cal-cell {
  min-height: 40px; padding: 2px 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  border: 1px solid transparent; border-radius: 3px; background: none; box-shadow: none; color: var(--ink);
  font: inherit; font-size: 0.85rem; line-height: 1.3; cursor: pointer;
}
button.cal-cell:hover { background: rgba(201,162,74,.15); filter: none; }
.cal-cell.sun, .cal-week.sun { color: var(--danger); }
.cal-cell.sat, .cal-week.sat { color: #3d5a8a; }
.cal-cell.today .cal-num { border-bottom: 2px solid var(--gold); }
.cal-cell.selected { border-color: var(--gold); background: var(--gold-soft); }
.cal-dots { color: var(--wax); font-size: 0.55rem; letter-spacing: 1px; line-height: 1.2; }
.cal-dots small { font-size: 0.6rem; margin-left: 1px; }
.day-posts { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.day-posts:empty { display: none; }
.day-list { list-style: none; padding: 0; margin: 4px 0 0; font-size: 0.92rem; }
.day-list li { padding: 3px 0; }
.day-list li .meta { margin-left: 4px; }

/* 오늘의 날씨 */
.weather-now { display: flex; align-items: center; gap: 10px; }
.weather-icon { font-size: 2.4rem; line-height: 1; }
.weather-temp { font-family: var(--title); font-size: 2.2rem; }
.weather-label { font-family: var(--title); font-size: 1.1rem; margin-bottom: 4px; }
.weather-place { margin-top: 6px; color: var(--gold); }

@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .home-card { padding: 34px 20px 28px; }
  .home-card::after { inset: 6px; }
}
#editor select { font: inherit; color: var(--ink); background: rgba(255,250,235,.6); border: 1px solid var(--line); border-radius: 3px; padding: 3px 8px; margin-left: 6px; }
.reply-to { color: var(--wax); font-weight: 600; }

/* 상단 메뉴: 왼쪽(홈 · 새 글 · 게시판) / 오른쪽(프로필 · 로그아웃 · 관리) */
#nav .nav-right { margin-left: auto; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
#nav .nav-right #logout { margin-left: 0; }
#nav a.active { color: #fff3cf; background: rgba(201,162,74,.22); }
#nav .nav-right a:first-child { font-family: inherit; font-size: 0.95rem; color: var(--gold-soft); }
#nav .nav-right a:first-child::before { content: none; }
