:root {
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bg-gradient: radial-gradient(circle at top, rgba(79, 70, 229, 0.12), transparent 55%),
                   linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    --bg-color: #f5f7fb;
    --surface-color: rgba(255, 255, 255, 0.96);
    --surface-muted: rgba(255, 255, 255, 0.65);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(79, 70, 229, 0.25);
    --shadow-soft: 0 20px 45px rgba(15, 23, 42, 0.08);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
    --text-color: #1f2933;
    --text-muted: #5f6c7b;
    --text-subtle: #94a3b8;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --accent: #22d3ee;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --success: #22c55e;
    --info: #0ea5e9;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-gradient: radial-gradient(circle at top, rgba(79, 70, 229, 0.25), transparent 55%),
                       linear-gradient(180deg, #0f172a 0%, #111928 100%);
        --bg-color: #0f172a;
        --surface-color: rgba(15, 23, 42, 0.9);
        --surface-muted: rgba(30, 41, 59, 0.75);
        --border-color: rgba(148, 163, 184, 0.18);
        --border-strong: rgba(165, 180, 252, 0.35);
        --text-color: #e2e8f0;
        --text-muted: #cbd5f5;
        --text-subtle: #94a3b8;
        --shadow-soft: 0 25px 60px rgba(15, 23, 42, 0.65);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text-color);
    background: var(--bg-gradient);
    min-height: 100vh;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: min(1080px, 92%);
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(16px);
    background: rgba(248, 250, 252, 0.72);
    border-bottom: 1px solid var(--border-color);
}

@media (prefers-color-scheme: dark) {
    .site-header {
        background: rgba(15, 23, 42, 0.85);
    }
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 0;
}

.logo {
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: 0.03em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s ease, background 0.2s ease;
}

.nav-links a.has-indicator {
    position: relative;
    padding-right: 1.25rem;
}

.nav-links .nav-indicator-dot {
    position: absolute;
    top: 0.45rem;
    right: 0.4rem;
    width: 0.5rem;
    height: 0.5rem;
    background: var(--danger);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.nav-links a:hover,
.nav-links a:focus-visible {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

main {
    flex: 1;
    padding: 2.5rem 0 3.5rem;
}

.site-footer {
    background: rgba(255, 255, 255, 0.8);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.9rem;
    backdrop-filter: blur(12px);
}

@media (prefers-color-scheme: dark) {
    .site-footer {
        background: rgba(15, 23, 42, 0.85);
    }
}

.flash-messages {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.flash {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--surface-muted);
}

.flash.success {
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.flash.error {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.flash.info {
    border-color: rgba(14, 165, 233, 0.3);
    color: var(--info);
}

.flash.inline {
    margin-bottom: 1rem;
}

.card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.45);
}

@media (prefers-color-scheme: dark) {
    .card {
        border: 1px solid rgba(148, 163, 184, 0.16);
    }
}

.hero {
    display: grid;
    gap: 1.5rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(14, 165, 233, 0.12));
    border: 1px solid rgba(79, 70, 229, 0.15);
}

.hero-content h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.8rem, 2.5vw, 2.4rem);
}

.hero-content p {
    margin: 0 0 1rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.hero-tags h2 {
    margin: 0 0 0.75rem;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.12);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
}

.tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    margin-right: 0.4rem;
    margin-bottom: 0.35rem;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 500;
}

.tag-badge.muted {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-subtle);
}

.tag-badge.danger {
    background: rgba(239, 68, 68, 0.18);
    color: var(--danger);
}

.link-more {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.link-more:hover,
.link-more:focus-visible {
    text-decoration: underline;
}

.post-list {
    display: grid;
    gap: 1.5rem;
}

.post-card header {
    margin-bottom: 0.75rem;
}

.post-card h2,
.post-card h3 {
    margin: 0;
    font-size: 1.4rem;
}

.post-card h2 a,
.post-card h3 a {
    color: inherit;
    text-decoration: none;
}

.post-card h2 a:hover,
.post-card h3 a:hover,
.post-card h2 a:focus-visible,
.post-card h3 a:focus-visible {
    color: var(--primary);
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.45rem;
}

.post-excerpt {
    margin: 1rem 0 1.25rem;
    color: var(--text-muted);
}

.post-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.post-shortcuts {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.post-shortcuts a {
    color: var(--text-subtle);
    font-size: 0.85rem;
    text-decoration: none;
}

.post-shortcuts span {
    color: var(--text-subtle);
    font-size: 0.85rem;
}

.post-shortcuts form {
    margin: 0;
}

.favorite-inline-form {
    display: inline-flex;
    align-items: center;
}

.favorite-toggle-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.post-favorite {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.favorite-count-label,
.favorite-count {
    color: var(--text-subtle);
    font-size: 0.9rem;
}

.favorite-login-tip {
    color: var(--text-subtle);
    font-size: 0.9rem;
}

.post-shortcuts a:hover {
    color: var(--primary);
}

.post-detail .post-header {
    margin-bottom: 1.5rem;
}

.post-detail h1 {
    margin: 0 0 0.75rem;
    font-size: clamp(2rem, 2.8vw, 2.4rem);
}

.post-tags {
    margin-top: 0.75rem;
}

.post-body {
    font-size: 1.05rem;
    line-height: 1.8;
}

.post-actions {
    display: flex;
    gap: 0.75rem;
    margin: 1rem 0 2rem;
}

.comments header {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-bottom: 1rem;
}

.comment-count {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.comment-list {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.comment-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    background: rgba(255, 255, 255, 0.6);
}

@media (prefers-color-scheme: dark) {
    .comment-item {
        background: rgba(30, 41, 59, 0.6);
    }
}

.comment-meta {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    margin-bottom: 0.6rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.comment-delete-form {
    margin-left: auto;
}

.comment-body {
    color: var(--text-color);
}

.comment-form h3 {
    margin: 0 0 0.8rem;
}

.comment-signin {
    margin: 0;
    color: var(--text-muted);
}

.comment-signin a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.button.small {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

.button:hover,
.button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.15);
}

.button.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.button.primary:hover,
.button.primary:focus-visible {
    box-shadow: 0 12px 32px rgba(79, 70, 229, 0.3);
}

.button.danger {
    background: linear-gradient(135deg, var(--danger), var(--danger-dark));
    color: #fff;
}

.button.ghost {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: var(--text-muted);
}

.button.danger.ghost {
    border-color: rgba(239, 68, 68, 0.35);
    color: var(--danger);
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.markdown-body {
    line-height: 1.75;
    font-size: 1rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin-top: 1.6em;
    margin-bottom: 0.8em;
    line-height: 1.4;
}

.markdown-body h1 { font-size: 2rem; }
.markdown-body h2 { font-size: 1.6rem; }
.markdown-body h3 { font-size: 1.35rem; }
.markdown-body h4 { font-size: 1.2rem; }

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre {
    margin: 0 0 1.1em;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.25rem;
}

.markdown-body code {
    font-family: var(--font-mono);
    background: rgba(148, 163, 184, 0.18);
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
}

.markdown-body pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-family: var(--font-mono);
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
}

.markdown-body blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
    color: var(--text-muted);
    background: rgba(79, 70, 229, 0.08);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.markdown-body details.callout {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: var(--radius-md);
    background: rgba(148, 163, 184, 0.08);
    padding: 0;
    margin: 1.25rem 0;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.markdown-body details.callout summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0.85rem 1rem;
    font-weight: 600;
    list-style: none;
    background: rgba(255, 255, 255, 0.55);
    color: var(--text-color);
}

.markdown-body details.callout summary::marker,
.markdown-body details.callout summary::-webkit-details-marker {
    display: none;
}

.markdown-body details.callout summary:focus-visible {
    outline: 2px solid rgba(79, 70, 229, 0.35);
    outline-offset: 2px;
}

.markdown-body .callout-title {
    flex: 1;
}

.markdown-body .callout-content {
    padding: 0.9rem 1.1rem 1.15rem;
    background: rgba(255, 255, 255, 0.9);
}

.markdown-body details.callout.callout-info {
    border-color: rgba(14, 165, 233, 0.35);
    background: rgba(14, 165, 233, 0.1);
}

.markdown-body details.callout.callout-success {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.1);
}

.markdown-body details.callout.callout-warning {
    border-color: rgba(250, 204, 21, 0.35);
    background: rgba(250, 204, 21, 0.12);
}

.markdown-body details.callout.callout-error {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.12);
}

.markdown-body details.callout[open] summary {
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

@media (prefers-color-scheme: dark) {
    .markdown-body details.callout {
        border-color: rgba(148, 163, 184, 0.35);
        background: rgba(30, 41, 59, 0.6);
        box-shadow: 0 18px 36px rgba(2, 6, 23, 0.45);
    }

    .markdown-body details.callout summary {
        background: rgba(15, 23, 42, 0.92);
        color: var(--text-color);
    }

    .markdown-body details.callout[open] summary {
        border-bottom-color: rgba(148, 163, 184, 0.35);
    }

    .markdown-body .callout-content {
        background: rgba(15, 23, 42, 0.82);
    }

    .markdown-body details.callout.callout-info {
        border-color: rgba(56, 189, 248, 0.45);
        background: rgba(8, 145, 178, 0.24);
    }

    .markdown-body details.callout.callout-success {
        border-color: rgba(74, 222, 128, 0.45);
        background: rgba(21, 128, 61, 0.24);
    }

    .markdown-body details.callout.callout-warning {
        border-color: rgba(250, 204, 21, 0.45);
        background: rgba(202, 138, 4, 0.24);
    }

    .markdown-body details.callout.callout-error {
        border-color: rgba(248, 113, 113, 0.45);
        background: rgba(190, 18, 60, 0.24);
    }
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 0.95rem;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 0.6rem 0.75rem;
}

.clamp-3,
.clamp-4 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.clamp-3 { -webkit-line-clamp: 3; }
.clamp-4 { -webkit-line-clamp: 4; }

.empty-state {
    color: var(--text-muted);
}

.form-card.narrow {
    max-width: 520px;
    margin: 0 auto 2rem;
}

.form-header h1 {
    margin: 0;
}

.form-header .form-tip {
    margin-top: 0.5rem;
}

.form-tip {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.form-grid {
    display: grid;
    gap: 1.1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-field label {
    font-weight: 600;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="email"],
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.85);
    font: inherit;
}

.input-search {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.85);
    font: inherit;
}

.form-field textarea {
    min-height: 220px;
    resize: vertical;
}

.form-field.markdown-field {
    gap: 0.75rem;
}

.markdown-editor {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.markdown-editor.has-error {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.markdown-error {
    margin: 0.6rem 0 0;
    color: var(--danger);
    font-size: 0.85rem;
}

.markdown-editor.compact {
    border-radius: var(--radius-sm);
    box-shadow: none;
}

.markdown-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.85rem;
    background: rgba(79, 70, 229, 0.08);
    border-bottom: 1px solid var(--border-color);
}

.markdown-tool {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border 0.2s ease, transform 0.2s ease;
}

.markdown-tool:hover,
.markdown-tool:focus-visible {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.15);
    border-color: rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

.markdown-panels {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 320px;
}

.markdown-editor.compact .markdown-panels {
    min-height: 220px;
}

.markdown-panel {
    position: relative;
    min-height: 100%;
}

.markdown-panel-editor {
    background: rgba(255, 255, 255, 0.95);
}

.markdown-panel-editor textarea {
    width: 100%;
    height: 100%;
    border: none;
    resize: none;
    padding: 1rem 1.15rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: inherit;
    background: transparent;
}

.markdown-panel-preview {
    border-left: 1px solid var(--border-color);
    background: rgba(248, 250, 252, 0.88);
    padding: 1rem 1.2rem;
    overflow: auto;
}

.markdown-editor.compact .markdown-panel-preview {
    padding: 0.85rem 1rem;
}

.markdown-preview {
    min-height: 100%;
}

.markdown-preview:empty::before {
    content: '右侧实时预览 Markdown 内容';
    color: var(--text-subtle);
    font-size: 0.9rem;
}

.CodeMirror {
    font-family: var(--font-mono);
    height: 100%;
    background: transparent;
    color: inherit;
}

.CodeMirror-lines {
    padding: 1rem 1.1rem 1rem 1.35rem !important;
}

.CodeMirror-gutters {
    background: transparent;
    border-right: 1px solid var(--border-color);
}

.CodeMirror-cursor {
    border-left: 2px solid var(--primary) !important;
}

.CodeMirror-activeline-background {
    background: rgba(79, 70, 229, 0.08) !important;
}

.CodeMirror-selected {
    background: rgba(79, 70, 229, 0.15) !important;
}

.markdown-editor.compact .CodeMirror-lines {
    padding: 0.8rem 0.9rem 0.8rem 1.15rem !important;
}

.comment-editor-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

@media (max-width: 960px) {
    .markdown-panels {
        grid-template-columns: 1fr;
    }

    .markdown-panel-preview {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .select-control {
        max-width: 100%;
    }
}

@media (prefers-color-scheme: dark) {
    .markdown-editor {
        background: rgba(15, 23, 42, 0.88);
        box-shadow: 0 20px 45px rgba(2, 6, 23, 0.6);
    }

    .markdown-toolbar {
        background: rgba(99, 102, 241, 0.18);
    }

    .markdown-panel-editor {
        background: rgba(15, 23, 42, 0.92);
    }

    .markdown-panel-preview {
        background: rgba(30, 41, 59, 0.65);
    }

    .markdown-tool {
        color: rgba(186, 197, 219, 0.86);
    }

    .markdown-tool:hover,
    .markdown-tool:focus-visible {
        background: rgba(129, 140, 248, 0.25);
        border-color: rgba(165, 180, 252, 0.35);
    }

    .markdown-preview:empty::before {
        color: var(--text-subtle);
    }

    .select-shell select {
        background: rgba(15, 23, 42, 0.92);
        border-color: rgba(148, 163, 184, 0.55);
        color: rgba(236, 241, 255, 0.98);
        box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.18);
    }

    .select-shell select option {
        background: rgba(15, 23, 42, 0.98);
        color: rgba(236, 241, 255, 0.98);
    }

    .select-shell select:focus {
        border-color: rgba(165, 180, 252, 0.65);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
        background: rgba(30, 41, 59, 0.88);
    }

    .select-shell::after {
        border-color: rgba(226, 232, 240, 0.9);
    }

    .table-input {
        background: rgba(16, 21, 34, 0.96);
        border-color: rgba(120, 131, 210, 0.55);
        color: rgba(248, 250, 255, 0.98);
        caret-color: rgba(248, 250, 255, 0.98);
    }

    .table-input::placeholder {
        color: rgba(198, 211, 236, 0.68);
    }

    .table-input:focus {
        border-color: rgba(165, 180, 252, 0.72);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4);
        background: rgba(30, 39, 64, 0.97);
    }

    .bulk-tag-form fieldset,
    .form-field.tag-filter-field {
        background: rgba(12, 18, 32, 0.95);
        border-color: rgba(118, 130, 204, 0.55);
    }

    .bulk-tag-form legend,
    .form-field.tag-filter-field legend {
        background: rgba(12, 18, 32, 0.95);
        color: rgba(234, 238, 255, 0.96);
    }

    .checkbox-chip span,
    .radio-chip span {
        border-color: rgba(118, 130, 204, 0.6);
        background: rgba(34, 44, 73, 0.85);
        color: rgba(210, 218, 249, 0.9);
    }

    .checkbox-chip:hover span,
    .radio-chip:hover span,
    .checkbox-chip:focus-within span,
    .radio-chip:focus-within span {
        border-color: rgba(165, 180, 252, 0.75);
        background: rgba(99, 102, 241, 0.38);
        color: rgba(240, 244, 255, 0.99);
    }

    .checkbox-chip input,
    .radio-chip input {
        accent-color: rgba(165, 180, 252, 0.85);
    }

    .checkbox-chip input:checked + span,
    .radio-chip input:checked + span {
        border-color: rgba(188, 199, 255, 0.85);
        background: rgba(99, 102, 241, 0.6);
        color: rgba(250, 252, 255, 1);
    }
}

.field-hint {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: var(--text-subtle);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tag-collection {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.tag-collection.compact {
    gap: 0.35rem;
}

.tag-placeholder {
    color: var(--text-subtle);
    font-size: 0.85rem;
}

.checkbox-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.checkbox-chip,
.radio-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.checkbox-chip input,
.radio-chip input {
    margin: 0;
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

.checkbox-chip span,
.radio-chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(148, 163, 184, 0.12);
    font-weight: 600;
    color: var(--text-color);
    transition: background 0.2s ease, border 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.checkbox-chip:hover span,
.radio-chip:hover span,
.checkbox-chip:focus-within span,
.radio-chip:focus-within span {
    transform: translateY(-1px);
    border-color: rgba(79, 70, 229, 0.4);
    background: rgba(79, 70, 229, 0.12);
    color: var(--primary);
}

.checkbox-chip input:checked + span,
.radio-chip input:checked + span {
    border-color: rgba(79, 70, 229, 0.55);
    background: rgba(79, 70, 229, 0.18);
    color: var(--primary);
}

.bulk-tag-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bulk-tag-form fieldset {
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.2rem 1rem 1rem;
    background: rgba(255, 255, 255, 0.82);
    position: relative;
}

.bulk-tag-form legend {
    font-weight: 600;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-color);
    padding: 0 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
}

.bulk-tag-mode,
.bulk-tag-options {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.bulk-tag-form .field-hint {
    margin-top: 0.4rem;
}

.select-column {
    width: 3rem;
    text-align: center;
    vertical-align: middle;
}

.select-column input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
}

.form-field.tag-filter-field {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.2rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: var(--surface-color);
    position: relative;
}

.form-field.tag-filter-field legend {
    font-weight: 600;
    color: var(--text-color);
    padding: 0 0.6rem;
    border-radius: 999px;
    background: var(--surface-color);
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
}

.class-filter-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.class-filter-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.class-filter-form .filter-field {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    background: var(--surface-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.class-filter-form .filter-field legend {
    font-weight: 600;
    color: var(--text-color);
    background: var(--surface-color);
    border-radius: 999px;
    padding: 0 0.45rem;
    align-self: flex-start;
    margin-bottom: 0.25rem;
}

.class-filter-form .filter-layout {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 960px) {
    .class-filter-form .filter-layout {
        grid-template-columns: minmax(220px, 260px) 1fr;
    }
}

.column-chip-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
}

.filter-main .tag-collection {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.result-meta {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.class-status summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.class-status summary::marker {
    color: var(--primary);
}

.class-status .status-section {
    margin-bottom: 1rem;
}

.class-status .member-list {
    list-style: none;
    padding: 0;
    margin: 0.4rem 0 0;
    display: grid;
    gap: 0.35rem;
}

.class-status .member-list li {
    font-size: 0.92rem;
    color: var(--text-muted);
}

.grid.two-column {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    margin-bottom: 1.5rem;
}

.form-inline {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

.form-inline input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.85);
}

.tag-manage-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.tag-manage-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.6);
}

.inline-form {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    margin-right: 0.35rem;
}

.inline-form input[type="text"] {
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.85);
}

.responsive-table {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th,
td {
    text-align: left;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

th {
    background: rgba(79, 70, 229, 0.08);
    font-weight: 600;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.row-actions form {
    margin: 0;
}

.table-control {
    display: inline-flex;
    align-items: center;
    width: 100%;
}

.select-control {
    max-width: 180px;
}

.select-shell {
    position: relative;
    width: 100%;
}

.select-shell select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    padding: 0.55rem 2.4rem 0.55rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(79, 70, 229, 0.18);
    background: rgba(79, 70, 229, 0.08);
    font: inherit;
    color: inherit;
    cursor: pointer;
    transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.select-shell select option {
    color: var(--text-color);
    background: var(--surface-color);
}

.select-shell::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0.9rem;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: translateY(-50%) rotate(45deg);
    pointer-events: none;
}

.select-shell select:focus {
    outline: none;
    border-color: rgba(79, 70, 229, 0.55);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
    background: rgba(79, 70, 229, 0.12);
}

.table-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.9);
    font: inherit;
    color: inherit;
    transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.table-input::placeholder {
    color: rgba(148, 163, 184, 0.8);
}

.table-input:focus {
    outline: none;
    border-color: rgba(79, 70, 229, 0.45);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
    background: rgba(255, 255, 255, 1);
}

.muted-text {
    color: var(--text-subtle);
}

.action-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.tag-summary h1 {
    margin-top: 0;
}

.tag-path {
    color: var(--text-muted);
    margin: 0.35rem 0 0;
}

.tag-users {
    margin-top: 1.5rem;
}

.tree-card {
    overflow: hidden;
}

.tag-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.2rem;
}

@media (prefers-color-scheme: dark) {
    .bulk-tag-form fieldset,
    .form-field.tag-filter-field {
        background: rgba(10, 14, 24, 0.96);
        border-color: rgba(120, 132, 214, 0.6);
    }

    .bulk-tag-form legend,
    .form-field.tag-filter-field legend {
        background: rgba(10, 14, 24, 0.96);
        color: rgba(236, 240, 255, 0.98);
    }

    .checkbox-chip span,
    .radio-chip span {
        border-color: rgba(128, 140, 228, 0.65);
        background: rgba(38, 50, 83, 0.82);
        color: rgba(224, 231, 255, 0.94);
    }

    .checkbox-chip:hover span,
    .radio-chip:hover span,
    .checkbox-chip:focus-within span,
    .radio-chip:focus-within span {
        border-color: rgba(174, 186, 255, 0.85);
        background: rgba(99, 102, 241, 0.52);
        color: rgba(245, 248, 255, 1);
    }

    .checkbox-chip input,
    .radio-chip input {
        accent-color: rgba(174, 186, 255, 0.9);
    }

    .checkbox-chip input:checked + span,
    .radio-chip input:checked + span {
        border-color: rgba(190, 200, 255, 0.9);
        background: rgba(99, 102, 241, 0.68);
        color: rgba(252, 253, 255, 1);
    }

    .table-input {
        background: rgba(12, 18, 32, 0.97);
        border-color: rgba(142, 154, 232, 0.65);
        color: rgba(248, 250, 255, 0.99);
        caret-color: rgba(248, 250, 255, 0.99);
    }

    .table-input::placeholder {
        color: rgba(202, 214, 240, 0.75);
    }

    .table-input:focus {
        background: rgba(24, 32, 56, 0.98);
        border-color: rgba(176, 190, 255, 0.88);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.45);
    }
}

.tag-node {
    position: relative;
}

.tag-node.has-children > .tag-node-card {
    padding-left: 0.85rem;
}

.tag-tree-children {
    list-style: none;
    margin: 0.8rem 0 0 1.25rem;
    padding-left: 1.25rem;
    border-left: 2px solid var(--border-strong);
    display: grid;
    gap: 1rem;
}

.tag-tree-children.is-collapsed {
    display: none;
}

.tag-node-card {
    padding: 1rem 1.2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.7);
    transition: border 0.2s ease, transform 0.2s ease;
}

.tag-node-card:hover {
    transform: translateY(-2px);
    border-color: rgba(79, 70, 229, 0.35);
}

.tag-node-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.tag-node-header h3 {
    flex: 1;
    margin: 0;
}

.tag-node-header .muted-text {
    white-space: nowrap;
}

.tag-toggle {
    align-self: flex-start;
    border: 1px solid var(--border-strong);
    background: rgba(79, 70, 229, 0.12);
    color: var(--primary);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.tag-toggle:hover,
.tag-toggle:focus-visible {
    background: rgba(79, 70, 229, 0.22);
    border-color: rgba(79, 70, 229, 0.4);
}

.tag-toggle-icon {
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.tag-toggle[aria-expanded="false"] .tag-toggle-icon {
    transform: rotate(-135deg);
}

@media (prefers-color-scheme: dark) {
    .tag-node-card {
        background: rgba(30, 41, 59, 0.85);
        border-color: rgba(148, 163, 184, 0.22);
    }

    .tag-node-card:hover {
        border-color: rgba(165, 180, 252, 0.45);
    }

    .tag-tree-children {
        border-color: rgba(129, 140, 248, 0.28);
    }

    .tag-toggle {
        background: rgba(99, 102, 241, 0.22);
        border-color: rgba(129, 140, 248, 0.45);
        color: rgba(199, 210, 254, 0.9);
    }

    .tag-badge {
        background: rgba(129, 140, 248, 0.28);
        color: rgba(226, 232, 240, 0.95);
    }

    .tag-chip {
        background: rgba(129, 140, 248, 0.28);
        color: rgba(226, 232, 240, 0.95);
    }

    .responsive-table {
        border-color: rgba(148, 163, 184, 0.32);
    }

    th {
        background: rgba(129, 140, 248, 0.18);
        color: rgba(226, 232, 240, 0.92);
    }

    th,
    td {
        border-bottom-color: rgba(148, 163, 184, 0.22);
    }

    .tag-manage-list li {
        background: rgba(30, 41, 59, 0.7);
        border-color: rgba(148, 163, 184, 0.22);
    }

    .inline-form input[type="text"] {
        background: rgba(15, 23, 42, 0.85);
        border-color: rgba(129, 140, 248, 0.35);
        color: var(--text-color);
    }

    .link-more {
        color: rgba(196, 181, 253, 0.95);
    }
}

.admin-hero h1 {
    margin: 0 0 0.75rem;
}

.comment-item + .comment-item {
    margin-top: 0;
}

.post-actions .button {
    flex: 0 0 auto;
}

.comment-form form textarea {
    min-height: 160px;
}

.comment-form form button {
    align-self: flex-start;
}

.profile-meta {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    margin-top: 1.2rem;
}

.profile-meta h2 {
    margin: 0 0 0.5rem;
}

.profile-meta p {
    margin: 0 0 0.75rem;
}

.profile-meta .muted-text {
    margin-bottom: 0.5rem;
    display: block;
}

.messages-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.messages-container {
    display: flex;
    gap: 1.5rem;
}

.messages-sidebar {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-right: 1px solid var(--border-color);
    padding-right: 1.25rem;
}

.messages-sidebar h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
}

.messages-search {
    display: flex;
    gap: 0.5rem;
}

.messages-search input[type="text"] {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
}

.messages-search-results ul,
.messages-conversations {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.messages-conversations li a {
    display: block;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-color);
    border: 1px solid transparent;
    background: rgba(148, 163, 184, 0.08);
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.messages-conversations li.is-active a {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.12);
}

.messages-conversations li a:hover,
.messages-conversations li a:focus-visible {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.conversation-name {
    font-weight: 600;
}

.conversation-unread {
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.conversation-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.messages-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.thread-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.thread-header h2 {
    margin: 0 0 0.3rem;
    font-size: 1.3rem;
}

.thread-note {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.thread-note.danger {
    color: var(--danger-dark);
}

.thread-preference-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.thread-preference-form select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
}

.messages-list {
    flex: 1;
    padding: 1rem;
    background: rgba(148, 163, 184, 0.08);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 480px;
    overflow-y: auto;
}

.message-item {
    max-width: min(70%, 460px);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--surface-color);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    position: relative;
}

.message-item.from-self {
    margin-left: auto;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}

.message-item.from-them {
    margin-right: auto;
}

.message-meta {
    font-size: 0.75rem;
    color: var(--text-subtle);
    margin-bottom: 0.3rem;
}

.message-item.from-self .message-meta {
    color: rgba(255, 255, 255, 0.85);
}

.message-body {
    word-break: break-word;
    line-height: 1.55;
}

.message-item.from-self .message-body {
    color: #fff;
}

.messages-compose {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.messages-compose textarea {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 1rem;
    resize: vertical;
    min-height: 120px;
}

.messages-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(148, 163, 184, 0.08);
}

@media (max-width: 900px) {
    .messages-container {
        flex-direction: column;
    }

    .messages-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 1rem;
    }

    .messages-list {
        max-height: none;
    }
}

@media (max-width: 768px) {
    .top-nav {
        flex-wrap: wrap;
    }

    .nav-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        background: var(--surface-color);
        border-radius: var(--radius-md);
        padding: 0.75rem;
        border: 1px solid var(--border-color);
    }

    .nav-links.is-open {
        display: flex;
    }

    .post-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    table {
        min-width: 100%;
    }
}

@media (max-width: 540px) {
    .card {
        padding: 1.35rem;
    }

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline input[type="text"] {
        width: 100%;
    }

    .action-group {
        flex-direction: column;
        align-items: stretch;
    }
}
