:root {
    --sand: #f5f0e8;
    --sand-dark: #eae5db;
    --sand-mid: #ede8de;
    --ocean: #4a8fa8;
    --ocean-light: #5b9bb5;
    --grass: #7a9e7e;
    --text: #2c3e50;
    --text-light: #5a6b7a;
    --sky-top: #c0d8eb;
    --sky-bottom: #dbe9f2;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--sand);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 80%, #e4ddd2 100%);
    z-index: -2;
}

.dunes { position: relative; height: 150px; overflow: hidden; }
.dunes svg { position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; }

header { position: relative; padding: 1rem 2rem; z-index: 1; }
nav { max-width: 800px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.4rem; font-weight: 700; color: var(--ocean); text-decoration: none; letter-spacing: -0.02em; }
.nav-links a { color: var(--text-light); text-decoration: none; font-size: 0.95rem; }
.nav-links a:hover { color: var(--ocean); }

main { position: relative; max-width: 800px; margin: 0 auto; padding: 0 2rem 2rem; z-index: 1; }
.hero { text-align: center; padding: 3rem 0 2rem; }
.hero h1 { font-size: 2.8rem; font-weight: 700; color: var(--text); margin-bottom: 0.5rem; }
.subtitle { font-size: 1.3rem; color: var(--text-light); margin-bottom: 0.5rem; }
.tagline { font-size: 1.05rem; color: var(--text-light); max-width: 500px; margin: 0 auto; }

.playground-section {
    margin: 2rem -4rem 3rem;
    padding: 0 2rem;
}

.features { display: grid; gap: 2rem; padding: 1rem 0 3rem; }
.feature h2 { font-size: 1.2rem; color: var(--ocean); margin-bottom: 0.5rem; }
.feature p { color: var(--text-light); font-size: 0.95rem; }
.feature code { background: var(--sand-dark); padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.85em; }

.deeper {
    border-top: 1px solid #c8c3b8;
    margin-top: 1rem;
    padding-top: 2.5rem;
    padding-bottom: 2rem;
}
.deeper h2 {
    font-size: 0.85rem;
    font-variant: small-caps;
    letter-spacing: 0.08em;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}
.deeper h3 {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
    margin-bottom: 1rem;
}
.deeper h3 code {
    background: var(--sand-dark);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.85em;
}
.deeper p {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

footer { position: relative; text-align: center; padding: 1.5rem 2rem; color: var(--text-light); font-size: 0.9rem; background: var(--sand); z-index: 1; }
footer a { color: var(--ocean); text-decoration: none; }
footer a:hover { text-decoration: underline; }
a { color: var(--ocean); }

/* Nav links spacing */
.nav-links { display: flex; gap: 1.5rem; }

/* ── Doc pages ────────────────────────────────────────── */

.doc-page::before {
    background: linear-gradient(180deg, var(--sky-bottom) 0%, var(--sand) 30%);
}

/* Two-column layout with sidebar */
.doc-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    max-width: 1060px;
    margin: 0 auto;
    min-height: calc(100vh - 120px);
    position: relative;
    z-index: 1;
}

.doc-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1.5rem 0 2rem 1.5rem;
    border-right: 1px solid var(--sand-dark);
    font-size: 0.85rem;
}

.doc-sidebar-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--sand-dark);
}
.doc-sidebar-header a {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}
.doc-sidebar-header a:hover { color: var(--ocean); }

.doc-sb-link {
    display: block;
    padding: 0.15rem 0.5rem;
    color: var(--text-light);
    text-decoration: none;
    border-radius: 3px;
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    font-size: 0.8rem;
}
.doc-sb-link:hover { color: var(--ocean); background: var(--sand-dark); }
.doc-sb-active { color: var(--ocean); font-weight: 600; background: var(--sand-dark); }

.doc-sb-group {
    display: block;
    padding: 0.25rem 0.5rem;
    margin-top: 0.3rem;
    color: var(--text-light);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.8rem;
    list-style: none;
}
.doc-sb-group::-webkit-details-marker { display: none; }
.doc-sb-group::before {
    content: '▸';
    display: inline-block;
    width: 1em;
    font-size: 0.7em;
    transition: transform 0.15s;
}
details[open] > .doc-sb-group::before { transform: rotate(90deg); }
.doc-sb-group-items { padding-left: 0.5rem; }

.doc-main { padding: 0 2rem 4rem; }
.doc-main-wide { max-width: 800px; margin: 0 auto; position: relative; z-index: 1; }

@media (max-width: 768px) {
    .doc-layout { grid-template-columns: 1fr; }
    .doc-sidebar { display: none; }
}

.doc-main h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.doc-intro {
    color: var(--text-light);
    font-size: 1.05rem;
    margin-bottom: 2rem;
}

.doc-breadcrumb {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}
.doc-breadcrumb a { color: var(--ocean); text-decoration: none; }
.doc-breadcrumb a:hover { text-decoration: underline; }

.doc-module-doc {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    line-height: 1.7;
}
.doc-module-doc p { margin-bottom: 0.75rem; }
.doc-module-doc code {
    background: var(--sand-dark);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
}

/* Module index */
.doc-module-list { margin-top: 1rem; }

.doc-group {
    margin-bottom: 2rem;
}
.doc-subgroup {
    margin-bottom: 1.5rem;
}
.doc-group-heading {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ocean);
    margin-bottom: 0.4rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--sand-dark);
}

.doc-module-entry {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--sand-dark);
}
.doc-module-entry a {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    font-size: 0.9rem;
    color: var(--ocean);
    text-decoration: none;
    font-weight: 500;
}
.doc-module-entry a:hover { text-decoration: underline; }
.doc-summary {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Item sections */
.doc-section {
    margin-top: 2rem;
}
.doc-section h2 {
    font-size: 0.8rem;
    font-variant: small-caps;
    letter-spacing: 0.08em;
    color: var(--text-light);
    border-bottom: 1px solid var(--sand-dark);
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
}

.doc-item {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--sand-dark);
}
.doc-item:last-child { border-bottom: none; }

.doc-item-name {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.doc-sig {
    display: block;
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    font-size: 0.8rem;
    color: #a0b0b8;
    background: #1a2233;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin: 0.4rem 0 0.6rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

.doc-item-doc {
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.6;
}
.doc-item-doc p { margin-bottom: 0.5rem; }
.doc-item-doc code {
    background: var(--sand-dark);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.85em;
}
.doc-item-doc pre {
    background: #1a2233;
    color: #a0b0b8;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}
.doc-item-doc pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

/* Constructors & operations */
.doc-constructors, .doc-operations {
    margin: 0.4rem 0 0.5rem 1rem;
}
.doc-ctor, .doc-op {
    padding: 0.2rem 0;
}
.doc-ctor code, .doc-op code {
    font-size: 0.85rem;
}
.doc-ctor-fields {
    color: var(--text-light);
}
.doc-op-name {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

/* Syntax highlighting (matches playground theme) */
.hl-kw { color: #b8a0d8; }
.hl-ty { color: #f0c865; }
.hl-fn { color: #5bbed6; }
.hl-str { color: #98c87a; }
.hl-num { color: #e8a050; }
.hl-cm { color: #6a7a88; font-style: italic; }
.hl-op { color: #a0b8c8; }
.hl-tvar { color: #7ecfc0; }
.hl-ctor { color: #e8a050; }
.hl-macro { color: #c4a0e8; }
.hl-annot { color: #8bc078; }
.hl-punc { color: #8090a0; }
.hl-ns { color: #6ec5a0; }
.hl-bool { color: #e8a050; }

/* Cross-reference links in type signatures */
.doc-sig-link {
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    opacity: 0.9;
}
.doc-sig-link:hover {
    opacity: 1;
    border-bottom-style: solid;
}

/* Search */
.doc-search {
    position: relative;
    margin-bottom: 2rem;
}
#doc-search-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    border: 1px solid var(--sand-dark);
    border-radius: 6px;
    background: white;
    color: var(--text);
    outline: none;
    font-family: inherit;
}
#doc-search-input:focus {
    border-color: var(--ocean);
    box-shadow: 0 0 0 2px rgba(74, 143, 168, 0.15);
}
#doc-search-input::placeholder {
    color: #b0b8c0;
}
.doc-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--sand-dark);
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
}
.doc-sr-item {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--sand-dark);
    font-size: 0.9rem;
}
.doc-sr-item:last-child { border-bottom: none; }
.doc-sr-item:hover { background: var(--sand-dark); }
.doc-sr-kind {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--ocean);
    background: var(--sand-dark);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    margin-right: 0.3rem;
}
.doc-sr-mod {
    color: var(--text-light);
    font-size: 0.8rem;
}
.doc-sr-empty {
    padding: 0.75rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Prevent flash of unstyled content before web component registers */
peat-playground:not(:defined) {
    min-height: 340px;
    visibility: hidden;
}

/* Playground: stack panels vertically on the landing page */
.playground-section .peat-pg-panels {
    flex-direction: column;
    position: relative;
}
.playground-section .peat-pg-editor {
    border-right: none;
}
/* Hide output pane until Run is clicked */
.playground-section .peat-pg-output-pane {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    max-height: 60%;
    border-bottom: 2px solid #4a8fa8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.playground-section peat-playground.peat-pg-has-output .peat-pg-output-pane {
    display: flex;
}
