:root {
    --bg-main: #ffffff;
    --bg-content: #f8f9fc;
    --bg-inner: #f1f5f9;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-dim: #9ca3af;
    --border-color: #e5e7eb;
    --border-bright: #f3f4f6;
    --primary-accent: #2563eb;
    --secondary-accent: #4f46e5;
    --success: #10b981;
    --info: #0ea5e9;
    --warning: #f59e0b;
    --danger: #ef4444;
    --primary-blue: var(--primary-accent);
    --secondary-blue: var(--secondary-accent);
    --fu: 'Inter', system-ui, -apple-system, sans-serif;
    --fd: 'Outfit', sans-serif;
    --fm: 'JetBrains Mono', monospace;
    --sidebar-width: 280px;
    --topbar-height: 64px;
    --hover-bg: #f3f4f6;
    --active-bg: #eff6ff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--fu);
    color: var(--text-primary);
    background-color: var(--bg-content);
    overflow: hidden;
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-main);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    font-family: var(--fd);
}

.logo i {
    font-size: 24px;
    color: var(--primary-accent);
    -webkit-text-fill-color: initial;
    background: none;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 18px;
    line-height: 1;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.nav-group {
    margin-bottom: 12px;
}

.nav-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    font-family: var(--fm);
    cursor: default;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--active-bg);
    color: var(--primary-accent);
    border-left: 3px solid var(--primary-accent);
    padding-left: 17px;
}

.nav-item.has-children i {
    font-size: 12px;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-content);
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    flex-shrink: 0;
}

.topbar-left .topbar-link {
    text-decoration: none;
    color: var(--primary-accent);
    font-weight: 700;
    font-size: 14px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.lang-selector, .api-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s;
}

.lang-selector:hover, .api-link:hover {
    color: var(--text-primary);
}

.api-link {
    color: var(--info);
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: all 0.15s;
}

.theme-toggle:hover {
    border-color: var(--primary-accent);
    color: var(--primary-accent);
}

/* Scrollable Content */
.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.content-wrapper::-webkit-scrollbar {
    width: 6px;
}
.content-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-family: var(--fm);
}

.breadcrumbs .ph-house {
    color: var(--text-primary);
    font-size: 16px;
}

.breadcrumbs .current {
    color: var(--primary-accent);
    background: var(--active-bg);
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 700;
    border: 1px solid rgba(37, 99, 235, 0.1);
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-family: var(--fd);
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -1px;
}

.page-header p {
    font-size: 16px;
    color: var(--text-secondary);
}

/* Showcase Component */
.showcase-container {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.showcase-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.showcase-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 12px;
    color: var(--primary-accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: var(--fm);
}

.showcase-brand i {
    font-size: 20px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--active-bg);
    color: var(--primary-accent);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(37, 99, 235, 0.1);
}

.screenshot-wrapper {
    padding: 12px;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    background-size: 24px 24px;
}

.screenshot-wrapper img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 15px 45px rgba(0,0,0,0.6);
    border: 1px solid var(--border-bright);
}

.section-text {
    padding: 24px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
}

.section-text h3 {
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--secondary-accent);
}

.section-text strong {
    color: var(--info);
}

.section-text ul li {
    margin-bottom: 12px;
    list-style: none;
    position: relative;
    padding-left: 20px;
}

.section-text ul li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary-accent);
}

.page-content {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.page-content.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Architecture Grid */
.arch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.arch-card {
    background: var(--bg-content);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
}

.arch-card:hover {
    border-color: var(--primary-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.arch-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--active-bg);
    color: var(--primary-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.arch-card strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary) !important;
    margin-bottom: 6px;
}

.arch-card p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

/* Step Cards */
.step-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: var(--bg-content);
    padding: 18px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.step-card:hover {
    border-color: var(--primary-accent);
    box-shadow: var(--shadow-sm);
}

.step-number {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
    background: var(--active-bg);
    color: var(--primary-accent);
    font-family: var(--fd);
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-body strong {
    display: block;
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--text-primary) !important;
}

.step-body p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.step-body img,
.section-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-top: 12px;
    display: block;
}

/* Docs Table */
.docs-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}

.docs-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-content);
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-family: var(--fm);
}

.docs-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: top;
    line-height: 1.5;
}

.docs-table tr:last-child td {
    border-bottom: none;
}

.docs-table tr:hover td {
    background: var(--bg-content);
}

.docs-table code {
    background: var(--active-bg);
    color: var(--primary-accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--fm);
    font-size: 12px;
    font-weight: 500;
}

/* Code Block */
.code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px 20px;
    border-radius: 10px;
    font-family: var(--fm);
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    margin: 8px 0 16px;
    border: 1px solid #313244;
}

/* Loading Placeholder */
.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-dim);
    gap: 12px;
}

.loading-placeholder i {
    font-size: 28px;
    animation: spin 1s linear infinite;
}

.loading-placeholder p {
    font-size: 14px;
    color: var(--text-secondary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Inline code in section text */
.section-text code {
    background: var(--active-bg);
    color: var(--primary-accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--fm);
    font-size: 13px;
    font-weight: 500;
}

/* Legacy step-item compat */
.step-item {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    transition: transform 0.2s, border-color 0.2s;
}

.step-item:hover {
    transform: translateX(4px);
    border-color: var(--secondary-accent);
}

.step-item strong {
    display: block;
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.step-item p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Hamburger & Sidebar Controls (hidden on desktop) */
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s;
}

.hamburger:hover {
    background: var(--hover-bg);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.15s;
}

.sidebar-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Tablet (≤1024px) ────────────────────────────── */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }

    .content-wrapper {
        padding: 28px;
    }

    .page-header h1 {
        font-size: 30px;
    }

    .arch-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ── Mobile (≤768px) ─────────────────────────────── */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .app-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* Sidebar becomes slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .hamburger {
        display: flex;
    }

    .sidebar-close {
        display: flex;
    }

    .sidebar-header {
        justify-content: space-between;
    }

    /* Main content fills viewport */
    .main-content {
        width: 100%;
    }

    .topbar {
        padding: 0 16px;
    }

    .content-wrapper {
        padding: 20px 16px;
        max-width: 100%;
    }

    .page-header h1 {
        font-size: 26px;
        letter-spacing: -0.5px;
    }

    .page-header p {
        font-size: 14px;
    }

    .section-text {
        padding: 18px;
    }

    .section-text h3 {
        font-size: 18px;
    }

    .showcase-container {
        border-radius: 12px;
    }

    .breadcrumbs {
        flex-wrap: wrap;
        gap: 6px;
        font-size: 11px;
    }

    /* Grid to single column on mobile */
    .arch-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .arch-card:hover {
        transform: none;
    }

    /* Table horizontal scroll */
    .docs-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .docs-table thead,
    .docs-table tbody,
    .docs-table tr,
    .docs-table th,
    .docs-table td {
        display: revert;
    }

    .docs-table th,
    .docs-table td {
        white-space: nowrap;
        padding: 8px 10px;
        font-size: 12px;
    }

    /* Code block scroll */
    .code-block {
        font-size: 12px;
        padding: 12px 14px;
    }

    /* Step cards stack nicely */
    .step-card {
        padding: 14px;
        gap: 12px;
    }

    .step-number {
        width: 28px;
        height: 28px;
        min-width: 28px;
        font-size: 12px;
    }

    .step-body strong {
        font-size: 14px;
    }

    .step-body p {
        font-size: 13px;
    }

    /* Hide lang selector text on mobile */
    .lang-selector span {
        display: none;
    }

    .topbar-right {
        gap: 14px;
    }

    .api-link {
        font-size: 12px;
    }

    /* Close sidebar on nav click (handled by JS) */
}

/* ── Small mobile (≤480px) ───────────────────────── */
@media (max-width: 480px) {
    .content-wrapper {
        padding: 16px 12px;
    }

    .page-header h1 {
        font-size: 22px;
    }

    .page-header {
        margin-bottom: 20px;
    }

    .section-text {
        padding: 14px;
    }

    .section-text h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .arch-card {
        padding: 14px;
    }

    .arch-icon {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    .breadcrumbs .current {
        padding: 3px 8px;
        font-size: 10px;
    }

    .step-card {
        flex-direction: column;
        gap: 8px;
    }

    .topbar {
        height: 52px;
    }

    .sidebar-header {
        height: 52px;
    }
}
