html,
body {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    margin: 0;
}

html.mh-theme-light,
html.mh-theme-light body {
    background: #ffffff;
    color: #271333;
    color-scheme: light;
}

html.mh-theme-dark,
html.mh-theme-dark body {
    background: #0f0718;
    color: #f7f2ff;
    color-scheme: dark;
}

html.mh-theme-dark .mud-layout,
html.mh-theme-dark .mh-layout-root,
html.mh-theme-dark .mh-main,
html.mh-theme-dark .mud-main-content {
    background: #0f0718 !important;
    color: #f7f2ff !important;
}

html.mh-theme-dark .mh-appbar,
html.mh-theme-dark .mud-appbar.mh-appbar {
    background: color-mix(in srgb, #160d22 92%, transparent) !important;
    border-bottom-color: #3d2855 !important;
    color: #f7f2ff !important;
}

html.mh-theme-dark .mh-drawer,
html.mh-theme-dark .mud-drawer.mh-drawer {
    background: #160d22 !important;
    border-right-color: #3d2855 !important;
    color: #f7f2ff !important;
}

html.mh-theme-dark .mh-mobile-nav {
    background: color-mix(in srgb, #160d22 94%, transparent) !important;
    border-top-color: #3d2855 !important;
    color: #f7f2ff !important;
}

html.mh-theme-light .mud-layout,
html.mh-theme-light .mh-layout-root,
html.mh-theme-light .mh-main,
html.mh-theme-light .mud-main-content {
    background: #ffffff;
    color: #271333;
}

a {
    color: inherit;
    text-decoration: none;
}

.mh-hero {
    background:
        linear-gradient(135deg, rgba(124, 58, 237, .18), rgba(196, 181, 253, .08)),
        var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 8px;
    padding: clamp(1.5rem, 5vw, 4rem);
}

.mh-hero-copy {
    max-width: 760px;
}

.mh-home-hero {
    align-items: stretch;
    background:
        radial-gradient(circle at top right, rgba(167, 139, 250, .22), transparent 34rem),
        linear-gradient(135deg, rgba(124, 58, 237, .14), rgba(255, 255, 255, 0)),
        var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 8px;
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
    padding: clamp(1.5rem, 5vw, 3rem);
}

.mh-home-pulse {
    align-self: stretch;
    background: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 28%, var(--mud-palette-divider));
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    justify-content: center;
    padding: 1.25rem;
}

.mh-home-tile {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    height: 100%;
    min-height: 190px;
    transition: border-color .16s ease, transform .16s ease;
}

.mh-home-tile:hover {
    border-color: var(--mud-palette-primary);
    transform: translateY(-2px);
}

.mh-page-title {
    margin-bottom: .25rem;
}

.mh-page-heading {
    min-width: 0;
}

.mh-page-actions {
    justify-content: flex-end;
}

.mh-filter {
    min-width: 180px;
}

.mh-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.mh-card .mud-card-content {
    flex: 1;
}

.mh-card-summary {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mh-cover {
    aspect-ratio: 2 / 3;
    background: var(--mud-palette-lines-default);
    object-fit: cover;
    width: 100%;
}

.mh-match-cover {
    aspect-ratio: 2 / 3;
    border-radius: 6px;
    flex: 0 0 72px;
    object-fit: cover;
    width: 72px;
}

.mh-wizard-cover {
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    flex: 0 0 120px;
    object-fit: cover;
    width: 120px;
}

.mh-modal-backdrop {
    align-items: center;
    background: rgba(10, 3, 18, .62);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: clamp(1rem, 4vw, 2rem);
    position: fixed;
    z-index: 1500;
}

.mh-modal {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(10, 3, 18, .38);
    max-height: min(90vh, 920px);
    max-width: 980px;
    overflow: auto;
    padding: clamp(1rem, 3vw, 1.5rem);
    width: min(100%, 980px);
}

.mh-modal-header {
    gap: 1rem;
}

.mh-selected-manga {
    min-width: 0;
}

.mh-modal-cover {
    aspect-ratio: 2 / 3;
    background: var(--mud-palette-lines-default);
    border-radius: 8px;
    flex: 0 0 96px;
    object-fit: cover;
    width: 96px;
}

.mh-filter-modal {
    max-width: 760px;
}

.mh-card-metadata-modal {
    max-width: 860px;
}

.reader-toolbar {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
    padding: .75rem;
    position: sticky;
    top: 76px;
    z-index: 2;
}

.reader {
    display: grid;
    justify-items: center;
    padding-bottom: 2rem;
}

.reader img {
    background: #05020a;
    border-radius: 8px;
    max-width: min(100%, 980px);
    min-height: 60vh;
    object-fit: contain;
}

.mh-reader-state {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: center;
    min-height: 45vh;
    padding: 2rem;
}

.mh-reader-shell {
    min-height: calc(100vh - 120px);
}

.mh-reader-session-toolbar {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: .85rem 1rem;
    position: sticky;
    top: 76px;
    z-index: 3;
}

.mh-reader-title {
    min-width: 0;
}

.mh-reader-title .mud-typography-h2 {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mh-reader-actions {
    flex: 0 0 auto;
    justify-content: flex-end;
}

.mh-reader-frame-wrap {
    background:
        radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--mud-palette-primary) 16%, transparent), transparent 28rem),
        #08040d;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 8px;
    min-height: calc(100vh - 220px);
    overflow: hidden;
    position: relative;
}

.mh-reader-frame {
    background: #fff;
    border: 0;
    display: block;
    height: calc(100vh - 220px);
    min-height: 620px;
    width: 100%;
}

.mh-reader-frame-loading {
    align-items: center;
    background: color-mix(in srgb, #160d22 82%, transparent);
    color: #fffaff;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    inset: 0;
    justify-content: center;
    pointer-events: none;
    position: absolute;
}

.mh-reader-fallback-modal {
    max-width: 620px;
}

html body .mh-row-card .mh-bento-host,
html body .mh-row-card .mh-bento-host .mh-bento-grid,
html body .mh-row-card .mh-bento-host .bzb-grid {
    --mh-bento-item-min-height: 52px !important;
    --mh-bento-row-height: 52px !important;
    --bzb-item-min-height: 52px !important;
    --bzb-row-height: 52px !important;
}

html body .mh-row-card .mh-bento-host .mh-bento-grid,
html body .mh-row-card .mh-bento-host .bzb-grid {
    grid-auto-rows: 52px !important;
}

html body .mh-row-card .mh-bento-host .bzb-item {
    min-height: 0 !important;
}

html body .mh-row-card {
    align-items: stretch !important;
    display: grid !important;
    grid-template-columns: 164px minmax(0, 1fr) !important;
    min-height: 176px !important;
    overflow: hidden !important;
}

html body .mh-row-card > .mh-cover-frame {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface)) !important;
    border-right: 1px solid var(--mud-palette-divider) !important;
    min-height: 100% !important;
    overflow: hidden !important;
    position: relative !important;
}

html body .mh-row-card > .mh-cover-frame .mh-row-cover {
    display: block !important;
    height: 100% !important;
    min-height: 176px !important;
    object-fit: cover !important;
    width: 100% !important;
}

html body .mh-row-card > .mh-bento-card-content,
html body .mh-row-card > .mud-card-content.mh-bento-card-content {
    min-width: 0 !important;
}

html body .mh-row-card .mh-bento-card-actions,
html body .mh-row-card .mud-card-actions.mh-bento-card-actions {
    align-items: center !important;
    border-top: 1px solid var(--mud-palette-divider) !important;
    display: flex !important;
    gap: .5rem !important;
    justify-content: flex-end !important;
    margin-top: .65rem !important;
    padding: .75rem 0 0 !important;
    width: 100% !important;
}

#blazor-error-ui {
    background: #fff7ed;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .12);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: .75rem 1rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
}

.loading-progress {
    display: block;
    height: 8rem;
    margin: 20vh auto 1rem;
    width: 8rem;
}

.loading-progress circle {
    fill: none;
    stroke: #e9d5ff;
    stroke-width: .6rem;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: #7c3aed;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
}

html.mh-theme-dark .loading-progress circle {
    stroke: #3d2855;
}

html.mh-theme-dark .loading-progress circle:last-child {
    stroke: #c4b5fd;
}

.loading-progress-text {
    font-weight: 700;
    text-align: center;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 720px) {
    .mh-page-title {
        align-items: start !important;
        display: grid !important;
        gap: .75rem !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
    }

    .mh-page-kicker,
    .mh-page-subtitle {
        display: none !important;
    }

    .mh-page-actions {
        align-items: center !important;
        justify-content: flex-end !important;
        justify-self: end;
    }

    .mh-home-hero {
        grid-template-columns: 1fr;
    }

    .reader-toolbar {
        top: 64px;
    }

    .mh-reader-session-toolbar {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
        top: 64px;
    }

    .mh-reader-actions {
        justify-content: stretch;
    }

    .mh-reader-actions .mud-button-root {
        flex: 1 1 0;
    }

    .mh-reader-frame,
    .mh-reader-frame-wrap {
        min-height: calc(100vh - 250px);
    }

    .mh-modal-backdrop {
        align-items: stretch;
        padding: .75rem;
    }

    .mh-modal {
        max-height: calc(100vh - 1.5rem);
    }

    .mh-modal-cover {
        flex-basis: 72px;
        width: 72px;
    }
}

@media (max-width: 600px) {
    html body .mh-row-card {
        grid-template-columns: 1fr !important;
    }

    html body .mh-row-card > .mh-cover-frame {
        border-bottom: 1px solid var(--mud-palette-divider) !important;
        border-right: 0 !important;
        max-height: 280px !important;
    }

    html body .mh-row-card > .mh-cover-frame .mh-row-cover {
        height: 280px !important;
        max-height: 280px !important;
        min-height: 280px !important;
        width: 100% !important;
    }

    html body .mh-row-card .mh-bento-host,
    html body .mh-row-card .mh-bento-host .mh-bento-grid,
    html body .mh-row-card .mh-bento-host .bzb-grid {
        --mh-bento-item-min-height: 92px !important;
        --mh-bento-row-height: 92px !important;
        --bzb-item-min-height: 92px !important;
        --bzb-row-height: 92px !important;
    }

    html body .mh-row-card .mh-bento-host .mh-bento-grid,
    html body .mh-row-card .mh-bento-host .bzb-grid {
        grid-auto-rows: auto !important;
    }

    html body .mh-row-card .mh-bento-host.mh-entry-bento .mh-bento-grid,
    html body .mh-row-card .mh-bento-host.mh-entry-bento .bzb-grid {
        display: grid !important;
        grid-auto-flow: row !important;
        grid-auto-rows: auto !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    html body .mh-row-card .mh-bento-host.mh-entry-bento .bzb-item {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        min-height: 104px !important;
    }

    html body .mh-row-card .mh-bento-host.mh-entry-bento .bzb-item:first-child {
        grid-column: 1 / -1 !important;
        min-height: 190px !important;
    }

    html body .mh-row-card .mh-bento-card-actions,
    html body .mh-row-card .mud-card-actions.mh-bento-card-actions {
        justify-content: stretch !important;
    }

    html body .mh-row-card .mh-bento-card-actions .mud-button-root,
    html body .mh-row-card .mud-card-actions.mh-bento-card-actions .mud-button-root {
        flex: 1 1 0 !important;
    }
}
