:root {
  --point: #e8342a;
  --point-light: #fdeceb;
  --point-dark: #c9241b;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; overflow-x: hidden; }
button, .chip, .post-card, a { touch-action: manipulation; }
body {
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 16px;
  background: #fff;
  color: #1c1c1e;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app { max-width: 480px; margin: 0 auto; background: #fff; min-height: 100vh; position: relative; }

/* ===== 헤더 ===== */
header {
  position: sticky; top: 0; z-index: 50;
  background: #fff; border-bottom: 1px solid #eee;
  padding-top: env(safe-area-inset-top);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.logo { display: flex; align-items: center; gap: 6px; }
.logo .mark { font-size: 16px; font-weight: 800; color: var(--point); letter-spacing: -0.5px; }
.header-icons { display: flex; align-items: center; gap: 0; }
.icon-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer; color: #444; border-radius: 50%;
  transition: background 0.15s ease;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:active { background: #f0f0f0; }

.search-bar { padding: 0 12px 8px; }
.search-bar .box { display: flex; background: #f2f2f4; border-radius: 8px; overflow: hidden; }
.search-bar input { flex: 1; border: none; background: transparent; padding: 9px 12px; font-size: 15px; outline: none; }
.search-bar button {
  border: none; background: transparent; padding: 0 12px; color: var(--point);
  font-size: 13px; font-weight: 600; cursor: pointer; min-width: 40px;
}

.category-scroll {
  display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  background: #fff; border-bottom: 1px solid #eee;
}
.category-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 6px 13px; border-radius: 20px; background: #f2f2f4; color: #666;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
  cursor: pointer;
}
.chip.active { background: var(--point); color: #fff; }

/* ===== 목록 ===== */
.list-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 6px; }
.list-head h2 { font-size: 15px; font-weight: 700; }
.list-head .count { font-size: 11.5px; color: #aaa; font-weight: 400; margin-left: 4px; }
.sort-tabs { display: flex; gap: 14px; font-size: 13px; color: #aaa; }
.sort-tabs a { padding: 6px 2px; display: inline-block; }
.sort-tabs a.active { color: var(--point); font-weight: 700; }

.post-card {
  background: #fff; margin: 0 0 -1px; padding: 10px 14px; display: flex; flex-direction: column;
  gap: 4px; transition: background 0.15s ease; border-bottom: 1px solid #f0f0f0;
}
.post-card:active { background: #fafafa; }
.post-card.notice { background: var(--point-light); }
.card-top { display: flex; align-items: center; gap: 6px; }
.cat-tag {
  font-size: 11.5px; color: var(--point); background: var(--point-light);
  padding: 3px 8px; border-radius: 4px; font-weight: 700; flex-shrink: 0;
}
.post-card.notice .cat-tag { background: #fff; }
.p-title {
  font-size: 15px; font-weight: 600; color: #1c1c1e; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1; min-width: 0;
}
.p-title .cnt { color: var(--point); font-size: 12px; margin-left: 3px; font-weight: 700; }
.card-bottom { display: flex; justify-content: space-between; align-items: center; }
.p-meta { font-size: 12.5px; color: #999; display: flex; gap: 6px; }
.p-stats { display: flex; gap: 10px; font-size: 12.5px; color: #999; }
.p-stats .like { color: var(--point); font-weight: 700; }

.empty-hint, .infinite-hint { text-align: center; padding: 30px 18px; font-size: 13px; color: #bbb; }

.pagination { display: flex; justify-content: center; gap: 6px; padding: 16px 14px 30px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 13px; color: #666; background: #fff; border: 1px solid #eee;
}
.pagination a.active { background: var(--point); color: #fff; border-color: var(--point); font-weight: 700; }

/* ===== 상세 화면 ===== */
.pv-header { padding: 16px 16px 12px; border-bottom: 1px solid #f3f3f3; }
.pv-header h2 { font-size: 19px; line-height: 1.4; margin-bottom: 10px; }
.pv-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #999; flex-wrap: wrap; }
.pv-meta .cat-tag { margin: 0; }
.pv-meta .writer { color: #333; font-weight: 700; }
.pv-body {
  padding: 14px 16px; font-size: 16px; line-height: 1.8; border-bottom: 8px solid #f5f5f7;
}

.cw-gate {
  margin: 14px 16px; padding: 28px 20px; border-radius: 12px; background: #fafafa; border: 1px solid #eee;
  text-align: center;
}
.cw-gate-icon { font-size: 26px; margin-bottom: 10px; }
.cw-gate-text { font-size: 14px; color: #555; margin-bottom: 16px; line-height: 1.6; white-space: pre-wrap; }
.cw-gate-btn {
  padding: 10px 20px; border-radius: 20px; border: 1px solid #ddd; background: #fff; font-size: 13.5px;
  font-weight: 700; color: #555; cursor: pointer;
}

.pv-actions { display: flex; justify-content: center; gap: 10px; padding: 14px 16px; border-bottom: 8px solid #f5f5f7; }
.pv-actions button, .pv-actions a {
  flex: 1; padding: 12px 6px; min-height: 44px; border-radius: 10px; border: 1px solid #eee;
  background: #fff; font-size: 14px; font-weight: 600; color: #555; text-align: center; cursor: pointer;
}
.pv-actions .like { color: var(--point); border-color: #f8c9c5; background: var(--point-light); }
.pv-actions .like.liked { background: var(--point); color: #fff; }

.comment-section { padding: 16px 16px 90px; }
.comment-section h4 { font-size: 13px; margin-bottom: 12px; color: #444; }
.comment-item { display: flex; gap: 8px; padding: 10px 0; border-bottom: 1px solid #f5f5f5; }
.c-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--point-light); color: var(--point);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.c-writer { font-weight: 700; font-size: 13.5px; margin-right: 6px; }
.c-date { color: #ccc; font-size: 11.5px; }
.c-body { font-size: 14px; margin-top: 3px; color: #333; white-space: pre-wrap; word-break: break-word; }

.comment-form {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  display: flex; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid #eee; z-index: 60;
}
.comment-form input {
  flex: 1; border: 1px solid #eee; border-radius: 20px; background: #f5f5f7;
  padding: 12px 16px; font-size: 16px; outline: none;
}
.comment-form button {
  padding: 0 18px; background: var(--point); color: #fff; border: none; border-radius: 20px;
  font-size: 14px; font-weight: 700; cursor: pointer; min-height: 44px;
}
.comment-login-hint {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  padding: 14px; text-align: center; background: #fff; border-top: 1px solid #eee; z-index: 60;
  font-size: 13.5px; color: #999;
}
.comment-login-hint a { color: var(--point); font-weight: 700; }

.fab-write {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 56px; height: 56px;
  border-radius: 50%; background: var(--point); color: #fff; border: none; font-size: 26px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(232,52,42,0.35);
  cursor: pointer; z-index: 55; text-decoration: none;
}

/* ===== 폼 (글쓰기 / 로그인 / 회원가입) ===== */
.form-page-heading { padding: 16px 16px 4px; }
.form-page-heading h2 { font-size: 18px; font-weight: 800; }

.form-body { padding: 16px; }
.form-submit-row { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.form-submit-row .btn-primary { width: 100%; margin-top: 0; }
.form-cancel-link { font-size: 13px; color: #999; }
.form-body label { display: block; font-size: 13px; color: #999; margin: 16px 0 6px; }
.form-body label:first-child { margin-top: 0; }
.form-body select, .form-body input[type="text"], .form-body input[type="password"], .form-body textarea {
  width: 100%; border: none; border-bottom: 1px solid #eee; padding: 12px 2px; font-size: 16px;
  font-family: inherit; outline: none; background: transparent; -webkit-appearance: none; appearance: none; border-radius: 0;
}
.form-body select:focus, .form-body input:focus, .form-body textarea:focus { border-bottom-color: var(--point); }
.form-body textarea { height: 220px; resize: none; border: 1px solid #eee; border-radius: 10px; padding: 12px; margin-top: 4px; }
.form-hint { font-size: 12px; color: #aaa; margin-top: 6px; }
.form-body input[type="file"] {
  width: 100%; border: 1px dashed #ddd; border-radius: 10px; padding: 10px; font-size: 13px;
  background: #fafafa; margin-top: 4px;
}

/* ===== 블록 에디터 (이미지/동영상/텍스트 순서 배치) ===== */
.block-list { display: flex; flex-direction: column; margin-top: 4px; }
.block-item { padding: 10px 0; border-bottom: 1px solid #f2f2f2; }
.block-item:last-child { border-bottom: none; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.block-type { font-size: 11.5px; font-weight: 600; color: #bbb; }
.block-actions { display: flex; align-items: center; gap: 1px; }
.block-actions button {
  width: 26px; height: 26px; border: none; background: none; color: #ccc; font-size: 11px; cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.block-actions button:hover { color: #888; }
.block-actions button:active { background: #f0f0f0; color: #555; }
.block-item textarea.block-text {
  width: 100%; min-height: 90px; border: 1px solid #eee; border-radius: 8px; padding: 10px; font-size: 15px;
  font-family: inherit; resize: vertical; outline: none; background: #fff;
}
.block-item textarea.block-text:focus { border-color: var(--point); }
.block-media-preview {
  width: 100%; min-height: 60px; border-radius: 8px; overflow: hidden; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center; margin-bottom: 8px;
}
.block-media-preview img, .block-media-preview video { width: 100%; max-height: 260px; object-fit: contain; display: block; }
.block-file-hint { font-size: 12.5px; color: #bbb; padding: 20px 0; }
.block-embed-preview { position: relative; width: 100%; padding-top: 56.25%; border-radius: 8px; overflow: hidden; background: #000; }
.block-embed-preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.block-item input.block-file {
  width: 100%; border: 1px dashed #ddd; border-radius: 8px; padding: 8px; font-size: 12.5px; background: #fff;
}
.block-toolbar { display: flex; gap: 8px; margin-top: 10px; }
.block-toolbar button {
  flex: 1; padding: 10px 6px; border: 1px solid #eee; border-radius: 8px; background: #fff;
  font-size: 13px; font-weight: 600; color: #555; cursor: pointer;
}
.block-toolbar button:active { background: #f5f5f5; }

.attach-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border: 1px solid #eee; border-radius: 8px; margin-bottom: 6px; background: #fafafa;
}
.attach-name { font-size: 13.5px; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { color: #aaa; font-size: 12px; }
.attach-row button { border: none; background: none; color: var(--point); font-size: 12.5px; font-weight: 700; cursor: pointer; flex-shrink: 0; }

/* ===== 게시글 본문 블록 렌더링 ===== */
.pv-block-text { margin: 4px 0; white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.pv-block-image, .pv-block-video, .pv-block-embed { margin: 4px 0; position: relative; }
.pv-block-image img, .pv-block-video img { width: 100%; border-radius: 10px; display: block; }
.pv-block-video video { width: 100%; border-radius: 10px; display: block; background: #000; }
.media-lock-badge {
  position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,0.65); color: #fff;
  font-size: 11.5px; padding: 5px 10px; border-radius: 20px; font-weight: 600; z-index: 2;
}
.play-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px; z-index: 2;
}
.media-locked-video {
  min-height: 160px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(135deg, #4a4a4d, #1c1c1e);
  display: flex; align-items: center; justify-content: center;
}
.media-locked-video .locked-icon { font-size: 34px; opacity: 0.5; }
.embed-ratio { position: relative; width: 100%; padding-top: 56.25%; border-radius: 10px; overflow: hidden; background: #000; }
.embed-ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.pv-attachments { padding: 14px 16px; border-bottom: 8px solid #f5f5f7; }
.pv-attachments h4 { font-size: 13px; color: #444; margin-bottom: 10px; }
.pv-attach-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border: 1px solid #eee; border-radius: 8px; margin-bottom: 6px; background: #fafafa;
}
.pv-attach-item a { color: var(--point); font-weight: 700; font-size: 12.5px; flex-shrink: 0; }

.auth-wrap { padding: 32px 24px; text-align: center; }
.lock-icon { font-size: 40px; margin-bottom: 14px; }
.auth-heading { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.auth-wrap .sub { font-size: 13px; color: #999; margin-bottom: 30px; }
.auth-form { text-align: left; }
.auth-form label { display: block; font-size: 13px; color: #999; margin: 16px 0 6px; }
.auth-form label:first-child { margin-top: 0; }
.auth-form input, .auth-form select {
  width: 100%; border: 1px solid #eee; border-radius: 10px; padding: 13px 14px; font-size: 15px;
  outline: none; background: #f9f9fa;
}
.auth-form input:focus, .auth-form select:focus { border-color: var(--point); background: #fff; }
.auth-form .checkbox-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 18px; font-size: 12.5px; color: #777; line-height: 1.5; }
.auth-form .checkbox-row input { width: auto; margin-top: 3px; }
.btn-primary {
  width: 100%; margin-top: 22px; padding: 14px; border: none; border-radius: 10px; background: var(--point);
  color: #fff; font-size: 15.5px; font-weight: 700; cursor: pointer; min-height: 48px;
}
.btn-primary:active { background: var(--point-dark); }
.btn-danger {
  width: 100%; margin-top: 22px; padding: 13px; border: 1px solid #f8c9c5; border-radius: 10px;
  background: var(--point-light); color: var(--point-dark); font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-danger:active { background: #f8d9d6; }
.auth-switch { margin-top: 18px; font-size: 13.5px; color: #999; }
.auth-switch a { color: var(--point); font-weight: 700; }

/* ===== 정적 페이지 (이용약관/개인정보처리방침) ===== */
.static-page { padding: 20px 18px 40px; }
.static-page h1 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.static-updated { font-size: 12px; color: #aaa; margin-bottom: 20px; }
.static-page h2 { font-size: 14.5px; font-weight: 700; margin: 22px 0 8px; }
.static-page p { font-size: 14px; line-height: 1.8; color: #333; }
.static-page ul { margin: 4px 0 4px 18px; }
.static-page li { font-size: 14px; line-height: 1.8; color: #333; }
.static-page .static-note { margin-top: 28px; padding-top: 16px; border-top: 1px solid #eee; font-size: 12.5px; color: #999; }
.static-page .static-note a { color: var(--point); font-weight: 600; }

.alert-box {
  margin: 14px 16px 0; padding: 12px 14px; border-radius: 10px; font-size: 13.5px;
  background: var(--point-light); color: var(--point-dark);
}
.alert-box.success { background: #eafaf0; color: #1a8f4c; }

/* ===== 프로필 ===== */
.profile-hero { padding: 28px 20px 20px; background: #fff; border-bottom: 8px solid #f5f5f7; text-align: center; }
.profile-hero .avatar-lg {
  width: 68px; height: 68px; border-radius: 50%; background: var(--point-light); color: var(--point);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; margin: 0 auto 12px;
}
.profile-hero .nickname { font-size: 18px; font-weight: 800; }
.profile-hero .username { font-size: 12.5px; color: #aaa; margin-top: 2px; }
.profile-hero .badge {
  display: inline-block; margin-top: 10px; padding: 5px 12px; border-radius: 20px; font-size: 12px;
  font-weight: 700; color: var(--point); background: var(--point-light);
}
.profile-hero .joined { margin-top: 8px; font-size: 12px; color: #bbb; }
.profile-bio { margin-top: 12px; font-size: 13.5px; color: #555; line-height: 1.6; white-space: pre-wrap; }
.profile-follow-counts { display: flex; justify-content: center; gap: 18px; margin-top: 14px; font-size: 13px; color: #999; }
.profile-follow-counts strong { color: #1c1c1e; font-weight: 800; }
.profile-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.btn-mini {
  border: 1px solid #eee; background: #fff; border-radius: 20px; padding: 8px 16px; font-size: 13px;
  font-weight: 700; cursor: pointer; color: #555; min-height: 36px;
}
.btn-mini.primary { background: var(--point); border-color: var(--point); color: #fff; }
.btn-mini.danger { color: var(--point); border-color: #f8c9c5; background: var(--point-light); }
a.btn-mini { display: inline-flex; align-items: center; justify-content: center; }

/* ===== 사이드 드로어 ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0); z-index: 150; visibility: hidden; pointer-events: none;
  transition: background 0.25s ease, visibility 0.25s ease;
}
.drawer-overlay.active { background: rgba(0,0,0,0.4); visibility: visible; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: -280px; bottom: 0; width: 260px; background: #fff; z-index: 151;
  padding: calc(20px + env(safe-area-inset-top)) 18px 20px; transition: right 0.25s ease;
}
.drawer-overlay.active .drawer { right: 0; }
.drawer .profile { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid #eee; margin-bottom: 12px; }
.drawer .profile .avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--point-light); color: var(--point);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.drawer .profile .name { font-size: 15px; font-weight: 700; }
.drawer .profile .desc { font-size: 12px; color: #999; }
.drawer-menu a { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 2px; font-size: 14.5px; color: #333; }
.drawer-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 20px; background: var(--point); color: #fff; font-size: 11px; font-weight: 700;
}
.icon-btn-badge {
  position: absolute; top: 6px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--point);
}
.drawer-close { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border: none; background: none; font-size: 18px; cursor: pointer; }

/* ===== 삭제 등 위험한 동작 확인용 커스텀 모달 (네이티브 confirm() 은 일부 브라우저/웹뷰에서
   막히거나 자동 취소되어 "버튼을 눌러도 아무 반응이 없는" 문제가 있어 직접 구현한다) ===== */
.confirm-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.confirm-modal-overlay.active { display: flex; }
.confirm-modal { background: #fff; border-radius: 14px; padding: 22px 20px; max-width: 320px; width: 100%; }
.confirm-modal p { font-size: 14.5px; color: #333; line-height: 1.6; margin-bottom: 18px; white-space: pre-wrap; }
.confirm-modal-actions { display: flex; gap: 8px; }
.confirm-modal-actions button {
  flex: 1; padding: 12px; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; border: 1px solid #eee;
}
.confirm-modal-actions .cm-cancel { background: #f5f5f7; color: #555; }
.confirm-modal-actions .cm-ok { background: var(--point); color: #fff; border-color: var(--point); }
