:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2430;
  --sub: #6b7280;
  --line: #e6e9f0;
  --brand: #2f6df0;
  --blue: rgb(0, 179, 242);
  --red: rgb(255, 0, 16);
  --teal: rgb(0, 157, 145);
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 8px 24px rgba(20, 30, 60, .06);
  --radius: 16px;
  --kor: 국어;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }

/* ── 헤더 ── */
.top {
  background: linear-gradient(135deg, #2f6df0, #5b8dff);
  color: #fff;
  padding: 22px 20px 26px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; max-width: 1080px; margin: 0 auto; }
.brand-emoji {
  width: 46px; height: 46px; object-fit: contain; flex: 0 0 auto;
  background: rgba(255,255,255,.9); border-radius: 12px; padding: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.brand-title { font-weight: 800; font-size: 24px; }
.brand-sub { max-width: 1080px; margin: 6px auto 0; opacity: .9; font-size: 14px; }

/* ── 레이아웃 ── */
main { max-width: 1080px; margin: 0 auto; padding: 22px 16px 60px; }
.loading { text-align: center; color: var(--sub); padding: 60px 0; }

/* ── 검색 + 필터 ── */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-sel {
  flex: 0 1 auto; min-width: 120px;
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 11px 34px 11px 14px; font-size: 15px; font-weight: 600; color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.filter-sel:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.filter-reset {
  border: 1px solid var(--line); background: var(--card); color: var(--sub);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
}
.filter-reset:hover { color: var(--ink); border-color: var(--brand); }
.search-wrap { position: relative; flex: 1 1 220px; min-width: 180px; display: flex; }
.search-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .6; pointer-events: none; }
.search {
  flex: 1 1 auto; width: 100%;
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 11px 14px 11px 36px; font-size: 15px; box-shadow: var(--shadow);
}
.search:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--sub);
  border-radius: 999px; padding: 8px 15px; font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow); transition: .12s;
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── 과목 섹션 ── */
.subj-sec { margin: 26px 0 8px; }
.subj-head { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; }
.subj-dot { width: 12px; height: 12px; border-radius: 4px; }
.subj-name { font-size: 19px; font-weight: 800; }
.subj-count { color: var(--sub); font-size: 14px; font-weight: 600; }

/* ── 차시 카드 그리드 ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; box-shadow: var(--shadow); cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; transition: transform .12s, box-shadow .12s;
  text-decoration: none; color: inherit;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(20,30,60,.10), 0 14px 40px rgba(20,30,60,.10); }
.card-unitcha { font-size: 14px; font-weight: 800; }
.card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; color: #fff; }
.badge.info { background: #7c6ff0; }
.badge.vid { background: #e11d48; }
.badge.ws { background: var(--teal); }
.badge.quiz { background: #f59e0b; }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.4; }
.card-date { color: var(--sub); font-size: 12.5px; margin-top: auto; }
.empty { text-align: center; color: var(--sub); padding: 50px 0; }

/* ── 상세 ── */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--brand); font-weight: 700; text-decoration: none; margin-bottom: 14px; font-size: 15px; }
.detail-head { margin-bottom: 8px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--sub); font-size: 14px; margin-bottom: 6px; }
.detail-title { font-size: 24px; font-weight: 800; line-height: 1.35; margin: 4px 0 2px; }

.section-label { font-size: 13px; font-weight: 800; color: var(--sub); letter-spacing: .5px; margin: 26px 0 10px; text-transform: uppercase; }

/* 영상 */
.videos { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.video-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-cap { padding: 10px 14px; font-size: 14px; font-weight: 600; }

/* 제목 + 링크 복사 */
.title-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.title-row .detail-title { flex: 1 1 auto; }
.copy-link-btn {
  flex: 0 0 auto; margin-top: 4px;
  border: 1px solid var(--line); background: var(--card); color: var(--brand);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow); white-space: nowrap;
}
.copy-link-btn:hover { border-color: var(--brand); background: #eef3ff; }
.copy-link-btn:active { transform: scale(.97); }

/* 인포그래픽 */
.infogrid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.infocard { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.infoimg { display: block; }
.infocard img { display: block; width: 100%; height: auto; }
.img-actions { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.img-btn {
  flex: 1 1 0; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 9px 8px; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.img-btn:hover { border-color: var(--brand); color: var(--brand); background: #eef3ff; }
.img-btn:active { transform: scale(.97); }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px);
  background: #1f2430; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(20,30,60,.25);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 100; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 자료 링크 */
.reslist { display: flex; flex-wrap: wrap; gap: 10px; }
.reslink {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 15px; font-weight: 700; font-size: 14.5px; box-shadow: var(--shadow); color: var(--ink);
}
.reslink:hover { border-color: var(--brand); color: var(--brand); }
.reslink .ic { font-size: 17px; }
.reslink .tag { font-size: 11px; font-weight: 700; color: var(--teal); border: 1px solid var(--teal); border-radius: 999px; padding: 1px 7px; }

/* 콘텐츠 한 줄 그리드(인포·유튜브·학습지·기타링크) */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 6px; }
.mcard { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.mcard-media { display: block; position: relative; height: 190px; background: #f0f2f7; overflow: hidden; }
.mcard-media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.mcard-media.video { background: #000; }
.mcard-media.video iframe { width: 100%; height: 100%; border: 0; display: block; }
.ws-thumb { width: 100%; height: 100%; border: 0; background: #fff; pointer-events: none; }
.mcard-media.ws { background: #fff; }
.mcard-open { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(31,36,48,.86); color: #fff; font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.mcard-media.linkbox { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); padding: 14px; text-align: center; }
.mcard-media.quizbox { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-decoration: none; padding: 14px; text-align: center; background: #fff7e6; color: #92400e; }
.quizbox-name { font-weight: 800; font-size: 16px; }
.linkbox-ic { font-size: 30px; }
.linkbox-label { font-weight: 700; font-size: 14px; }
.mcard-cap { padding: 10px 12px 0; font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard-cap .tag { font-size: 11px; font-weight: 700; color: var(--teal); border: 1px solid var(--teal); border-radius: 999px; padding: 1px 7px; flex: 0 0 auto; }
.mcard-actions { display: flex; gap: 6px; padding: 10px 12px; margin-top: auto; }
.mbtn { flex: 1 1 0; min-width: 0; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 9px; padding: 8px 6px; font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.mbtn.wide { flex: 1 1 100%; }
.mbtn:hover { border-color: var(--brand); color: var(--brand); background: #eef3ff; }
.mbtn:active { transform: scale(.97); }

/* 수업 블록 */
.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.block-head { font-size: 17px; font-weight: 800; margin: 0 0 8px; }
.block-head.blue { color: var(--blue); }
.block-head.red { color: var(--red); }
.block-head.teal { color: var(--teal); }
.block .line { margin: 4px 0; }
.block .line.red { color: var(--red); font-weight: 700; }
.block img { max-width: 100%; height: auto; border-radius: 10px; margin: 8px 0; border: 1px solid var(--line); }
.inline-link { color: var(--brand); text-decoration: none; font-weight: 700; }
.inline-link:hover { text-decoration: underline; }

/* 성취기준 카드 */
.std { background: #eef3ff; border: 1px solid #d6e2ff; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 12px; }
.std-code { font-weight: 800; color: var(--brand); }
.std-text { margin: 4px 0 0; }
.std-levels { margin-top: 8px; font-size: 13.5px; color: var(--sub); display: grid; gap: 3px; }

/* 푸터 */
.foot { max-width: 1080px; margin: 0 auto; padding: 24px 16px 40px; color: var(--sub); font-size: 13px; text-align: center; border-top: 1px solid var(--line); }
.foot-links { margin-top: 6px; display: flex; gap: 8px; justify-content: center; }
.foot-links a { color: var(--brand); text-decoration: none; }
.foot-design { margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; color: var(--ink); }
.foot-emoji { width: 28px; height: 28px; object-fit: contain; }

@media (max-width: 560px) {
  .brand-title { font-size: 21px; }
  .detail-title { font-size: 21px; }
}
