/* ===== Prompt Engineering 2026 V3 — Shared Styles ===== */
:root {
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #5b21b6;
    --primary-glow: rgba(124, 58, 237, 0.4);
    --secondary: #06b6d4;
    --secondary-light: #22d3ee;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --dark-0: #030712;
    --dark-1: #0f172a;
    --dark-2: #1e293b;
    --dark-3: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-glass: rgba(255, 255, 255, 0.08);
    --glass-blur: 20px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-card: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 60px rgba(124,58,237,0.1);
    --transition-fast: 0.2s cubic-bezier(0.4,0,0.2,1);
    --transition-smooth: 0.4s cubic-bezier(0.4,0,0.2,1);
    --sidebar-width: 280px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', 'Sarabun', -apple-system, sans-serif;
    background: var(--dark-0);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
}
body::before {
    content: '';
    position: fixed; inset: 0;
    pointer-events: none; z-index: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(124,58,237,0.12) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 90%, rgba(6,182,212,0.07) 0%, transparent 50%);
}

/* ===== SIDEBAR NAVIGATION ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-glass);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

/* Sidebar Brand */
.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
}
.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.sidebar-brand-icon { font-size: 1.6rem; }
.sidebar-brand-text {
    font-size: 1rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, var(--primary-light));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--primary-light);
}

/* Sidebar Progress */
.sidebar-progress {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
}
.sidebar-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.sidebar-progress-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-progress-count {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary-light);
}
.sidebar-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--dark-3);
    border-radius: 3px;
    overflow: hidden;
}
.sidebar-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--dark-3) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--dark-3); border-radius: 4px; }

/* Sidebar Links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    position: relative;
}
.sidebar-link:hover {
    background: rgba(124, 58, 237, 0.08);
    color: var(--text-primary);
}
.sidebar-link-active {
    background: rgba(124, 58, 237, 0.12);
    color: var(--primary-light);
    border-left-color: var(--primary);
}
.sidebar-link-home {
    margin: 0 12px 4px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border-left: none;
}
.sidebar-link-home.sidebar-link-active {
    background: rgba(124, 58, 237, 0.15);
    border-left: none;
}

/* Sidebar Sections (Collapsible Groups) */
.sidebar-section {
    margin-bottom: 4px;
}
.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all var(--transition-fast);
    text-align: left;
}
.sidebar-section-title:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}
.sidebar-section-icon { font-size: 0.9rem; }
.sidebar-chevron {
    margin-left: auto;
    font-size: 0.6rem;
    transition: transform 0.2s;
    color: var(--text-muted);
}
.sidebar-section-title[aria-expanded="false"] .sidebar-chevron {
    transform: rotate(-90deg);
}

/* Section Items (Indented Sub-items) */
.sidebar-section-items {
    padding-left: 12px;
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    opacity: 1;
}
.sidebar-section-items.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Sub-links with indent */
.sidebar-link-sub {
    padding: 8px 16px 8px 28px;
    font-size: 0.8rem;
    font-weight: 500;
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-right: 12px;
}
.sidebar-link-sub:hover {
    background: rgba(124, 58, 237, 0.08);
}
.sidebar-link-sub.sidebar-link-active {
    background: rgba(124, 58, 237, 0.15);
    color: var(--primary-light);
    border-left: none;
    border-right: none;
    position: relative;
}
.sidebar-link-sub.sidebar-link-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

/* Module Dot (completion indicator) */
.sidebar-module-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--dark-3);
    border: 1.5px solid var(--text-muted);
    flex-shrink: 0;
    transition: all 0.2s;
}
.sidebar-link-completed .sidebar-module-dot {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

/* Sidebar Badge */
.sidebar-badge {
    margin-left: auto;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-badge-new {
    background: rgba(6, 182, 212, 0.15);
    color: var(--secondary-light);
}

/* ===== MOBILE TOPBAR ===== */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: rgba(3, 7, 18, 0.95);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-glass);
    align-items: center;
    padding: 0 16px;
    z-index: 150;
    gap: 12px;
}
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: none;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.sidebar-toggle:hover { background: rgba(124, 58, 237, 0.1); color: white; }
.mobile-brand {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}
.mobile-progress {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-light);
    padding: 4px 10px;
    background: rgba(124, 58, 237, 0.1);
    border-radius: 12px;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 190;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.overlay-visible {
    opacity: 1;
}

/* ===== MAIN CONTENT LAYOUT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 40px 40px 60px;
    position: relative;
    z-index: 1;
    /* Center content in remaining space */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-content > * {
    width: 100%;
    max-width: 900px;
}

/* ===== LEGACY TOPBAR (for module pages still using it) ===== */
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: 56px;
    background: rgba(3,7,18,0.92);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-glass);
    display: flex; align-items: center;
    padding: 0 24px;
    z-index: 100;
    gap: 16px;
}
.topbar .logo { font-size: 1.3rem; }
.topbar .title {
    font-size: 0.9rem; font-weight: 700; color: white;
}
.topbar .nav-links {
    margin-left: auto;
    display: flex; gap: 8px;
}
.topbar .nav-links a {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.78rem; font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition-fast);
}
.topbar .nav-links a:hover { background: rgba(124,58,237,0.1); color: white; }
.topbar .nav-links a.active { background: rgba(124,58,237,0.2); color: var(--primary-light); }

/* ===== LAYOUT (legacy page-container for module pages) ===== */
.page-container {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    padding: 80px 40px 60px;
    position: relative; 
    z-index: 1;
}

/* ===== MODULE HEADER ===== */
.module-header { margin-bottom: 40px; padding-bottom: 24px; border-bottom: 1px solid var(--border-glass); }
.module-number {
    display: inline-block; padding: 4px 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 20px; font-size: 0.75rem; font-weight: 700; color: white;
    margin-bottom: 12px;
}
.module-header h1 {
    font-size: 2.2rem; font-weight: 800;
    background: linear-gradient(135deg, #fff, var(--primary-light, #a78bfa));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--primary-light, #a78bfa);
    line-height: 1.3; margin-bottom: 8px;
}
.module-header .subtitle { font-size: 1rem; color: var(--text-muted); }

/* ===== TYPOGRAPHY ===== */
h2 {
    font-size: 1.5rem; font-weight: 700; color: var(--text-primary);
    margin: 40px 0 16px; padding-left: 14px;
    border-left: 3px solid var(--primary);
}
h3 { font-size: 1.15rem; font-weight: 600; color: var(--text-primary); margin: 28px 0 12px; }
h4 { font-size: 1rem; font-weight: 600; color: var(--primary-light); margin: 20px 0 8px; }
p { margin-bottom: 16px; color: var(--text-secondary); }
strong { color: var(--text-primary); }
ul, ol { margin: 12px 0 12px 24px; color: var(--text-secondary); }
li { margin-bottom: 6px; }
li::marker { color: var(--primary-light); }
blockquote {
    border-left: 3px solid var(--primary);
    padding: 12px 20px; margin: 16px 0;
    background: rgba(124,58,237,0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic; color: var(--text-secondary);
}

/* ===== CARDS ===== */
.card {
    background: rgba(30,41,59,0.5);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px; margin: 20px 0;
    backdrop-filter: blur(8px);
    transition: all var(--transition-fast);
}
.card:hover { border-color: rgba(124,58,237,0.3); box-shadow: var(--shadow-glow); }
.card-title {
    font-size: 1.05rem; font-weight: 700; color: white;
    margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}

/* ===== TABLES ===== */
table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.88rem; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-glass); }
th {
    background: rgba(124,58,237,0.2); color: #e2e8f0;
    font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
}
td { color: var(--text-secondary); }
tr:hover td { background: rgba(124,58,237,0.04); }

/* ===== CODE BLOCKS ===== */
.code-block {
    background: #0d1117;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 20px 24px;
    padding-right: 80px; /* เว้นที่สำหรับปุ่ม Copy */
    margin: 16px 0;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.8;
    color: #e2e8f0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    position: relative;
}
.code-block strong,
.code-block b {
    color: #c4b5fd;
    font-weight: 700;
}
code {
    font-family: 'Fira Code', monospace;
    background: rgba(124,58,237,0.1);
    padding: 2px 6px; border-radius: 4px;
    font-size: 0.85em; color: var(--primary-light);
}

/* ===== CALLOUTS ===== */
.callout {
    padding: 16px 20px; border-radius: var(--radius-sm);
    margin: 16px 0; border-left: 4px solid;
}
.callout-info { 
    background: rgba(6,182,212,0.08); 
    border-color: var(--secondary);
}
.callout-info, .callout-info li, .callout-info p {
    color: #155e75;
}
.callout-warning { 
    background: rgba(245,158,11,0.08); 
    border-color: var(--accent);
}
.callout-warning, .callout-warning li, .callout-warning p {
    color: #92400e;
}
.callout-tip { 
    background: rgba(16,185,129,0.08); 
    border-color: var(--success);
}
.callout-tip, .callout-tip li, .callout-tip p {
    color: #065f46;
}
.callout-success {
    background: rgba(16,185,129,0.08);
    border-color: var(--success);
}
.callout-success, .callout-success li, .callout-success p {
    color: #065f46;
}
.callout-danger { 
    background: rgba(239,68,68,0.08); 
    border-color: var(--danger);
}
.callout-danger, .callout-danger li, .callout-danger p {
    color: #991b1b;
}
.callout-title { font-weight: 700; margin-bottom: 4px; font-size: 0.9rem; }
.callout-info .callout-title { color: #0e7490; }
.callout-warning .callout-title { color: #b45309; }
.callout-tip .callout-title, .callout-success .callout-title { color: #047857; }
.callout-danger .callout-title { color: #dc2626; }

/* Dark mode adjustments for callouts */
@media (prefers-color-scheme: dark) {
    .callout-info, .callout-info li, .callout-info p { color: #67e8f9; }
    .callout-info .callout-title { color: #22d3ee; }
    .callout-warning, .callout-warning li, .callout-warning p { color: #fcd34d; }
    .callout-warning .callout-title { color: #fbbf24; }
    .callout-tip, .callout-tip li, .callout-tip p,
    .callout-success, .callout-success li, .callout-success p { color: #6ee7b7; }
    .callout-tip .callout-title, .callout-success .callout-title { color: #34d399; }
    .callout-danger, .callout-danger li, .callout-danger p { color: #fca5a5; }
    .callout-danger .callout-title { color: #f87171; }
    .callout-neutral, .callout-neutral li, .callout-neutral p { color: #d4d4d8; }
    .callout-neutral .callout-title { color: #a1a1aa; }
}

/* Neutral callout (grey) */
.callout-neutral {
    background: rgba(113,113,122,0.1);
    border-color: #71717a;
}
.callout-neutral, .callout-neutral li, .callout-neutral p {
    color: #3f3f46;
}
.callout-neutral .callout-title { color: #52525b; }

/* ===== TAGS ===== */
.tag {
    display: inline-block; padding: 3px 10px;
    border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.tag-beginner { background: rgba(16,185,129,0.15); color: #34d399; }
.tag-intermediate { background: rgba(245,158,11,0.15); color: #fbbf24; }
.tag-advanced { background: rgba(239,68,68,0.15); color: #f87171; }
.tag-expert { background: rgba(124,58,237,0.15); color: #a78bfa; }
.tag-new { background: rgba(6,182,212,0.15); color: #22d3ee; }

/* ===== FRAMEWORK CARDS ===== */
.framework-card {
    background: linear-gradient(135deg, rgba(30,41,59,0.6), rgba(15,23,42,0.8));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px; margin: 20px 0;
    position: relative; overflow: hidden;
}
.framework-card::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 100%; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}
.framework-name { font-size: 1.3rem; font-weight: 800; color: white; margin-bottom: 4px; letter-spacing: 1px; }
.framework-full-name { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.framework-components { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.framework-components .comp {
    padding: 6px 14px;
    background: rgba(124,58,237,0.12);
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 20px; font-size: 0.78rem; font-weight: 600; color: var(--primary-light);
}

/* ===== NAV FOOTER ===== */
.module-nav {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 60px; padding-top: 24px;
    border-top: 1px solid var(--border-glass);
}
.module-nav a {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    background: rgba(124,58,237,0.1);
    border: 1px solid rgba(124,58,237,0.3);
    color: var(--primary-light); text-decoration: none;
    font-size: 0.85rem; font-weight: 600;
    transition: all var(--transition-fast);
}
.module-nav a:hover { background: rgba(124,58,237,0.2); color: white; }

/* ===== SKIP LINK (Accessibility) ===== */
.skip-link {
    position: absolute;
    top: -50px;
    left: 0;
    background: var(--primary, #7c3aed);
    color: white;
    padding: 10px 20px;
    z-index: 1000;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0 0 8px 0;
    transition: top 0.2s;
    text-decoration: none;
}
.skip-link:focus {
    top: 0;
}

/* ===== FOCUS STATES (Accessibility) ===== */
a:focus-visible,
button:focus-visible,
.module-card:focus-visible {
    outline: 3px solid var(--secondary, #06b6d4);
    outline-offset: 3px;
    border-radius: var(--radius-sm, 8px);
}
@supports selector(:focus-visible) {
    a:focus:not(:focus-visible),
    button:focus:not(:focus-visible) {
        outline: none;
    }
}

/* ===== PROGRESS BAR (module pages) ===== */
.progress-bar {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--dark-2, #1e293b);
    z-index: 99;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary, #7c3aed), var(--secondary, #06b6d4));
    transition: width 0.3s ease;
    border-radius: 0 2px 2px 0;
}
.progress-text {
    position: absolute;
    right: 12px;
    top: 6px;
    font-size: 0.7rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 600;
}

/* ===== CTA BUTTONS ===== */
.hero-cta {
    margin-top: 32px;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--primary, #7c3aed), var(--secondary, #06b6d4));
    color: white;
    border-radius: var(--radius-sm, 8px);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: all var(--transition-fast, 0.2s);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
    border: none;
    cursor: pointer;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.5);
}
.btn-primary:focus-visible {
    outline: 3px solid var(--secondary, #06b6d4);
    outline-offset: 3px;
}
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.4);
    color: var(--primary-light, #a78bfa);
    border-radius: var(--radius-sm, 8px);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    transition: all var(--transition-fast, 0.2s);
    cursor: pointer;
}
.btn-secondary:hover {
    background: rgba(124, 58, 237, 0.2);
    color: white;
}
.btn-secondary:focus-visible {
    outline: 3px solid var(--secondary, #06b6d4);
    outline-offset: 3px;
}

/* ===== COPY BUTTON (Code Blocks) ===== */
.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Inter', 'Sarabun', sans-serif;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
    z-index: 10;
}
.copy-btn:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #818cf8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}
.copy-btn:active {
    transform: translateY(0);
}
.copy-btn.copied {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Mobile: slightly smaller button */
@media (max-width: 768px) {
    .code-block {
        padding: 16px 20px;
        padding-right: 70px;
        font-size: 0.8rem;
    }
    .copy-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* Token example copy button (M1) */
.token-copy-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: 'Inter', 'Sarabun', sans-serif;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}
.token-copy-btn:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #818cf8 100%);
    transform: translateY(-50%) scale(1.02);
}
.token-copy-btn.copied {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* ===== RESPONSIVE TABLES ===== */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
    border-radius: var(--radius-sm, 8px);
}
.table-wrapper table {
    margin: 0;
    min-width: 500px;
}

/* ===== BACK TO TOP ===== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--primary, #7c3aed);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 90;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
}
.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}
.back-to-top:hover {
    background: var(--primary-light, #a78bfa);
    transform: translateY(-2px);
}

/* ===== SR-ONLY (Screen Reader Only) ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== INDEX PAGE — Hero & Module Grid ===== */
.hero {
    text-align: center;
    padding: 60px 20px 40px;
}
.hero h1 {
    font-size: 2.8rem; font-weight: 900;
    background: linear-gradient(135deg, #fff, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--primary-light);
    margin-bottom: 16px;
}
.hero .subtitle { font-size: 1.1rem; color: var(--text-muted); max-width: 600px; margin: 0 auto 32px; }
.hero .stats { display: flex; justify-content: center; gap: 32px; flex-wrap: wrap; margin-top: 24px; }
.hero .stat { text-align: center; }
.hero .stat-number { font-size: 2rem; font-weight: 800; color: var(--primary-light); }
.hero .stat-label { font-size: 0.8rem; color: var(--text-muted); }

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 0;
    margin: 24px 0 40px;
}
.module-card {
    background: rgba(30,41,59,0.5);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 20px;
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}
.module-card:hover {
    border-color: rgba(124,58,237,0.4);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}
.module-card .mc-icon { font-size: 1.8rem; margin-bottom: 8px; }
.module-card .mc-number { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.module-card .mc-title { font-size: 0.95rem; font-weight: 700; color: white; margin: 4px 0; }
.module-card .mc-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; }
.module-card .mc-badge {
    position: absolute; top: 12px; right: 12px;
    padding: 2px 8px; border-radius: 10px;
    font-size: 0.65rem; font-weight: 700;
}
.mc-badge-new { background: rgba(6,182,212,0.2); color: var(--secondary-light); }
.mc-badge-updated { background: rgba(124,58,237,0.2); color: var(--primary-light); }
.module-card .mc-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 8px; }

.section-title {
    font-size: 1.1rem; font-weight: 700; color: var(--text-primary);
    margin: 40px 0 8px;
    display: flex; align-items: center; gap: 8px;
}

/* ===== RESPONSIVE ===== */

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
    .main-content {
        padding: 40px 60px 60px;
    }
    .main-content > * {
        max-width: 900px;
    }
    .page-container {
        max-width: 900px;
    }
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Extra Large Desktop (1400px+) */
@media (min-width: 1400px) {
    .main-content {
        padding: 40px 80px 60px;
    }
    .main-content > * {
        max-width: 950px;
    }
    .page-container {
        max-width: 950px;
    }
}

/* Desktop (1024px - 1199px) */
@media (max-width: 1199px) {
    :root { --sidebar-width: 260px; }
    .main-content {
        max-width: 900px;
    }
}

/* Tablet Landscape (768px - 1023px) */
@media (max-width: 1024px) {
    :root { --sidebar-width: 260px; }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .modules-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .hero h1 {
        font-size: 2.4rem;
    }
    .module-header h1 {
        font-size: 1.9rem;
    }
}

/* Tablet Portrait & Large Mobile (576px - 767px) */
@media (max-width: 768px) {
    /* Hide sidebar on mobile, show topbar */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
    }
    .mobile-topbar {
        display: flex;
    }
    .sidebar-overlay {
        display: block;
    }
    .main-content {
        margin-left: 0;
        padding: 72px 16px 40px;
    }

    /* Legacy module pages */
    .page-container { padding: 70px 16px 40px; }
    .module-header h1 { font-size: 1.6rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.05rem; }
    
    /* Tables responsive */
    table { font-size: 0.8rem; }
    th, td { padding: 8px 10px; }
    
    /* Grid responsive */
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .modules-grid { 
        grid-template-columns: 1fr; 
    }
    
    /* Framework cards */
    .framework-components { gap: 6px; }
    .framework-components .comp { font-size: 0.7rem; padding: 4px 10px; }
    
    /* Navigation */
    .topbar .nav-links { display: none; }
    .module-nav {
        flex-direction: column;
        gap: 12px;
    }
    .module-nav a {
        width: 100%;
        justify-content: center;
    }
    
    /* Hero */
    .hero h1 { font-size: 2rem; }
    .hero .subtitle { font-size: 1rem; }
    .hero .stats { gap: 20px; }
    .hero .stat-number { font-size: 1.6rem; }
    .hero-cta { flex-direction: column; align-items: center; }
    .btn-primary, .btn-secondary { width: 100%; max-width: 280px; justify-content: center; }
    
    /* Misc */
    .progress-text { display: none; }
    .back-to-top { bottom: 16px; right: 16px; }
    
    /* Cards */
    .card { padding: 16px; }
    .callout { padding: 12px 16px; }
    
    /* Code blocks */
    .code-block { 
        padding: 14px; 
        font-size: 0.78rem;
    }
    
    /* Feature cards for token example */
    .card[style*="text-align: center"] {
        padding: 1.25rem !important;
    }
    .card[style*="text-align: center"] div[style*="font-size: 2.5rem"] {
        font-size: 2rem !important;
    }
    .card[style*="text-align: center"] div[style*="font-size: 1.8rem"] {
        font-size: 1.5rem !important;
    }
}

/* Mobile (max-width: 575px) */
@media (max-width: 575px) {
    .page-container { 
        padding: 65px 12px 32px; 
    }
    .main-content {
        padding: 65px 12px 32px;
    }
    
    .module-header { 
        margin-bottom: 24px; 
        padding-bottom: 16px; 
    }
    .module-header h1 { 
        font-size: 1.4rem; 
        line-height: 1.4;
    }
    .module-header .subtitle { 
        font-size: 0.9rem; 
    }
    .module-number {
        padding: 3px 10px;
        font-size: 0.7rem;
    }
    
    h2 { 
        font-size: 1.15rem; 
        margin: 28px 0 12px;
        padding-left: 10px;
    }
    h3 { 
        font-size: 1rem; 
        margin: 20px 0 10px;
    }
    h4 { 
        font-size: 0.9rem; 
    }
    p { 
        font-size: 0.9rem; 
    }
    
    /* Tables - horizontal scroll */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 0.75rem;
    }
    th, td { 
        padding: 6px 8px; 
    }
    
    /* Cards */
    .card { 
        padding: 14px; 
        margin: 14px 0;
    }
    .card-title { 
        font-size: 0.95rem; 
    }
    
    /* Callouts */
    .callout { 
        padding: 10px 12px; 
        margin: 12px 0;
    }
    .callout-title { 
        font-size: 0.85rem; 
    }
    .callout ul, .callout ol {
        margin-left: 16px;
    }
    .callout li {
        font-size: 0.85rem;
    }
    
    /* Hero */
    .hero { 
        padding: 40px 12px 24px; 
    }
    .hero h1 { 
        font-size: 1.6rem; 
    }
    .hero .subtitle { 
        font-size: 0.9rem; 
    }
    .hero .stats { 
        gap: 16px; 
    }
    .hero .stat-number { 
        font-size: 1.4rem; 
    }
    .hero .stat-label { 
        font-size: 0.7rem; 
    }
    
    /* Buttons */
    .btn-primary, .btn-secondary {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    /* Code blocks */
    .code-block {
        padding: 12px;
        font-size: 0.72rem;
        border-radius: 6px;
    }
    code {
        font-size: 0.8em;
        padding: 1px 4px;
    }
    
    /* Lists */
    ul, ol { 
        margin-left: 18px; 
    }
    li { 
        font-size: 0.9rem; 
        margin-bottom: 4px;
    }
    
    /* Framework cards */
    .framework-card { 
        padding: 16px; 
    }
    .framework-name { 
        font-size: 1.1rem; 
    }
    .framework-components .comp { 
        font-size: 0.65rem; 
        padding: 3px 8px; 
    }
    
    /* Module nav */
    .module-nav { 
        margin-top: 40px; 
        padding-top: 16px;
    }
    .module-nav a { 
        padding: 10px 16px; 
        font-size: 0.8rem; 
    }
    
    /* Back to top */
    .back-to-top { 
        width: 40px; 
        height: 40px; 
        font-size: 1rem;
        bottom: 12px;
        right: 12px;
    }
    
    /* Token example cards - mobile specific */
    .card[style*="text-align: center"] {
        padding: 1rem !important;
    }
    .card[style*="text-align: center"] div[style*="font-size: 2.5rem"] {
        font-size: 1.8rem !important;
        margin-bottom: 0.3rem !important;
    }
    .card[style*="text-align: center"] div[style*="font-size: 1rem"] {
        font-size: 0.9rem !important;
    }
    .card[style*="text-align: center"] div[style*="font-size: 1.8rem"] {
        font-size: 1.3rem !important;
    }
    .card[style*="text-align: center"] div[style*="font-size: 0.85rem"] {
        font-size: 0.75rem !important;
    }
    .card[style*="text-align: center"] code {
        font-size: 0.95rem !important;
    }
    .card[style*="text-align: center"] button {
        padding: 0.3rem 0.5rem !important;
    }
}

/* Extra Small Mobile (max-width: 375px) */
@media (max-width: 375px) {
    .page-container { 
        padding: 60px 10px 28px; 
    }
    .module-header h1 { 
        font-size: 1.25rem; 
    }
    h2 { 
        font-size: 1.05rem; 
    }
    .hero h1 { 
        font-size: 1.4rem; 
    }
    .hero .stat-number { 
        font-size: 1.2rem; 
    }
    
    /* Very small tables */
    table {
        font-size: 0.7rem;
    }
    th, td { 
        padding: 5px 6px; 
    }
}

/* ===== GRID UTILITIES ===== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ===== TECHNIQUE CARDS (for grid layouts) ===== */
.technique-card {
    background: rgba(30,41,59,0.5);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition-fast);
}
.technique-card:hover {
    border-color: rgba(124,58,237,0.3);
}
.technique-card h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.technique-card h4 i {
    color: var(--primary-light);
}
.technique-card ul {
    margin-left: 0;
    list-style: none;
}
.technique-card li {
    padding-left: 20px;
    position: relative;
    margin-bottom: 8px;
}
.technique-card li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary-light);
}

@media (max-width: 768px) {
    .technique-card {
        padding: 16px;
    }
    .technique-card h4 {
        font-size: 0.95rem;
    }
}

@media (max-width: 575px) {
    .technique-card {
        padding: 14px;
    }
    .technique-card li {
        font-size: 0.85rem;
    }
}

/* ===== FEATURE CARDS ===== */
.feature-card {
    background: rgba(30,41,59,0.5);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    transition: all var(--transition-fast);
}
.feature-card:hover {
    border-color: rgba(124,58,237,0.3);
    transform: translateY(-2px);
}
.feature-card .icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}
.feature-card h4 {
    color: var(--text-primary);
    margin-bottom: 8px;
}
.feature-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .feature-card {
        padding: 18px;
    }
    .feature-card .icon {
        font-size: 2rem;
    }
}

@media (max-width: 575px) {
    .feature-card {
        padding: 14px;
    }
    .feature-card .icon {
        font-size: 1.8rem;
    }
    .feature-card h4 {
        font-size: 0.9rem;
    }
    .feature-card p {
        font-size: 0.8rem;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== INVESTIGATION LAB — Collapsible Example Boxes ===== */
.lab-box {
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    margin: 22px 0;
    background: rgba(99, 102, 241, 0.04);
    overflow: hidden;
}
.lab-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 18px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.08);
    user-select: none;
    transition: background 0.2s ease;
}
.lab-summary:hover { background: rgba(99, 102, 241, 0.14); }
.lab-summary::-webkit-details-marker { display: none; }
.lab-summary-title {
    flex: 1 1 auto;
    min-width: 180px;
    color: #e2e8f0;
    font-size: 1rem;
    line-height: 1.5;
}
.lab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Inter', 'Sarabun', sans-serif;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.lab-btn-download {
    background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.lab-btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
}
.lab-btn-copy {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}
.lab-btn-copy:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.45);
}
.lab-btn-copy.copied {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
.lab-caret {
    flex: 0 0 auto;
    color: #a5b4fc;
    font-size: 0.8rem;
    transition: transform 0.25s ease;
}
details[open] > .lab-summary .lab-caret { transform: rotate(180deg); }
.lab-body { padding: 6px 18px 18px; }
.lab-prompt {
    background: #0d1117;
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-left: 4px solid #10b981;
    border-radius: 10px;
    padding: 16px 18px;
    margin: 10px 0 0;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.84rem;
    line-height: 1.7;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
}
@media (max-width: 575px) {
    .lab-summary-title { flex-basis: 100%; }
    .lab-btn { padding: 6px 10px; font-size: 0.75rem; }
}
