:root {
  --bg: #f5f3ef; --surface: #ffffff; --surface2: #faf9f7;
  --border: #e2ddd5; --accent: #2c5f8a; --accent-light: #e8f1f8;
  --accent2: #c8773a; --text: #1a1a1a; --text-muted: #7a7068;
  --tag-bg: #edf4f9; --shadow: 0 2px 12px rgba(0,0,0,0.07); --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: 'Noto Sans KR', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── 로그인 게이트 ── */
#bootScreen { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 1000; }
/* 기본은 숨김. 세션 확인 후 auth.js 가 켠다. */
#gateScreen { position: fixed; inset: 0; background: var(--bg); display: none; align-items: flex-start; justify-content: center; z-index: 999; padding: 24px; overflow-y: auto; }
.gate-box { background: var(--surface); border-radius: 20px; margin: auto; padding: 40px 32px; width: 100%; max-width: 380px; box-shadow: 0 8px 48px rgba(44,95,138,0.15); text-align: center; }
.gate-logo { font-size: 2.4rem; margin-bottom: 14px; }
.gate-title { font-family: 'Noto Serif KR', serif; font-size: 1.15rem; font-weight: 700; color: var(--accent); margin-bottom: 6px; line-height: 1.4; }
.gate-sub { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 26px; line-height: 1.6; }
.gate-form { text-align: left; }
.gate-row { display: flex; gap: 10px; }
.gate-row > div { flex: 1; }
.gate-label { display: block; font-size: 0.72rem; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; letter-spacing: 0.04em; }
.gate-input { width: 100%; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.92rem; font-family: 'Noto Sans KR', sans-serif; color: var(--text); outline: none; transition: border-color 0.15s; margin-bottom: 12px; }
.gate-input:focus { border-color: var(--accent); }
.gate-btn { width: 100%; background: var(--accent); color: white; border: none; padding: 12px; border-radius: 8px; font-size: 0.95rem; font-family: 'Noto Sans KR', sans-serif; font-weight: 500; cursor: pointer; transition: background 0.15s; margin-top: 4px; }
.gate-btn:hover { background: #245079; }
.gate-btn:disabled { background: #aaa; cursor: not-allowed; }
.gate-error { font-size: 0.78rem; color: #dc2626; margin-top: 10px; min-height: 18px; text-align: center; line-height: 1.5; }
.gate-section { font-size: 0.72rem; font-weight: 700; color: var(--accent); margin: 4px 0 6px; letter-spacing: 0.02em; }
.gate-tel { display: inline-block; margin-top: 6px; font-size: 0.9rem; font-weight: 700; color: var(--accent); text-decoration: none; }
.gate-tel:hover { text-decoration: underline; }
.gate-hours { display: inline-block; margin-top: 2px; font-size: 0.7rem; color: var(--text-muted); }
.gate-help { font-size: 0.72rem; color: var(--text-muted); text-align: center; line-height: 1.6; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.gate-hint { font-size: 0.7rem; color: var(--text-muted); text-align: center; line-height: 1.6; margin-top: 2px; }
.gate-switch { text-align: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.gate-switch button { background: none; border: none; color: var(--accent); font-size: 0.75rem; font-family: 'Noto Sans KR', sans-serif; cursor: pointer; text-decoration: underline; }

/* ── 헤더 ── */
header { background: var(--accent); color: white; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 16px rgba(44,95,138,0.3); }
.header-inner { max-width: 760px; margin: 0 auto; padding: 18px 24px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.header-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.header-title { font-family: 'Noto Serif KR', serif; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.header-subtitle { font-size: 0.72rem; opacity: 0.7; margin-top: 2px; font-weight: 300; }
.sync-status { font-size: 0.72rem; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; flex-shrink: 0; }
.dot.off { background: #f87171; }
.dot.loading { background: #fbbf24; animation: blink 0.8s infinite; }
@keyframes blink { 0%,100%{opacity:1}50%{opacity:0.3} }
.role-badge { display: inline-block; font-size: 0.65rem; padding: 2px 8px; border-radius: 4px; font-weight: 700; margin-left: 8px; vertical-align: middle; }
.role-badge.admin { background: var(--accent2); color: white; }
.role-badge.member { background: rgba(255,255,255,0.25); color: white; }
.btn-header { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); color: white; padding: 7px 14px; border-radius: 6px; font-size: 0.78rem; font-family: 'Noto Sans KR', sans-serif; cursor: pointer; transition: background 0.15s; white-space: nowrap; }
.btn-header:hover { background: rgba(255,255,255,0.25); }

/* ── 탭 ── */
.tabs { max-width: 760px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; }
.tab { background: none; border: none; border-bottom: 3px solid transparent; color: rgba(255,255,255,0.65); padding: 9px 14px; font-size: 0.88rem; font-family: 'Noto Sans KR', sans-serif; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.tab:hover { color: white; }
.tab.active { color: white; border-bottom-color: var(--accent2); font-weight: 700; }

/* ── 메인 ── */
main { max-width: 760px; margin: 0 auto; padding: 24px 16px 90px; }
.search-wrap { position: relative; margin-bottom: 14px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: 0.4; pointer-events: none; }
#searchInput { width: 100%; padding: 12px 14px 12px 40px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 0.95rem; font-family: 'Noto Sans KR', sans-serif; background: var(--surface); color: var(--text); outline: none; transition: border-color 0.15s; }
#searchInput:focus { border-color: var(--accent); }

.notice { background: var(--accent-light); border: 1px solid #cfe2f0; border-radius: var(--radius); padding: 11px 14px; font-size: 0.78rem; color: #24506f; line-height: 1.6; margin-bottom: 14px; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { padding: 5px 13px; border-radius: 999px; border: 1.5px solid var(--border); font-size: 0.78rem; font-family: 'Noto Sans KR', sans-serif; cursor: pointer; background: var(--surface); color: var(--text-muted); transition: all 0.15s; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: white; font-weight: 500; }
.chip:hover:not(.active) { border-color: var(--accent); color: var(--accent); }
.stats-bar { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 14px; }
.qa-list { display: flex; flex-direction: column; gap: 10px; }

/* ── 목록 아이템 ── */
.qa-item { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: box-shadow 0.15s, border-color 0.15s; box-shadow: var(--shadow); }
.qa-item:hover { border-color: #c8d8e8; box-shadow: 0 4px 18px rgba(44,95,138,0.1); }
.qa-question { padding: 14px 16px; cursor: pointer; display: flex; align-items: flex-start; gap: 10px; }
.qa-q-mark { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: white; font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; font-family: 'Noto Serif KR', serif; }
.qa-q-content { flex: 1; min-width: 0; }
.qa-q-text { font-size: 0.95rem; font-weight: 500; line-height: 1.45; margin-bottom: 6px; word-break: keep-all; }
.qa-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.qa-tag { background: var(--tag-bg); color: var(--accent); font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.qa-date { font-size: 0.7rem; color: var(--text-muted); }
.qa-author { font-size: 0.7rem; color: var(--accent2); font-weight: 500; }
.qa-chevron { color: var(--text-muted); font-size: 0.85rem; transition: transform 0.2s; flex-shrink: 0; margin-top: 3px; }
.qa-item.open .qa-chevron { transform: rotate(180deg); }
.qa-answer { display: none; padding: 14px 16px 16px 50px; border-top: 1px solid var(--border); background: var(--surface2); }
.qa-item.open .qa-answer { display: block; }
.qa-a-mark { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--accent2); color: white; font-size: 0.75rem; font-weight: 700; align-items: center; justify-content: center; margin-right: 8px; margin-bottom: 8px; font-family: 'Noto Serif KR', serif; vertical-align: middle; }
.qa-a-text { font-size: 0.9rem; line-height: 1.7; color: #2a2a2a; white-space: pre-wrap; word-break: keep-all; }
.qa-body { font-size: 0.9rem; line-height: 1.7; white-space: pre-wrap; word-break: keep-all; margin-bottom: 4px; }
.qa-divider { border-top: 1px dashed var(--border); margin: 14px 0 12px; }
.qa-pending { font-size: 0.82rem; color: var(--text-muted); font-style: italic; }
.qa-item-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.btn-sm { font-size: 0.72rem; font-family: 'Noto Sans KR', sans-serif; padding: 4px 10px; border-radius: 5px; border: 1px solid var(--border); cursor: pointer; background: white; color: var(--text-muted); transition: all 0.12s; }
.btn-sm:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.btn-sm.danger:hover { background: #fef2f2; color: #dc2626; border-color: #dc2626; }
.status { font-size: 0.68rem; padding: 2px 8px; border-radius: 4px; font-weight: 700; }
.status.pending { background: #fdf0e3; color: #b25f1f; }
.status.answered { background: #e3f5e9; color: #1f7a45; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .emoji { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; line-height: 1.6; }

.fab { position: fixed; bottom: 28px; right: 20px; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: white; font-size: 1.5rem; border: none; cursor: pointer; box-shadow: 0 4px 20px rgba(44,95,138,0.4); display: flex; align-items: center; justify-content: center; transition: transform 0.15s; z-index: 50; }
.fab:hover { transform: scale(1.08); }

/* ── 모달 ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; padding: 16px; align-items: flex-end; justify-content: center; }
.modal-overlay.show { display: flex; }
@media (min-width: 600px) { .modal-overlay { align-items: center; } }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 24px; animation: slideUp 0.2s ease; }
@keyframes slideUp { from{transform:translateY(30px);opacity:0} to{transform:translateY(0);opacity:1} }
.modal-title { font-family: 'Noto Serif KR', serif; font-size: 1.1rem; font-weight: 700; color: var(--accent); margin-bottom: 16px; }
.private-note { background: var(--accent-light); border-radius: 7px; padding: 10px 12px; font-size: 0.76rem; color: #24506f; line-height: 1.6; margin-bottom: 18px; }
.answer-quote { background: var(--surface2); border-left: 3px solid var(--accent); border-radius: 0 7px 7px 0; padding: 10px 12px; font-size: 0.82rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 18px; max-height: 140px; overflow-y: auto; white-space: pre-wrap; }
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; letter-spacing: 0.04em; }
.form-control { width: 100%; padding: 10px 13px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 0.92rem; font-family: 'Noto Sans KR', sans-serif; color: var(--text); background: var(--surface); outline: none; transition: border-color 0.15s; resize: vertical; }
.form-control:focus { border-color: var(--accent); }
textarea.form-control { min-height: 100px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237a7068' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.btn-primary { background: var(--accent); color: white; border: none; padding: 10px 22px; border-radius: 7px; font-size: 0.9rem; font-family: 'Noto Sans KR', sans-serif; font-weight: 500; cursor: pointer; transition: background 0.15s; }
.btn-primary:hover { background: #245079; }
.btn-primary:disabled { background: #aaa; cursor: not-allowed; }
.btn-cancel { background: var(--surface2); color: var(--text-muted); border: 1.5px solid var(--border); padding: 10px 18px; border-radius: 7px; font-size: 0.9rem; font-family: 'Noto Sans KR', sans-serif; cursor: pointer; }

mark { background: #fff3b0; color: inherit; border-radius: 2px; padding: 0 1px; }
.spinner-wrap { display: flex; justify-content: center; padding: 48px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }

@media (max-width: 500px) {
  .header-title { font-size: 1rem; }
  .header-inner, .tabs { padding-left: 14px; padding-right: 14px; }
  main { padding: 16px 12px 90px; }
  .qa-question { padding: 12px; }
  .qa-answer { padding: 12px 12px 14px 44px; }
  .gate-box { padding: 32px 20px; }
}
