/* ===== reset ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===== design tokens ===== */
:root {
    color-scheme: light dark;

    --bg:        light-dark(#f6f6f4, #0e0e0f);
    --surface:   light-dark(#ffffff, #161618);
    --surface-2: light-dark(#ececea, #1f1f23);
    --border:    light-dark(#e2e2de, #2a2a2f);
    --text:      light-dark(#1b1b1d, #e9e9eb);
    --muted:     light-dark(#71717a, #8b8b94);
    --accent:    light-dark(#d63509, #ff4c1a);
    --link:      light-dark(#ab3413, #fc9312);

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --radius: 10px;
    --radius-s: 6px;
    --nav-h: 48px;
    --topbar-h: 42px;
    --pane-top: 28px;
    --transition: 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
    :root { --transition: 0s; }
}

/* ===== icons (iconoir) ===== */
.icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    vertical-align: -0.125em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ===== base ===== */
body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--link);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent);
}

button,
input {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
}

button,
[data-item] {
    cursor: pointer;
    touch-action: manipulation;
}

/* ===== app shell ===== */
.nav-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.crumb,
.bucket-head,
.scope-tabs {
    scrollbar-width: none;
}

.crumb::-webkit-scrollbar,
.bucket-head::-webkit-scrollbar,
.scope-tabs::-webkit-scrollbar {
    display: none;
}

.nav-action {
    align-self: center;
    flex-shrink: 0;
    margin-right: 16px;
    padding: 4px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    transition: border-color var(--transition), color var(--transition);
}

.nav-home,
.nav-home-user,
.nav-home a {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-home {
    flex-shrink: 0;
    padding-left: 16px;
    font-size: 13.5px;
    font-weight: 500;
}

.nav-home a {
    gap: 7px;
    color: var(--text);
}

.nav-home a:hover {
    color: var(--accent);
}

.nav-home-sep {
    color: var(--muted);
}

.nav-home-user[hidden] {
    display: none;
}

.nav-home-user a {
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.nav-home-user .avatar {
    width: 18px;
    height: 18px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 16px;
    margin-right: auto;
}

.nav-link,
.scope-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

.nav-home .icon,
.nav-link .icon,
.scope-tab .icon {
    width: 16px;
    height: 16px;
}

.nav-link:hover,
.scope-tab:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-link.active,
.scope-tab.active {
    color: var(--text);
}

.nav-link {
    position: relative;
    padding: 7px 10px;
    border-radius: var(--radius-s);
    font-size: 13.5px;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: -6px;
    height: 2px;
    background: var(--accent);
}

.topbar {
    position: sticky;
    top: var(--nav-h);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 28px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.crumb {
    min-width: 0;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow-x: auto;
}

.crumb-sep {
    margin: 0 7px;
}

.crumb-leaf {
    color: var(--text);
    font-weight: 500;
}

.crumb a {
    color: var(--muted);
}

.crumb a:hover {
    color: var(--accent);
}

.bucket-head {
    max-width: 980px;
    margin: calc(-1 * var(--pane-top)) auto 12px;
    display: flex;
    gap: 24px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.bucket-head[hidden] {
    display: none;
}

.bucket-head-key {
    color: var(--muted);
    user-select: none;
}

.bucket-head-key:hover,
.bucket-head-key.active {
    color: var(--text);
}

.bucket-head-feed {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}

.bucket-head-feed:hover {
    color: var(--accent);
}

.nav-search {
    position: relative;
    align-self: center;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-right: 12px;
    height: 30px;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-s);
    color: var(--muted);
    transition: border-color var(--transition), background var(--transition);
}

.nav-search-btn,
.nav-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: inherit;
}

.nav-search-btn {
    width: 30px;
    border-radius: var(--radius-s);
}

.nav-search-btn:hover,
.nav-search-clear:hover {
    color: var(--text);
}

.nav-search .icon {
    width: 15px;
    height: 15px;
}

.nav-search input {
    width: 0;
    padding: 0;
    outline: none;
    color: var(--text);
    transition: width var(--transition);
}

.nav-search input::placeholder {
    color: var(--muted);
}

.nav-search.open {
    background: var(--bg);
    border-color: var(--border);
}

.nav-search.open:focus-within {
    border-color: var(--accent);
}

.nav-search.open input {
    width: 190px;
}

.nav-search input::-webkit-search-cancel-button {
    display: none;
}

.nav-search-clear {
    width: 26px;
    font-size: 17px;
    line-height: 1;
    opacity: 0.55;
    transition: opacity var(--transition), color var(--transition);
}

.nav-search.open:focus-within .nav-search-clear,
.nav-search-clear:hover {
    opacity: 1;
}

.nav-search:not(.open) .nav-search-clear {
    display: none;
}

.nav-search input:placeholder-shown ~ .nav-search-clear {
    visibility: hidden;
}

.nav-search-recent {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}

.nav-search-recent button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    text-align: left;
    color: var(--muted);
    border-radius: var(--radius-s);
    font-size: 13px;
}

.nav-search-recent button span {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-search-recent button:hover {
    background: var(--surface-2);
}

.pane {
    max-width: 1180px;
    margin: 0 auto;
    padding: var(--pane-top) 32px 72px;
}

.pane[data-mode="object"] {
    padding-bottom: 0;
}

.section {
    display: none;
}

.section.active {
    display: block;
    margin-inline: auto;
}

[data-view="files"],
[data-view="search"] { max-width: 980px; }
[data-view="thoughts"],
[data-view="audio"],
[data-view="documents"],
[data-view="about"] { max-width: 680px; }
[data-view="images"] { max-width: 900px; }
[data-view="projects"] { max-width: 760px; }

/* ===== search results ===== */
.search-tabs {
    position: sticky;
    top: calc(var(--nav-h) + var(--topbar-h));
    z-index: 5;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    margin: calc(-1 * var(--pane-top)) -12px 24px;
    padding-top: 8px;
}

.search-body,
.search-group {
    margin-inline: auto;
}

.search-count {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--muted);
    margin-left: 4px;
}

.search-group {
    margin-bottom: 36px;
}

.search-group:first-child .label {
    margin-top: 0;
}

.search-group .label a {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    color: inherit;
}

.search-group .label a:hover {
    color: var(--accent);
}

mark.hit {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ===== shared bits ===== */
.label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 32px 0 12px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.card[data-item] {
    margin-bottom: 12px;
}

.card[data-item]:hover {
    border-color: var(--muted);
}

.avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.author,
.byline {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
}

.author:hover,
.byline:hover {
    color: inherit;
}

.author:hover .author-name,
.byline:hover .byline-name {
    text-decoration: underline;
}

.author-name,
.byline-name {
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.3;
}

.author-handle,
.byline-meta {
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.3;
}

.byline {
    display: inline-flex;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}

.byline-name {
    font-size: 13px;
    white-space: nowrap;
}

.byline-meta {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 500;
    padding: 4px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: var(--surface);
    color: var(--link);
    transition: border-color var(--transition), color var(--transition);
}

.pill .icon {
    width: 12px;
    height: 12px;
}

.nav-action:hover,
.pill:hover,
.object-nav:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.empty {
    max-width: 640px;
    margin-inline: auto;
    padding: 40px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.author .avatar {
    width: 32px;
    height: 32px;
}

.author-lg {
    gap: 18px;
}

.author-lg .avatar {
    width: 88px;
    height: 88px;
}

.author-lg .author-name {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.author-lg .author-handle {
    font-size: 13.5px;
}

/* ===== files ===== */
.file-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.file-table .num { width: 100px; text-align: right; }

.file-table td .icon {
    width: 15px;
    height: 15px;
    margin-right: 12px;
    color: var(--muted);
    vertical-align: -3px;
}

.path-owner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    vertical-align: middle;
}

.path-owner .avatar {
    width: 16px;
    height: 16px;
}

.path-owner:hover,
.path-dir:hover {
    color: var(--text);
    text-decoration: underline;
}

.path-dir {
    color: var(--muted);
}

.file-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-table td.num {
    color: var(--muted);
}

.file-table tbody tr:hover {
    background: var(--surface);
}

/* ===== images ===== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.gallery-thumb {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-s);
    background: var(--surface-2) center / cover;
    transition: filter var(--transition);
}

.gallery-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.object-content.is-image img {
    background: center / contain no-repeat;
}

.gallery-thumb:hover {
    filter: brightness(1.1);
}

/* ===== file view ===== */
[data-mode="object"] .section.active {
    display: none;
}

.object-view[hidden] {
    display: none;
}

.object-view {
    --object-foot-h: 56px;
    --object-head-h: 72px;
    --object-h: calc(100dvh - var(--nav-h) - var(--topbar-h) - var(--object-foot-h) - var(--object-head-h));
    display: grid;
    grid-template: 'back back' auto 'content meta' 1fr / 1fr 280px;
    column-gap: 32px;
}

.object-meta-toggle {
    grid-area: back;
    justify-self: end;
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
}

.object-meta-toggle:hover {
    color: var(--text);
    border-color: var(--muted);
}

.object-meta-toggle::before { content: '›'; }
.meta-collapsed .object-meta-toggle::before { content: '‹'; }

.meta-collapsed.object-view {
    grid-template-columns: 1fr 0;
    column-gap: 0;
}

.meta-collapsed .object-meta {
    display: none;
}

.object-back {
    grid-area: back;
    justify-self: start;
    margin-bottom: 18px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
}

.object-back:hover {
    color: var(--text);
}

.object-content {
    grid-area: content;
    min-width: 0;
}

.object-content.is-image,
.object-content.is-audio {
    height: var(--object-h);
}

.object-content.is-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.object-content.is-audio {
    display: grid;
    place-items: center;
    padding: 48px 32px;
}

.object-content.is-audio audio {
    width: 100%;
}

.object-content .prose {
    max-width: 720px;
    padding-bottom: 48px;
}

.thought-view {
    max-width: 600px;
    margin: 24px auto 0;
    padding: 18px 22px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.thought-view-body {
    margin: 12px 0 14px;
    font-size: 21px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.thought-view-body p {
    margin: 0;
}

.thought-view-date {
    font-size: 13px;
    color: var(--muted);
}

.pdf-pages {
    max-width: 760px;
}

.pdf-loading {
    padding: 40px;
    text-align: center;
    color: var(--muted);
}

.pdf-page {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
}

.object-meta {
    grid-area: meta;
    position: sticky;
    top: calc(var(--nav-h) + var(--topbar-h) + 24px);
    align-self: start;
    max-height: var(--object-h);
    padding-left: 20px;
    border-left: 1px solid var(--border);
    overflow: auto;
}

.object-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
    margin-bottom: 10px;
}

.object-kv {
    margin: 18px 0;
    font-size: 13px;
}

.object-cid {
    display: block;
    max-width: 32ch;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.object-foot {
    position: fixed;
    inset: auto 0 0 0;
    height: var(--object-foot-h);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--bg);
    z-index: 10;
}

.object-count {
    min-width: 7ch;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}

.object-nav {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-s);
    display: grid;
    place-items: center;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: color var(--transition), border-color var(--transition);
}

/* ===== thoughts ===== */
.thought-body {
    margin-top: 10px;
    font-size: 15px;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* ===== sounds ===== */
.track-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}

.track audio {
    width: 100%;
    height: 36px;
}

/* ===== docs ===== */
.doc-item h3 {
    font-size: 16px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.doc-excerpt {
    margin: 6px 0 12px;
    font-size: 13.5px;
    color: var(--muted);
}

/* ===== prose ===== */
.prose {
    font-size: 15.5px;
    line-height: 1.75;
}

.prose p,
.prose ul,
.prose ol {
    margin-bottom: 1.4em;
}

.prose ul,
.prose ol {
    padding-left: 1.4em;
}

.prose li {
    margin-bottom: 0.4em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
    margin: 1.8em 0 0.7em;
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.prose h1 { font-size: 1.5em; }
.prose h2 { font-size: 1.3em; }
.prose h3 { font-size: 1.1em; }

.prose h1:first-child,
.prose h2:first-child,
.prose p:first-child {
    margin-top: 0;
}

.prose a {
    text-decoration: underline;
}

.prose code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 0.1em 0.35em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
}

.prose pre {
    margin-bottom: 1.4em;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.prose pre code {
    padding: 0;
    background: none;
    border: none;
}

.prose blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1em;
    color: var(--muted);
}

.prose table {
    border-collapse: collapse;
    margin-bottom: 1.4em;
    font-size: 14px;
}

.prose td {
    padding: 4px 20px 4px 0;
}

.prose td:first-child {
    color: var(--muted);
}

.prose thead:empty,
.prose th:empty {
    display: none;
}

/* ===== projects ===== */
.project {
    padding: 18px 14px;
    border-bottom: 1px solid var(--border);
}

.project h3 {
    font-size: 15px;
    font-weight: 600;
    text-wrap: balance;
}

.project.highlight {
    box-shadow: inset 2px 0 0 var(--accent);
}

.project-desc {
    margin-top: 6px;
    font-size: 13.5px;
    color: var(--muted);
}

.project .byline {
    margin-top: 14px;
}

/* ===== profile / scope header ===== */
.scope-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.scope-inner {
    max-width: 980px;
    margin: 0 auto;
    padding: 28px 32px 0;
}

.scope-header .author {
    margin-bottom: 20px;
}

.scope-tabs {
    display: flex;
    gap: 4px;
    overflow: auto hidden;
}

.scope-header .scope-tabs {
    margin-bottom: -1px;
}

.scope-tab {
    padding: 9px 12px;
    font-size: 13px;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-s) var(--radius-s) 0 0;
}

.scope-tab.active {
    border-bottom-color: var(--accent);
}

/* ===== about ===== */
.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 20px;
}

.kv dt {
    color: var(--muted);
}

.friend {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.friend:hover {
    color: var(--accent);
}

/* ===== responsive ===== */
@media (max-width: 840px) {
    :root {
        --nav-h: 85px;
        --pane-top: 20px;
    }

    .nav-bar {
        flex-wrap: wrap;
        align-items: center;
    }

    .nav-home {
        margin-right: auto;
        height: 48px;
        padding-left: 10px;
    }

    .nav {
        order: 1;
        flex-basis: 100%;
        height: 36px;
        margin: 0;
        padding: 0;
        justify-content: space-around;
        border-top: 1px solid var(--border);
    }

    .nav-link,
    .scope-tab {
        flex: 1;
        justify-content: center;
        padding: 9px;
    }

    .nav-link.active::after {
        left: 0;
        right: 0;
        bottom: -1px;
    }

    .scope-header .scope-tabs {
        margin-inline: -16px;
        gap: 0;
    }

    .nav-home .icon,
    .nav-link .icon,
    .scope-tab .icon {
        width: 18px;
        height: 18px;
    }

    .nav-action,
    .nav-home-label,
    .nav-home-handle,
    .nav-link span,
    .scope-tab span {
        display: none;
    }

    .scope-inner {
        padding: 20px 16px 0;
    }

    .topbar {
        padding: 0 16px;
    }

    .nav-search {
        margin-right: 8px;
    }

    .nav-search.open {
        position: absolute;
        inset: 8px 8px auto;
        height: 32px;
        margin: 0;
        z-index: 25;
    }

    .nav-search.open input {
        width: 100%;
    }

    .search-tabs {
        margin-inline: -16px;
        margin-bottom: 20px;
        padding-inline: 7px;
    }

    .scope-tab .search-count {
        display: inline;
    }

    .pane {
        padding: var(--pane-top) 16px 56px;
    }

    .bucket-head {
        overflow-x: auto;
    }

    .file-table .c-size {
        display: none;
    }

    .gallery-grid {
        gap: 3px;
    }

    .object-view,
    .meta-collapsed.object-view {
        grid-template: 'back' auto 'meta' auto 'content' 1fr / 1fr;
    }

    .object-meta-toggle {
        transform: rotate(-90deg);
    }

    .object-meta {
        position: static;
        max-height: none;
        margin: 0 0 20px;
        padding: 0 0 20px;
        border-left: none;
        border-bottom: 1px solid var(--border);
    }

    .object-content {
        margin-bottom: var(--object-foot-h);
    }

    .object-content.is-image,
    .object-content.is-audio {
        height: auto;
    }

    .object-content.is-image img {
        height: auto;
        max-height: var(--object-h);
    }
}
