/* ── 변수 / 리셋 / 기반 ──────────────────────────────────────── */
:root {
  --bg:       #FFFFFF;
  --window:   #FFFFFF;
  --border:   #1A1A1A;
  --border-lt:#D8D8D8;
  --text:     #1A1A1A;
  --text-2:   #555555;
  --text-3:   #AAAAAA;

  --p1: #8C9E5C;
  --p2: #497B55;
  --p3: #D4A8C4;
  --p4: #F4F5EF;

  --script:   'Tangerine', cursive;
  --serif-en: 'Cormorant Garamond', Georgia, serif;
  --serif-kr: 'Gowun Mincho', serif;
  --sans:     'Inter', -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, video { max-width: 100%; height: auto; }
html, body { height: 100%; overscroll-behavior-x: none; }
body {
  background: var(--bg);
  font-family: var(--serif-kr);
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 36px 20px 48px 80px;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ── DOCK ────────────────────────────────────────────────────── */
.dock {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 100;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-2);
  position: relative;
}

.dock-icon {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #fff;
  transition: background 0.15s;
}
.dock-icon svg { display: block; }
.dock-item:hover .dock-icon { background: var(--border); color: #fff; }

/* 안읽은 채팅 알림 배지 */
.dock-badge {
  position: absolute;
  top: -4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: #fff;
  background: #D1495B;
  border-radius: 9px;
  line-height: 1;
  box-shadow: 0 0 0 2px #fff;
}
.dock-instagram:hover .dock-icon { background: var(--p3); border-color: var(--p3); color: #fff; }

/* 프로필 독 아이콘 — 로그인 계정에 따라 색조합 다르게 */
#dock-profile-icon.acct-aidric .dock-icon { color: var(--p2); border-color: var(--p2); }
#dock-profile-icon.acct-aidric:hover .dock-icon { background: var(--p2); border-color: var(--p2); color: #fff; }
#dock-profile-icon.acct-misaya .dock-icon { color: var(--p3); border-color: var(--p3); }
#dock-profile-icon.acct-misaya:hover .dock-icon { background: var(--p3); border-color: var(--p3); color: #fff; }

.dock-label {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
}

/* Board sub-menu */
.dock-submenu {
  display: none;
  position: absolute;
  left: 44px;
  top: 0;
  background: #fff;
  border: 1px solid var(--border);
  flex-direction: column;
  min-width: 80px;
  z-index: 200;
}
.dock-submenu a {
  padding: 8px 14px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: 1px solid var(--border-lt);
  white-space: nowrap;
  transition: background 0.15s;
}
.dock-submenu a:last-child { border-bottom: none; }
.dock-submenu a:hover { background: var(--border); color: #fff; }
.dock-sub-icon { vertical-align: -1px; margin-right: 5px; flex-shrink: 0; }

/* ── WINDOW ──────────────────────────────────────────────────── */
.window {
  width: 100%;
  max-width: 1200px;
  background: var(--window);
  border: 1px solid var(--border);
}

/* ── TITLE BAR ───────────────────────────────────────────────── */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.titlebar-title {
  font-family: var(--script);
  font-size: 32px;
  color: var(--text);
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.titlebar-title:hover { opacity: 0.7; }

.titlebar-controls { display: flex; gap: 6px; align-items: center; }
.titlebar-right { display: flex; align-items: center; gap: 8px; }
.ctrl-btn {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 1px solid #1A1A1A;
  display: flex; align-items: center; justify-content: center;
  font-size: 7px; line-height: 1; color: transparent;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.titlebar-controls:hover .ctrl-close { background: #497B55; border-color: #497B55; color: #fff; }
.titlebar-controls:hover .ctrl-min   { background: #D4A8C4; border-color: #D4A8C4; color: #fff; }
.titlebar-controls:hover .ctrl-max   { background: #fff; border-color: #1A1A1A; color: #1A1A1A; }
.ctrl-close::before { content: '✕'; }
.ctrl-min::before   { content: '−'; }
.ctrl-max::before   { content: '+'; }

/* ── DESKTOP MODE BUTTON ─────────────────────────────────────── */
.dt-mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  margin-left: 8px;
  color: var(--text-3);
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
  flex-shrink: 0;
}
.dt-mode-btn:hover { color: var(--text); background: rgba(0,0,0,0.06); }
@media (max-width: 700px) { .dt-mode-btn { display: none; } }
@media (display-mode: standalone) { .dt-mode-btn { display: flex !important; } }

/* ── TOP BAR ─────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 30px 20px;
  border-bottom: 1px solid var(--border-lt);
}

.clock-time {
  font-family: var(--sans);
  font-weight: 100;
  font-size: 64px;
  letter-spacing: -2px;
  color: var(--text);
  line-height: 1;
}

.clock-date {
  font-family: var(--serif-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 5px;
}

.visitors-block { text-align: right; }
.visitors-label {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.visitors-counts { display: flex; gap: 14px; justify-content: flex-end; align-items: baseline; }
.visitor-item { text-align: center; }
.visitor-num {
  font-family: var(--sans);
  font-weight: 200;
  font-size: 28px;
  color: var(--text);
  line-height: 1;
  display: block;
}
.visitor-sub { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); font-family: var(--sans); }
.visitor-divider { width: 1px; height: 26px; background: var(--border-lt); align-self: center; }

.home-dday { display: flex; align-items: center; gap: 6px; color: #555; }
.home-dday-heart { width: 16px; height: 16px; flex-shrink: 0; }
.home-dday-num {
  font-family: var(--sans);
  font-weight: 100;
  font-size: 28px;
  letter-spacing: -1px;
  color: #555;
}

/* ── 비밀글 비밀번호 모달 ─────────────────────────────────────── */
.pw-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.pw-modal {
  background: #fff;
  border: 1px solid var(--border);
  padding: 28px 32px;
  width: 300px;
  text-align: center;
}
.pw-modal h3 { font-family: var(--script); font-size: 22px; margin-bottom: 16px; }
.pw-modal p { font-size: 12px; color: var(--text-3); margin-bottom: 14px; font-family: var(--sans); }
.pw-modal input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-lt); font-family: var(--sans);
  font-size: 13px; margin-bottom: 12px; outline: none; text-align: center;
}
.pw-modal input:focus { border-color: var(--border); }
.pw-modal .pw-error { font-size: 11px; color: #B04040; font-family: var(--sans); margin-bottom: 8px; }
.pw-modal-btns { display: flex; gap: 8px; }
.pw-modal-btns button { flex: 1; padding: 8px; font-family: var(--sans); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid var(--border); cursor: pointer; }
.pw-modal-btns .pw-ok { background: var(--text); color: #fff; border-color: var(--border); }

/* ── 이미지 라이트박스 (api.js 공통 컴포넌트) ────────────────── */
.am-lightbox {
  position: fixed; inset: 0;
  background: rgba(10,10,10,0.86);
  z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 26px;
}
.am-lightbox.open { display: flex; }
.am-lightbox-img {
  max-width: 100%;
  max-height: 74vh;
  object-fit: contain;
  box-shadow: 0 16px 50px rgba(0,0,0,0.45);
}
.am-lightbox-meta {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.6);
  min-height: 1px;
}
.am-lightbox-actions { display: flex; gap: 10px; }
.am-lightbox-btn {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 9px 18px;
  border-radius: 3px;
  transition: background 0.15s;
}
.am-lightbox-btn:hover { background: rgba(255,255,255,0.22); }
.am-lightbox-close {
  position: absolute;
  top: 18px; right: 18px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.am-lightbox-close:hover { background: rgba(255,255,255,0.22); }
@media (max-width: 700px) {
  .am-lightbox-btn { padding: 8px 16px; font-size: 9.5px; }
  .am-lightbox-close { top: calc(14px + env(safe-area-inset-top)); }
}

/* ── 프로필 모달 (Discord 스타일 프로필 카드, api.js 공통 컴포넌트) ── */
.profile-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.profile-modal-card {
  background: #fff;
  border: 1px solid var(--border);
  width: 300px;
  max-width: 100%;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  position: relative;
  text-align: center;
  padding: 32px 28px 26px;
}
.profile-modal-close {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1; color: var(--text-3);
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.profile-modal-close:hover { background: #f0f0f0; color: var(--text); }
.profile-modal-avatar {
  width: 84px; height: 84px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--border-lt);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--script);
  font-size: 38px;
  color: var(--text-2);
  overflow: hidden;
}
.profile-modal-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-modal-name {
  font-family: var(--serif-en);
  font-size: 21px;
  color: var(--text);
  margin-bottom: 6px;
}
.profile-modal-status {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-bottom: 10px;
}
.profile-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.profile-status-dot.online  { background: var(--p2); }
.profile-status-dot.away    { background: #D9A441; }
.profile-status-dot.offline { background: var(--text-3); }
.profile-status-label {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.profile-modal-message {
  font-family: var(--serif-kr);
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-2);
  word-break: break-word;
}
.profile-modal-actions {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 14px;
}
.profile-modal-dm-btn, .profile-modal-facetime-btn {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--text-2);
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 16px;
  transition: color 0.2s, border-color 0.2s, background 0.15s;
}
.profile-modal-dm-btn:hover { color: var(--text); background: #f7f7f7; }
.profile-modal-facetime-btn { color: var(--text-3); border-color: currentColor; }
.profile-modal-facetime-btn:hover { background: #f7f7f7; }
.profile-modal-edit-btn {
  margin-top: 14px;
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: none; border: none; cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.profile-modal-edit-btn:hover { color: var(--text); background: #f0f0f0; }

.profile-edit { text-align: left; }
.profile-edit-section-label {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 16px 0 8px;
}
.profile-edit-section-label:first-child { margin-top: 0; }
.profile-edit-icon-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.profile-edit-icon-preview {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--border-lt);
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--script); font-size: 18px; color: var(--text-2);
}
.profile-edit-icon-preview img { width: 100%; height: 100%; object-fit: cover; }
.profile-edit-icon-name { font-family: var(--sans); font-size: 11px; color: var(--text-2); flex: 1; }
.profile-edit-icon-btn {
  font-family: var(--sans); font-size: 9.5px; letter-spacing: 0.06em;
  color: var(--text-2); border: 1px solid var(--border-lt);
  padding: 5px 10px; border-radius: 6px; cursor: pointer; background: #fff;
  transition: background 0.15s, border-color 0.15s;
}
.profile-edit-icon-btn:hover { background: #f0f0f0; border-color: var(--border); }
.profile-edit-icon-del {
  font-family: var(--sans); font-size: 9.5px; letter-spacing: 0.06em;
  color: #B04040; border: 1px solid #e0b0b0;
  padding: 5px 10px; border-radius: 6px; cursor: pointer; background: #fff;
  transition: background 0.15s, border-color 0.15s;
}
.profile-edit-icon-del:hover { background: #fdf0f0; border-color: #B04040; }
.profile-edit-sync {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 10.5px; color: var(--text-2);
  margin-bottom: 4px; cursor: pointer;
}
.profile-edit-sync-hint { font-family: var(--sans); font-size: 9px; color: var(--text-3); margin-bottom: 8px; }
.profile-edit-select, .profile-edit-input {
  width: 100%;
  border: 1px solid var(--border-lt);
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
  background: #fff;
  color: var(--text);
}
.profile-edit-select:focus, .profile-edit-input:focus { border-color: var(--border); }
.profile-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.profile-edit-save, .profile-edit-cancel {
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 8px 16px; border: 1px solid var(--border); cursor: pointer;
}
.profile-edit-save { background: var(--text); color: #fff; }
.profile-edit-cancel { background: #fff; color: var(--text-2); }
.profile-modal-error { font-family: var(--sans); font-size: 10.5px; color: #B04040; margin-top: 8px; }

/* ── PAGINATION (home guestbook + board) ──────────────────────── */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 28px; }
.page-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.05em;
  border: 1px solid var(--border-lt); cursor: pointer;
  background: #fff; color: var(--text-2); transition: all 0.15s;
}
.page-btn.active, .page-btn:hover { background: var(--text); color: #fff; border-color: var(--text); }

/* ── RESPONSIVE ──────────────────────────────────────────────── */

@media (max-width: 1000px) {
  .window { max-width: 840px; }
  .clock-time { font-size: 50px; }
  .visitor-num { font-size: 22px; }
  .top-bar { padding: 18px 22px 16px; }
}

@media (max-width: 700px) {
  /* iOS 입력창 자동 확대 방지 (16px 미만이면 확대됨) */
  input, textarea, select { font-size: 16px !important; }

  /* dock이 하단으로 이동하므로 좌측 패딩 제거; PWA 안전영역 처리 */
  body { padding: calc(10px + env(safe-area-inset-top)) 10px calc(66px + env(safe-area-inset-bottom)) 10px; overflow-x: hidden; }
  html { overflow-x: hidden; }
  /* flex item인 .window가 content에 의해 늘어나지 않도록 너비 명시 고정 */
  .window { width: calc(100vw - 20px); max-width: calc(100vw - 20px); min-width: 0; overflow-x: hidden; }

  /* Dock → 하단 탭 바 */
  .dock {
    left: 0; right: 0; bottom: 0; top: auto;
    transform: none;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom)) 4px;
    gap: 0;
    background: #fff;
    border-top: 1px solid var(--border-lt);
    border-right: none;
  }
  .dock-item { padding: 0 6px; flex-direction: column; gap: 2px; }
  .dock-icon { width: 30px; height: 30px; font-size: 13px; }
  .dock-icon svg { width: 14px; height: 14px; }
  .dock-label { font-size: 7.5px; }
  .dock.dock-kb-hidden { display: none; }

  /* Board 서브메뉴: dock 위쪽에 표시 */
  .dock-submenu {
    left: 50%; top: auto; bottom: calc(100% + 6px);
    transform: translateX(-50%);
  }

  /* 상단 바 */
  .clock-time { font-size: 38px; }
  .visitor-num { font-size: 20px; }
  .home-dday-num { font-size: 20px; }
  .home-dday-heart { width: 13px; height: 13px; }
  .top-bar { padding: 14px 16px 12px; }

  /* 날짜: 연도 숨기고 MM.DD만 표시 */
  .date-year { display: none; }

  /* 관리자 탭 가로 스크롤 */
  .admin-tabs { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-x; flex-wrap: nowrap; overscroll-behavior-x: contain; }
  .admin-tab { flex-shrink: 0; white-space: nowrap; }
  .admin-panel { padding: 16px 14px 90px; }
  .admin-post-row { grid-template-columns: 1fr auto auto auto; gap: 6px; }

  /* 글쓰기 페이지 */
  .write-area { padding: 18px 16px calc(90px + env(safe-area-inset-bottom)); }
  .w-grid-2 { grid-template-columns: 1fr; gap: 12px; }

  /* 채팅: 키보드 올라와도 입력창 보이도록 */
  .chat-wrapper { height: calc(100svh - 220px); min-height: 320px; }

  /* 터치 타겟 확대 */
  .dock-submenu a { padding: 12px 18px; font-size: 11px; }
  .profile-modal-close { width: 36px; height: 36px; font-size: 20px; }

  /* macOS 타이틀바 버튼: 모바일에서 장식용으로만 사용 */
  .ctrl-btn { pointer-events: none; }
}
