:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f0f2f7;
    --text: #151821;
    --muted: #5d6475;
    --line: #e3e6ee;
    --accent: #2f5bea;
    --accent-ink: #ffffff;
    --accent-soft: #e8eefe;
    --program: #0f8a6a;
    --program-soft: #e2f5ee;
    --material: #b45309;
    --material-soft: #fdf0dc;
    --danger: #d23b3b;
    --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 6px 20px rgba(20, 24, 40, .06);
    --radius: 14px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1117;
        --surface: #171a22;
        --surface-2: #1f232d;
        --text: #e9ebf1;
        --muted: #9aa1b2;
        --line: #2a2f3b;
        --accent: #6b8cff;
        --accent-ink: #0c1020;
        --accent-soft: #1d2647;
        --program: #3fcf9f;
        --program-soft: #13312a;
        --material: #f0a44b;
        --material-soft: #3a2a14;
        --danger: #ff6b6b;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* 머리 */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; font-weight: 900; }
.top .spacer { flex: 1; }
.top .admin-link { color: var(--muted); font-size: 13px; text-decoration: none; }

.hero { padding: 20px 0 8px; }
.banner { display: block; border-radius: var(--radius); overflow: hidden; background: #1b2230; box-shadow: var(--shadow); aspect-ratio: 1792 / 592; }
.banner img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: left center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 36px); letter-spacing: -.02em; line-height: 1.25; }
.hero p { margin: 0; color: var(--muted); font-size: 16px; }
.notice { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 14px; white-space: pre-line; }

/* 도구줄 */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0 12px; }
.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.tabs .n { font-weight: 500; opacity: .75; margin-left: 4px; font-size: 12px; }
.search { flex: 1; min-width: 200px; position: relative; }
.search input { width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; }
.search input:focus { border-color: var(--accent); }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; scrollbar-width: thin; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.chips button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* 카드 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 48px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.card-head { display: flex; gap: 12px; padding: 16px 16px 0; align-items: flex-start; }
.tile { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 20px; background: linear-gradient(135deg, var(--c1, #5b6cf0), var(--c2, #3a46b8)); overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.card h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.meta-top { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.badge.program { background: var(--program-soft); color: var(--program); }
.badge.material { background: var(--material-soft); color: var(--material); }
.cat { font-size: 12px; color: var(--muted); }
.card p { margin: 10px 16px 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; padding: 14px 16px 16px; display: flex; align-items: center; gap: 10px; }
.card-foot .info { flex: 1; font-size: 12px; color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 9px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn.program { background: var(--program); color: #fff; }
.btn.material { background: var(--material); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; grid-column: 1 / -1; }

footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 20px 0 40px; }

.msg { max-width: 480px; margin: 15vh auto; padding: 0 16px; text-align: center; }
.msg p { color: var(--muted); }

@media (max-width: 560px) {
    .hero { padding-top: 12px; }
    /* 휴대폰: 배너를 조금 높게 잘라 왼쪽 글자를 크게 보이게 */
    .banner { aspect-ratio: 2 / 1; border-radius: 12px; }
    .tabs { width: 100%; }
    .tabs button { flex: 1; padding: 7px 6px; }
    .grid { grid-template-columns: 1fr; }
}
