/* 한가족신문 톤: 블랙 헤더 + 크라프트지 마스트헤드 + 크림 본문 + 레드 스탬프 포인트 */
@font-face { font-family: 'Pretendard'; src: url('/fonts/Pretendard-Regular.ttf') format('truetype'); font-weight: 400 500; font-display: swap; }
@font-face { font-family: 'Pretendard'; src: url('/fonts/Pretendard-Bold.ttf') format('truetype'); font-weight: 600 900; font-display: swap; }

:root {
  color-scheme: light;
  --header-black: #111111;
  --kraft: #C7A572;
  --kraft-deep: #9C7C4A;
  --kraft-pale: #F1E5C9;
  --cream: #F3EEE2;
  --paper: #FFFFFF;
  --ink: #1A1A1A;
  --ink-soft: #5B5B5B;
  --ink-faint: #9A9A9A;
  --stamp-red: #C81E2C;
  --stamp-red-deep: #970F1B;
  --gold: #C9A227;
  --line: #E3DCC8;

  /* 상태 색 (크림 배경 위에서 읽히도록 채도 낮춤) */
  --ok-bg: #E7F0E1;   --ok-ink: #2F5A22;
  --err-bg: #FDEDEE;  --err-ink: #970F1B;
  --info-bg: #F1E5C9; --info-ink: #5E4520;
  --warn-bg: #FBF0D2; --warn-ink: #7A5A06;

  /* 기존 이름 호환 */
  --bg: var(--cream); --card: var(--paper); --text: var(--ink); --muted: var(--ink-soft);
  --primary: var(--stamp-red); --primary-ink: #fff; --danger: var(--stamp-red);
  --radius: 10px;
  --font-display: 'Pretendard', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font: 15px/1.6 'Pretendard', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}
a { color: var(--stamp-red); text-decoration: none; }
a:hover { color: var(--stamp-red-deep); text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 800; margin: .2rem 0 1rem; }
h2 {
  font-size: 1.1rem; font-weight: 800; margin: 2.2rem 0 .9rem; padding-bottom: 8px;
  border-bottom: 2px solid var(--ink); display: flex; align-items: center; gap: 8px;
}
h2::before { content: ''; width: 4px; height: 1em; background: var(--stamp-red); border-radius: 1px; }
h3 { font-size: 1rem; font-weight: 700; margin: 1.25rem 0 .5rem; }
code { background: var(--kraft-pale); padding: 1px 6px; border-radius: 4px; font-size: .9em; }
code.big { font-size: 1.15rem; letter-spacing: .05em; background: var(--paper); border: 1px dashed var(--kraft-deep); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 28px; padding-bottom: 80px; }

/* ---------- 상단 블랙 바 ---------- */
.topbar { background: var(--header-black); color: #fff; }
.topbar-inner { display: flex; align-items: center; gap: 28px; min-height: 58px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; }
.brand:hover { text-decoration: none; }
.brand img { height: 30px; display: block; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  padding: 18px 12px 16px; color: rgba(255, 255, 255, .72); font-weight: 600; font-size: .93rem;
  border-bottom: 3px solid transparent;
}
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a.active { color: #fff; border-bottom-color: var(--gold); }
.me { display: flex; align-items: center; gap: 12px; font-size: .88rem; color: rgba(255, 255, 255, .85); }
.me a, .me button.link { color: rgba(255, 255, 255, .72); }
.me a:hover, .me button.link:hover { color: #fff; }
.me form { margin: 0; }
.topbar .role { background: rgba(255, 255, 255, .14); color: #fff; }
.topbar.solo .topbar-inner { justify-content: center; }

/* ---------- 크라프트지 마스트헤드 ---------- */
.masthead {
  background-color: var(--kraft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  text-align: center; padding: 22px 16px 16px;
}
.masthead .title { font-family: var(--font-display); font-weight: 800; font-size: clamp(24px, 4.5vw, 32px); letter-spacing: .02em; margin: 0 0 10px; color: var(--ink); }
.dateline {
  max-width: 640px; margin: 0 auto; display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--ink); padding: 8px 0;
  border-top: 1px solid rgba(0, 0, 0, .18); border-bottom: 1px solid rgba(0, 0, 0, .18);
}
.dateline .sep { color: var(--ink-soft); }
.dateline .stamp { background: var(--stamp-red); color: #fff; font-weight: 700; padding: 2px 10px; border-radius: 4px; font-size: 11.5px; letter-spacing: .03em; }

/* ---------- 카드 ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.card.narrow { max-width: 540px; }
.card.center { text-align: center; margin: 48px auto; }
.card.notice { border-color: var(--line); border-left: 4px solid var(--stamp-red); background: var(--paper); }
.card > h1:first-child, .card > h3:first-child { margin-top: 0; }
details.card > summary { cursor: pointer; font-family: var(--font-display); }
details.card[open] > summary { margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cards .card { margin: 0; border-top: 3px solid var(--ink); }
.cards h3 { margin-top: 0; }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start; }
.two-col .card h1 { margin-top: 0; }

/* ---------- 로그인 ---------- */
.login { min-height: 56vh; display: grid; place-items: center; }
.login .card { width: 100%; max-width: 380px; text-align: center; padding: 30px 26px; border-top: 3px solid var(--stamp-red); }
.login .card form { text-align: left; }
.login input { background: var(--kraft-pale); padding: 11px 13px; }
.login .btn.primary { width: 100%; padding: 12px; font-size: 1rem; }

/* ---------- 통계 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px;
  color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .06); border-top: 3px solid var(--ink);
}
a.stat:hover { border-top-color: var(--stamp-red); text-decoration: none; color: var(--ink); }
.stat b { display: block; font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1.2; }
a.stat b { color: var(--stamp-red); }
.stat span { color: var(--ink-soft); font-size: .9rem; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; color: var(--ink); font-weight: 700; background: var(--kraft-pale); white-space: nowrap; border-bottom: 2px solid var(--kraft); }
tbody tr:hover td { background: #FBF8F0; }
tr:last-child td { border-bottom: 0; }
tr.inactive td { opacity: .5; }
.nowrap { white-space: nowrap; }
.actions { white-space: nowrap; text-align: right; }
.actions form { display: inline; margin: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 폼 ---------- */
label { display: block; font-weight: 600; font-size: .9rem; }
label small { font-weight: 400; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 6px;
}
input[type=radio], input[type=checkbox] { display: inline; width: auto; margin: 0 4px 0 0; accent-color: var(--stamp-red); }
input[type=file] { background: var(--kraft-pale); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.radio-row label { display: inline-flex; align-items: center; margin-right: 16px; font-weight: 400; }
.stack { display: grid; gap: 14px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.grid-form.inner { gap: 14px 20px; }
.grid-form .full { grid-column: 1 / -1; }
#intern-fields[hidden], .btn[hidden] { display: none; }
.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
}
.filters select { width: auto; margin: 0; }
label.inline { display: inline-flex; align-items: center; font-weight: 400; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; border-color: var(--ink-faint); color: var(--ink); }
.btn.primary { background: var(--stamp-red); border-color: var(--stamp-red); color: #fff; font-family: var(--font-display); letter-spacing: .02em; }
.btn.primary:hover { background: var(--stamp-red-deep); border-color: var(--stamp-red-deep); color: #fff; }
.btn.danger { color: var(--stamp-red); border-color: #F0C4C8; }
.btn.danger:hover { background: var(--err-bg); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--paper); }
.btn.small { padding: 4px 11px; font-size: .84rem; border-radius: 99px; }
button.link { background: none; border: 0; color: var(--stamp-red); cursor: pointer; font: inherit; padding: 0; }

/* ---------- 알림 ---------- */
.flash { padding: 11px 14px 11px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; border-left-width: 4px; }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: #CFE0C3; border-left-color: var(--ok-ink); }
.flash-err { background: var(--err-bg); color: var(--err-ink); border-color: #F0C4C8; border-left-color: var(--stamp-red); }
.flash-info { background: var(--paper); color: var(--ink-soft); border-color: var(--line); border-left-color: var(--stamp-red); }

/* ---------- 배지 ---------- */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--kraft-pale); color: var(--ink-soft); white-space: nowrap; }
.badge-submitted { background: var(--warn-bg); color: var(--warn-ink); }
.badge-reviewed { background: var(--ok-bg); color: var(--ok-ink); }
.badge-revision { background: var(--err-bg); color: var(--err-ink); }
.badge-none { background: #EEEAE0; color: var(--ink-faint); }
.role { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: .74rem; font-weight: 700; background: var(--kraft-pale); color: var(--kraft-deep); vertical-align: middle; }
.role-admin { background: var(--stamp-red); color: #fff; }
.role-mentor { background: var(--ink); color: #fff; }

progress { width: 120px; height: 8px; vertical-align: middle; accent-color: var(--stamp-red); }
progress.wide { width: 100%; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 22px; margin: 0 0 12px; }
.kv dt { color: var(--ink-soft); font-size: .92rem; }
.kv dd { margin: 0; font-weight: 500; }
.pre { white-space: pre-wrap; word-break: break-word; background: #FBF8F0; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.files { padding-left: 20px; }
.files.plain { list-style: none; padding: 0; color: var(--ink-soft); }
.history { list-style: none; padding: 0; }
.history li.current { font-weight: 700; }
.feedback { background: var(--kraft-pale); color: var(--ink); border-left: 3px solid var(--kraft-deep); border-radius: 8px; padding: 10px 14px; margin-top: 10px; }
.feedback p { margin: 4px 0 0; }

.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.empty { color: var(--ink-soft); padding: 28px; text-align: center; background: var(--paper); border: 1px dashed var(--kraft); border-radius: var(--radius); }

/* ---------- 하단 ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--ink-faint); font-size: .8rem; text-align: center; padding: 20px 16px 28px; }

@media (max-width: 760px) {
  .two-col, .grid-form { grid-template-columns: 1fr; }
  .topbar-inner { gap: 4px 16px; padding-top: 10px; }
  .topbar nav { order: 3; width: 100%; flex: none; overflow-x: auto; flex-wrap: nowrap; }
  .topbar nav a { padding: 10px 10px 8px; white-space: nowrap; }
  .me { margin-left: auto; }
  .card { padding: 16px; }
  main.wrap { padding-top: 20px; }
  /* Tables scroll sideways instead of squeezing text one character per line. */
  .table-wrap table { min-width: 600px; }
  .masthead { padding: 14px 16px 10px; }
  .masthead .title { margin-bottom: 6px; }
  .dateline { gap: 6px; padding: 6px 0; font-size: 12px; }
  .dateline .optional { display: none; }
}
