@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@300;400;600&family=Noto+Sans+KR:wght@300;400;500&display=swap');

/* ================================================================
   CSS 변수
   ================================================================ */
:root {
  --cream:     #faf7f2;
  --warm:      #fff9f0;
  --dark:      #2c2416;
  --mid:       #6b5c45;
  --light:     #a89880;
  --accent:    #c8956c;
  --accent-dk: #a0704a;
  --line:      #e8ddd0;
  --card:      #ffffff;
  --shadow:    0 2px 12px rgba(44,36,22,.08);
  --radius:    12px;
  --serif:     'Noto Serif KR', Georgia, serif;
  --sans:      'Noto Sans KR', sans-serif;
  --nav-h:     56px;
}

/* ================================================================
   테마 — 아침(morning) / 낮(day) / 밤(night)
   기본: morning
   ================================================================ */

/* :root = day (낮) 기준으로 재설정 */
:root {
  --cream:     #f7f4ef;
  --warm:      #fdf9f4;
  --dark:      #2c2416;
  --mid:       #6b5c45;
  --light:     #a89880;
  --accent:    #c8956c;
  --accent-dk: #a0704a;
  --line:      #e8ddd0;
  --card:      #ffffff;
  --nav-bg:    rgba(247,244,239,.96);
}

/* 🌅 아침 — 톤다운된 베이지/로즈 */
[data-theme="morning"] {
  --cream:     #f0ebe2;
  --warm:      #f8f3ec;
  --dark:      #3a2e22;
  --mid:       #7a6855;
  --light:     #b0987c;
  --accent:    #b8825a;
  --accent-dk: #9a6842;
  --line:      #ddd0c0;
  --card:      #faf6f0;
  --nav-bg:    rgba(240,235,226,.97);
}

/* ☀️ 낮 — 기존 크림 톤 (기본값과 동일) */
[data-theme="day"] {
  --cream:     #f7f4ef;
  --warm:      #fdf9f4;
  --dark:      #2c2416;
  --mid:       #6b5c45;
  --light:     #a89880;
  --accent:    #c8956c;
  --accent-dk: #a0704a;
  --line:      #e8ddd0;
  --card:      #ffffff;
  --nav-bg:    rgba(247,244,239,.96);
}

/* 🌙 밤 — 흑/파스텔 보라 다크 */
[data-theme="night"] {
  --cream:     #0f0e14;
  --warm:      #16151e;
  --dark:      #e8e4f0;
  --mid:       #b8b0cc;
  --light:     #7a7290;
  --accent:    #a98ece;
  --accent-dk: #8b6eb8;
  --line:      #2a2638;
  --card:      #1a1824;
  --nav-bg:    rgba(15,14,20,.97);
  --shadow:    0 2px 12px rgba(0,0,0,.4);
}

/* 테마 전환 애니메이션 */
*, *::before, *::after {
  transition: background-color .25s, border-color .25s, color .2s;
}

/* 헤더 배경색 테마 적용 */
.nav {
  background: var(--nav-bg, rgba(250,247,242,.96));
}

/* ── 테마 순환 버튼 ─────────────────────────────────────────── */
.theme-cycle-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--card);
  border: 1.5px solid var(--line);
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}
.theme-cycle-btn:hover {
  border-color: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}



/* ================================================================
   리셋
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { font-size: 16px; scroll-behavior: smooth; }
body  { font-family: var(--sans); background: var(--cream); color: var(--dark); line-height: 1.7; min-height: 100vh; }
img   { max-width: 100%; display: block; }
a     { color: inherit; text-decoration: none; }
button{ cursor: pointer; border: none; background: none; font-family: inherit; }

/* ================================================================
   네비게이션
   ================================================================ */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--nav-bg, rgba(250,247,242,.96));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--nav-h);
}
.nav-logo  { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; cursor: pointer; }
.nav-logo span { color: var(--accent); }
.nav-logo strong { font-weight: 700; }
.nav-menu  { display: flex; gap: 4px; }
.nav-btn   { padding: 6px 12px; border-radius: 20px; font-size: .85rem; color: var(--mid); transition: all .2s; }
.nav-btn:hover, .nav-btn.active { background: var(--accent); color: #fff; }
.nav-user  { display: flex; align-items: center; gap: 8px; }
.nav-user-name { font-size: .85rem; color: var(--mid); }
.btn-logout{ font-size: .8rem; color: var(--light); padding: 4px 8px; border-radius: 8px; }
.btn-logout:hover { color: var(--accent); }

/* ================================================================
   페이지 래퍼
   ================================================================ */
.page { display: none; }
.page.active { display: block; }

/* 로그인·스크랩북 등 서브페이지 패딩 */
.page-padded { padding: 0 0 80px; }

/* ================================================================
   대시보드 레이아웃 — 메인(좌) + 우측 플로팅 사이드바
   최대폭 1280px
   ================================================================ */

/* 대시보드 전체 래퍼 */
.dashboard-wrapper {
  display: flex;
  max-width: 1280px;
  margin: 24px auto;
  padding: 0 20px;
  gap: 24px;
  align-items: flex-start;
}

/* ── 메인 스테이지 (왼쪽, 유동 너비) ─────────────────────────── */
.main-stage {
  flex: 1;
  min-width: 0;
  background: var(--cream);  /* 위젯 사이 여백이 보이도록 배경색 변경 */
  border-radius: 16px;
  padding: 20px;
  min-height: 700px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

/* ── 우측 플로팅 사이드바 (고정 너비) ────────────────────────── */
.right-sidebar {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-h) + 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - var(--nav-h) - 32px);
  overflow-y: auto;
}
.right-sidebar::-webkit-scrollbar { width: 3px; }
.right-sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* ── 개별 사이드바 블록 ──────────────────────────────────────── */
.sidebar-block {
  display: flex;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 6px rgba(44,36,22,.07);
  border: 1.5px solid var(--line);
  padding: 13px 14px;
  cursor: pointer;
  user-select: none;
  transition: all .2s ease;
  gap: 0;
}
.sidebar-block:hover {
  box-shadow: 0 4px 14px rgba(44,36,22,.12);
  border-color: var(--accent);
}
.sidebar-block.active {
  background: var(--warm);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(200,149,108,.15);
}
.sidebar-block.dragging {
  opacity: .4;
  border: 2px dashed var(--accent);
  box-shadow: none;
  transform: none;
}

/* 6점 드래그 핸들 */
.drag-handle {
  cursor: grab;
  color: var(--light);
  font-size: 1rem;
  letter-spacing: -2px;
  padding-right: 12px;
  opacity: .45;
  transition: opacity .2s;
  flex-shrink: 0;
  line-height: 1;
}
.drag-handle:hover { opacity: 1; }
.drag-handle:active { cursor: grabbing; }

/* 블록 내부 콘텐츠 */
.block-content {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
}
.block-icon  { font-size: 1.15rem; flex-shrink: 0; }
.block-title { font-family: var(--serif); font-size: .9rem; font-weight: 600; color: var(--dark); }
.block-sub   { font-size: .72rem; color: var(--light); margin-top: 1px; }

/* 드래그 오버 시 메인 스테이지 시각 피드백 */
.main-stage.drag-over {
  border-color: var(--accent);
  border-style: dashed;
  background: var(--warm);
}

/* ── 모바일 대응 ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dashboard-wrapper {
    flex-direction: column-reverse;   /* 모바일: 사이드바가 하단 */
    gap: 0;
    margin: 0;
    padding: 0;
  }
  .right-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding: 12px 16px;
  }
  .right-sidebar::-webkit-scrollbar { display: none; }
  .sidebar-block {
    min-width: 140px;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 12px;
  }
  .drag-handle { display: none; }   /* 모바일은 드래그 핸들 숨김 */
  .block-sub   { display: none; }
  .main-stage {
    border-radius: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
    min-height: 400px;
    padding: 20px 16px;
  }
}

/* ================================================================
   메인 스테이지 — 내부 콘텐츠 공통
   ================================================================ */
.stage-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.stage-title {
  font-family: var(--serif); font-size: 1.1rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}


/* ================================================================
   위젯 섹션 (본문에 쌓이는 각 위젯)
   ================================================================ */
.widget-section {
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  overflow: hidden;
  background: var(--card);
}
.widget-section:last-child { margin-bottom: 0; }

/* 최소화된 위젯 상단 바 (드래그 핸들 + 닫기만) */
.widget-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  cursor: default;
  min-height: 28px;
}
.widget-drag-handle {
  cursor: grab;
  color: var(--light);
  font-size: .9rem;
  letter-spacing: 1px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: .5;
  transition: opacity .2s;
  user-select: none;
  line-height: 1;
}
.widget-drag-handle:hover { opacity: 1; }
.widget-drag-handle:active { cursor: grabbing; }
.widget-close-btn {
  font-size: .82rem;
  color: var(--light);
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  cursor: pointer;
  border: none;
  background: none;
  line-height: 1;
}
.widget-close-btn:hover {
  color: var(--accent);
  background: var(--line);
}
.widget-body {
  padding: 16px;
}

/* 안내 메시지 */
.stage-guide { padding: 20px 0; }

/* ================================================================
   게시글 카드
   ================================================================ */
.card { background: var(--card); border-radius: var(--radius); border: 1.5px solid var(--line); overflow: hidden; margin-bottom: 14px; transition: transform .2s, border-color .2s; cursor: pointer; }
.card:hover  { transform: translateY(-2px); border-color: var(--accent); }
.card-img    { width: calc(100% - 10px); max-height: 480px; object-fit: contain; background: var(--cream); display: block; margin: 5px auto; border-radius: 8px; }
.card-body   { padding: 14px 16px; }
.card-meta   { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.card-author { font-size: .78rem; font-weight: 500; color: var(--accent); }
.card-date   { font-size: .76rem; color: var(--light); }
.card-cat    { font-size: .7rem; padding: 2px 8px; background: var(--cream); border-radius: 10px; color: var(--mid); margin-left: auto; }
.card-title  { font-family: var(--serif); font-size: .98rem; font-weight: 600; margin-bottom: 5px; }
.card-content{ font-size: .86rem; color: var(--mid); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { padding: 9px 16px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--light); }
.card-footer span { color: var(--accent); font-weight: 500; }

/* ================================================================
   스크랩 카드
   ================================================================ */
.scrap-card     { background: var(--card); border-radius: var(--radius); border: 1.5px solid var(--line); display: flex; gap: 12px; padding: 14px; margin-bottom: 12px; cursor: pointer; transition: transform .2s, border-color .2s; }
.scrap-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.scrap-thumb    { width: 76px; height: 76px; flex-shrink: 0; border-radius: 8px; object-fit: cover; background: var(--cream); }
.scrap-thumb-ph { width: 76px; height: 76px; flex-shrink: 0; border-radius: 8px; background: var(--cream); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.scrap-info     { flex: 1; min-width: 0; }
.scrap-site     { font-size: .72rem; color: var(--light); margin-bottom: 2px; }
.scrap-title    { font-size: .88rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.scrap-desc     { font-size: .76rem; color: var(--mid); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scrap-memo     { font-size: .76rem; color: var(--accent); margin-top: 4px; font-style: italic; }

/* ================================================================
   핀셋 보드 그리드
   ================================================================ */
.pinset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.pinset-board-item      { border-radius: 10px; overflow: hidden; border: 1.5px solid var(--line); transition: border-color .2s, transform .2s; cursor: pointer; }
.pinset-board-item:hover{ border-color: var(--accent); transform: translateY(-2px); }
.pinset-board-item.selected {
  border-color: var(--accent);
  background: var(--warm);
  transform: none;
}
.pinset-board-thumb     { width: 100%; height: 80px; object-fit: cover; display: block; background: var(--cream); }
.pinset-board-thumb-ph  { width: 100%; height: 80px; background: var(--cream); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.pinset-board-info      { padding: 8px 10px; }
.pinset-board-name      { font-size: .85rem; font-weight: 600; color: var(--dark); }
.pinset-board-desc      { font-size: .74rem; color: var(--light); margin-top: 2px; }

/* ================================================================
   캘린더
   ================================================================ */
.cal-nav-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav-btn { background: none; border: none; cursor: pointer; color: var(--mid); font-size: 1rem; padding: 3px 8px; border-radius: 6px; }
.cal-nav-btn:hover { background: var(--cream); color: var(--accent); }
.cal-month-label { font-family: var(--serif); font-size: .95rem; font-weight: 600; }
.cal-grid    { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; text-align: center; }
.cal-dow     { font-size: .65rem; font-weight: 600; color: var(--light); padding: 3px 0; }
.cal-day     { font-size: .78rem; padding: 5px 2px; border-radius: 6px; color: var(--dark); position: relative; line-height: 1.2; }
.cal-day.other { color: var(--line); }
.cal-day.today { background: var(--accent); color: white; font-weight: 600; }
.cal-day.has-post { cursor: pointer; }
.cal-day.has-post:not(.today):hover { background: var(--cream); }
.cal-dot { display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); margin: 1px auto 0; }
.cal-day.today .cal-dot { background: white; }

/* ================================================================
   버튼
   ================================================================ */
.btn        { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border-radius: 24px; font-size: .9rem; font-weight: 500; transition: all .2s; }
.btn-primary{ background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }
.btn-outline{ border: 1.5px solid var(--line); color: var(--mid); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm     { padding: 6px 14px; font-size: .82rem; }
.btn-full   { width: 100%; }

/* ================================================================
   FAB
   ================================================================ */
.fab { position: fixed; bottom: 24px; right: 20px; z-index: 200; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1.3rem; box-shadow: 0 4px 16px rgba(200,149,108,.4); display: flex; align-items: center; justify-content: center; transition: all .2s; }
.fab:hover  { background: var(--accent-dk); transform: scale(1.05); }
.fab.hidden { display: none; }

/* ================================================================
   오버레이 & 모달
   ================================================================ */
.overlay        { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.45); align-items: flex-end; }
.overlay.active { display: flex; }
.modal          { background: var(--warm); border-radius: 20px 20px 0 0; width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px 20px 40px; animation: slideUp .25s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle   { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 18px; }
.modal-title    { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; margin-bottom: 18px; }
.modal-head     { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-close    { font-size: 1.2rem; color: var(--light); }

@media (min-width: 640px) {
  .overlay        { align-items: center; }
  .modal          { border-radius: 20px; max-width: 520px; margin: auto; }
}

/* ================================================================
   폼
   ================================================================ */
.fg   { margin-bottom: 14px; }
.fl   { display: block; font-size: .8rem; color: var(--mid); margin-bottom: 5px; font-weight: 500; }
.fi, .fta, .fsel { width: 100%; padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 10px; font-family: var(--sans); font-size: .88rem; background: #fff; color: var(--dark); transition: border-color .2s; }
.fi:focus, .fta:focus, .fsel:focus { outline: none; border-color: var(--accent); }
.fta  { min-height: 110px; resize: vertical; }
.fhint{ font-size: .76rem; color: var(--light); margin-top: 3px; }

/* ================================================================
   이미지 업로드
   ================================================================ */
.upload-area       { border: 2px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; cursor: pointer; transition: all .2s; }
.upload-area:hover { border-color: var(--accent); background: var(--cream); }
.upload-icon       { font-size: 1.8rem; margin-bottom: 6px; }
.upload-text       { font-size: .82rem; color: var(--light); }
#post-img-preview  { width: 100%; border-radius: 10px; margin-top: 10px; display: none; }

/* ================================================================
   댓글
   ================================================================ */
.cmt-input { flex: 1; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 24px; font-size: .86rem; font-family: var(--sans); background: #fff; }
.cmt-input:focus { outline: none; border-color: var(--accent); }

/* ================================================================
   로그인 페이지
   ================================================================ */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box  { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 26px; width: 100%; max-width: 360px; }
.login-title{ font-family: var(--serif); font-size: 1.35rem; text-align: center; margin-bottom: 6px; }
.login-sub  { text-align: center; font-size: .83rem; color: var(--light); margin-bottom: 24px; }

/* ================================================================
   서브 페이지 공통 (스크랩북 전체 보기 등)
   ================================================================ */
.container { max-width: 680px; margin: 0 auto; padding: 0 16px; }
.hero       { text-align: center; padding: 40px 16px 28px; }
.hero-title { font-family: var(--serif); font-size: 1.9rem; font-weight: 300; line-height: 1.3; margin-bottom: 6px; }
.hero-title strong { color: var(--accent); font-weight: 600; }
.hero-sub   { font-size: .88rem; color: var(--light); letter-spacing: .05em; }

/* ================================================================
   빈 상태 / 로딩
   ================================================================ */
.loading, .empty { text-align: center; padding: 48px 20px; color: var(--light); font-size: .88rem; }
.empty-icon { font-size: 2.8rem; margin-bottom: 10px; }

/* ================================================================
   토스트
   ================================================================ */
.toast { position: fixed; bottom: 88px; left: 50%; z-index: 500; transform: translateX(-50%) translateY(16px); background: var(--dark); color: #fff; padding: 9px 18px; border-radius: 20px; font-size: .83rem; opacity: 0; transition: all .3s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 밤 테마 추가 스타일 ──────────────────────────────────────── */
[data-theme="night"] .card,
[data-theme="night"] .sidebar-block,
[data-theme="night"] .widget-section,
[data-theme="night"] .scrap-card {
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
[data-theme="night"] .btn-primary {
  background: var(--accent);
  box-shadow: 0 2px 10px rgba(169,142,206,.3);
}
[data-theme="night"] .fi,
[data-theme="night"] .fta,
[data-theme="night"] .fsel {
  background: var(--warm);
  color: var(--dark);
}
[data-theme="night"] .upload-area {
  border-color: var(--line);
  background: var(--warm);
}
[data-theme="night"] .modal {
  background: var(--warm);
}
[data-theme="night"] .login-box {
  background: var(--card);
}
