@font-face {
  font-family: "Nanum Gothic Coding";
  src: url("/assets/fonts/nanum-gothic-coding/NanumGothicCoding-Bold.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nanum Gothic Coding";
  src: url("/assets/fonts/nanum-gothic-coding/NanumGothicCoding-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f4ef;
  --ink: #1a1a1a;
  --muted: #666;
  --line: #ddd8ce;
  --accent: #0a6b56;
  --card: #fffef9;
  --danger: #a33;
  --max: 1100px;
  --font: "Nanum Gothic Coding", monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 700;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #e8f2ee 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #f0ebe3 0%, transparent 45%),
    var(--bg);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  width: 95%;
  max-width: min(var(--max), 95vw);
  margin: 0 auto;
  padding: 0 0 48px;
  box-sizing: border-box;
}
header.site {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
header.site h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
header.site h1 a { color: inherit; text-decoration: none; }
.nav-meta { color: var(--muted); font-size: 0.85rem; }
.nav-meta a.portal-home {
  color: var(--muted);
  text-decoration: none;
}
.nav-meta a.portal-home:hover {
  color: var(--accent);
  text-decoration: underline;
}

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.tag-chip {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 0.88rem;
  text-decoration: none !important;
  border-radius: 999px;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff !important;
  font-weight: 600;
}

.board-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
}
.board-search-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.board-search input[type="search"] {
  flex: 1 1 180px;
  min-width: 140px;
  max-width: 320px;
  height: 2.25rem;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 4px;
  font-size: 0.92rem;
}
.board-search input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}
.board-search .btn { height: 2.25rem; padding: 0 14px; }

table.board {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
}
table.board th,
table.board td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.95rem;
}
table.board th {
  background: #f0ebe3;
  font-weight: 600;
  color: #444;
}
table.board th .sort-link {
  color: inherit;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
table.board th .sort-link:hover { color: var(--accent); }
table.board th .sort-link.is-active { color: var(--accent); }
table.board th .sort-link.sort-asc::after { content: " ▲"; font-size: 0.7em; }
table.board th .sort-link.sort-desc::after { content: " ▼"; font-size: 0.7em; }
table.board tr:last-child td { border-bottom: none; }
table.board .col-no { width: 56px; color: var(--muted); text-align: center; }
table.board .col-date { width: 110px; color: var(--muted); white-space: nowrap; }
table.board .col-views { width: 64px; color: var(--muted); text-align: right; }
table.board .col-title { width: auto; overflow: hidden; }
table.board .title-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
/* 태그+제목 → 아이콘(고정 칸 정렬) */
table.board .title-link {
  color: inherit;
  text-decoration: none;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.board .title-link:hover { color: var(--accent); text-decoration: underline; }
table.board .title-link .title-tag {
  color: #5a6570;
  font-weight: 700;
  margin-right: 2px;
}
table.board .title-media {
  display: inline-grid;
  flex: 0 0 auto;
  grid-template-columns: 2.6rem 2.4rem 2.8rem;
  align-items: center;
  justify-items: center;
  gap: 4px;
  margin-left: auto;
}
table.board .title-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 24px;
}
table.board tr.pinned {
  background: #f3faf7;
}
table.board tr.pinned .title-link { font-weight: 650; }
.hot-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.25;
  background: #ef6c00;
  color: #fff !important;
  text-decoration: none !important;
}
.pin-mark {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 3px;
}
table.board .title-yt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 24px;
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #f0d0d0;
  background: linear-gradient(180deg, #fff 0%, #fff7f7 100%);
  line-height: 0;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}
table.board .yt-ico {
  display: block;
  width: 16px;
  height: 16px;
}
table.board .btn-pdf {
  box-sizing: border-box;
  min-height: 24px;
  height: auto;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  border-radius: 3px;
  border: 1px solid #303f9f;
  background: #3f51b5;
  color: #fff !important;
  text-decoration: none !important;
  box-shadow: 0 1px 2px rgba(48, 63, 159, 0.28);
  overflow: visible;
}
table.board .btn-pdf:hover {
  background: #303f9f;
  border-color: #283593;
  filter: none;
  text-decoration: none !important;
}

.post-title { font-size: 1.45rem; margin: 0 0 8px; letter-spacing: -0.02em; }
.post-meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; }
.post-files {
  margin: 22px 0 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--card);
}
.post-files h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}
.post-files ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-files li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}
.post-files li:first-child { border-top: none; padding-top: 0; }
.post-files .file-size,
.post-files .muted { color: var(--muted); font-size: 0.85rem; }

.post-body {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 18px 20px;
  white-space: normal;
  word-break: break-word;
}
.actions { margin: 18px 0; display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff !important;
  text-decoration: none !important;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 2px;
}
.btn.secondary {
  background: transparent;
  color: var(--accent) !important;
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
}
.btn:hover { filter: brightness(1.05); }

.pager {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.pager-num,
.pager-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none !important;
  border-radius: 4px;
}
.pager-num:hover,
.pager-nav:hover { border-color: var(--accent); color: var(--accent); }
.pager-num.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff !important;
  font-weight: 600;
}
.pager-nav.disabled {
  opacity: 0.35;
  pointer-events: none;
}
.pager-ellipsis { padding: 0 4px; color: var(--muted); }
.flash {
  padding: 10px 12px;
  background: #e8f5f0;
  border: 1px solid #b7d9cc;
  margin-bottom: 14px;
  font-size: 0.92rem;
}
.flash.error { background: #fce8e8; border-color: #e0b4b4; }

/* portal */
.portal-hero { padding: 36px 0 12px; }
.portal-hero .brand {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0 0 10px;
}
.portal-hero p { color: var(--muted); max-width: 36rem; margin: 0 0 28px; font-size: 1.05rem; }
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.site-link {
  display: block;
  padding: 18px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  color: inherit !important;
  text-decoration: none !important;
  transition: border-color .15s, transform .15s;
}
.site-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.site-link strong { display: block; font-size: 1.1rem; margin-bottom: 4px; }
.site-link span { color: var(--muted); font-size: 0.88rem; }

/* admin */
.admin-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.admin-bar a {
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 0.88rem;
  text-decoration: none;
}
.admin-bar a.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
form.stack label { display: block; margin: 12px 0 4px; font-size: 0.9rem; font-weight: 600; }
form.stack input[type=text],
form.stack input[type=password],
form.stack select,
form.stack textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}
form.stack textarea { min-height: 220px; resize: vertical; }
form.stack .row-check { margin-top: 12px; display: flex; align-items: center; gap: 8px; }
.login-box {
  max-width: 360px;
  margin: 48px auto;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
}
.empty { color: var(--muted); padding: 28px 0; text-align: center; }

.yt-embed {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 16 / 9;
  margin: 0 0 20px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.yt-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.lesson-section {
  margin: 28px 0 8px;
}

.view-board-list {
  margin: 36px 0 8px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.view-board-heading {
  margin: 0 0 12px;
  font-size: 1.1rem;
}
.view-board-more {
  margin: 14px 0 0;
}
table.board tr.is-current {
  background: rgba(10, 107, 86, 0.08);
}
table.board tr.is-current .title-link {
  font-weight: 700;
}
.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.lesson-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 1.05rem;
  line-height: 1.45;
}
.lesson-list-num {
  flex: 0 0 2em;
  font-weight: 700;
  color: #0a7;
  text-align: right;
}
.lesson-list-body {
  flex: 1 1 auto;
  min-width: 0;
}
.lesson-list-head {
  display: block;
  word-break: break-word;
}
.lesson-list-sound {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.95rem;
  word-break: break-word;
}

.board-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: 0 0 14px;
}
.board-toolbar .board-search { margin: 0; flex: 1 1 220px; }
.view-toggle {
  display: inline-flex;
  gap: 6px;
  flex: 0 0 auto;
}
.view-chip {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 0.85rem;
  text-decoration: none !important;
  border-radius: 999px;
}
.view-chip:hover { border-color: var(--accent); color: var(--accent); }
.view-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff !important;
  font-weight: 600;
}

/* 카드 최소폭 ~216px (직전 대비 2배) — 해상도에 따라 auto-fill */
.wrap:has(.board-cards) {
  max-width: min(1680px, 98vw);
}
.board-cards {
  --board-card-min: 13.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--board-card-min), 1fr));
  gap: 12px;
  margin: 0 0 8px;
}
.board-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.board-card:hover {
  border-color: #c5d8d0;
  box-shadow: 0 3px 12px rgba(10, 107, 86, 0.08);
}
.board-card.is-pinned {
  border-color: #9dccbc;
  background: #f7fcfa;
}
.board-card-media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #e8efe9;
  overflow: hidden;
  text-decoration: none !important;
}
.board-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.board-card-ph {
  display: block;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(135deg, #d7e8e1 0%, #eef3ef 55%, #e4ddd3 100%);
}
.board-card-hot {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
}
.board-card-hot .hot-badge {
  padding: 2px 6px;
  font-size: 0.65rem;
}
.board-card-pin {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--accent);
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
}
.board-card-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 11px 11px;
  flex: 1 1 auto;
}
.board-card-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  color: #5a6570;
  letter-spacing: 0.02em;
}
.board-card-title {
  color: inherit;
  text-decoration: none !important;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;
}
.board-card-title:hover { color: var(--accent); }
.board-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 0.72rem;
}
.board-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}
.board-card-actions .title-yt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  min-width: 30px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #f0d0d0;
  background: linear-gradient(180deg, #fff 0%, #fff7f7 100%);
  line-height: 0;
}
.board-card-actions .yt-ico {
  display: block;
  width: 14px;
  height: 14px;
}
.board-card-actions .btn-pdf {
  min-height: 22px;
  padding: 2px 8px;
  font-size: 0.68rem;
}

@media (max-width: 640px) {
  table.board .col-views { display: none; }
  .post-title { font-size: 1.25rem; }
  .board-cards { --board-card-min: 10rem; gap: 10px; }
}
@media (max-width: 400px) {
  .board-cards { --board-card-min: 100%; }
}
