/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --c-bg: #fafaf9;
    --c-surface: #ffffff;
    --c-text: #1a1a1a;
    --c-text-muted: #6b7280;
    --c-primary: #0e7c3a;
    --c-primary-dark: #065f28;
    --c-primary-light: #d1fae5;
    --c-accent: #f59e0b;
    --c-accent-light: #fef3c7;
    --c-border: #e5e7eb;
    --c-danger: #dc2626;
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-reading: 'Merriweather', Georgia, serif;
    --max-w: 720px;
    --max-w-wide: 1080px;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1; }

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

img { max-width: 100%; height: auto; }

/* === NAV === */
.nav {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: var(--max-w-wide);
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--c-text);
}
.nav-brand:hover { color: var(--c-primary); }
.nav-disc { font-size: 1.5rem; }
.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.nav-links a {
    color: var(--c-text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--c-primary); }
.nav-cta {
    background: var(--c-primary) !important;
    color: #fff !important;
    padding: 0.4rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem !important;
}
.nav-cta:hover {
    background: var(--c-primary-dark) !important;
}
.nav-badge {
    background: var(--c-primary-light);
    color: var(--c-primary-dark);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; }
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--c-text);
    margin: 5px 0;
    transition: 0.3s;
}

/* === HERO === */
.hero {
    background: linear-gradient(135deg, #065f28 0%, #0e7c3a 50%, #10b981 100%);
    color: #fff;
    padding: 5rem 1.5rem 4rem;
    text-align: center;
}
.hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}
.hero .subtitle {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.5;
}
.hero .byline {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 2rem;
}
.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-white {
    background: #fff;
    color: var(--c-primary-dark);
}
.btn-white:hover {
    background: #f0fdf4;
    color: var(--c-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-outline {
    background: transparent;
    color: #fff;
    border: 2px solid rgba(255,255,255,0.5);
}
.btn-outline:hover {
    border-color: #fff;
    color: #fff;
    transform: translateY(-1px);
}
.btn-primary {
    background: var(--c-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--c-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* === SECTIONS === */
.section {
    max-width: var(--max-w-wide);
    margin: 0 auto;
    padding: 3rem 1.5rem;
}
.section-narrow {
    max-width: var(--max-w);
}

/* === CHAPTER LIST === */
.chapter-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}
.chapter-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--c-text);
}
.chapter-card:hover {
    border-color: var(--c-primary);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
    color: var(--c-text);
}
.chapter-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--c-primary);
    min-width: 2.5rem;
    text-align: center;
}
.chapter-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}
.chapter-info p {
    font-size: 0.9rem;
    color: var(--c-text-muted);
}
.chapter-lock {
    margin-left: auto;
    color: var(--c-text-muted);
    font-size: 1.2rem;
    flex-shrink: 0;
}
.chapter-free {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--c-primary);
    background: var(--c-primary-light);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    flex-shrink: 0;
}

/* === CHAPTER CONTENT === */
.chapter-header {
    background: linear-gradient(135deg, #065f28 0%, #0e7c3a 100%);
    color: #fff;
    padding: 3rem 1.5rem 2.5rem;
    text-align: center;
}
.chapter-header .ch-num {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}
.chapter-header h1 {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 800;
    line-height: 1.2;
}
.chapter-header .ch-subtitle {
    font-size: 1.1rem;
    opacity: 0.85;
    margin-top: 0.5rem;
}
.chapter-body {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    font-family: var(--font-reading);
    font-size: 1.05rem;
    line-height: 1.8;
}
.chapter-body p { margin-bottom: 1.3rem; }
.chapter-body h2 {
    font-family: var(--font-body);
    font-size: 1.4rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    color: var(--c-primary-dark);
}
.chapter-body h3 {
    font-family: var(--font-body);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
}
.chapter-body ul, .chapter-body ol {
    margin: 1rem 0 1.3rem 1.5rem;
}
.chapter-body li { margin-bottom: 0.5rem; }
.chapter-body blockquote {
    border-left: 4px solid var(--c-primary);
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background: var(--c-primary-light);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
}
.chapter-body .callout {
    background: var(--c-accent-light);
    border-left: 4px solid var(--c-accent);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-family: var(--font-body);
    font-size: 0.95rem;
}
.chapter-body .callout strong {
    color: #92400e;
}
.chapter-nav {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}
.chapter-nav a {
    font-weight: 600;
    font-size: 0.95rem;
}

/* === GATE / AUTH PAGES === */
.gate-page {
    max-width: 480px;
    margin: 4rem auto;
    padding: 0 1.5rem;
    text-align: center;
}
.gate-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-md);
}
.gate-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.gate-card p {
    color: var(--c-text-muted);
    margin-bottom: 1.5rem;
}
.gate-card .divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--c-text-muted);
    font-size: 0.85rem;
}
.gate-card .divider::before,
.gate-card .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--c-border);
}
.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.input-group input {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font-body);
    transition: border-color 0.2s;
}
.input-group input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(14,124,58,0.1);
}

/* === FLASH MESSAGES === */
.flash-container {
    max-width: var(--max-w-wide);
    margin: 0 auto;
    padding: 1rem 1.5rem 0;
}
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.flash-error { background: #fef2f2; color: var(--c-danger); border: 1px solid #fecaca; }
.flash-success { background: #f0fdf4; color: var(--c-primary-dark); border: 1px solid #bbf7d0; }

/* === ABOUT === */
.about-section {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 3rem 1.5rem;
}
.about-section h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}
.about-section p {
    font-family: var(--font-reading);
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 1.3rem;
}

/* === ADMIN === */
.admin-wrap {
    max-width: var(--max-w-wide);
    margin: 0 auto;
    padding: 2rem 1.5rem;
}
.admin-wrap h1 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.stat-card .stat-num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--c-primary);
}
.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--c-text-muted);
    margin-top: 0.25rem;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--c-border);
}
.admin-table th, .admin-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--c-border);
    font-size: 0.9rem;
}
.admin-table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--c-text-muted);
}
.admin-form {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}
.admin-form label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    margin-top: 1rem;
}
.admin-form label:first-child { margin-top: 0; }
.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.95rem;
}
.admin-form textarea {
    min-height: 300px;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}
.admin-form input:focus, .admin-form textarea:focus {
    outline: none;
    border-color: var(--c-primary);
}
.checkbox-row {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}
.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}
.badge-active {
    background: var(--c-primary-light);
    color: var(--c-primary-dark);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-inactive {
    background: #fef2f2;
    color: var(--c-danger);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* === FOOTER === */
.footer {
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    padding: 2rem 1.5rem;
    text-align: center;
    margin-top: auto;
}
.footer-inner { max-width: var(--max-w-wide); margin: 0 auto; }
.footer p { font-size: 0.9rem; color: var(--c-text-muted); }
.footer-tagline { font-style: italic; margin-top: 0.3rem; font-size: 0.85rem !important; }

/* === 404 === */
.page-404 {
    text-align: center;
    padding: 5rem 1.5rem;
}
.page-404 h1 { font-size: 4rem; color: var(--c-primary); }
.page-404 p { color: var(--c-text-muted); margin: 1rem 0; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .nav-links { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--c-surface); border-bottom: 1px solid var(--c-border); flex-direction: column; padding: 1rem 1.5rem; gap: 0.75rem; }
    .nav-links.open { display: flex; }
    .nav-toggle { display: block; }
    .hero { padding: 3rem 1.5rem 2.5rem; }
    .chapter-nav { flex-direction: column; text-align: center; }
    .input-group { flex-direction: column; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}