:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --fg: #111418;
    --muted: #5b6470;
    --line: #e6e8ec;
    --line-strong: #d7dbe1;
    --accent: #e85d1a;
    --accent-soft: #fdeadd;
    --accent-dark: #b8430b;
    --secondary: #1c8a99;
    --secondary-soft: #d8eef2;
    --radius: 10px;
    --radius-sm: 6px;
    --maxw: 1180px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, .07);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #161a20;
        --fg: #e7eaef;
        --muted: #98a2b0;
        --line: #232830;
        --line-strong: #2c333d;
        --accent: #ff8245;
        --accent-soft: #3a1d0c;
        --accent-dark: #ff8245;
        --secondary: #4cc1d2;
        --secondary-soft: #133941;
        --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
        --shadow-md: 0 6px 22px rgba(0,0,0,.4);
    }
    .video-card .thumb-placeholder { background: #20252d; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ----- Header ------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.site-header > div {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0.85rem 1.25rem;
}
.site-header .brand {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}
.site-header .brand img {
    height: 28px;
    width: auto;
    display: block;
}
@media (prefers-color-scheme: dark) {
    .site-header .brand img { filter: brightness(1.05); }
}
.site-header nav {
    display: flex;
    gap: 1.25rem;
    flex: 1;
    flex-wrap: wrap;
}
.site-header nav a {
    color: var(--muted);
    font-size: 0.95rem;
}
.site-header nav a:hover { color: var(--fg); text-decoration: none; }
.site-header .lang {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px;
}
.site-header .lang a {
    padding: 0.2rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    border-radius: 999px;
}
.site-header .lang a[aria-current] {
    background: var(--surface);
    color: var(--fg);
    box-shadow: var(--shadow-sm);
}
.site-header .lang a:hover { text-decoration: none; }

/* ----- Layout ------------------------------------------------------------- */

.site-main {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 2.5rem 1.25rem 4rem;
}

.site-footer {
    max-width: var(--maxw);
    margin: 3rem auto 1rem;
    padding: 1.5rem 1.25rem;
    color: var(--muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--line);
}

h1, h2, h3 { letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 2.4vw + 1rem, 2.5rem); margin: 0 0 0.5rem; }
h2 { font-size: 1.4rem; margin: 2.5rem 0 1rem; }
h3 { font-size: 1.05rem; }
.tagline { color: var(--muted); font-size: 1.15rem; margin: 0 0 2rem; max-width: 60ch; }

/* ----- Cards / grid ------------------------------------------------------- */

.grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.video-card {
    display: block;
    color: var(--fg);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.video-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--line-strong);
    text-decoration: none;
}
.video-card .thumb-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #e9ecf2, #d6dae3);
    overflow: hidden;
}
.video-card img,
.video-card .thumb-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.video-card .duration {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(0,0,0,.72);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.01em;
}
.video-card .meta { padding: 0.85rem 1rem 1rem; }
.video-card h3 { margin: 0; font-size: 0.98rem; line-height: 1.35; }

/* ----- Category list ------------------------------------------------------ */

.category-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.category-list a {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--fg);
    font-size: 0.9rem;
    font-weight: 500;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.category-list a:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

/* ----- Course list -------------------------------------------------------- */

.course-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.course-list a {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--fg);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.course-list a:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    text-decoration: none;
}
.course-list .course-title { font-weight: 600; }
.course-list .course-desc { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }

.lesson-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: lesson;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.lesson-list li {
    counter-increment: lesson;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.lesson-list li::before {
    content: counter(lesson, decimal-leading-zero);
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 1.75rem;
}
.lesson-list a { flex: 1; color: var(--fg); }
.lesson-list a:hover { color: var(--accent); }
.lesson-list .duration { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* ----- Video page --------------------------------------------------------- */

.video-page .player-wrap {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-md);
}
.video-page video { width: 100%; display: block; }
.video-page .meta {
    color: var(--muted);
    font-size: 0.92rem;
    margin: 0 0 1.25rem;
}
.video-page .meta .dot { margin: 0 0.5rem; opacity: 0.5; }

.description {
    margin: 1.5rem 0;
    max-width: 70ch;
}
.description p { margin: 0 0 1rem; }
.description a { word-break: break-word; }
.description code {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    font-size: 0.92em;
}

.tags { list-style: none; padding: 0; margin: 1.25rem 0; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tags a {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background .15s ease;
}
.tags a:hover { text-decoration: none; filter: brightness(0.96); }

.course-link {
    display: inline-block;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 0.92rem;
}
.course-link a { font-weight: 600; }

/* ----- Search ------------------------------------------------------------- */

.search-form {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0 2rem;
    max-width: 520px;
}
.search-form input {
    flex: 1;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--surface);
    color: var(--fg);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.search-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-form button {
    padding: 0.65rem 1.1rem;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s ease;
}
.search-form button:hover { filter: brightness(1.08); }

/* ----- Prose -------------------------------------------------------------- */

.prose { max-width: 65ch; }
.prose h1 { margin-bottom: 1rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin: 0.35rem 0; }

/* ----- Section spacing ---------------------------------------------------- */

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin: 2.5rem 0 1rem;
}
.section-head h2 { margin: 0; }
.section-head .more { color: var(--muted); font-size: 0.9rem; }

/* ----- Mobile tweaks ------------------------------------------------------ */

@media (max-width: 640px) {
    .site-header > div { gap: 0.75rem; padding: 0.65rem 1rem; }
    .site-header nav { gap: 0.85rem; font-size: 0.9rem; }
    .site-main { padding: 1.5rem 1rem 3rem; }
    h2 { margin-top: 2rem; }
    .grid { gap: 1rem; }
}
