:root {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --fg: #16181d;
    --muted: #646b76;
    --line: #e4e4e0;
    --accent: #e5383b;
    --accent-fg: #ffffff;
    --accent-soft: #fdecec;
    --ok: #1f8a4c;
    --warn: #b7791f;
    --term-bg: #14161c;
    --term-fg: #d7dde5;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
    --mono: ui-monospace, "JetBrains Mono", "Fira Code", monospace;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #171a20;
        --fg: #e6e9ee;
        --muted: #8b939f;
        --line: #262b33;
        --accent: #ff5c5f;
        --accent-soft: #2a1617;
        --ok: #4cc27f;
        --warn: #e0a84a;
        --term-bg: #0a0b0e;
        --shadow: none;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: .5rem; }
h2 { font-size: 1.5rem; margin-bottom: 1rem; }
h3 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.warn { color: var(--warn); }
.ok { color: var(--ok); margin-top: .75rem; }
.mono, code, pre { font-family: var(--mono); }

.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 1rem; }
@media (min-width: 640px) { .wrap { padding: 0 1.5rem; } }
.narrow { max-width: 480px; padding-top: 3rem; padding-bottom: 3rem; }
.prose.narrow { max-width: 760px; }

/* ---------- topbar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 1rem; }
.logo { font-family: var(--mono); font-weight: 700; font-size: 1.3rem; text-decoration: none; color: var(--fg); }
.logo span { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 1.25rem; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover, .nav a.active { color: var(--fg); }
.nav a.btn { color: var(--accent-fg); }
.nav-sep { width: 1px; height: 22px; background: var(--line); }
.nav-toggle, .nav-burger { display: none; }
@media (max-width: 820px) {
    .nav-burger { display: block; cursor: pointer; padding: 10px 4px; }
    .nav-burger span, .nav-burger span::before, .nav-burger span::after {
        display: block; width: 22px; height: 2px; background: var(--fg); position: relative; content: "";
    }
    .nav-burger span::before { position: absolute; top: -7px; }
    .nav-burger span::after { position: absolute; top: 7px; }
    .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch;
           background: var(--surface); border-bottom: 1px solid var(--line); padding: .5rem 1rem 1rem; gap: .25rem; }
    .nav a { padding: .6rem 0; }
    .nav-sep { width: 100%; height: 1px; }
    .nav-toggle:checked ~ .nav { display: flex; }
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    background: var(--accent); color: var(--accent-fg); border: 1px solid var(--accent);
    padding: .6rem 1.1rem; border-radius: 10px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    transition: filter .15s, transform .15s;
}
.btn:hover { filter: brightness(1.08); color: var(--accent-fg); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .35rem .8rem; font-size: .9rem; }
.btn-lg { padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-danger { background: transparent; color: var(--accent); border-color: var(--accent); }

/* ---------- hero ---------- */
.hero { background: var(--surface); border-bottom: 1px solid var(--line); }
.hero-in { display: grid; grid-template-columns: 1.2fr 1fr; gap: 3rem; align-items: center; padding-top: 4.5rem; padding-bottom: 4.5rem; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); margin: .5rem 0 1rem; }
.hero h1 em { font-style: normal; color: var(--accent); }
.eyebrow { font-family: var(--mono); color: var(--accent); font-size: .9rem; letter-spacing: .06em; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 46ch; }
.hero-cta { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 2rem; }
.hero-term {
    background: var(--term-bg); color: var(--term-fg); border-radius: var(--radius); padding: 1.5rem;
    font-size: .9rem; line-height: 1.7; overflow-x: auto; box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
.hero-term .c { color: #7d8794; }
.hero-term b { color: #ff5c5f; }
.hero-term i { color: #4cc27f; font-style: normal; }
.cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (max-width: 860px) {
    .hero-in { grid-template-columns: 1fr; gap: 2rem; padding-top: 3rem; padding-bottom: 3rem; }
}

/* ---------- steps / sections ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; padding-top: 3rem; padding-bottom: 1rem; }
.step span {
    display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; margin-bottom: .75rem;
}
.step h3 { margin-bottom: .25rem; }
@media (max-width: 700px) { .steps { grid-template-columns: 1fr; } }

.section { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1.25rem; }
.section-head h2 { margin: 0; }
.section-head a { color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.page-head { padding-top: 2.5rem; }
.account-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.crumbs { padding-top: 1.5rem; }
.crumbs a { text-decoration: none; }

.about { padding-top: 3rem; padding-bottom: 4rem; }
.about > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; max-width: 760px; }
.about p { margin-bottom: .75rem; }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow);
    transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); color: inherit; }
.card-cover { position: relative; aspect-ratio: 16 / 9; background: var(--term-bg); display: grid; place-items: center; overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-cover-ebook    { background: linear-gradient(135deg, #e5383b, #7a1f3d); }
.card-cover-script   { background: linear-gradient(135deg, #14161c, #2d3748); }
.card-cover-tutorial { background: linear-gradient(135deg, #1f6f8b, #14161c); }
.card-cover-label { font-family: var(--mono); color: rgba(255,255,255,.85); font-size: 1.4rem; font-weight: 700; letter-spacing: .05em; }
.card-body { padding: 1rem 1.1rem .5rem; flex: 1; }
.card-body h3 { margin: .4rem 0 .35rem; }
.card-body p { font-size: .925rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1.1rem 1rem; font-size: .9rem; }
.card-foot .more { color: var(--muted); }
.card:hover .more { color: var(--accent); }
.price { font-weight: 700; }
.price-free { color: var(--ok); }
.badge { position: absolute; font-size: .75rem; font-weight: 600; padding: .2rem .55rem; border-radius: 6px; }
.badge-level { top: .6rem; left: .6rem; background: rgba(255,255,255,.92); color: #16181d; }
.badge-dur { bottom: .5rem; right: .5rem; background: rgba(0,0,0,.75); color: #fff; font-family: var(--mono); }
.tag {
    display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent);
}
.tag-level { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.chip { padding: .35rem .9rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-size: .9rem; background: var(--surface); }
.chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ---------- item page ---------- */
.item { display: grid; grid-template-columns: 1fr 340px; gap: 2.5rem; padding-top: 1rem; padding-bottom: 4rem; align-items: start; }
.item .meta { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.item .lead { margin-bottom: 1.5rem; max-width: none; }
.item-side { position: sticky; top: 84px; }
.buybox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.buybox-cover { border-radius: 10px; margin-bottom: 1rem; width: 100%; }
.buybox-price { font-size: 2rem; font-weight: 800; margin-bottom: 1rem; }
.buybox form .btn { margin-top: .75rem; }
.buybox-list { list-style: none; margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; color: var(--muted); }
.buybox-list li::before { content: "✓ "; color: var(--ok); }
.locked { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; }
@media (max-width: 900px) {
    .item { grid-template-columns: 1fr; }
    .item-side { position: static; order: -1; }
}

.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 1.5rem; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-page { max-width: 960px; padding-top: 1rem; padding-bottom: 4rem; }

/* ---------- prose ---------- */
.prose { max-width: 75ch; }
.prose > * + * { margin-top: 1rem; }
.prose h1 { margin-bottom: 1rem; }
.prose h2 { margin-top: 2rem; margin-bottom: .5rem; }
.prose h3 { margin-top: 1.5rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: .3rem; }
.prose code { background: var(--accent-soft); padding: .1rem .35rem; border-radius: 5px; font-size: .9em; }
.prose pre { background: var(--term-bg); color: var(--term-fg); padding: 1rem 1.25rem; border-radius: 10px; overflow-x: auto; font-size: .9rem; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--muted); }
.prose img { border-radius: 10px; }
.prose table { border-collapse: collapse; width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0; }
.form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .95rem; }
.form input:not([type=checkbox]):not([type=file]), .form textarea, .form select {
    font: inherit; font-weight: 400; color: var(--fg); background: var(--surface); border: 1px solid var(--line);
    border-radius: 10px; padding: .65rem .8rem; width: 100%;
}
.form textarea.mono { font-family: var(--mono); font-size: .9rem; line-height: 1.5; }
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { flex-direction: row !important; align-items: flex-start; gap: .55rem !important; font-weight: 400 !important; }
.check input { margin-top: .3rem; accent-color: var(--accent); flex-shrink: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 320px; gap: 2rem; }
.form-side { display: flex; flex-direction: column; gap: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
legend { padding: 0 .4rem; font-weight: 600; font-size: .9rem; }
.admin-cover { max-height: 140px; border-radius: 8px; }
.danger-zone { margin-top: 1rem; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }

.flash { padding: .8rem 1rem; border-radius: 10px; margin: 1rem 0; border: 1px solid; }
.flash-ok    { background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: var(--ok); }
.flash-error { background: var(--accent-soft); border-color: var(--accent); }
.flash-info  { background: color-mix(in srgb, var(--warn) 10%, transparent); border-color: var(--warn); }

/* ---------- account / admin ---------- */
.list { list-style: none; }
.list li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.library { display: flex; flex-direction: column; gap: .75rem; }
.lib-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.lib-row .tag { margin-right: .4rem; }

.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding-top: 1.25rem; padding-bottom: .25rem; }
.admin-nav > a:not(.btn) { text-decoration: none; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin: 1.5rem 0 2.5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.stat span { display: block; color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.5rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 1rem; }
.table { width: 100%; border-collapse: collapse; font-size: .925rem; }
.table th, .table td { padding: .65rem .9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.status { font-size: .8rem; font-weight: 600; padding: .15rem .5rem; border-radius: 6px; white-space: nowrap; }
.status-paid    { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.status-pending { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.status-failed  { background: var(--accent-soft); color: var(--accent); }

.error-page h1 { margin: 1rem 0 2rem; }

/* ---------- footer ---------- */
.footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 2rem; }
.footer-in { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 2rem; padding-top: 2.5rem; padding-bottom: 2rem; }
.footer-in > div { display: flex; flex-direction: column; gap: .4rem; }
.footer-in a:not(.logo) { text-decoration: none; color: var(--muted); }
.footer-in a:hover { color: var(--accent); }
.footer h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .25rem; }
.footer-bottom { border-top: 1px solid var(--line); padding-top: 1rem; padding-bottom: 1.5rem; }
@media (max-width: 760px) { .footer-in { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .footer-in { grid-template-columns: 1fr; } }
