:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --text: #37352f;
    --muted: #787774;
    --border: rgba(55, 53, 47, 0.12);
    --link: #0f7b6c;
    --link-hover-bg: rgba(15, 123, 108, 0.08);
    --shadow:
        0 1px 2px rgba(15, 15, 15, 0.04), 0 8px 24px rgba(15, 15, 15, 0.06);
    --radius: 14px;
    --max-width: 860px;
    --nav-row-hover: #f1f1ef;
    --nav-row-active: #e9efe9;
    --nav-rail: rgba(55, 53, 47, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    background: var(--bg);
}

body {
    margin: 0 auto;
    max-width: var(--max-width);
    padding: clamp(16px, 4vw, 48px) clamp(14px, 4vw, 28px)
        clamp(24px, 6vw, 64px);
    background: var(--bg);
    color: var(--text);
    font-family:
        ui-sans-serif,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Inter,
        Helvetica,
        Arial,
        sans-serif;
    line-height: 1.65;
    font-size: clamp(15px, 0.35vw + 14px, 16px);
}

/* Keep direct children aligned in a single column flow */
body > h1,
body > p:not(.VERSION),
body > hr {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

/* Title */
body > h1 {
    margin-top: 0;
    margin-bottom: clamp(12px, 2vw, 20px);
    font-size: clamp(1.8rem, 4.5vw, 2.5rem);
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

/* Tree listing container */
body > p:not(.VERSION) {
    margin-top: 0;
    margin-bottom: 0;
    width: 100%;
    max-width: none;
    padding: clamp(14px, 2.8vw, 24px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;

    font-family:
        ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas,
        "Liberation Mono", monospace;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--muted);
}

body > p:not(.VERSION).tree-enhanced {
    padding: clamp(10px, 2.5vw, 18px);
    font-family: inherit;
    font-size: 0.94rem;
    line-height: 1.45;
    color: var(--text);
}

.tree-enhanced .notion-nav {
    width: 100%;
}

.tree-enhanced .notion-tree,
.tree-enhanced .notion-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-enhanced .notion-item {
    margin: 2px 0;
}

.tree-enhanced .notion-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 30px;
}

.tree-enhanced .notion-toggle,
.tree-enhanced .notion-toggle-spacer {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    flex: 0 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tree-enhanced .notion-toggle {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.76rem;
    line-height: 1;
    padding: 0;
}

.tree-enhanced .notion-toggle:hover {
    background: var(--nav-row-hover);
    color: var(--text);
}

.tree-enhanced .notion-toggle-spacer {
    visibility: hidden;
}

.tree-enhanced .notion-link,
.tree-enhanced .notion-link:link,
.tree-enhanced .notion-link:visited,
.tree-enhanced .notion-link:active {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    padding: 5px 8px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
}

.tree-enhanced .notion-link:hover {
    background: var(--nav-row-hover);
    color: var(--text);
}

.tree-enhanced .notion-link:focus-visible {
    outline: 2px solid rgba(15, 123, 108, 0.35);
    outline-offset: 1px;
}

.tree-enhanced .notion-children {
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid var(--nav-rail);
}

.tree-enhanced .notion-item:not(.is-open) > .notion-children {
    display: none;
}

.tree-enhanced .notion-item.is-folder > .notion-row > .notion-link {
    font-weight: 600;
}

/* Links */
a,
a:link,
a:visited,
a:active {
    color: var(--link);
    text-decoration: none;
    border-radius: 6px;
    padding: 0;
    margin: 0;
    transition:
        background-color 140ms ease,
        color 140ms ease;
}

a:hover {
    color: var(--link);
    background: var(--link-hover-bg);
    text-decoration: none;
}

/* Make the parent-directory dot look subtle */
a[href="../"] {
    font-weight: 600;
    color: var(--muted);
}

/* Hide the footer credits visually */
.VERSION,
body > hr {
    display: none !important;
}

/* File type colour cleanup - override tree defaults */
.NORM,
.FIFO,
.CHAR,
.DIR,
.BLOCK,
.LINK,
.SOCK,
.EXEC {
    color: inherit !important;
}

/* Dark mode-ish support if system is dark */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #191919;
        --surface: #202020;
        --text: #e9e9e7;
        --muted: #a8a8a3;
        --border: rgba(255, 255, 255, 0.08);
        --link: #4dad9f;
        --link-hover-bg: rgba(77, 173, 159, 0.14);
        --shadow: none;
        --nav-row-hover: #2a2a29;
        --nav-row-active: #24342f;
        --nav-rail: rgba(255, 255, 255, 0.12);
    }
}
