/* 평화교사 자료실 — 모바일 우선 스타일
   색을 바꾸려면 :root 의 값만 바꾸면 사이트 전체에 적용됩니다. */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1d2321;
  --muted: #5d6762;
  --line: #e2ddd2;
  --brand: #1f6f5c;
  --brand-ink: #ffffff;
  --brand-soft: #dcefe8;
  --accent: #b97a0f;
  --accent-soft: #fbefd6;
  --danger: #b3261e;
  --danger-soft: #fbe3e1;
  --ok-soft: #e1f2e7;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1c211f;
    --surface-2: #252b28;
    --text: #e9ece9;
    --muted: #a3ada8;
    --line: #2f3633;
    --brand: #5fbfa4;
    --brand-ink: #0d1f1a;
    --brand-soft: #1f3a32;
    --accent: #f2b950;
    --accent-soft: #3a2f17;
    --danger: #ff8a80;
    --danger-soft: #3d1f1d;
    --ok-soft: #1d3326;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Segoe UI', Roboto, sans-serif;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3 { line-height: 1.3; margin: 0 0 0.4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.8em; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }

/* 상단 / 하단 바 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand img { border-radius: 50%; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 0.85rem; cursor: pointer; min-height: 36px;
}
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.75rem;
}
.bottomnav svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.bottomnav a.active { color: var(--brand); font-weight: 700; }

.page {
  max-width: 960px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
}
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 700; text-decoration: underline; cursor: pointer; font-size: inherit; }
.demo-banner {
  background: var(--accent-soft); color: var(--text); font-size: 0.82rem;
  padding: 6px 16px; text-align: center;
}

/* 공통 블록 */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.narrow { max-width: 420px; margin: 24px auto; }
.section { margin-top: 24px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-head a { font-size: 0.9rem; text-decoration: none; }
.muted { color: var(--muted); }
.small-text { font-size: 0.82rem; margin-top: 6px; }
.stack { display: grid; gap: 12px; }
.hint { background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; }
.alert { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.success { background: var(--ok-soft); border-radius: 10px; padding: 10px 12px; }
.login-logo { display: block; margin: 0 auto 12px; }
.narrow h1 { text-align: center; }

label { display: grid; gap: 4px; font-size: 0.9rem; font-weight: 600; }
input[type='email'], input[type='search'], input[type='url'], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  font-weight: 400; font-size: 1rem;
}
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px;
}
.code-input { letter-spacing: 0.4em; text-align: center; font-size: 1.4rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600;
  width: 100%; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.small { min-height: 40px; width: auto; padding: 6px 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* 홈 */
.hero h1 { font-size: 1.6rem; margin-bottom: 4px; }
.hero .muted:first-child { margin-bottom: 0; }
.search { margin: 12px 0; }
.search input { border-radius: 999px; padding-left: 18px; }

/* 필터 */
.filters {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 16px; margin-bottom: 12px;
}
.filters[open] { padding-bottom: 14px; }
.filters summary { cursor: pointer; padding: 10px 0; font-weight: 700; list-style-position: inside; }
.badge {
  display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); font-size: 0.78rem; text-align: center;
}
.filter-group { margin-top: 10px; }
.filter-group h3 { color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px;
  padding: 6px 14px; min-height: 38px; cursor: pointer; font-size: 0.9rem;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.count { font-size: 0.9rem; margin: 4px 2px 10px; }
.active-filters { margin-bottom: 8px; }

/* 자료 카드 */
.grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.mcard {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.mcard:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); }
.mcard h3 { font-size: 1.02rem; margin: 2px 0 0; }
.mcard-top, .mcard-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.mcard-desc {
  color: var(--muted); font-size: 0.9rem; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mcard-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.8rem; margin-top: auto; padding-top: 4px; }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem;
  background: var(--surface-2); color: var(--muted);
}
.tag-format { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.operator { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 16px 0 0; }
.members-note { margin: 16px 0 0; }
.tag-event { background: var(--danger); color: #fff; font-weight: 700; }
.events { display: grid; gap: 10px; }
@media (min-width: 640px) { .events { grid-template-columns: repeat(2, 1fr); } }
.event-card {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border: 1.5px solid var(--accent); border-radius: var(--radius); padding: 14px 16px;
}
.event-card h3 { font-size: 1.1rem; margin: 8px 0 6px; }
.event-card .detail-desc { margin: 0; font-size: 0.93rem; }
.notice-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.notice-links .btn { width: auto; }
.notice-img { width: 100%; max-width: 320px; border-radius: 10px; display: block; margin: 0 0 10px; }
.event-card .notice-links { margin: 0 0 12px; }
.event-body.has-img { display: grid; gap: 10px; }
.event-body .notice-img { max-width: 200px; }
@media (min-width: 640px) { .event-body.has-img { grid-template-columns: 160px 1fr; align-items: start; } .event-body .notice-img { margin: 0; } }
.hwpl-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hwpl-link {
  display: flex; align-items: center; gap: 8px; padding: 14px; min-height: 56px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.92rem;
}
.hwpl-link .ext { margin-left: auto; color: var(--brand); }
.tag-age { background: transparent; border: 1px solid var(--line); }
.tag-official { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* 자료 상세 */
.detail h1 { margin-top: 10px; }
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-size: 0.9rem; }
.detail-desc { white-space: pre-line; }
.video { position: relative; aspect-ratio: 16 / 9; margin: 16px 0; border-radius: var(--radius); overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.links { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.links a {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 14px; min-height: 48px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); text-decoration: none; color: var(--text);
}
.links .open { color: var(--brand); font-weight: 600; white-space: nowrap; font-size: 0.9rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 20px 0; }
.facts dt { color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* 로딩 */
.center-screen { display: grid; place-items: center; min-height: 60vh; }
.center-screen.small { min-height: 120px; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ---------- 3단계: 올리기 · 관리자 ---------- */
textarea { min-height: 0; resize: vertical; line-height: 1.5; }
.form { display: grid; gap: 18px; }
.form h1 { margin-bottom: 0; }
.form > .muted { margin: -10px 0 0; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-size: 0.9rem; font-weight: 600; padding: 0; margin-bottom: 6px; }
.req { color: var(--accent); font-size: 0.75rem; font-weight: 600; margin-left: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint.small { font-size: 0.82rem; margin: 0 0 8px; }
.link-row { display: grid; gap: 6px; padding: 10px; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: 8px; }
.link-row .btn { justify-self: end; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 640px) { .photo-grid { grid-template-columns: repeat(5, 1fr); } }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb button {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / 0.6); color: #fff; font-size: 1.1rem; cursor: pointer;
}
.photo-add {
  aspect-ratio: 1; display: grid; place-items: center; text-align: center; padding: 6px;
  border: 1.5px dashed var(--line); border-radius: 10px; color: var(--brand); font-size: 0.85rem; cursor: pointer;
  background: var(--surface);
}
.photo-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.admin-box { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; }
.admin-box legend { float: left; width: 100%; color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.center { text-align: center; }
.done-mark {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-size: 2rem; font-weight: 700;
}
.hero .btn.primary { margin-top: 4px; }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 9;
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-size: 2rem; text-decoration: none;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.2);
}
@media (min-width: 960px) { .fab { right: calc(50% - 480px + 16px); } }

.mcard.has-thumb { padding-top: 0; overflow: hidden; }
.mcard-thumb { width: calc(100% + 28px); margin: 0 -14px 6px; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--surface-2); }
.status-pending { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.status-approved { background: var(--ok-soft); color: var(--brand); font-weight: 700; }
.status-rejected { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.note { background: var(--danger-soft); border-radius: 10px; padding: 8px 12px; font-size: 0.88rem; margin: 6px 0 0; }
.mine-item { display: grid; align-content: start; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 16px 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; display: block; }
.danger-text { color: var(--danger); margin-top: 8px; }

.admin-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); margin-bottom: 12px; border-color: var(--accent); }
.admin-link span:last-child { margin-left: auto; color: var(--accent); }
.admin-link .badge { background: var(--accent); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tabs button { flex: 1; min-height: 42px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.review { display: grid; gap: 8px; }
.review h3 { font-size: 1.05rem; margin: 0; }
.review .small-text { margin: 0; }
.review-photos { display: flex; gap: 6px; overflow-x: auto; }
.review-photos img { height: 96px; border-radius: 8px; }
.plain-links { margin: 0; padding-left: 18px; font-size: 0.9rem; }
.small-link { font-size: 0.9rem; text-decoration: none; }
.add-box { margin-bottom: 10px; padding: 4px 16px; }
.add-box[open] { padding-bottom: 16px; }
.add-box summary { cursor: pointer; padding: 10px 0; font-weight: 700; }
.people { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.person-main strong { margin-right: 6px; }
.person-main .tag { margin-right: 4px; }
.person-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
@media (min-width: 640px) { .person { grid-template-columns: 1fr auto; align-items: center; } }

/* ---------- 4단계: 본부 소통함 · 공지 ---------- */
.bottomnav a { position: relative; }
.nav-badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 0.7rem; line-height: 18px; text-align: center; font-weight: 700;
}
.q-received { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.q-reviewing { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.q-answered { background: var(--ok-soft); color: var(--brand); font-weight: 700; }
.tag-new { background: var(--danger); color: #fff; font-weight: 700; }
.list-title { margin-top: 20px; }
.status-filter { margin: 16px 0 8px; }
.chip-count { display: inline-block; margin-left: 4px; font-size: 0.78rem; opacity: 0.75; }
.qlist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.qrow {
  display: grid; gap: 4px; padding: 12px 14px; border-radius: 12px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
}
.qrow.fresh { border-color: var(--danger); }
.qrow-top { display: flex; flex-wrap: wrap; gap: 6px; }
.linked-material {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  text-decoration: none; color: var(--text); margin: 4px 0 8px;
}
.linked-material .btn { justify-self: start; padding-left: 0; }
.thread h1 { margin: 8px 0 2px; }
.bubble {
  white-space: pre-line; padding: 12px 14px; border-radius: 14px; margin: 10px 0; max-width: 92%;
  background: var(--surface); border: 1px solid var(--line);
}
.bubble.from-hq { margin-left: auto; background: var(--brand-soft); border-color: transparent; }
.bubble-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.status-select { margin: 16px 0 8px; max-width: 240px; }
.reply-form { margin-top: 12px; }
.notices { display: grid; gap: 8px; }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.notice[open] { padding-bottom: 12px; }
.notice summary { cursor: pointer; padding: 10px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.notice-title { font-weight: 700; flex: 1 1 60%; }
.notice .detail-desc { margin: 0 0 10px; }
.tabs button { font-size: 0.92rem; }
