*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --ink: #1a1a1a; --ink-soft: #444; --ink-muted: #888;
  --cream: #f5f0e8; --cream-dark: #ede6d6;
  --accent: #1a3a6b; --accent-light: #2a5c8a;
  --white: #ffffff; --red: #c0392b; --border: #e8e8e8;
  --font-serif: 'Noto Serif KR', serif;
  --font-sans: 'Noto Sans KR', sans-serif;
}
html { font-size: 16px; }
body { font-family: var(--font-sans); background: var(--white); color: var(--ink); min-height: 100vh; }
.hidden { display: none !important; }

/* ── HEADER ── */
#main-header { position: sticky; top: 0; z-index: 100; background: white; border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 8px; }
.site-logo { text-decoration: none; margin-right: 16px; }
.logo-kr { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 700; color: var(--ink); white-space: nowrap; }

/* ── NAV ── */
#main-nav { display: flex; gap: 0; flex: 1; }
.nav-item { position: relative; }
.nav-link {
  display: block; padding: 6px 14px;
  text-decoration: none; font-size: 0.88rem; font-weight: 400;
  color: var(--ink-soft); transition: color 0.2s; white-space: nowrap;
  cursor: pointer;
}
.nav-link:hover, .nav-link.active { color: var(--ink); }
.sub-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: white; border: 1px solid var(--border);
  border-radius: 8px; min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1); z-index: 200;
  padding: 6px 0; margin-top: 4px;
}
.sub-menu.open { display: block; }
.sub-menu a {
  display: block; padding: 9px 18px;
  text-decoration: none; font-size: 0.85rem;
  color: var(--ink-soft); transition: all 0.15s;
}
.sub-menu a:hover { background: #f5f5f5; color: var(--ink); }
.sub-menu a.locked { color: #ccc; cursor: not-allowed; }
.sub-menu a.locked:hover { background: none; color: #ccc; }

/* ── HEADER RIGHT ── */
.header-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link-sm { padding: 5px 10px; text-decoration: none; font-size: 0.82rem; color: var(--ink-soft); }
.nav-link-sm:hover { color: var(--ink); }
.user-name { font-size: 0.8rem; color: var(--ink-muted); margin-right: 4px; }
.btn-logout {
  padding: 5px 10px; border: 1px solid #ddd; border-radius: 4px;
  background: none; font-size: 0.8rem; color: var(--ink-soft);
  cursor: pointer; font-family: var(--font-sans); transition: all 0.2s;
}
.btn-logout:hover { border-color: #aaa; color: var(--ink); }
.btn-admin {
  padding: 5px 10px; border: 1px solid var(--accent); border-radius: 4px;
  background: none; font-size: 0.8rem; color: var(--accent);
  cursor: pointer; font-family: var(--font-sans); transition: all 0.2s; margin-left: 4px;
}
.btn-admin:hover { background: var(--accent); color: white; }

/* ── HAMBURGER ── */
.hamburger { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; margin-left: auto; color: var(--ink); }

/* ── MOBILE NAV ── */
.mobile-nav { border-top: 1px solid var(--border); background: white; }
.mobile-nav-group { border-bottom: 1px solid #f0f0f0; }
.mobile-nav-parent {
  width: 100%; padding: 13px 20px; background: none; border: none;
  font-family: var(--font-sans); font-size: 0.92rem; color: var(--ink);
  text-align: left; cursor: pointer; display: flex; justify-content: space-between;
}
.mobile-nav-sub { background: #fafafa; }
.mobile-nav-sub a, .mobile-nav-direct {
  display: block; padding: 10px 32px;
  text-decoration: none; font-size: 0.87rem; color: var(--ink-soft);
}
.mobile-nav-direct { padding: 13px 20px; font-size: 0.92rem; color: var(--ink); }
.mobile-nav-sub a.locked { color: #ccc; }
.mobile-nav-divider { height: 1px; background: #eee; margin: 4px 0; }
#mobile-guest a, #mobile-user a {
  display: block; padding: 11px 20px;
  text-decoration: none; font-size: 0.88rem; color: var(--ink-soft);
}

/* ── HOME ── */
#home-view { display: flex; flex-direction: column; min-height: calc(100vh - 60px); }
.hero { flex: 1; display: flex; align-items: center; justify-content: center; padding: 80px 32px; text-align: center; }
.hero-main { max-width: 600px; }
.hero-tagline {
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 2.5vw, 1.75rem);
  font-weight: 600; color: var(--accent); line-height: 1.9; margin-bottom: 40px;
}
.hero-brand-sub { font-size: 0.88rem; color: #999; letter-spacing: 0.05em; }
.hero-brand-sub strong { color: #666; font-weight: 500; }
.site-footer { padding: 18px 32px; text-align: right; border-top: 1px solid #eee; background: #fafafa; }
.site-footer p { font-size: 0.78rem; color: #aaa; line-height: 1.7; }
.footer-mobile { display: none; }

/* ── LIST ── */
.list-container { max-width: 1100px; margin: 0 auto; padding: 40px 24px; }
.list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.list-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--ink-muted); }
.list-breadcrumb .bc-parent { color: var(--ink-muted); }
.list-breadcrumb .bc-sep { color: #ccc; }
.list-breadcrumb .bc-child { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.btn-write { padding: 7px 16px; background: var(--accent); color: white; border: none; border-radius: 6px; font-size: 0.83rem; cursor: pointer; font-family: var(--font-sans); }
.btn-write:hover { background: var(--accent-light); }
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.post-card { background: white; border-radius: 10px; overflow: hidden; border: 1px solid #eee; cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.post-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); border-color: #ccc; }
.post-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.post-thumb-placeholder { width: 100%; aspect-ratio: 16/9; background: #f0f0f0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.post-thumb-placeholder img { width: 100%; height: 100%; object-fit: cover; }
.post-info { padding: 13px 15px; }
.post-title { font-size: 0.88rem; font-weight: 500; margin-bottom: 5px; line-height: 1.4; }
.post-meta { font-size: 0.72rem; color: var(--ink-muted); }
.post-empty { grid-column: 1/-1; text-align: center; padding: 80px 0; color: var(--ink-muted); font-size: 0.88rem; }
.loading { display: flex; align-items: center; justify-content: center; min-height: 200px; color: var(--ink-muted); font-size: 0.88rem; }

/* ── DETAIL ── */
.detail-container { max-width: 820px; margin: 0 auto; padding: 40px 24px; }
.btn-back { background: none; border: none; color: var(--accent); font-size: 0.85rem; cursor: pointer; margin-bottom: 20px; padding: 0; font-family: var(--font-sans); }
.btn-back:hover { text-decoration: underline; }
#detail-title { font-family: var(--font-serif); font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; line-height: 1.3; }
.detail-meta { font-size: 0.76rem; color: var(--ink-muted); margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid #eee; }
.youtube-wrap { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 8px; margin-bottom: 20px; background: #000; }
.youtube-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
/* 유튜브 링크 클릭 방지 오버레이 (제목/공유 버튼 영역) */
.yt-block {
  position: absolute;
  z-index: 10;
  background: transparent;
  cursor: default;
}
.yt-block-top {
  top: 0; left: 0; right: 0;
  height: 60px;
}
.yt-block-corner {
  bottom: 0; right: 0;
  width: 220px;
  height: 80px;
}
.detail-content { font-size: 0.93rem; line-height: 1.9; color: var(--ink-soft); white-space: pre-wrap; }
.detail-actions { margin-top: 24px; padding-top: 16px; border-top: 1px solid #eee; display: flex; gap: 8px; }
.btn-edit { padding: 7px 16px; background: none; border: 1px solid var(--accent); color: var(--accent); border-radius: 6px; font-size: 0.82rem; cursor: pointer; font-family: var(--font-sans); transition: all 0.2s; }
.btn-edit:hover { background: var(--accent); color: white; }
.btn-delete { padding: 7px 16px; background: none; border: 1px solid var(--red); color: var(--red); border-radius: 6px; font-size: 0.82rem; cursor: pointer; font-family: var(--font-sans); transition: all 0.2s; }
.btn-delete:hover { background: var(--red); color: white; }

/* ── WRITE ── */
.write-container { max-width: 700px; margin: 0 auto; padding: 40px 24px; }
.write-container h2 { font-family: var(--font-serif); font-size: 1.4rem; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--ink-soft); margin-bottom: 6px; }
.form-group input, .form-group textarea {
  width: 100%; padding: 10px 13px; border: 1.5px solid #e0e0e0; border-radius: 8px;
  font-family: var(--font-sans); font-size: 0.9rem; color: var(--ink); background: #fafafa;
  transition: border-color 0.2s; outline: none;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--accent); background: white; }
.form-group textarea { resize: vertical; min-height: 120px; }
.thumb-tab-btns { display: flex; gap: 8px; margin-bottom: 10px; }
.thumb-tab { padding: 6px 14px; border: 1.5px solid #ddd; border-radius: 6px; background: none; font-size: 0.82rem; cursor: pointer; font-family: var(--font-sans); color: var(--ink-soft); transition: all 0.2s; }
.thumb-tab.active { border-color: var(--accent); color: var(--accent); background: #eef4fb; }
.thumb-input-wrap input[type="file"] { width: 100%; padding: 8px; border: 1.5px dashed #ddd; border-radius: 8px; font-size: 0.85rem; cursor: pointer; background: #fafafa; }
.thumb-preview { position: relative; margin-top: 10px; display: inline-block; }
.thumb-preview img { width: 160px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid #eee; }
.btn-clear-thumb { position: absolute; top: -8px; right: -8px; background: #ff4444; color: white; border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 0.7rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.write-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.btn-cancel { padding: 9px 22px; background: none; border: 1px solid #ddd; border-radius: 8px; font-size: 0.88rem; cursor: pointer; font-family: var(--font-sans); }
.btn-cancel:hover { border-color: #aaa; }
.btn-primary { width: 100%; padding: 11px; background: var(--accent); color: white; border: none; border-radius: 8px; font-family: var(--font-sans); font-size: 0.92rem; font-weight: 500; cursor: pointer; transition: background 0.2s; margin-top: 4px; }
.btn-primary:hover { background: var(--accent-light); }

/* ── ADMIN ── */
.admin-container { max-width: 820px; margin: 0 auto; padding: 40px 24px; }
.admin-tabs { display: flex; border-bottom: 2px solid #eee; margin-bottom: 24px; }
.admin-tab { padding: 10px 24px; background: none; border: none; font-size: 0.9rem; cursor: pointer; font-family: var(--font-sans); color: var(--ink-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.admin-desc { font-size: 0.83rem; color: var(--ink-muted); margin-bottom: 20px; }
.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-item { background: white; border: 1px solid #eee; border-radius: 10px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 1px 4px rgba(0,0,0,0.04); gap: 12px; }
.user-item-info { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.user-item-name { font-weight: 500; font-size: 0.92rem; }
.user-item-email { font-size: 0.76rem; color: var(--ink-muted); }
.user-item-date { font-size: 0.7rem; color: #bbb; }
.user-item-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.badge { padding: 2px 9px; border-radius: 20px; font-size: 0.7rem; font-weight: 500; }
.badge-pending { background: #fff3e0; color: #e65100; }
.badge-approved { background: #e8f5e9; color: #1b5e20; }
.badge-grade { background: #e3f2fd; color: #1565c0; }
.grade-select { padding: 5px 8px; border: 1px solid #ddd; border-radius: 5px; font-size: 0.78rem; font-family: var(--font-sans); color: var(--ink); background: white; outline: none; cursor: pointer; }
.btn-approve { padding: 5px 12px; background: var(--accent); color: white; border: none; border-radius: 5px; font-size: 0.78rem; cursor: pointer; font-family: var(--font-sans); }
.btn-approve:hover { background: var(--accent-light); }
.btn-unapprove { padding: 5px 12px; background: none; border: 1px solid #ddd; border-radius: 5px; font-size: 0.78rem; cursor: pointer; font-family: var(--font-sans); color: var(--ink-soft); }
.btn-unapprove:hover { border-color: var(--red); color: var(--red); }
.log-filters { margin-bottom: 16px; }
.log-filters select { padding: 7px 12px; border: 1px solid #ddd; border-radius: 6px; font-family: var(--font-sans); font-size: 0.85rem; background: white; outline: none; }
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-item { background: white; border: 1px solid #eee; border-radius: 8px; padding: 12px 16px; display: grid; grid-template-columns: 1fr 1fr auto auto; align-items: center; gap: 12px; font-size: 0.83rem; }
.log-user { font-weight: 500; }
.log-post { color: var(--ink-soft); }
.log-time { color: var(--ink-muted); font-size: 0.76rem; }
.log-duration { background: #eef4fb; color: var(--accent); padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 500; white-space: nowrap; }

/* ── PENDING / NOACCESS ── */
.pending-container { min-height: calc(100vh - 60px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; }
.pending-icon { font-size: 3rem; margin-bottom: 16px; }
.pending-container h2 { font-family: var(--font-serif); font-size: 1.5rem; margin-bottom: 12px; }
.pending-container p { color: var(--ink-muted); line-height: 1.8; margin-bottom: 24px; }
.btn-logout-sm { padding: 7px 18px; border: 1px solid #ddd; border-radius: 6px; background: none; font-size: 0.84rem; cursor: pointer; font-family: var(--font-sans); }

/* ── AUTH MODAL ── */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-card { background: white; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px; position: relative; box-shadow: 0 24px 80px rgba(0,0,0,0.2); }
.modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 1rem; cursor: pointer; color: #aaa; padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { color: var(--ink); }
.modal-card h2 { font-family: var(--font-serif); font-size: 1.4rem; margin-bottom: 22px; }
.signup-notice { font-size: 0.82rem; color: var(--accent); background: #eef4fb; border-radius: 8px; padding: 10px 14px; margin-bottom: 18px; line-height: 1.6; }
.form-switch { text-align: center; margin-top: 14px; font-size: 0.82rem; color: var(--ink-muted); }
.form-switch a { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-message { margin-top: 14px; padding: 10px 14px; border-radius: 8px; font-size: 0.84rem; line-height: 1.5; }
.auth-message.success { background: #eefbf3; color: #1a7a4a; border: 1px solid #a8e6c2; }
.auth-message.error { background: #fef2f2; color: #c0392b; border: 1px solid #f5c0c0; }

/* ── RESPONSIVE ── */
@media (max-width: 860px) {
  #main-nav { display: none; }
  #guest-buttons { display: none; }
  .hamburger { display: block; }
  .header-inner { padding: 0 16px; }
  .hero { padding: 48px 20px; }
  .hero-tagline { font-size: 1.2rem; }
  .list-container, .detail-container, .write-container, .admin-container { padding: 28px 16px; }
  .post-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  #detail-title { font-size: 1.3rem; }
  .log-item { grid-template-columns: 1fr 1fr; }
  .modal-card { padding: 32px 22px; }
  .user-item { flex-direction: column; align-items: flex-start; }
  .user-item-right { width: 100%; }
  .footer-pc { display: none; }
  .footer-mobile { display: block; }
  .site-footer { text-align: center; }
}

/* ── 내신/독해 3단계 드롭다운 ── */
.sub-menu-wide {
  min-width: 280px;
  display: none;
  flex-direction: row;
  gap: 0;
  padding: 8px 0;
}
.sub-menu-wide.open { display: flex; }
.sub-menu-wide:not(#sub-naeshin):not(#sub-syntax) {
  min-width: 420px;
}
.sub-menu-group {
  flex: 1;
  padding: 0 4px;
}
.sub-menu-header {
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 2px;
  cursor: default;
}
.sub-menu-header-link {
  display: block;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 2px;
  text-decoration: none;
  transition: color 0.15s;
}
.sub-menu-header-link:hover {
  color: var(--accent);
}
.sub-menu-group + .sub-menu-group {
  border-left: 1px solid #f0f0f0;
}

/* 모바일 내신 헤더 */
.mobile-sub-header {
  padding: 10px 32px;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  background: #fafafa;
  border-top: 1px solid #f0f0f0;
}
