:root {
  --ink: #23262f;
  --muted: #6b7080;
  --line: #e3e5ec;
  --brand: #c8384a;      /* 단청 홍색 */
  --brand-dark: #a62a3b;
  --indigo: #2f3c7e;     /* 쪽빛 */
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 24, 40, 0.08);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: #f6f7fb; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--indigo); }

.loading { padding: 80px; text-align: center; color: var(--muted); }

/* ───── 버튼 / 입력 ───── */
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--brand); color: #fff; font-weight: 600; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: rgba(255,255,255,.85); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #fff; }
.btn.danger { background: #fff; color: #c0392b; border: 1px solid #f0c4bf; }
.btn.danger:hover { background: #fdf0ee; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.icon-btn:hover { background: rgba(0,0,0,.06); color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, textarea.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; outline: none;
}
.input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(47,60,126,.12); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.5; }
.error-text { color: #c0392b; font-size: 13px; min-height: 18px; margin: 4px 0 10px; }

/* ───── 로그인 ───── */
.auth-page {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg, #2f3c7e 0%, #5a4d8c 55%, #c8384a 100%);
}
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card h1 { margin: 0 0 4px; font-size: 26px; }
.auth-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.tabs { display: flex; gap: 6px; background: #f1f2f6; padding: 4px; border-radius: 12px; margin-bottom: 20px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.auth-card .btn { width: 100%; padding: 12px; }

/* ───── 상단바 ───── */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.logo { font-weight: 800; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.logo .dot { width: 26px; height: 26px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: #fff; font-size: 14px; }
.spacer { flex: 1; }
.mode-badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.mode-badge.closed { background: #e8ecf8; color: var(--indigo); }
.mode-badge.open { background: #e3f6ea; color: #1e7d45; }
.auth-title { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-title h1 { margin: 0; }
.who { color: var(--muted); font-size: 14px; }

/* ───── 대시보드 ───── */
.dash { max-width: 1180px; margin: 0 auto; padding: 28px; }
.dash-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.dash-head h2 { margin: 0; font-size: 24px; }
.join-form { display: flex; gap: 8px; }
.join-form .input { width: 280px; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.board-tile {
  border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .12s, box-shadow .12s; border: 0; text-align: left; padding: 0;
}
.board-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(20,24,40,.12); }
.board-tile .thumb { height: 96px; }
.board-tile .meta { padding: 14px 16px 16px; }
.board-tile h3 { margin: 0 0 4px; font-size: 17px; }
.board-tile p { margin: 0 0 10px; color: var(--muted); font-size: 13px; min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-tile .tags { display: flex; gap: 6px; font-size: 12px; color: var(--muted); }
.tag { background: #f1f2f6; padding: 2px 8px; border-radius: 999px; }
.tag.mine { background: #fde8eb; color: var(--brand-dark); }
.new-tile {
  border: 2px dashed #cfd3df; background: transparent; box-shadow: none; display: grid; place-items: center;
  min-height: 190px; color: var(--muted); font-weight: 700; font-size: 16px;
}
.new-tile:hover { border-color: var(--brand); color: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* ───── 배경 ───── */
.bg-sky      { background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%); }
.bg-celadon  { background: linear-gradient(135deg, #9cc9b4 0%, #dff0e7 100%); }
.bg-peach    { background: linear-gradient(135deg, #ffb8a3 0%, #ffe9df 100%); }
.bg-lavender { background: linear-gradient(135deg, #c3b1ec 0%, #efe8fb 100%); }
.bg-night    { background: linear-gradient(135deg, #18203d 0%, #3b3561 100%); }
.bg-hanji    { background: #f1ebdd radial-gradient(rgba(150,120,80,.10) 1px, transparent 1px) 0 0 / 14px 14px; }

/* ───── 보드 화면 ───── */
.board-page { min-height: 100%; }
.board-header { display: flex; align-items: flex-start; gap: 14px; padding: 18px 28px; }
.board-header .title-wrap { flex: 1; min-width: 0; }
.board-header h1 { margin: 2px 0 2px; font-size: 26px; word-break: break-word; }
.board-header p { margin: 0; opacity: .8; font-size: 14px; white-space: pre-wrap; }
.board-header .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.bg-night .board-header { color: #fff; }
.presence { font-size: 13px; padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.85); color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.presence .led { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; }
.presence.off .led { background: #e67e22; }

.posts { padding: 6px 28px 120px; }
.layout-wall { column-width: 280px; column-gap: 18px; }
.layout-wall .card { break-inside: avoid; margin-bottom: 18px; }
.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; align-items: start; }
.layout-stream { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.posts .empty { column-span: all; grid-column: 1 / -1; background: rgba(255,255,255,.7); border-radius: var(--radius); }

/* ───── 게시물 카드 ───── */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; animation: pop .25s ease; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.card.color-yellow { background: #fff5bd; }
.card.color-pink   { background: #ffdbe4; }
.card.color-green  { background: #dbf3d4; }
.card.color-blue   { background: #d8ebff; }
.card.color-purple { background: #ebdfff; }
.card-top { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.card-top .author { font-weight: 700; color: var(--ink); }
.card-top .menu { margin-left: auto; display: flex; }
.card h3 { margin: 0; font-size: 17px; word-break: break-word; }
.card .content { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.55; font-size: 15px; }
.card img.photo { width: 100%; border-radius: 10px; display: block; max-height: 420px; object-fit: cover; background: #eee; }
.card .link { display: block; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.7); border: 1px solid rgba(0,0,0,.06); text-decoration: none; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .link:hover { text-decoration: underline; }
.card-foot { display: flex; gap: 6px; margin-top: 2px; }
.react { border: 0; background: rgba(0,0,0,.05); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.react:hover { background: rgba(0,0,0,.09); }
.react.on { background: #ffe1e6; color: var(--brand-dark); font-weight: 700; }

.comments { border-top: 1px solid rgba(0,0,0,.07); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.comments[hidden] { display: none; }
.comments ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.comments li { font-size: 13px; line-height: 1.45; display: flex; gap: 6px; align-items: flex-start; }
.comments li .c-body { flex: 1; word-break: break-word; white-space: pre-wrap; }
.comments li b { margin-right: 4px; }
.comments li .c-time { color: var(--muted); font-size: 11px; margin-left: 4px; }
.comments form { display: flex; gap: 6px; }
.comments .input { padding: 7px 10px; font-size: 13px; }

.fab {
  position: fixed; right: 28px; bottom: 28px; width: 62px; height: 62px; border-radius: 50%;
  border: 0; background: var(--brand); color: #fff; font-size: 32px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(200,56,74,.45); z-index: 6;
}
.fab:hover { background: var(--brand-dark); }

/* ───── 모달 ───── */
.overlay { position: fixed; inset: 0; background: rgba(15,18,30,.45); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; background: #fff; border-radius: 18px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 20px; flex: 1; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.modal-foot .left { margin-right: auto; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 54px; height: 40px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch.round { width: 34px; height: 34px; border-radius: 50%; }
.swatch.on { border-color: var(--ink); }
.swatch.on::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; color: var(--ink); }
.bg-night.swatch.on::after { color: #fff; }
.swatch-label { font-size: 11px; color: var(--muted); text-align: center; margin-top: 3px; }
.swatch-wrap { display: flex; flex-direction: column; align-items: center; }
.c-white { background: #fff; } .c-yellow { background: #fff5bd; } .c-pink { background: #ffdbe4; }
.c-green { background: #dbf3d4; } .c-blue { background: #d8ebff; } .c-purple { background: #ebdfff; }

.layout-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layout-pick button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 6px; cursor: pointer; font-size: 13px; }
.layout-pick button .ico { font-size: 20px; display: block; margin-bottom: 4px; }
.layout-pick button.on { border-color: var(--indigo); background: #eef0fa; font-weight: 700; }

.image-box { display: flex; flex-direction: column; gap: 8px; }
.image-box img { max-width: 100%; max-height: 220px; border-radius: 10px; object-fit: cover; }
.image-row { display: flex; gap: 8px; align-items: center; }

.share-row { display: flex; gap: 8px; }
.share-code { font-size: 13px; color: var(--muted); margin-top: 8px; }
.share-code .btn { margin-top: 8px; }
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.member-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.member-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.member-sub { font-size: 12px; color: var(--muted); }
.member-empty { color: var(--muted); justify-content: center; }

/* ───── 토스트 ───── */
#toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: #23262f; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: fade .2s; }

@media (max-width: 640px) {
  .topbar, .board-header, .dash { padding-left: 16px; padding-right: 16px; }
  .posts { padding-left: 16px; padding-right: 16px; }
  .board-header { flex-direction: column; }
  .join-form .input { width: 100%; }
  .join-form { width: 100%; }
}
