:root {
    color-scheme: dark;
    --bg: #222325;
    --panel: rgba(34, 35, 37, 0.72);
    --panel-soft: rgba(255, 255, 255, 0.04);
    --line: rgba(255, 255, 255, 0.12);
    --text: #f6f6f6;
    --muted: #b6b6b6;
    --cyan: #ffffff;
    --green: #71d199;
    --amber: #ff963b;
    --rose: #e56b7f;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(#313131, #0a0a0a);
    color: var(--text);
    font-family: "Comic Sans MS", "Helvetica Neue", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    cursor: url(https://cdn.jsdelivr.net/gh/Tomotoes/images/blog/default.cur), auto;
}

a {
    color: inherit;
}

a,
button,
label,
img,
summary,
input[type="file"] {
    cursor: url(https://cdn.jsdelivr.net/gh/Tomotoes/images/blog/pointer.cur), pointer;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
}

button:disabled {
    opacity: 0.58;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
    background: rgba(10, 10, 10, 0.64);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.brand,
.nav-links,
.auth-state {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand {
    text-decoration: none;
    font-weight: 700;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 7px;
    background: #fff;
    color: #222325;
}

.nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-links a:hover {
    color: var(--text);
}

.page-shell {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 780px) minmax(230px, 300px);
    gap: 1.25rem;
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 2.5rem;
}

.profile-panel,
.composer-panel,
.post-card,
.quick-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.profile-panel,
.side-panel {
    position: sticky;
    top: 5rem;
    align-self: start;
}

.profile-panel {
    padding: 1.25rem;
    text-align: center;
}

.profile-avatar {
    display: block;
    width: 6.5rem;
    height: 6.5rem;
    margin: 0 auto 1rem;
    border: 3px solid #fff;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.3);
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--amber);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.profile-form {
    display: grid;
    gap: 0.65rem;
}

.profile-field {
    display: grid;
    gap: 0.55rem;
}

.profile-display {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 1.9rem;
    align-items: center;
    gap: 0.35rem;
}

.profile-name-display h1 {
    margin: 0;
    color: #fff;
    font-size: 1.7rem;
    font-weight: 300;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.profile-bio-display .bio {
    margin: 0;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.edit-icon {
    display: inline-grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 0.95rem;
}

.edit-icon:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.45);
    text-shadow: 0 0 2px #fff;
}

.profile-editor {
    display: grid;
    gap: 0.5rem;
}

.profile-editor[hidden] {
    display: none;
}

.profile-editor input,
.profile-editor textarea {
    text-align: center;
}

.profile-editor textarea {
    min-height: 5.5rem;
}

#profileUsername {
    color: #fff;
    font-size: 1.15rem;
}

.compact-save {
    width: 100%;
}

.avatar-upload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--muted);
    cursor: pointer;
}

.avatar-upload:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}

.avatar-upload input {
    display: none;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.65rem;
    font-size: clamp(1.7rem, 3vw, 2.4rem);
}

h2 {
    margin-bottom: 0.65rem;
    font-size: 1.15rem;
}

.bio,
.quick-panel p,
.post-meta,
.comment-meta,
.login-hint,
.status-text {
    color: var(--muted);
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.profile-stats.single-stat {
    grid-template-columns: 1fr;
}

.profile-stats div {
    padding: 0.85rem;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.profile-stats strong {
    display: block;
    font-size: 1.35rem;
}

.profile-stats span {
    color: var(--muted);
    font-size: 0.85rem;
}

.feed-column,
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.composer-panel,
.quick-panel {
    padding: 1rem;
}

.composer-head,
.post-header,
.form-row,
.post-actions,
.comment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.post-form {
    display: grid;
    gap: 0.75rem;
}

.post-form[aria-disabled="true"] {
    opacity: 0.62;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.8rem 0.9rem;
    background: #111318;
    color: var(--text);
    outline: none;
}

textarea {
    min-height: 8rem;
    line-height: 1.65;
}

input:focus,
textarea:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(79, 195, 220, 0.15);
}

.primary-btn,
.ghost-btn,
.icon-btn,
.tab-btn,
.download-link,
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}

.primary-btn {
    background: var(--cyan);
    color: #061014;
    font-weight: 700;
}

.primary-btn:hover {
    background: #72d9ee;
}

.ghost-btn,
.tab-btn,
.action-btn {
    background: var(--panel-soft);
    border: 1px solid var(--line);
}

.ghost-btn:hover,
.tab-btn:hover,
.action-btn:hover {
    border-color: rgba(79, 195, 220, 0.55);
}

.icon-btn {
    width: 2.25rem;
    padding: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.5rem;
}

.feed-list {
    display: grid;
    gap: 1rem;
}

.post-card {
    padding: 1rem;
}

.post-author {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.avatar-badge {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 8px;
    background: #27303a;
    color: var(--green);
    font-weight: 800;
}

.post-meta,
.comment-meta {
    font-size: 0.85rem;
}

.post-title {
    margin: 1rem 0 0.65rem;
    font-size: 1.3rem;
}

.post-body {
    color: #dce2e8;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.markdown-body {
    white-space: normal;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 1rem 0 0.55rem;
    color: #fff;
    font-weight: 500;
}

.markdown-body p,
.markdown-body ul,
.markdown-body blockquote,
.markdown-body pre {
    margin: 0.75rem 0;
}

.markdown-body ul {
    padding-left: 1.35rem;
}

.markdown-body blockquote {
    border-left: 3px solid var(--amber);
    padding: 0.15rem 0 0.15rem 0.8rem;
    color: var(--muted);
}

.markdown-body pre {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.85rem;
    background: #0d1014;
}

.markdown-body code {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.1rem 0.3rem;
    background: #0d1014;
    color: #fff;
}

.markdown-body pre code {
    border: 0;
    padding: 0;
    background: transparent;
}

.markdown-body a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 0.22rem;
}

.markdown-body img {
    display: block;
    width: min(100%, 920px);
    max-height: 720px;
    margin: 0.85rem 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    object-fit: contain;
    background: #0d1014;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: -0.15rem 0 0.85rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 1.65rem;
    border: 1px solid rgba(113, 209, 153, 0.34);
    border-radius: 7px;
    padding: 0.15rem 0.55rem;
    background: rgba(113, 209, 153, 0.09);
    color: #bff4d3;
    font-size: 0.82rem;
}

.post-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.read-only-actions {
    gap: 0.55rem;
}

.action-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2.15rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 0.9rem;
}

.action-btn.active {
    border-color: rgba(229, 107, 127, 0.8);
    color: #ffd5dc;
}

.danger-action,
.danger-link {
    border-color: rgba(229, 107, 127, 0.55);
    color: #ffd5dc;
}

.danger-link {
    min-height: 1.75rem;
    border: 1px solid rgba(229, 107, 127, 0.55);
    border-radius: 7px;
    padding: 0.2rem 0.55rem;
    background: rgba(229, 107, 127, 0.12);
    font-size: 0.85rem;
}

.project-details {
    margin-top: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #12161b;
}

.project-details summary {
    padding: 0.85rem 1rem;
    cursor: pointer;
    color: var(--amber);
}

.project-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 0 1rem 1rem;
}

.project-gallery figure {
    margin: 0;
}

.project-gallery img {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    border: 1px solid var(--line);
    object-fit: cover;
}

.project-gallery figcaption {
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.comments {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.comment-list {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 0.8rem;
}

.comment {
    padding: 0.75rem;
    background: #12161b;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.comment-body {
    margin: 0.35rem 0 0;
    color: #dce2e8;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-form {
    display: flex;
    gap: 0.6rem;
}

.guest-comment-form {
    display: grid;
    grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr) auto;
}

.comment-form input {
    min-width: 0;
}

.quick-panel {
    border-top: 3px solid var(--green);
}

.hot-posts {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.8rem;
}

.hot-post {
    display: grid;
    grid-template-columns: 1.8rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem;
    background: #12161b;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
}

.hot-post:hover {
    border-color: rgba(79, 195, 220, 0.55);
}

.hot-rank {
    display: grid;
    place-items: center;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 7px;
    background: rgba(242, 184, 75, 0.18);
    color: #ffe0a1;
    font-weight: 800;
}

.hot-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hot-likes {
    color: var(--muted);
    font-size: 0.85rem;
}

.download-link {
    width: 100%;
    margin-top: 0.4rem;
    background: rgba(113, 209, 153, 0.16);
    border: 1px solid rgba(113, 209, 153, 0.45);
    color: #bff4d3;
}

.auth-dialog {
    width: min(92vw, 420px);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
}

.auth-dialog::backdrop {
    background: rgba(0, 0, 0, 0.68);
}

.dialog-close-form {
    display: flex;
    justify-content: flex-end;
    margin: -0.35rem -0.35rem 0;
}

.auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn.active {
    background: var(--cyan);
    color: #061014;
    font-weight: 700;
}

.auth-form {
    display: grid;
    gap: 0.75rem;
}

.auth-form h2 {
    margin-bottom: 0.2rem;
}

.empty-state {
    padding: 1.2rem;
    background: rgba(24, 27, 32, 0.86);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 1100px) {
    .page-shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .side-panel {
        grid-column: 2;
        position: static;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 780px) {
    .topbar {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: space-between;
    }

    .page-shell {
        grid-template-columns: 1fr;
    }

    .profile-panel,
    .side-panel {
        position: static;
    }

    .side-panel {
        grid-column: auto;
        display: flex;
    }

    .project-gallery {
        grid-template-columns: 1fr;
    }

    .comment-form,
    .composer-head,
    .post-header {
        align-items: stretch;
        flex-direction: column;
    }

    .guest-comment-form {
        grid-template-columns: 1fr;
    }
}
