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

:root {
    --bg: #faf6f0;
    --text: #292524;
    --border: #d6d3d1;
}

[data-theme="dark"] {
    --bg: #1c1917;
    --text: #f5f5f4;
    --border: #57534e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: all 0.3s ease;
    overflow-x: hidden;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    animation: fadeIn 0.6s ease-out;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: opacity 0.2s;
}

nav a:hover {
    opacity: 0.6;
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 1.4rem;
    padding: 0.5rem 0.6rem;
    line-height: 1;
    transition: opacity 0.2s;
}

.theme-btn:hover {
    opacity: 0.6;
}

/* Version Badge */
.version-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--text);
    color: var(--bg);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 2px solid var(--text);
    position: relative;
    overflow: hidden;
}

.version-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.version-badge.loading {
    pointer-events: none;
}

.version-badge.loading .version-text {
    animation: pulse 1.5s ease-in-out infinite;
}

.version-prefix {
    opacity: 0.7;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.version-text {
    font-weight: 700;
}

.version-badge.loaded {
    animation: fadeIn 0.5s ease-out;
}

/* Hero */
.hero {
    margin-bottom: 4rem;
}

.hero-content {
    animation: slideIn 0.8s ease-out;
}

.subtitle {
    font-size: 1.25rem;
    color: #78716c;
    margin-bottom: 2rem;
    max-width: 600px;
    line-height: 1.6;
}

.cta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    border: 2px solid var(--text);
    color: var(--text);
    background: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn:hover {
    background: var(--text);
    color: var(--bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
}

.btn-primary:hover {
    background: none;
    color: var(--text);
}

/* Book layout: side-by-side on wide screens, stacked on smaller */
.book-layout {
    display: flex;
    gap: 6rem;
    align-items: flex-start;
}

.book-main {
    flex: 1;
    min-width: 0;
}

.book-examples {
    width: 400px;
    flex-shrink: 0;
    position: relative;
}

.book-examples h2 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.5;
    margin-bottom: 0.75rem;
    margin-top: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.book-examples h2:first-child {
    margin-top: 0;
}

.book-examples pre {
    background: var(--bg);
    border: 2px solid var(--border);
    padding: 1.5rem;
    overflow-x: auto;
    margin-bottom: 2rem;
    font-size: 0.85rem;
    line-height: 1.7;
}

.example-with-mascot {
    position: relative;
}

.window-mascot {
    position: absolute;

    width: 90px;
    height: auto;

    top: -40px;
    right: 20px;

    z-index: 10;

    pointer-events: none;
}

.book-examples h2 .mascot {
    width: 28px;
    height: auto;
    display: block;
    opacity: 1;
}

/* Prism token colors */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: var(--comment);
    font-style: italic;
}

.token.keyword,
.token.control,
.token.directive,
.token.unit,
.token.boolean {
    color: var(--keyword);
}

.token.string,
.token.char {
    color: var(--string);
}

.token.number {
    color: var(--number);
}

.token.function {
    color: var(--function);
}

.token.class-name,
.token.type {
    color: var(--type);
}

.token.builtin,
.token.attr-name {
    color: var(--module);
}

.token.operator {
    color: var(--text);
}

.token.punctuation {
    color: var(--text-secondary, #555);
}

.token.variable {
    color: var(--text);
}

.example-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    border: 2px solid var(--text);
    cursor: pointer;
    outline: none;
    max-width: 180px;
}

.example-select:hover {
    opacity: 0.8;
}

.toolbar-spacer {
    flex: 1;
}

.playground-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg);
    border-bottom: 2px solid var(--text);
}

#outputTerminal {
    padding: 1.5rem;
    background: var(--bg);
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
}

pre {
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
}

code {
    color: var(--text);
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2.5rem;
    margin-bottom: 2rem;
    animation: fadeIn 1s ease-out 0.6s both;
}

.feature {
    transition: transform 0.3s ease;
}

.feature h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature p {
    opacity: 0.6;
}

/* Footer */
footer {
    border-top: 2px solid var(--text);
    padding-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    animation: fadeIn 1s ease-out 0.8s both;
}

.social {
    display: flex;
    gap: 1.5rem;
}

.social a {
    color: var(--text);
    text-decoration: none;
    font-size: 1.25rem;
    transition: all 0.3s ease;
}

.social a:hover {
    opacity: 0.6;
    transform: translateY(-2px);
}

@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation: 0.3s ease-out both vt-out;
}

::view-transition-new(root) {
    animation: 0.3s ease-out both vt-in;
}

@keyframes vt-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

@keyframes vt-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .container {
        padding: 2rem 1.5rem;
    }

    header {
        margin-bottom: 2rem;
        flex-wrap: wrap;
        gap: 1rem;
    }

    nav {
        width: 100%;
        justify-content: space-between;
    }

    .book-layout {
        flex-wrap: wrap;
    }

    .book-examples {
        width: 100%;
    }

    h1 {
        font-size: 3rem;
    }

    .subtitle {
        font-size: 1.25rem;
    }

    .cta {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    .version-badge {
        width: 100%;
        justify-content: center;
    }

    .playground-editor {
        min-height: 200px;
    }

    .playground-editor pre,
    .playground-editor textarea {
        padding: 1rem;
    }

    .example-select {
        max-width: 100%;
        width: 100%;
    }

    .playground-toolbar {
        flex-wrap: wrap;
        padding: 0.5rem 1rem;
    }

    #outputTerminal {
        padding: 1rem;
        max-height: 200px;
    }

    pre {
        font-size: 0.85rem;
    }

    .features {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    footer {
        flex-direction: column;
        text-align: center;
    }
}