:root {
    /* Palette - "Dark Mode Premium" */
    --primary: #f1f5f9;
    /* Slate 100 */
    --accent: #60a5fa;
    /* Blue 400 - Lighter for dark mode */
    --accent-glow: rgba(96, 165, 250, 0.15);
    --bg-body: #0f172a;
    /* Slate 900 */
    --surface: #1e293b;
    /* Slate 800 */
    --text-main: #cbd5e1;
    /* Slate 300 */
    --text-head: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --success: #34d399;
    /* Emerald 400 */
    --warning: #fbbf24;
    /* Amber 400 */
    --code-bg: #020617;
    /* Slate 950 */

    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);

    --spacing-section: 4rem;
    /* Material 3 Expressive Easing Tokens */
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Bouncy */
    --ease-standard: cubic-bezier(0.2, 0.0, 0, 1.0);
    /* Standard M3 */
    --ease-out-circ: cubic-bezier(0.075, 0.82, 0.165, 1);
    /* Smooth Out */
}

/* Base Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* Smooth Theme Transitions */
body,
.card,
.step-icon,
.credential-box,
.code-block,
header,
.toc-container,
.copy-btn,
.time-badge,
.badge,
.brand-logo,
.timeline::before {
    transition: background-color 0.7s var(--ease-standard),
        color 0.7s var(--ease-standard),
        border-color 0.7s var(--ease-standard),
        box-shadow 0.7s var(--ease-standard);
}

/* Layout Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.layout-wrapper {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .layout-wrapper {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* TOC Sidebar */
.toc-container {
    position: sticky;
    top: 2rem;
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: none;
    /* Hide by default on small screens via media query above, but we want it valid */
}

@media (min-width: 1025px) {
    .toc-container {
        display: block;
    }
}

#toc h3 {
    margin-top: 0;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

#toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc li {
    margin-bottom: 0.75rem;
}

#toc a {
    color: var(--text-main);
    font-size: 0.95rem;
    display: block;
    padding: 0.25rem 0;
    transition: color 0.2s;
    border: none;
    font-weight: 400;
}

#toc a:hover,
#toc a.active {
    color: var(--accent);
}

/* Header */
header {
    background-color: var(--surface);
    padding: 3rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid #334155;
    /* Slate 700 */
    position: relative;
    overflow: hidden;
}

/* Subtle decorative blob in header */
header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: 0;
    pointer-events: none;
    animation: floatBlob 20s infinite alternate ease-in-out;
}

@keyframes floatBlob {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(-5%, 5%) scale(1.1);
    }
}

.header-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 2rem;
    text-align: left;
}

.brand-link {
    display: block;
    flex-shrink: 0;
    border: none;
    line-height: 0;
}

.brand-link:hover {
    border: none;
}

.brand-logo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin-bottom: 0;
    /* flex-shrink removed from here as it's on parent now, but keeping it doesn't hurt */
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s var(--ease-spring);
}

.brand-logo:hover {
    transform: scale(1.1) rotate(5deg);
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        text-align: center;
    }

    .brand-logo {
        margin-bottom: 1.5rem;
    }

    .subtitle {
        margin: 0 auto;
    }
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-head);
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.05em;
    line-height: 1.1;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-weight: 300;
    margin: 0;
    max-width: 600px;
}

/* Main Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.4s var(--ease-out-circ), box-shadow 0.4s var(--ease-out-circ);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-soft);
}

/* Typography within content */
h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-head);
    margin-top: 0;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-head);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

p {
    margin-bottom: 1.25rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s var(--ease-standard);
}

a:hover {
    border-bottom-color: var(--accent);
}

/* Elements */
.code-block-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.code-block {
    background-color: var(--code-bg);
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin-bottom: 0;
    /* Wrapped now */
    border: 1px solid #334155;
    /* Slate 700 */
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s var(--ease-standard), transform 0.2s var(--ease-spring);
    opacity: 0;
    transform: scale(0.9);
}

.code-block-wrapper:hover .copy-btn {
    opacity: 1;
    transform: scale(1);
}

.copy-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

.copy-btn.copied {
    background-color: var(--success);
    color: white;
    border-color: var(--success);
    transform: scale(1.1);
}

code {
    font-family: 'JetBrains Mono', monospace;
    background-color: rgba(0, 0, 0, 0.3);
    color: #e2e8f0;
    padding: 0.2em 0.4em;
    border-radius: 0.375rem;
    font-size: 0.85em;
    border: 1px solid #334155;
}

.code-block code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
    border: none;
}

/* Alerts/Notes */
.note {
    background-color: rgba(251, 191, 36, 0.1);
    /* Amber 400 with opacity */
    border-left: 4px solid var(--warning);
    padding: 1.25rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    color: var(--text-main);
}

.note-title {
    color: var(--warning);
    font-weight: 700;
    margin-top: 0;
    display: block;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* Stepper Layout */
.timeline {
    position: relative;
    padding-left: 0;
    list-style: none;
    margin-top: 3rem;
}

/* Vertical Line */
.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2rem;
    /* Center of the icon (4rem width / 2) */
    width: 2px;
    background: #334155;
    /* Slate 700 */
    z-index: 0;
}

.step-item {
    position: relative;
    padding-left: 5rem;
    /* Space for icon */
    margin-bottom: 4rem;
}

.step-item:last-child {
    margin-bottom: 0;
}

/* The Icon Circle */
.step-icon {
    position: absolute;
    left: 0;
    top: 0;
    width: 4rem;
    height: 4rem;
    background-color: var(--surface);
    border: 2px solid #334155;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    color: var(--text-muted);
    transition: all 0.5s var(--ease-spring);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

/* Active styling for effect */
.step-item:hover .step-icon,
.step-item.active .step-icon {
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.15);
    box-shadow: 0 0 0 6px var(--accent-glow);
}

.step-icon svg {
    width: 1.75rem;
    height: 1.75rem;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid #334155;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th {
    background-color: #0f172a;
    /* Slate 900 */
    text-align: left;
    padding: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid #334155;
}

td {
    padding: 1rem;
    border-bottom: 1px solid #334155;
    /* Slate 700 */
}

tr:last-child td {
    border-bottom: none;
}

/* Credential Box */
.credential-box {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid #334155;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.cred-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
}

.cred-value {
    font-weight: 500;
    color: var(--text-head);
    font-size: 1.1rem;
}

/* Footer */
footer {
    margin-top: 6rem;
    padding-top: 3rem;
    border-top: 1px solid #334155;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-bottom: 3rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    background-color: #334155;
    /* Slate 700 */
    color: #cbd5e1;
    /* Slate 300 */
    font-weight: 500;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--accent);
    color: var(--text-head);
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    border: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-standard), transform 0.3s var(--ease-spring);
    z-index: 100;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.back-to-top svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Completed Step Styling */
.step-item.completed .step-icon {
    border-color: var(--success);
    color: var(--success);
    background-color: var(--surface);
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2), inset 0 0 0 100px rgba(52, 211, 153, 0.1);
}

.step-item.completed h2::after {
    content: ' ✓';
    color: var(--success);
    font-size: 0.8em;
    margin-left: 0.5rem;
}

/* Printer Friendly Mode */
@media print {
    body {
        background-color: white;
        color: black;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    header {
        background: none;
        border-bottom: 2px solid #000;
        padding: 1rem 0;
        margin-bottom: 1rem;
    }

    header::before {
        display: none;
    }

    h1 {
        font-size: 2rem;
        color: black;
    }

    .subtitle {
        color: #555;
    }

    .card {
        background: none;
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .step-icon {
        border-color: black;
        color: black;
        box-shadow: none !important;
        background: white;
    }

    .timeline::before {
        background: #ddd;
    }

    .code-block {
        background-color: #f5f5f5;
        color: black;
        border: 1px solid #ddd;
    }

    code {
        background-color: #eee;
        color: black;
        border: none;
    }

    .copy-btn,
    .back-to-top,
    .toc-container {
        display: none !important;
    }

    a {
        text-decoration: underline;
        color: black;
    }
}

/* Light Mode Overrides */
body.light-mode {
    --bg-body: #eef2f6;
    /* Soft Blue-Grey */
    --surface: #fafafa;
    --text-head: #0f172a;
    /* Slate 900 */
    --text-main: #334155;
    /* Slate 700 */
    --text-muted: #64748b;
    /* Slate 500 */
    --accent: #2563eb;
    /* Blue 600 */
    --accent-glow: rgba(37, 99, 235, 0.3);
    --border-light: #e2e8f0;
    --code-bg: #f1f5f9;
}

/* Specific Light Mode Component Fixes */
body.light-mode header::before {
    opacity: 0.5;
    /* Tone down the blob */
    filter: hue-rotate(10deg);
}

body.light-mode .card {
    border-color: var(--border-light);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

body.light-mode .code-block {
    background-color: var(--code-bg);
    color: #334155;
    /* Force dark text in light mode */
    border-color: var(--border-light);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Softer shadow */
}

body.light-mode code {
    background-color: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

body.light-mode .code-block code {
    background: transparent;
    color: inherit;
}

body.light-mode .copy-btn {
    background-color: white;
    color: var(--text-muted);
    border-color: var(--border-light);
}

body.light-mode .copy-btn:hover {
    background-color: var(--accent);
    color: white;
}

body.light-mode .toc-container {
    background: white;
    border-color: var(--border-light);
}

body.light-mode .timeline::before {
    background: #cbd5e1;
    /* Slate 300 for timeline line */
}

body.light-mode .step-item.completed .step-icon {
    background-color: white;
}

body.light-mode .brand-logo {
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.2);
    border-color: rgba(0, 0, 0, 0.05);
}

body.light-mode .credential-box {
    background: #f1f5f9;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-color: var(--border-light);
}

/* Progress Bar */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    z-index: 1000;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--ease-standard);
    z-index: 20;
}

body.light-mode .theme-toggle {
    border-color: var(--border-light);
    background: #f1f5f9;
}

.theme-toggle:hover {
    color: var(--accent);
    transform: rotate(15deg);
    background: rgba(255, 255, 255, 0.05);
}

body.light-mode .theme-toggle:hover {
    background: #e2e8f0;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* Badge Row */
.badge-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.time-badge {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: 500;
}

body.light-mode .time-badge {
    background: #f1f5f9;
    color: #475569;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: var(--surface);
    color: var(--text-head);
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transform: translateY(20px);
    animation: toastIn 0.4s var(--ease-spring) forwards;
}

body.light-mode .toast {
    background: white;
    border-color: var(--border-light);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.toast.toast-out {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Particle Effect (Moved to end) */
.particle {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: particlepop 0.8s ease-out forwards;
}

@keyframes particlepop {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translate(var(--dest-x), var(--dest-y)) scale(0) rotate(var(--rot));
        opacity: 0;
    }
}