/* KbauBlocks design system. AGPL-3.0-or-later. */
:root {
    --bg: #0e0e0e;
    --surface: #161616;
    --surface-2: #1d1d1d;
    --surface-3: #262626;
    --border: #2a2a2a;
    --text: #ededed;
    --text-muted: #9a9a9a;
    --header-bg: #000000;
    --header-text: #ffffff;
    --accent: #ffffff;
    --accent-strong: #d4d4d4;
    --accent-ink: #000000;
    --warm: #ffb648;
    --love: #ff5d73;
    --danger: #ff5d5d;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    --font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
    color-scheme: dark;
}
:root[data-theme="light"] {
    --bg: #f4f5f4;
    --surface: #ffffff;
    --surface-2: #f0f1f0;
    --surface-3: #e4e6e4;
    --border: #dcdfdc;
    --text: #151816;
    --text-muted: #5f6762;
    --accent: #111111;
    --accent-strong: #000000;
    --accent-ink: #ffffff;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }

/* Header: always solid black */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    color: var(--header-text);
    border-bottom: 1px solid #1a1a1a;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 900; font-size: 1.1rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.nav { display: flex; gap: 2px; }
.nav a {
    color: #d8d8d8;
    padding: 7px 11px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
}
.nav a:hover, .nav a.active { background: #1c1c1c; color: #fff; text-decoration: none; }
.nav a.create { color: #ffffff; }
.search {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    background: #141414;
    border: 1px solid #262626;
    border-radius: 999px;
    padding: 0 12px;
    height: 36px;
}
.search:focus-within { border-color: #3a3a3a; background: #181818; }
.search input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: #fff;
    font: inherit;
    font-size: 0.95rem;
}
.search svg { width: 16px; height: 16px; color: #888; margin-right: 8px; flex: none; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }

/* Buttons & form controls */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 800;
    font-size: 0.92rem;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { height: 30px; padding: 0 12px; font-size: 0.82rem; }
.btn.on { border-color: var(--accent); color: var(--accent); }
.btn.love.on { border-color: var(--love); color: var(--love); }
.site-header .btn { background: #161616; border-color: #2a2a2a; color: #fff; }
.site-header .btn.primary { background: #ffffff; color: #000000; border-color: #ffffff; }

label { display: block; font-weight: 800; font-size: 0.9rem; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="email"], input[type="url"], textarea, select {
    width: 100%;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    font-size: 0.95rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
/* The header search pill shows focus itself (slightly lighter); no outline box inside it. */
.search input:focus { outline: none; }
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.notice {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.notice.warn { border-color: #5a4720; background: #1f1a10; color: #ffd58a; }
:root[data-theme="light"] .notice.warn { background: #fff6e3; color: #6b4d00; border-color: #f0d79a; }
.notice.error { border-color: #5a2020; background: #1f1010; color: #ffb3b3; }
:root[data-theme="light"] .notice.error { background: #ffecec; color: #8a1c1c; border-color: #f3c0c0; }
.notice.ok { border-color: #1d4d3f; background: #0f1d18; color: #9ff0d6; }
:root[data-theme="light"] .notice.ok { background: #e6fbf4; color: #0b6b50; border-color: #b4ead9; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button, .tabs a {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 7px 14px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}
.tabs button:hover, .tabs a:hover { color: var(--text); text-decoration: none; }
.tabs .active { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* Project grid */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 34px 0 14px; gap: 12px; }
.section-head h2 { margin: 0; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--text);
    display: flex;
    flex-direction: column;
    transition: transform 0.12s ease, border-color 0.12s ease;
}
.project-card:hover { transform: translateY(-2px); border-color: #3a3a3a; text-decoration: none; }
.thumb {
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #1b1b1b, #121212);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
:root[data-theme="light"] .thumb { background: linear-gradient(135deg, #eceeed, #e1e4e2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .placeholder { width: 42px; opacity: 0.35; }
.project-card .meta { padding: 10px 12px 12px; }
.project-card .title { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card .by { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card .stats { display: flex; gap: 10px; font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-muted);
    vertical-align: middle;
}
.badge.accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.badge.warn { background: rgba(255, 182, 72, 0.15); color: var(--warm); }
.empty { color: var(--text-muted); padding: 30px 0; text-align: center; }

/* Hero */
.hero {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    padding: clamp(28px, 6vw, 64px);
    background:
        radial-gradient(circle at 85% 20%, rgba(255, 255, 255, 0.10), transparent 45%),
        radial-gradient(circle at 70% 90%, rgba(255, 182, 72, 0.16), transparent 40%),
        var(--surface);
    border: 1px solid var(--border);
}
.hero p { font-size: 1.1rem; color: var(--text-muted); max-width: 560px; }
.hero .blocks { position: absolute; right: -20px; top: 50%; transform: translateY(-50%); width: min(38%, 360px); opacity: 0.95; }
.hero-content { position: relative; max-width: 620px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 18px; }
.feature { padding: 18px; }
.feature .icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 900; margin-bottom: 10px; color: var(--accent-ink); }

/* Project page */
.project-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.player {
    width: 100%;
    aspect-ratio: 480 / 400;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.owner-line { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--surface-3);
    flex: none;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: var(--accent-ink);
}
.avatar.lg { width: 96px; height: 96px; border-radius: 26px; font-size: 2.2rem; }
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 0.85rem; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }

/* Comments */
.comment { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.comment .body { flex: 1; min-width: 0; }
.comment .head { display: flex; gap: 8px; align-items: baseline; font-size: 0.88rem; flex-wrap: wrap; }
.comment .head a { font-weight: 800; color: var(--text); }
.comment .text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 2px 0 4px; }
.comment .tools { display: flex; gap: 12px; align-items: center; font-size: 0.8rem; flex-wrap: wrap; margin-top: 4px; }
.comment .tools button { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 0; font: inherit; font-weight: 700; }
.comment .tools button:hover { color: var(--text); }
.replies { margin-left: 40px; }

/* Profile */
/* Banner fades from the profile colour (top) into the card colour (bottom), so the name sits on plain UI grey. */
.profile-banner { position: relative; height: 170px; }
.profile-banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 0%, transparent 15%, var(--surface) 92%);
}
.profile-head { position: relative; display: flex; gap: 18px; align-items: flex-end; margin-top: -84px; padding: 0 20px; flex-wrap: wrap; }
.profile-head .avatar { border: 4px solid var(--surface); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 10px 0; }
.stat-row b { display: block; font-size: 1.2rem; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 60;
}
.dropdown-menu a, .dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    color: var(--text);
    padding: 8px 10px;
    border-radius: 8px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.user-chip { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #fff; font: inherit; font-weight: 800; cursor: pointer; padding: 4px; border-radius: 10px; }
.user-chip:hover { background: #1c1c1c; }

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}
.modal { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    border: 1px solid #2a2a2a;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: 700;
    z-index: 200;
    box-shadow: var(--shadow);
}

/* Table-ish list */
.list-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.list-row .thumb { width: 96px; flex: none; border-radius: 8px; }
.list-row .grow { flex: 1; min-width: 180px; }

.ext-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ext-card .banner { aspect-ratio: 2 / 1; background: var(--surface-2); }
.ext-card .banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ext-card .meta { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.ext-card .desc { font-size: 0.88rem; color: var(--text-muted); flex: 1; }

footer.site-footer { border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.85rem; }
footer .inner { max-width: 1200px; margin: 0 auto; padding: 22px 16px; display: flex; gap: 18px; flex-wrap: wrap; }

/* Verified tick */
.verified { display: inline-flex; vertical-align: -0.12em; margin-left: 0.3em; width: 1em; height: 1em; flex: none; }
.verified svg { width: 100%; height: 100%; margin: 0; }
.verified .seal { fill: var(--accent); }
.verified .check { stroke: var(--accent-ink); }
.user-name { display: inline-flex; align-items: center; min-width: 0; }
h1 .verified { width: 0.8em; height: 0.8em; }

/* People lists (followers, following, friends, user search) */
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.user-card { display: flex; align-items: center; gap: 12px; padding: 12px; color: var(--text); }
.user-card:hover { border-color: var(--accent); text-decoration: none; }
.user-card-text { display: flex; flex-direction: column; min-width: 0; }
.user-card-text b, .user-card-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-link { background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.stat-link:hover span { color: var(--text); text-decoration: underline; }

/* Search box dropdown */
.search { position: relative; }
.search-suggest {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 50;
}
.search-suggest .suggest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
}
.search-suggest .suggest-item:hover, .search-suggest .suggest-item.active { background: var(--surface-3); text-decoration: none; }
.search-suggest .suggest-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-suggest .suggest-icon { width: 30px; display: inline-flex; justify-content: center; color: var(--text-muted); flex: none; }
.search-suggest .suggest-icon svg { width: 18px; height: 18px; margin: 0; color: inherit; }
.search-suggest .verified svg { margin: 0; }

/* Project page: owners edit the title, Description and Notes in place */
input.title-input[type="text"] {
    width: 100%;
    margin: 4px 0 8px;
    padding: 4px 8px;
    margin-left: -8px;
    font: inherit;
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.2;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
}
input.title-input[type="text"]:hover { border-color: var(--border); }
input.title-input[type="text"]:focus { background: var(--surface-2); border-color: var(--border); outline: none; }
textarea.inline-edit {
    width: 100%;
    min-height: 90px;
    resize: vertical;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    padding: 10px 12px;
    overflow: hidden;
}

/* Admin page */
.grow { flex: 1; min-width: 0; }
.badge.danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.small-tabs { margin: 0 0 14px; }
.small-tabs button { font-size: 0.85rem; padding: 6px 12px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat-tile { display: flex; flex-direction: column; gap: 2px; padding: 16px; text-align: left; color: var(--text); font: inherit; }
button.stat-tile { cursor: pointer; }
button.stat-tile:hover { border-color: var(--accent); }
.stat-tile b { font-size: 1.6rem; line-height: 1.1; }
.admin-user { display: flex; align-items: center; gap: 14px; padding: 12px 14px; margin-bottom: 10px; flex-wrap: wrap; }
.admin-user.is-banned { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.admin-user select { width: auto; padding: 6px 8px; }
.ban-reason { margin-top: 4px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 10%, transparent); }
.log-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.log-row { display: flex; align-items: baseline; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.log-row:first-child { border-top: 0; }
.log-time { flex: none; width: 150px; white-space: nowrap; }
.log-text { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.log-ip { flex: none; }
.log-filter { background: color-mix(in srgb, var(--warm) 6%, var(--surface)); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--surface-3); font-weight: 700; }
.chip button { border: 0; background: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 4px; }
.chip button:hover { color: var(--danger); }
.quote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--border); }

/* Pinned comment */
.comment.pinned { background: color-mix(in srgb, var(--accent) 5%, transparent); border-radius: 12px; padding: 10px; margin: 0 -10px 10px; }
.pinned-label { font-weight: 800; color: var(--text-muted); margin-bottom: 2px; }

/* Comment votes */
.comments-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.comments-head h2 { margin: 0; }
.comment-sort { margin: 0; }
.vote-box { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; padding: 1px 4px; border-radius: 999px; background: var(--surface-2); }
.comment .tools .vote { padding: 2px 6px; font-size: 0.75rem; line-height: 1; color: var(--text-muted); border-radius: 999px; }
.comment .tools .vote:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }
.comment .tools .vote:disabled { opacity: 0.35; cursor: default; }
.comment .tools .vote.up.on { color: var(--accent); }
.comment .tools .vote.down.on { color: var(--danger); }
.vote-score { min-width: 1.6em; text-align: center; font-weight: 800; font-size: 0.8rem; color: var(--text); }
.link-button { background: none; border: 0; padding: 0; color: var(--text); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* Project thumbnail editor */
.thumb-editor { margin-top: 18px; }
.thumb-preview { width: 120px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); flex: none; }

@media (max-width: 900px) {
    .project-layout { grid-template-columns: 1fr; }
    .hero .blocks { display: none; }
}
@media (max-width: 720px) {
    .header-inner { gap: 8px; }
    .nav { display: none; }
    .nav.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #000;
        padding: 8px 16px 14px;
        border-bottom: 1px solid #1a1a1a;
    }
    .menu-toggle { display: inline-flex; background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
    .brand span { display: none; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .replies { margin-left: 18px; }
}

/* Extras: Claude MCP setup card */
.claude-mcp { border-color: #d97757; }
.claude-mcp .steps { margin: 16px 0; padding-left: 22px; display: grid; gap: 10px; }
.claude-mcp .steps li { padding-left: 4px; }
.code-wrap { position: relative; }
pre.code {
    margin: 0;
    padding: 12px 70px 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.45;
}
pre.code code, .claude-mcp code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.claude-mcp :not(pre) > code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: 0.85em; }
.code-wrap .copy-btn { position: absolute; top: 8px; right: 8px; }

/* ---------- Profile editor (Settings > Profile) ---------- */
.card.profile-editor-card { max-width: 760px !important; padding: 0 0 20px; overflow: hidden; }
.profile-editor-card > :not(.pe-preview) { margin-left: 20px; margin-right: 20px; }
.pe-preview { --pe-color: #ffffff; position: relative; }
.pe-drop { position: relative; cursor: pointer; overflow: hidden; outline: none; }
.pe-drop:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
.pe-banner {
    display: block;
    aspect-ratio: 4 / 1;
    background: linear-gradient(120deg, var(--pe-color), #000);
    border-bottom: 1px solid var(--border);
}
.pe-banner-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.pe-banner.has-image .pe-banner-img { display: block; }
.pe-hover, .pe-drop-label, .pe-busy {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    font-weight: 800;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s ease;
}
.pe-hover { background: rgba(0, 0, 0, .45); }
.pe-drop:hover > .pe-hover, .pe-drop:focus-visible > .pe-hover { opacity: 1; }
.pe-icon { display: inline-flex; width: 40px; height: 40px; border-radius: 999px; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .25); }
.pe-drop-label { background: rgba(0, 0, 0, .55); border: 2px dashed rgba(255, 255, 255, .7); border-radius: inherit; font-size: .95rem; text-align: center; }
.pe-preview.dragging .pe-drop-label { opacity: .85; }
.pe-preview.dragging .pe-drop.over .pe-drop-label { opacity: 1; background: rgba(0, 0, 0, .3); border-color: #fff; border-style: solid; }
.pe-preview.dragging .pe-hover { opacity: 0 !important; }
.pe-busy { background: rgba(0, 0, 0, .5); }
.pe-drop.busy > .pe-busy { opacity: 1; }
.pe-spinner { width: 28px; height: 28px; border-radius: 999px; border: 3px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: pe-spin .8s linear infinite; }
@keyframes pe-spin { to { transform: rotate(360deg); } }
.pe-head { position: relative; display: flex; align-items: flex-end; gap: 16px; padding: 0 20px; margin-top: -56px; pointer-events: none; }
.pe-head > * { pointer-events: auto; }
.pe-avatar {
    width: 112px;
    height: 112px;
    flex: none;
    border-radius: 30px;
    border: 4px solid var(--surface);
    background: var(--surface-3);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.pe-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pe-avatar .pe-drop-label { font-size: .8rem; border-radius: 26px; }
.pe-head-text { padding-bottom: 8px; min-width: 0; }
.pe-name { font-size: 1.45rem; font-weight: 900; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-image-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.pe-fields { margin-top: 18px; }
.pe-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.pe-label label { margin: 0; }
.pe-count { font-size: .78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pe-count.near { color: #ffb86b; }
.pe-swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pe-swatch {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 2px solid var(--border);
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: transform .12s ease;
}
.pe-swatch:hover { transform: scale(1.08); }
.pe-swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.pe-swatch.custom { display: inline-flex; align-items: center; justify-content: center; background: conic-gradient(#ff5c5c, #ffd84d, #4cd98a, #3ec7e0, #5b8cff, #a66bff, #ff5c5c); font-weight: 900; color: #000; }
.pe-swatch.custom span { background: rgba(255, 255, 255, .85); border-radius: 999px; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: .9rem; line-height: 1; }
.pe-swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; border: 0; }
.pe-savebar {
    position: sticky;
    bottom: 16px;
    z-index: 5;
    display: none;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px 10px 16px;
    margin-top: 8px;
    margin-bottom: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
    font-weight: 800;
}
.pe-savebar.show { display: flex; animation: pe-pop .18s ease; }
@keyframes pe-pop { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 520px) {
    .pe-avatar { width: 88px; height: 88px; border-radius: 24px; }
    .pe-head { margin-top: -44px; gap: 12px; }
    .pe-name { font-size: 1.1rem; }
    .pe-head-text { padding-bottom: 2px; }
    .pe-savebar { border-radius: 16px; }
}

/* ---------- Image cropper ---------- */
.modal.crop-modal { max-width: 680px; }
.crop-stage {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 12px;
    background: repeating-conic-gradient(#1b1b1b 0 25%, #222 0 50%) 0 0 / 20px 20px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    outline: none;
}
.crop-stage:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.crop-stage.dragging { cursor: grabbing; }
.crop-stage.busy { pointer-events: none; opacity: .7; }
.crop-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; image-rendering: auto; }
.crop-frame { position: absolute; pointer-events: none; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .62); outline: 2px solid #fff; }
.crop-grid {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity .15s ease;
    background:
        linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255, 255, 255, .45) 0, rgba(255, 255, 255, .45) calc(33.33% + .5px), transparent 0, transparent calc(66.66% - .5px), rgba(255, 255, 255, .45) 0, rgba(255, 255, 255, .45) calc(66.66% + .5px), transparent 0),
        linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255, 255, 255, .45) 0, rgba(255, 255, 255, .45) calc(33.33% + .5px), transparent 0, transparent calc(66.66% - .5px), rgba(255, 255, 255, .45) 0, rgba(255, 255, 255, .45) calc(66.66% + .5px), transparent 0);
}
.crop-stage.dragging .crop-grid { opacity: 1; }
.crop-controls { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.crop-zoom { flex: 1; accent-color: var(--accent); padding: 0; border: 0; background: none; }
.crop-zoom-icon { font-weight: 900; color: var(--text-muted); width: 16px; text-align: center; }
.crop-status { min-width: 0; }

/* Profile page banner image */
.profile-banner.has-image { height: auto; aspect-ratio: 4 / 1; max-height: 300px; overflow: hidden; }
.profile-banner .banner-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-banner.has-image::after { background: linear-gradient(to bottom, transparent 0%, transparent 45%, color-mix(in srgb, var(--surface) 92%, transparent) 100%); }

[hidden] { display: none !important; }

/* ---------- Header messages button ---------- */
.msg-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    color: #fff;
    background: #161616;
    border: 1px solid #2a2a2a;
}
.msg-button:hover, .msg-button.active { background: #262626; text-decoration: none; }
.msg-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ff4d5e;
    color: #fff;
    font-size: .7rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #000;
}

/* ---------- Messages page ---------- */
main.dm-main { max-width: 1200px; padding-bottom: 24px; }
.dm {
    display: grid;
    grid-template-columns: 330px 1fr;
    height: calc(100vh - 56px - 48px);
    min-height: 460px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.dm-sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.dm-sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.dm-sidebar-head h1 { margin: 0; font-size: 1.4rem; }
.dm-new { display: inline-flex; align-items: center; gap: 6px; }
.dm-tabs { display: flex; gap: 6px; padding: 4px 16px 8px; }
.dm-tabs button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}
.dm-tabs button:hover { color: var(--text); }
.dm-tabs button.active { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.dm-filter { padding: 0 16px 10px; }
.dm-filter input { padding: 8px 12px; border-radius: 999px; }
.dm-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.dm-section { font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 10px 8px 4px; }
.dm-empty-list { padding: 24px 12px; text-align: center; line-height: 1.5; }
.dm-item { display: flex; gap: 10px; align-items: center; padding: 9px 8px; border-radius: 12px; color: var(--text); }
.dm-item:hover { background: var(--surface-2); text-decoration: none; }
.dm-item.selected { background: var(--surface-3); }
.dm-item .avatar { width: 44px; height: 44px; border-radius: 14px; }
.dm-item-text { flex: 1; min-width: 0; }
.dm-item-top, .dm-item-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dm-item-top b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: .88rem; }
.dm-item.unread .dm-preview { color: var(--text); font-weight: 800; }
.dm-pin { display: inline-flex; color: var(--text-muted); }
.dm-count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ff4d5e;
    color: #fff;
    font-size: .72rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dm-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dm-welcome { margin: auto; text-align: center; padding: 24px; max-width: 360px; }
.dm-welcome-icon { width: 84px; height: 84px; margin: 0 auto 12px; border-radius: 999px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--border); color: var(--text-muted); }
.dm-welcome h2 { margin: 0 0 6px; }
.dm-loading { margin: auto; }
.dm-chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.dm-chat-who { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.dm-chat-who:hover { text-decoration: none; }
.dm-chat-who > div { min-width: 0; }
.dm-chat-name { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-back { display: none !important; }
.icon-btn {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 999px;
    border: 1px solid transparent;
    background: none;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--text); background: var(--surface-3); border-color: var(--border); }
.dm-menu { right: 0; left: auto; min-width: 180px; }
.dm-menu .danger-text { color: var(--danger); }
.dm-scroll-wrap { flex: 1; min-height: 0; position: relative; }
.dm-messages { position: absolute; inset: 0; overflow-y: auto; padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 2px; }
.dm-older { align-self: center; margin-bottom: 8px; }
.dm-day { text-align: center; margin: 14px 0 8px; }
.dm-day span { font-size: .75rem; font-weight: 800; color: var(--text-muted); background: var(--surface-2); padding: 3px 10px; border-radius: 999px; }
.dm-msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; max-width: 100%; }
.dm-msg.grouped { margin-top: 0; }
.dm-msg.mine { flex-direction: row-reverse; }
.dm-msg .avatar.sm, .dm-avatar-space { width: 28px; height: 28px; flex: none; }
.dm-bubble {
    max-width: min(520px, 75%);
    padding: 8px 13px;
    border-radius: 18px;
    background: var(--surface-3);
    color: var(--text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.4;
}
.dm-msg:not(.mine) .dm-bubble { border-bottom-left-radius: 6px; }
.dm-msg:not(.mine).grouped .dm-bubble { border-top-left-radius: 6px; }
.dm-msg.mine .dm-bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.dm-msg.mine.grouped .dm-bubble { border-top-right-radius: 6px; }
.dm-msg.mine .dm-bubble a { color: inherit; text-decoration: underline; }
.dm-bubble.gone { background: none !important; color: var(--text-muted) !important; border: 1px dashed var(--border); font-style: italic; }
.dm-msg-actions { display: flex; gap: 8px; align-items: center; opacity: 0; transition: opacity .12s ease; padding-bottom: 4px; }
.dm-msg:hover .dm-msg-actions, .dm-msg:focus-within .dm-msg-actions { opacity: 1; }
.dm-msg-actions button { background: none; border: 0; padding: 0; font: inherit; font-size: .78rem; font-weight: 800; color: var(--text-muted); cursor: pointer; }
.dm-msg-actions button:hover { color: var(--text); }
.dm-seen { align-self: flex-end; font-size: .74rem; margin: 2px 4px 0 0; }
.dm-notice { margin: 0 14px 8px; padding: 9px 13px; border-radius: 12px; font-size: .86rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.dm-notice.warn { color: #ffcf7a; border-color: #5a4515; background: #2a2210; }
:root[data-theme="light"] .dm-notice.warn { color: #6b4d00; border-color: #f0d79a; background: #fff6e3; }
.dm-notice.hidden { display: none; }
.dm-request-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 14px 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.dm-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px 14px; position: relative; }
.dm-composer textarea { flex: 1; resize: none; overflow-y: hidden; min-height: 42px; max-height: 160px; padding: 10px 16px; border-radius: 22px; line-height: 1.35; }
.dm-composer.disabled textarea { opacity: .6; }
.dm-send { width: 42px; height: 42px; padding: 0; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.dm-counter { position: absolute; right: 70px; bottom: 24px; }
.dm-quote { margin: 0 0 8px; padding: 8px 12px; border-left: 3px solid var(--border); color: var(--text-muted); white-space: pre-wrap; max-height: 140px; overflow: auto; }
.dm-new-modal input { margin-bottom: 8px; }
.dm-pick { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.dm-pick-row { display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.dm-pick-row:hover { background: var(--surface-2); }
@media (max-width: 760px) {
    main.dm-main { padding: 0; }
    .dm { grid-template-columns: 1fr; height: calc(100dvh - 56px); border-radius: 0; border-left: 0; border-right: 0; }
    .dm.chat-open .dm-sidebar { display: none; }
    .dm:not(.chat-open) .dm-pane { display: none; }
    .dm-back { display: inline-flex !important; }
    .dm-msg-actions { display: none; }
    .dm-bubble { max-width: 82%; }
}

/* Settings > Privacy */
.privacy-limit { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.privacy-limit button { min-width: 56px; }
.blocked-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.blocked-row:first-child { border-top: 0; }
.dm-chat-who .muted.small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .header-right > a.btn.small[href$="mystuff"] { display: none; } }
@media (max-width: 520px) { .user-chip > .small { display: none; } }

/* Live collaboration (project page) */
.collab-card { margin-top: 14px; }
.collab-people { display: flex; flex-direction: column; gap: 4px; }
.collab-person { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.collab-credit { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.collab-avatars { display: flex; gap: 10px; flex-wrap: wrap; }
.collab-avatars a { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 800; font-size: .9rem; }
.badge.live-badge { background: #0f2a17; color: #69db7c; }
