:root {
    color-scheme: light;
    --text: #1e293b;
    --muted: #475569;
    --green: #0f766e;
    --surface: #ffffff;
    --wash: #f0fdfa;
    --border: #cce9e5;
    --header: rgb(255 255 255 / 94%);
    --shadow: rgb(15 118 110 / 8%);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --text: #f1f5f9;
    --muted: #cbd5e1;
    --green: #99f6e4;
    --surface: #182638;
    --wash: #0f172a;
    --border: #325151;
    --header: rgb(15 23 42 / 94%);
    --shadow: rgb(0 0 0 / 18%);
}

* { box-sizing: border-box; }

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(180deg, var(--wash), var(--surface) 74%);
    color: var(--text);
    font: 16px/1.6 "Noto Sans KR", sans-serif;
    word-break: keep-all;
}

button { font: inherit; }

:focus-visible {
    outline: 3px solid #0d9488;
    outline-offset: 4px;
}

.site-header {
    position: sticky;
    z-index: 1;
    top: 0;
    background: var(--header);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    gap: 1rem;
    margin-inline: auto;
    padding: 0.85rem 2rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--green);
    font: 700 1.3rem "Outfit", "Noto Sans KR", sans-serif;
    text-decoration: none;
    white-space: nowrap;
}

.brand-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #2dd4bf, #0d9488);
    color: #fff;
}

nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

nav a {
    border-radius: 999px;
    padding: 0.52rem 0.85rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

nav a:hover, nav [aria-current="page"] {
    background: var(--wash);
    color: var(--green);
}

nav [aria-current="page"] { box-shadow: inset 0 0 0 1px var(--border); }
nav .quiz-link { color: #fff; background: linear-gradient(135deg, #8b40cb, #c63479); }
nav .quiz-link:hover { background: #8737ae; color: #fff; }

.theme-toggle, .close-button {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 1.48rem;
    line-height: 1;
}

.sun, [data-theme="dark"] .moon { display: none; }
[data-theme="dark"] .sun { display: inline; }

.content {
    flex: 1;
    width: min(100% - 3rem, 1170px);
    margin-inline: auto;
    padding: clamp(2rem, 5vw, 4.3rem) 0 clamp(3rem, 7vw, 6rem);
}

.intro {
    margin-bottom: clamp(1.55rem, 3vw, 2.5rem);
}

.intro h1 {
    margin: 0;
    color: var(--text);
    font-size: clamp(2.2rem, 5vw, 3.65rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.055em;
}

.intro p {
    margin: 0.6rem 0 0;
    color: var(--muted);
    font-size: clamp(0.92rem, 2vw, 1.06rem);
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(1rem, 2vw, 1.6rem);
    margin: 0;
    padding: 0;
    list-style: none;
}

.video-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 6px 20px var(--shadow);
    cursor: pointer;
    text-align: left;
    transition: transform 180ms ease, border-color 180ms ease;
}

.video-card:hover {
    transform: translateY(-3px);
    border-color: #2dd4bf;
}

.thumbnail {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #123b39;
}

.thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-icon {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: grid;
    width: 45px;
    height: 45px;
    place-items: center;
    border: 1px solid rgb(255 255 255 / 55%);
    border-radius: 50%;
    background: rgb(10 28 34 / 85%);
}

.play-icon::after {
    width: 0;
    height: 0;
    margin-left: 3px;
    border: 7px solid transparent;
    border-right: 0;
    border-left: 11px solid #fff;
    content: "";
}

.card-title {
    display: block;
    padding: 0.95rem 1.05rem 1.05rem;
    font-weight: 700;
}

dialog {
    width: min(56rem, 100% - 2rem);
    max-width: none;
    max-height: calc(100% - 2rem);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--surface);
    color: var(--text);
}

dialog::backdrop { background: rgb(7 20 30 / 78%); }

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
}

.dialog-header h2 {
    margin: 0;
    font-size: clamp(0.92rem, 2.4vw, 1.2rem);
}

.close-button { width: 38px; height: 38px; }

video {
    display: block;
    width: 100%;
    max-height: min(70vh, 46rem);
    aspect-ratio: 16 / 9;
    background: #07141e;
}

.video-error { margin: 0; padding: 0.9rem 1rem; color: var(--muted); }
.site-footer { padding: 1.7rem 1.5rem; background: #1e293b; color: #cbd5e1; text-align: center; font-size: 0.83rem; }
.site-footer p { margin: 0.2rem 0; }
.site-footer .footer-information { max-width: 43rem; margin: 0 auto 0.75rem; }
.site-footer a { color: #99f6e4; }

@media (max-width: 850px) {
    .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .site-header-inner { flex-wrap: wrap; gap: 0.55rem; padding: 0.55rem 1rem; }
    .site-header nav { order: 3; width: 100%; justify-content: center; }
    .brand-icon { width: 39px; height: 39px; }
    .content { width: calc(100% - 2rem); }
}

@media (max-width: 460px) {
    .video-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .video-card { transition: none; }
}
