html, body {
    font-family: system-ui, -apple-system, "Noto Sans JP", "Yu Gothic", sans-serif;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.article-page {
    max-width: 1280px;
}

.auth-page {
    display: flex;
    justify-content: center;
    padding-top: 3rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
}

.article-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.article-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.article-panel {
    border: 1px solid #d7dee8;
    border-radius: 8px;
    padding: 1rem;
    background: #fff;
}

.article-table-wrap {
    border: 1px solid #d7dee8;
    border-radius: 8px;
}

.article-table {
    margin-bottom: 0;
}

.article-table th {
    white-space: nowrap;
    color: #3d4852;
    background: #f6f8fb;
}

.article-col-compact {
    width: 1%;
    white-space: nowrap;
}

.article-col-actions {
    width: 1%;
}

.article-col-actions .d-flex {
    flex-wrap: nowrap;
}

.article-col-actions .btn {
    white-space: nowrap;
}

.article-tags-cell {
    max-width: 9rem;
}

.article-col-tags {
    max-width: 9rem;
}

.article-tags-cell .badge {
    margin: 0 0.25rem 0.25rem 0;
}

.article-memo-cell {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-disabled-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.article-disabled-hint {
    color: #8a94a3;
    font-size: 0.78rem;
}

.article-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.45);
}

.article-dialog {
    width: min(34rem, 100%);
    /* Matches the backdrop's 1rem padding on each side, so a dialog taller than the
       viewport scrolls internally instead of overflowing top and bottom with its own
       action buttons left unreachable (mobile-ui-dialog-review-2026-09-17 review). */
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    border-radius: 8px;
    padding: 1rem;
    background: #fff;
    box-shadow: 0 1rem 3rem rgba(15, 23, 42, 0.2);
}

.article-title-candidate-list {
    display: grid;
    gap: 0.5rem;
    max-height: 20rem;
    overflow-y: auto;
}

.article-title-candidate {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    cursor: pointer;
}

.article-title-candidate:has(input:checked) {
    border-color: #6b7a8c;
    background: #f6f8fb;
}

.article-title-candidate input[type="radio"] {
    margin-top: 0.3rem;
}

.article-title-candidate-text {
    display: block;
    font-weight: 600;
}

.article-title-candidate-reason {
    display: block;
    color: #667386;
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.article-heading-list {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0;
}

.article-preview-page {
    max-width: 920px;
}

.article-preview-heading {
    min-width: 0;
}

.article-preview-back {
    flex-shrink: 0;
    white-space: nowrap;
}

.article-preview-description {
    max-width: 48rem;
    margin: 0.35rem 0 0;
    color: #536172;
}

.article-preview-body {
    line-height: 1.85;
    color: #1d2733;
}

.article-preview-body h2 {
    margin-top: 2rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #d7dee8;
    font-size: 1.55rem;
}

.article-preview-body h3 {
    margin-top: 1.5rem;
    font-size: 1.2rem;
}

.article-preview-body p,
.article-preview-body ul,
.article-preview-body ol,
.article-preview-body blockquote {
    margin-bottom: 1rem;
}

.article-preview-body blockquote {
    padding: 0.75rem 1rem;
    border-left: 4px solid #6b7a8c;
    background: #f7f9fc;
}

.article-editor-grid {
    display: grid;
    grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.article-editor-sidebar,
.article-editor-main {
    display: grid;
    gap: 1rem;
}

.article-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

@media (min-width: 769px) and (min-height: 431px) {
    .article-editor-toolbar {
        /* Sit below MainLayout's sticky .top-row (height 3.5rem) instead of covering it. */
        top: 3.5rem;
    }
}

.article-editor-actions,
.article-section-header,
.article-heading-editor-footer,
.article-heading-save {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.article-editor-actions {
    flex-wrap: wrap;
}

.article-section-header {
    justify-content: space-between;
    margin-bottom: 0.9rem;
}

.article-section-header h2 {
    margin-bottom: 0;
}

.article-period-break {
    margin-bottom: 0;
}

.article-outline-tree {
    display: grid;
    gap: 0.4rem;
}

.article-outline-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
    color: #243244;
    background: #fff;
    text-align: left;
}

.article-outline-item:hover,
.article-outline-item.active {
    border-color: #6b7a8c;
    background: #f6f8fb;
}

.article-outline-item-child {
    width: calc(100% - 1.25rem);
    margin-left: 1.25rem;
}

.article-outline-title {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.55;
}

.article-outline-count {
    color: #667386;
    font-size: 0.85rem;
}

.article-body-editor {
    min-height: 28rem;
    resize: vertical;
}

.article-heading-editor-footer {
    justify-content: space-between;
    flex-wrap: wrap;
}

.article-heading-settings {
    display: grid;
    grid-template-columns: auto 7rem auto;
    gap: 0.5rem;
    align-items: center;
}

.article-heading-settings .form-label,
.article-heading-settings .form-check {
    margin-bottom: 0;
}

.article-editor-danger {
    margin-top: 1rem;
}

.article-empty-state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1.5rem;
    border: 1px dashed #d7dee8;
    border-radius: 8px;
    background: #f6f8fb;
}

.admin-user-table td {
    vertical-align: middle;
}

.admin-user-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    white-space: nowrap;
}

.admin-number-input {
    min-width: 7rem;
}

.admin-id-cell {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-audit-summary {
    min-width: 16rem;
}

@media (max-width: 768px) {
    .article-page-header {
        flex-direction: column;
    }

    .article-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .article-editor-grid {
        grid-template-columns: 1fr;
    }

    .article-heading-settings {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .article-heading-save {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    /* Mobile: stack table rows as cards instead of a table that needs horizontal scroll to
       reach the title or the row actions. Column order is reshuffled per-cell (title/status/
       actions first, supplementary fields after) via `order`, independent of source order so
       the desktop table markup and column order stay unchanged. */
    .article-table thead {
        display: none;
    }

    .article-table,
    .article-table tbody {
        display: block;
        width: 100%;
    }

    .article-table tbody tr {
        display: flex;
        flex-direction: column;
        border: 1px solid #d7dee8;
        border-radius: 8px;
        padding: 0.65rem 0.75rem;
        margin-bottom: 0.65rem;
    }

    .article-table tbody td {
        display: block;
        width: 100%;
        border: none !important;
        padding: 0.2rem 0;
        overflow-wrap: anywhere;
    }

    .article-table tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        color: #667386;
        font-size: 0.75rem;
    }

    .article-table tbody td.article-col-actions .d-flex {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    /* Bootstrap's .badge is `white-space: nowrap`, which blocks the tbody td's
       `overflow-wrap: anywhere` from ever taking effect: nowrap suppresses all wrap
       opportunities before overflow-wrap gets a say. A tag at the 50-char limit
       (ArticleService's per-tag cap) then renders as one unbroken run wider than the
       card, reintroducing horizontal scroll (mobile-ui-second-followup-2026-09-17 review). */
    .article-tags-cell {
        max-width: none;
    }

    .article-tags-cell .badge {
        white-space: normal;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .admin-user-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        white-space: normal;
    }

    .article-table:not(.admin-user-table) tbody td:nth-child(4) { order: 1; font-size: 1.05rem; }
    .article-table:not(.admin-user-table) tbody td:nth-child(3) { order: 2; }
    .article-table:not(.admin-user-table) tbody td:nth-child(7) { order: 3; }
    .article-table:not(.admin-user-table) tbody td:nth-child(1) { order: 4; }
    .article-table:not(.admin-user-table) tbody td:nth-child(2) { order: 5; }
    .article-table:not(.admin-user-table) tbody td:nth-child(5) { order: 6; }
    .article-table:not(.admin-user-table) tbody td:nth-child(6) { order: 7; }

    .admin-user-table tbody td:nth-child(1) { order: 1; }
    .admin-user-table tbody td:nth-child(8) { order: 2; }
    .admin-user-table tbody td:nth-child(2) { order: 3; }
    .admin-user-table tbody td:nth-child(3) { order: 4; }
    .admin-user-table tbody td:nth-child(4) { order: 5; }
    .admin-user-table tbody td:nth-child(5) { order: 6; }
    .admin-user-table tbody td:nth-child(6) { order: 7; }
    .admin-user-table tbody td:nth-child(7) { order: 8; }
}

@media (max-width: 640.98px), (max-height: 430px) {
    /* The editor toolbar wraps onto three rows at narrow widths; sticky there permanently
       covers ~23% of an SE-height viewport (mobile-ui-review-2026-09-16 report, finding #3)
       and strands the "記事情報を編集" panel off-screen when it expands (finding #4). Letting
       it scroll with the page fixes both: the trigger and the panel it reveals stay together.
       The max-height arm covers landscape phones (e.g. SE 667x375): width alone stays above
       641px there, which would otherwise leave both the sticky toolbar and the PC-style sidebar
       layout active on a viewport too short for either (mobile-ui-followup-2026-09-16 review). */
    .article-editor-toolbar {
        position: static;
    }

    .btn:not(.btn-sm) {
        min-height: 44px;
    }

    .article-col-actions .btn,
    .admin-user-actions .btn {
        min-height: 44px;
    }

    .top-row ::deep .btn-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* Editing and navigation keep the current task visible on small screens. */
body { background: #f5f7fb; color: #243244; }
h1 { font-size: clamp(1.55rem, 2vw, 2rem); font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.article-panel { border-color: #e0e5ed; border-radius: 12px; }
.article-page { margin-inline: auto; padding-bottom: 2rem; }
.btn { border-radius: 7px; }
.btn-primary { background: #245eae; border-color: #245eae; }
.btn-primary:hover { background: #194a8e; border-color: #194a8e; }
.required-label { color: #a32231; font-size: .75rem; }
summary { cursor: pointer; font-weight: 600; padding-block: .35rem; }
details[open] > summary { margin-bottom: .75rem; }
summary:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #258cfb; outline-offset: 3px; }
.app-dialog { border: 0; margin: auto; max-width: calc(100vw - 2rem); max-height: calc(100dvh - 2rem); }
.app-dialog::backdrop { background: rgba(15, 23, 42, .5); }
body:has(dialog[open]) { overflow: hidden; }
.guest-mode-banner { background: #eaf2fc; border: 1px solid #c9ddf4; border-radius: 8px; padding: .4rem .8rem; margin-bottom: 1rem; font-size: .875rem; }
.guest-mode-banner summary { font-weight: 400; }
.editor-fields { min-width: 0; }
.editor-mobile-switch, .search-toggle { display: none; }
.article-editor-main, .article-editor-sidebar { min-width: 0; }
.article-editor-toolbar { box-shadow: 0 3px 12px #2432440c; }
.editor-save-state { font-size: .8rem; color: #45566b; }
.editor-feedback { font-size: .875rem; color: #365170; margin-top: .5rem; }
.article-outline-item.active { border-left: 4px solid #245eae; padding-left: calc(.65rem - 3px); font-weight: 600; background: #eaf2fc; }
.article-outline-tree { max-height: 65vh; overflow-y: auto; padding: .2rem; }
.article-heading-editor-footer { padding: .65rem 0; background: #fff; border-top: 1px solid #e0e5ed; }
.generation-status { padding: .4rem .65rem; background: #edf5fd; border-radius: 6px; margin-bottom: .5rem; font-size: .875rem; }
.preview-toc { margin-bottom: 1.5rem; }
.preview-toc ol { padding-left: 1.4rem; }
.preview-toc li { padding-block: .3rem; }
.preview-toc .level-3 { margin-left: 1.2rem; }
.preview-edit-link { font-size: .8rem; margin-left: .75rem; white-space: nowrap; }
.article-preview-body h2, .article-preview-body h3, #article-meta, #heading-editor { scroll-margin-top: 11rem; }
@media (max-width: 768px), (max-height: 430px) {
    .content { padding-inline: 1rem !important; }
    .article-editor-toolbar { position: static; padding: .7rem; }
    .article-editor-actions { gap: .5rem; }
    .editor-mobile-switch { display: flex; gap: .5rem; margin-bottom: .75rem; }
    .article-editor-grid { grid-template-columns: 1fr; }
    .article-editor-grid.show-body .article-editor-sidebar,
    .article-editor-grid.show-outline .article-editor-main { display: none; }
    .article-outline-tree { max-height: none; }
    .article-body-editor { min-height: 16rem; height: clamp(16rem, 45dvh, 24rem); }
    .article-heading-editor-footer { position: static; }
    .article-heading-settings { grid-template-columns: auto minmax(4rem, 6rem); }
    .article-heading-settings .form-check { grid-column: 1 / -1; }
    .search-toggle { display: inline-block; padding: 0; }
    .search-fields:not(.expanded) { display: none; }
    .search-fields.expanded { margin-top: .4rem; }
    .auth-page { padding-top: 1rem; }
    .article-page-header { gap: .6rem; }
    .article-preview-body h2, .article-preview-body h3, #article-meta, #heading-editor { scroll-margin-top: 1rem; }
}

.article-preview-heading { max-width: 100%; }
.article-preview-body { overflow-wrap: anywhere; }
.create-settings-group + .create-settings-group { border-top: 1px solid #e0e5ed; padding-top: 1rem; }

.article-settings-page .article-panel > .d-flex > .btn { flex-shrink: 0; white-space: nowrap; }
.notification-summary { min-width: 0; overflow-wrap: anywhere; }

/* Bulk creation: keep configuration, actionable work, and completed history distinct. */
.bulk-form .bulk-settings-group { margin: 1.1rem 0 0; padding: 1rem 0 0; border: 0; border-top: 1px solid #e0e5ed; min-width: 0; }
.bulk-form fieldset legend { float: none; width: auto; margin-bottom: .35rem; }
.bulk-form [aria-invalid="true"] { border-color: #b42318; }
.bulk-start { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.2rem; padding: 1rem; background: #f3f5fb; border-radius: 8px; }
.bulk-start .btn { flex-shrink: 0; }
.bulk-start p { color: #49566a; overflow-wrap: anywhere; }
.bulk-progress-header { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: .75rem; }
.bulk-batch-picker { max-width: 28rem; margin-top: 1rem; }
.bulk-counts { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: 1rem; }
.bulk-badge { display: inline-block; width: fit-content; padding: .25rem .65rem; border-radius: 5px; font-size: .85rem; font-weight: 600; }
.bulk-running { background: #e8edff; color: #3349a2; }
.bulk-failed { background: #fce9e7; color: #9d2018; }
.bulk-stopped { background: #fff1d6; color: #805214; }
.bulk-succeeded { background: #e4f2e9; color: #24643d; }
.bulk-progress-row { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: .65rem 1rem; padding-block: .9rem; border-top: 1px solid #e0e5ed; }
.bulk-row-main { display: flex; flex-direction: column; gap: .35rem; min-width: 0; flex: 1 1 14rem; }
.bulk-row-main progress { width: min(100%, 20rem); accent-color: #5945c6; }
.bulk-row-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.bulk-row-note { flex-basis: 100%; overflow-wrap: anywhere; }
.bulk-warning { color: #805214; }
.bulk-complete-heading { color: #24643d; font-weight: 600; }
.bulk-completed { margin-top: .5rem; }
.bulk-completed summary { color: #49566a; }
@media (max-width: 768px) {
    .bulk-progress .btn, .bulk-resume, .bulk-form .btn, .bulk-form summary { min-height: 44px; }
    .bulk-form .btn-close { min-width: 44px; }
    .bulk-start { flex-direction: column; align-items: stretch; padding: .8rem; }
    .bulk-row-actions { width: 100%; }
    .bulk-progress-header .btn { font-size: .9rem; }
}
