:root {
    --mb-bg: #eef1f4;
    --mb-bg-deep: #d9e0e8;
    --mb-ink: #15202b;
    --mb-muted: #5b6775;
    --mb-brand: #c8102e;
    --mb-brand-dark: #9e0c24;
    --mb-line: rgba(21, 32, 43, 0.14);
    --mb-surface: rgba(255, 255, 255, 0.72);
    --mb-space: clamp(1rem, 2vw, 1.5rem);
    --mb-measure: min(52rem, 100%);
    --mb-font: system-ui, "Segoe UI", "Helvetica Neue", "Liberation Sans", "DejaVu Sans", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: auto;
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: var(--mb-font);
    font-size: 1.05rem;
    line-height: 1.55;
    color: var(--mb-ink);
    background:
        linear-gradient(115deg, rgba(200, 16, 46, 0.09) 0%, transparent 42%),
        linear-gradient(180deg, var(--mb-bg) 0%, var(--mb-bg-deep) 100%);
    background-attachment: fixed;
}

#app {
    width: min(100% - 2 * var(--mb-space), var(--mb-measure));
    margin: 0 auto;
    padding: clamp(2rem, 8vh, 4rem) 0 clamp(4rem, 12vh, 6rem);
    overflow: visible;
}

.mb-header {
    margin-bottom: 1.5rem;
    animation: rise 420ms ease-out both;
}

.brand {
    margin: 0 0 0.65rem;
    font-size: clamp(1.5rem, 4vw, 1.9rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--mb-brand);
}

.mb-header h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.45rem, 3.5vw, 1.9rem);
}

.lede {
    margin: 0 0 1rem;
    color: var(--mb-muted);
}

.progress {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    list-style: none;
    margin: 0;
    padding: 0.75rem 0 0;
    border-top: 1px solid var(--mb-line);
    font-size: 0.82rem;
    color: var(--mb-muted);
}

.progress-step.is-done {
    color: var(--mb-ink);
}

.progress-step.is-current,
.progress-step.is-current .progress-link {
    color: var(--mb-brand);
    font-weight: 600;
}

button.progress-link {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
}

.progress a,
.progress-link {
    color: inherit;
    text-decoration: none;
}

.progress a:hover,
.progress a:focus-visible,
.progress-link:hover,
.progress-link:focus-visible {
    color: var(--mb-brand);
    text-decoration: underline;
    outline: none;
}

.mb-panel {
    background: var(--mb-surface);
    border: 1px solid var(--mb-line);
    padding: clamp(1rem, 3vw, 1.5rem);
    animation: rise 420ms ease-out 60ms both;
    overflow: visible;
}

.section-title {
    margin: 1.25rem 0 0.65rem;
    font-size: 1.05rem;
}

.field-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.field {
    margin-bottom: 1rem;
}

.field-label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.field-input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--mb-line);
    background: #fff;
    font: inherit;
    color: inherit;
}

.field-input:focus {
    outline: 2px solid rgba(200, 16, 46, 0.35);
    outline-offset: 1px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.check-row .field-label {
    margin: 0;
    font-weight: 500;
}

.hint {
    margin: 0 0 1rem;
    color: var(--mb-muted);
    font-size: 0.95rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.25rem;
}

.btn {
    appearance: none;
    border: 1px solid var(--mb-line);
    background: #fff;
    color: var(--mb-ink);
    font: inherit;
    font-weight: 600;
    padding: 0.55rem 0.95rem;
    cursor: pointer;
    transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.btn:hover,
.btn:focus-visible {
    border-color: var(--mb-brand);
    color: var(--mb-brand-dark);
    outline: none;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--mb-brand);
    border-color: var(--mb-brand);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: var(--mb-brand-dark);
    border-color: var(--mb-brand-dark);
    color: #fff;
}

.btn-danger {
    color: var(--mb-brand-dark);
    border-color: rgba(200, 16, 46, 0.35);
}

.btn-small {
    padding: 0.3rem 0.55rem;
    font-size: 0.88rem;
    font-weight: 500;
}

.topic-list,
.sort-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.topic-item,
.sort-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.35rem 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--mb-line);
    align-items: center;
}

.topic-item-title,
.sort-title {
    font-weight: 600;
}

.topic-item-meta {
    grid-column: 1;
    color: var(--mb-muted);
    font-size: 0.9rem;
}

.topic-item-actions,
.sort-controls {
    display: flex;
    gap: 0.4rem;
    grid-row: 1 / span 2;
    grid-column: 2;
}

.topic-empty {
    color: var(--mb-muted);
    padding: 0.5rem 0;
}

.extra-row {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--mb-line);
}

.is-hidden {
    display: none !important;
}

.wysiwyg {
    border: 1px solid var(--mb-line);
    background: #fff;
}

.wysiwyg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.35rem;
    border-bottom: 1px solid var(--mb-line);
    background: rgba(238, 241, 244, 0.85);
}

.wysiwyg-btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    font: inherit;
    font-size: 0.85rem;
    padding: 0.25rem 0.45rem;
    cursor: pointer;
    color: var(--mb-ink);
}

.wysiwyg-btn:hover,
.wysiwyg-btn:focus-visible {
    border-color: var(--mb-line);
    outline: none;
}

.wysiwyg-btn.wy-bold {
    font-weight: 700;
}

.wysiwyg-btn.wy-italic {
    font-style: italic;
}

.wysiwyg-btn.wy-underline {
    text-decoration: underline;
}

.wysiwyg-emoji-wrap {
    position: relative;
    display: inline-flex;
}

.wysiwyg-emoji-panel {
    position: absolute;
    top: calc(100% + 0.2rem);
    left: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(6, 1.75rem);
    gap: 0.15rem;
    padding: 0.35rem;
    border: 1px solid var(--mb-line);
    background: #fff;
    box-shadow: 0 4px 14px rgba(21, 32, 43, 0.12);
}

.wysiwyg-emoji-btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
}

.wysiwyg-emoji-btn:hover,
.wysiwyg-emoji-btn:focus-visible {
    border-color: var(--mb-line);
    background: rgba(238, 241, 244, 0.9);
    outline: none;
}

.wysiwyg-editor {
    min-height: 6.5rem;
    padding: 0.65rem 0.75rem;
    outline: none;
}

.wysiwyg-editor blockquote {
    margin: 0.4rem 0;
    padding: 0.25rem 0.75rem;
    border-left: 3px solid var(--mb-line);
    color: var(--mb-muted);
}

.wysiwyg-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--mb-muted);
}

.preview-frame {
    width: 100%;
    min-height: 28rem;
    border: 1px solid var(--mb-line);
    background: #fff;
}

.source-area {
    width: 100%;
    min-height: 22rem;
    font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.4;
    padding: 0.75rem;
    border: 1px solid var(--mb-line);
    background: #fff;
    resize: vertical;
}

.mb-footer-nav {
    margin: 1.5rem 0 0;
}

.back-link {
    color: var(--mb-brand);
    font-weight: 600;
    text-decoration: none;
}

button.back-link {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
}

.back-link:hover,
.back-link:focus-visible {
    color: var(--mb-brand-dark);
    text-decoration: underline;
    outline: none;
}

@keyframes rise {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
