html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f4f7fb;
    color: #152033;
}

* {
    box-sizing: border-box;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

img,
svg {
    max-width: 100%;
}

.center-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(440px, 100%);
    background: #ffffff;
    border: 1px solid #d9e2ef;
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 20px 55px rgba(30, 44, 70, 0.12);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 28px;
    background: #ffffff;
    border-bottom: 1px solid #d9e2ef;
}

.topbar h1 {
    margin: 8px 0 0;
    font-size: 28px;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.topbar-actions,
.brand-row,
.button-row,
.tag-row,
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #17324d;
    color: #ffffff;
    font-weight: 700;
}

.version {
    color: #607089;
    font-size: 13px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: #e8f1ff;
    color: #1f5f9f;
    font-size: 12px;
    font-weight: 700;
}

.badge.soft {
    background: #edf3f0;
    color: #386653;
}

.badge.warning {
    background: #fff1d6;
    color: #8a5700;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    min-height: 0;
    min-width: 0;
}

.article-index {
    padding: 20px;
    border-right: 1px solid #d9e2ef;
    background: #fbfcfe;
    min-height: 0;
}

.article-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.field-label {
    display: block;
    margin: 0 0 6px;
    color: #607089;
    font-size: 12px;
    font-weight: 700;
}

.area-select {
    margin-bottom: 12px;
}

.article-card {
    display: grid;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: #ffffff;
    color: #152033;
    border: 1px solid #d9e2ef;
    border-radius: 8px;
    padding: 14px;
    min-width: 0;
}

.article-card.active {
    border-color: #2b6cb0;
    box-shadow: inset 3px 0 0 #2b6cb0;
}

.article-card span:first-child {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.article-card small {
    color: #607089;
    line-height: 1.45;
}

.article-owner {
    color: #386653;
    font-size: 12px;
    font-weight: 700;
}

.content-area {
    min-width: 0;
    padding: 20px 28px 32px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.tab {
    border: 1px solid #cbd6e2;
    border-radius: 8px;
    background: #ffffff;
    color: #43536a;
    padding: 9px 14px;
}

.tab.active {
    background: #17324d;
    border-color: #17324d;
    color: #ffffff;
}

.article-view,
.editor-panel,
.admin-create,
.user-card,
.empty-state {
    background: #ffffff;
    border: 1px solid #d9e2ef;
    border-radius: 8px;
    padding: 22px;
}

.article-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 20px;
    min-width: 0;
}

.article-header h2 {
    margin-bottom: 8px;
    font-size: 24px;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.article-header p {
    color: #607089;
    line-height: 1.55;
}

.stack,
.editor-panel,
.admin-create,
.user-card {
    display: grid;
    gap: 12px;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 18px;
    align-items: start;
}

.user-list {
    display: grid;
    gap: 12px;
}

.input,
.code-editor {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd6e2;
    border-radius: 8px;
    background: #ffffff;
    color: #152033;
    padding: 11px 12px;
    outline: none;
}

.input:focus,
.code-editor:focus {
    border-color: #2b6cb0;
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.title-input {
    font-size: 22px;
    font-weight: 700;
}

.code-editor {
    min-height: 420px;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    line-height: 1.55;
}

.button,
.icon-button {
    border: 1px solid transparent;
    border-radius: 8px;
    min-height: 40px;
    padding: 0 14px;
    font-weight: 700;
}

.button.primary,
.icon-button {
    background: #2b6cb0;
    color: #ffffff;
}

.button.secondary {
    background: #ffffff;
    color: #17324d;
    border-color: #cbd6e2;
}

.button.danger {
    background: #b42318;
    color: #ffffff;
}

.icon-button {
    width: 42px;
    padding: 0;
    font-size: 22px;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #43536a;
}

.message {
    border-radius: 8px;
    padding: 12px 14px;
    margin: 16px 0 0;
}

.message.error {
    background: #fff0ed;
    color: #9b1c13;
    border: 1px solid #f7c7c0;
}

.message.success {
    background: #eaf7ef;
    color: #276749;
    border: 1px solid #bfe6ca;
}

.markdown-body {
    line-height: 1.7;
    color: #26384f;
    overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin-top: 1.5em;
    letter-spacing: 0;
}

.markdown-body pre {
    overflow-x: auto;
    border-radius: 8px;
    background: #111827;
    color: #e5edf7;
    padding: 16px;
}

.markdown-body code {
    border-radius: 6px;
    background: #edf2f7;
    color: #9b2c2c;
    padding: 2px 5px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

#blazor-error-ui {
    display: none;
}

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: minmax(260px, 320px) 1fr;
    }

    .content-area {
        padding: 18px 22px 28px;
    }

    .admin-grid {
        grid-template-columns: 320px 1fr;
    }
}

@media (max-width: 900px) {
    .topbar,
    .article-header {
        align-items: stretch;
        flex-direction: column;
    }

    .workspace,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .workspace {
        display: block;
    }

    .topbar {
        padding: 16px 20px;
    }

    .topbar-actions {
        justify-content: space-between;
    }

    .article-index {
        border-right: 0;
        border-bottom: 1px solid #d9e2ef;
        padding: 16px 20px;
    }

    .article-list {
        display: flex;
        overflow-x: auto;
        gap: 12px;
        padding-bottom: 4px;
        scroll-snap-type: x proximity;
    }

    .article-card {
        flex: 0 0 min(360px, 78vw);
        scroll-snap-align: start;
    }

    .content-area {
        padding: 18px 20px 28px;
    }

    .tabs {
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .tab {
        flex: 0 0 auto;
    }

    .button-row {
        align-items: stretch;
    }

    .code-editor {
        min-height: 340px;
    }
}

@media (max-width: 640px) {
    .center-shell {
        align-items: stretch;
        padding: 14px;
    }

    .auth-card {
        align-self: center;
        padding: 20px;
    }

    .topbar {
        padding: 14px 16px;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .topbar-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .topbar-actions .button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .brand-mark {
        width: 32px;
        height: 32px;
    }

    .article-index {
        padding: 14px 16px;
    }

    .toolbar {
        display: grid;
        grid-template-columns: 1fr 42px;
        align-items: stretch;
    }

    .article-card {
        flex-basis: 84vw;
        padding: 12px;
    }

    .content-area {
        padding: 16px;
    }

    .article-view,
    .editor-panel,
    .admin-create,
    .user-card,
    .empty-state {
        padding: 16px;
    }

    .article-header h2 {
        font-size: 21px;
    }

    .button-row {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .button-row .button {
        width: 100%;
    }

    .title-input {
        font-size: 19px;
    }

    .code-editor {
        min-height: 300px;
        font-size: 14px;
    }

    .markdown-body pre {
        margin-left: -4px;
        margin-right: -4px;
        padding: 12px;
        font-size: 13px;
    }
}

@media (max-width: 420px) {
    .topbar-actions {
        grid-template-columns: 1fr;
    }

    .brand-row,
    .tag-row {
        gap: 6px;
    }

    .badge {
        min-height: 22px;
        padding: 0 8px;
        font-size: 11px;
    }

    .tabs {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }

    .tab,
    .button,
    .input,
    .code-editor {
        min-width: 0;
    }

    .article-card {
        flex-basis: 88vw;
    }
}
}
