:root {
    --color-bg: #ffffff;
    --color-cream: #f7f3ee;
    --color-surface: #ffffff;
    --color-border: #e7e1d8;
    --color-text: #17181a;
    --color-text-muted: #6b6660;
    --color-primary: #7c516f;
    --color-primary-dark: #5e3d54;
    --color-primary-soft: #f3e9f0;
    --color-accent: #6f95a3;
    --color-accent-soft: #eaf1f3;
    --color-success-bg: #e9f2e6;
    --color-success-text: #3d6b30;
    --color-error-bg: #fbeceb;
    --color-error-text: #9b3227;
    --radius: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 18px rgba(23, 24, 26, 0.06);
    --max-width: 1120px;
    --font: 'Lexend', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 0.5em;
    letter-spacing: -0.01em;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

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

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

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Header ---------- */
.topbar {
    background: var(--color-accent);
    color: #fff;
}
.topbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 0.82rem;
    gap: 12px;
}
.topbar a { color: #fff; opacity: 0.92; }
.topbar a:hover { opacity: 1; }

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 18px;
    padding-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}
.site-header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--color-text);
}
.site-header .logo svg { flex-shrink: 0; }
.site-header .logo .wordmark { color: var(--color-accent); }
.site-nav { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.site-nav a { color: var(--color-text); font-weight: 500; font-size: 0.95rem; }
.site-nav .btn { color: #fff; }

main { padding: 40px 0 72px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--color-primary); border: 1px solid var(--color-border); }
.btn.secondary:hover { background: var(--color-primary-soft); }
.btn.danger { background: var(--color-error-text); }
.btn.small { padding: 7px 14px; font-size: 0.875rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Hero ---------- */
.hero {
    background: var(--color-cream);
    border-radius: var(--radius-lg);
    padding: 56px 48px;
    margin-bottom: 48px;
    position: relative;
    overflow: hidden;
}
.hero__sprig {
    position: absolute;
    left: -24px;
    bottom: -24px;
    width: 120px;
    height: auto;
    opacity: 0.55;
    pointer-events: none;
}
.hero__content { position: relative; max-width: 640px; padding-left: 64px; }
@media (max-width: 640px) {
    .hero__content { padding-left: 0; }
    .hero__sprig { display: none; }
}
.hero h1 { margin-bottom: 0.4em; }
.hero p { font-size: 1.05rem; color: var(--color-text-muted); margin: 0 0 24px; max-width: 520px; }
@media (max-width: 640px) {
    .hero { padding: 36px 24px; }
    .hero h1 { font-size: 1.7rem; }
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

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

.course-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    border: 1px solid var(--color-border);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.course-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }
.course-card__cover { aspect-ratio: 16/9; background: var(--color-cream) center/cover no-repeat; }
.course-card__body { padding: 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.course-card__body h3 { color: var(--color-text); }
.course-card__price { font-weight: 700; color: var(--color-text); margin-top: auto; font-size: 1.05rem; }

.price-tag {
    display: inline-block;
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    padding: 5px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
}

.original-price {
    opacity: 0.7;
    font-weight: 400;
    margin-right: 4px;
}

form { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
form.wide { max-width: none; }
label { font-weight: 600; font-size: 0.9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
    padding: 11px 13px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    width: 100%;
    background: #fff;
    color: var(--color-text);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}
textarea { min-height: 160px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-inline { display: flex; align-items: center; gap: 8px; flex-direction: row; }
.help-text { color: var(--color-text-muted); font-size: 0.85rem; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.92rem; }
.flash.success { background: var(--color-success-bg); color: var(--color-success-text); }
.flash.error { background: var(--color-error-bg); color: var(--color-error-text); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.paid { background: var(--color-success-bg); color: var(--color-success-text); }
.badge.pending { background: #fff4e0; color: #8a5b12; }
.badge.cancelled, .badge.failed, .badge.expired { background: var(--color-error-bg); color: var(--color-error-text); }
.badge.draft { background: #eee; color: #666; }
.badge.published { background: var(--color-success-bg); color: var(--color-success-text); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
th { color: var(--color-text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }

.learn-layout { display: grid; grid-template-columns: 280px 1fr; gap: 32px; align-items: start; }
.learn-sidebar { position: sticky; top: 24px; }
@media (max-width: 800px) {
    .learn-layout { grid-template-columns: 1fr; }
    .learn-sidebar { position: static; }
}

.module-heading {
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-accent);
    margin: 20px 0 6px;
}
.module-heading:first-child { margin-top: 0; }

.chapter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.chapter-list a { display: block; padding: 10px 14px; border-radius: var(--radius); color: var(--color-text); font-size: 0.94rem; transition: background 0.12s ease; }
.chapter-list a:hover { background: var(--color-cream); text-decoration: none; }
.chapter-list a.active { background: var(--color-primary); color: #fff; }
.chapter-list a.active:hover { background: var(--color-primary); }

.video-wrapper { background: #000; border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.video-wrapper video { width: 100%; display: block; max-height: 70vh; }

.chapter-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 20px; }
.chapter-images img { border-radius: var(--radius); aspect-ratio: 4/3; object-fit: cover; }

.admin-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.admin-sidebar { background: var(--color-text); color: #f1ece8; padding: 26px 18px; }
.admin-sidebar a { color: #f1ece8; display: block; padding: 9px 12px; border-radius: var(--radius); opacity: 0.82; font-size: 0.94rem; }
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(255,255,255,0.12); opacity: 1; text-decoration: none; }
.admin-sidebar .brand { font-weight: 700; margin-bottom: 22px; display: block; font-size: 1.05rem; color: #fff; }
.admin-main { padding: 32px 36px; max-width: 1140px; }
@media (max-width: 800px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 18px; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--color-primary); }
.stat-card .label { color: var(--color-text-muted); font-size: 0.85rem; }

.thread { border-bottom: 1px solid var(--color-border); padding: 16px 0; }
.thread:last-child { border-bottom: none; }
.thread h3 { margin: 0 0 4px; }
.thread .meta { color: var(--color-text-muted); font-size: 0.85rem; }

.reply { padding: 14px 0; border-bottom: 1px solid var(--color-border); }
.reply:last-child { border-bottom: none; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.space-between { justify-content: space-between; }
.mt-0 { margin-top: 0; }
.text-muted { color: var(--color-text-muted); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }

.rich-content { max-width: 720px; }
.rich-content img { border-radius: var(--radius); margin: 12px 0; }

footer.site-footer {
    background: var(--color-text);
    color: #cfc9c2;
    padding: 28px 0;
    font-size: 0.85rem;
}
footer.site-footer a { color: #fff; }
