/* The brand foundation both clients load (Server: App.razor, App: wwwroot/index.html), next to
   MudBlazor's own stylesheet. Colours do not live here — MienHavenTheme is their one source and
   MudBlazor turns it into --mud-palette-* variables; this file carries what a MudTheme cannot. */

/* The spacing rhythm (#165, after WP8's grid): every gap, margin and padding a page sets by hand is one of these — on
   the 4-pixel steps MudBlazor's own spacing classes take (pa-1 … pa-6), with 12 px, WP8's base unit, in the middle and
   24 px, its page edge, at the top. MienHaven.UI.Tests' SpacingTokenTests fails the run for an inline style that names
   a size of its own. */
:root {
    --mh-space-xs: 4px;
    --mh-space-s: 8px;
    --mh-space-m: 12px;
    --mh-space-l: 16px;
    --mh-space-xl: 24px;
}

/* Open Sans, self-hosted (fonts/LICENSE-OpenSans.txt). Only the two weights the brand uses ship, which
   is why MienHavenTheme sets every weight to 400 or 600. */
@font-face {
    font-family: "Open Sans";
    src: url("fonts/OpenSans-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Open Sans";
    src: url("fonts/OpenSans-Semibold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* App bar and drawer are surfaces separated by a hairline, as in the package's dashboard previews,
   rather than shadowed bands. */
.mienhaven-appbar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.mienhaven-drawer {
    border-right: 1px solid var(--mud-palette-lines-default);
}

/* A section heading in the drawer (#110, DrawerOrder): small, quiet, and aligned with the rows' text. */
.mh-nav-section {
    padding: 14px 16px 4px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

/* The sign-in and server-setup screens: the brand's harbour motif ("für Login, Onboarding"), its
   quiet upper-left kept for the card, with the theme's background laid over it so the form stays the
   thing that reads. */
.mienhaven-auth-background {
    min-height: 100vh;
    background-color: var(--mud-palette-background);
    background-image: linear-gradient(180deg, rgba(255, 248, 241, 0.90) 0%, rgba(255, 248, 241, 0.80) 55%, rgba(255, 248, 241, 0.90) 100%),
                      url("images/mienhaven-harbor.webp");
    background-size: cover;
    background-position: right center;
}

.mienhaven-auth-background.mienhaven-auth-background-dark,
.theme-dark .mienhaven-auth-background {
    background-image: linear-gradient(180deg, rgba(28, 25, 23, 0.45) 0%, rgba(28, 25, 23, 0.78) 100%),
                      url("images/mienhaven-harbor.webp");
}

/* Sentence case everywhere, as the brand's buttons are (MienHavenTheme turns it off for buttons;
   MudBlazor's tabs carry their own uppercase). */
.mud-tab {
    text-transform: none;
}

::selection {
    background: rgba(var(--mud-palette-tertiary-rgb), 0.3);
}


/* The Office editors and the note editor pin their ribbon under the app bar and their status bar to
   the bottom of the screen. Scroll padding tells the browser those strips are covered, so the caret it
   scrolls into view while somebody types at the end of a document, or a field it brings into view on
   focus, stops between them instead of underneath. A global rule because the page itself is what
   scrolls, which no component's scoped CSS can reach. */
html:has(.mh-office, .mh-note-editor) {
    scroll-padding-top: calc(var(--mud-appbar-height, 64px) + 60px);
    scroll-padding-bottom: 40px;
}

@media (max-width: 600px) {
    html:has(.mh-office, .mh-note-editor) {
        scroll-padding-top: calc(var(--mud-appbar-height, 64px) * 7 / 8 + 56px);
    }
}

/* The notification bell's list (NotificationBell). Global because MudBlazor renders a menu's popover in
   the provider at the end of the page, out of reach of the component's scoped CSS. As wide as the screen
   allows and no wider, so a long subject line is cut rather than wrapped into a column of single words. */
.mh-notification-list {
    width: min(360px, calc(100vw - 32px));
}

.mh-notification-row {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
}

.mh-notification-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.mh-notification-title,
.mh-notification-line {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.mh-notification-title {
    font-weight: 600;
}

.mh-notification-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mud-palette-primary);
}

.mh-notification-time {
    margin-left: auto;
    font-size: 0.75rem;
    white-space: nowrap;
}

.mh-notification-line {
    font-size: 0.875rem;
}

.mh-notification-empty {
    padding: 16px;
}

/* The due-date dialog's calendar (DateInputDialog) has to fit a 320 px phone: MudBlazor sizes a static
   picker to 310 px, which a dialog's own margins and padding leave no room for. */
.mh-date-input.mud-picker-static,
.mh-date-input .mud-picker-static,
.mh-date-input .mud-picker-content {
    min-width: 0;
}

.mh-date-input .mud-picker-calendar-container {
    width: 100%;
}

.mh-date-input .mud-day {
    width: 32px;
    height: 32px;
    margin: 0 1px;
}

.mh-date-input .mud-picker-calendar-header-day .mud-day-label {
    width: 32px;
    margin: 0 1px;
}

.mh-date-input .mud-picker-month-container {
    width: 100%;
}

/* MudBlazor lays the days out as one wrapping row, and the 310 px it gives the calendar is what makes
   that wrap after seven. Widened to the dialog it wrapped after nine, and the days no longer stood under
   their weekdays (issue #33) — so the header and the days are held to exactly seven cells of 34 px. */
.mh-date-input .mud-picker-calendar,
.mh-date-input .mud-picker-calendar-header-day {
    width: calc(7 * 34px);
    margin-inline: auto;
}

/* A long list (GroupedList, #167): the toolbar above it, its headings, which open the jump list, the A–Z strip down the
   right edge and the jump list itself. Used by the address book, recipes, web links and notes. */
.mh-grouped-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.mh-grouped-toolbar__content {
    flex: 1 1 auto;
    min-width: 0;
}

.mh-grouped-row {
    display: grid;
}

/* Clear of the app bar when one is scrolled to the top. */
.mh-group-heading {
    scroll-margin-top: 80px;
    padding: 12px 0 4px;
}

.mh-group-heading-button,
.mh-group-heading-text {
    font: inherit;
    font-size: 1.125rem;
    color: var(--mud-palette-primary);
    font-weight: 600;
}

.mh-group-heading-button {
    background: none;
    border: 0;
    padding: 4px 8px;
    margin-left: -8px;
    border-radius: var(--mud-default-borderradius);
    cursor: pointer;
}

.mh-group-heading-button:hover,
.mh-group-heading-button:focus-visible {
    background: var(--mud-palette-action-default-hover);
}

.mh-group-section {
    padding: 12px 0 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-primary);
}

/* Headings in line with the items of a MudList. */
.mh-grouped-list--inset .mh-group-heading,
.mh-grouped-list--inset .mh-group-section {
    padding-inline: 16px;
}

/* The A–Z strip (GroupedList.razor.js, attachIndex): fixed to the screen, so it is there wherever the list is
   scrolled to. Wide enough for a thumb, narrow enough not to cover the call buttons. */
.mh-group-index {
    position: fixed;
    right: max(2px, env(safe-area-inset-right, 0px));
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: min(70vh, 560px);
    width: 22px;
    padding: 6px 0;
    border-radius: 11px;
    touch-action: none;
    user-select: none;
    cursor: pointer;
}

.mh-group-index.is-active {
    background: var(--mud-palette-action-default-hover);
}

.mh-group-index-letter {
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 600;
    color: var(--mud-palette-primary);
}

.mh-group-index-letter.is-empty {
    color: var(--mud-palette-text-disabled);
}

.mh-group-index-letter.is-current {
    transform: scale(1.5);
}

.mh-group-index-bubble {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1500;
    width: 88px;
    height: 88px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    font: 600 2.75rem/1 "Open Sans", sans-serif;
    color: var(--mud-palette-primary-text);
    background: var(--mud-palette-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

/* Room for the strip: the buttons at the end of a row stay clear of it. */
.mh-group-list-has-index {
    padding-right: 20px;
}

.mh-jump-grid {
    display: grid;
    grid-template-columns: repeat(4, 56px);
    gap: 8px;
    max-width: calc(100vw - 32px);
}

.mh-jump-grid .mh-jump-grid-button {
    min-width: 0;
    height: 56px;
    font-size: 1.25rem;
}

/* Sections with names ("November 2026") rather than letters: two or three to a row. */
.mh-jump-grid.mh-jump-grid--wide {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    width: min(440px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow-y: auto;
}

.mh-jump-grid--wide .mh-jump-grid-button {
    font-size: 0.9375rem;
    text-transform: none;
    white-space: normal;
    line-height: 1.2;
}

/* The photo dialog in full screen (PhotoAssetDetailDialog): MudBlazor's own dialog parts, which the
   component's scoped stylesheet does not reach. Black edge to edge, no padding, no footer. */

.mh-photo-fullscreen-content {
    padding: 0 !important;
    overflow: hidden !important;
}

/* Over the App's phone rule that leaves every dialog a hairline of backdrop: a photo gets the screen.
   By :has rather than a class on MudDialog, which MudBlazor does not pass on to the dialog once it is open. */
.mud-dialog.mud-dialog-fullscreen:has(.photo-detail__stage--fullscreen) {
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
    background: #000;
}

/* How many photos of the album a filter chip stands for (PhotoGridView, #48). */
.mh-photo-filter-n {
    margin-left: 4px;
    font-size: .8em;
    opacity: .7;
}

/* The changes of one release on the Neuigkeiten page (ReleaseNotesView, #45). */
.mh-release-notes {
    margin: 0;
    padding-left: 1.2em;
}

.mh-release-notes li + li {
    margin-top: 6px;
}

/* A page's create button steps up out of the way while an ActionBar is up: on a phone the bar spans
   the whole width, and the two would otherwise lie on top of each other (#59). The selector has to
   outweigh CreateFab's scoped rule, hence :root. */
:root:has(.mh-action-bar) .create-fab {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

/* The live QR scanner of the one-time codes (#80): the camera's picture, a square to aim with. */
.mh-totp-live {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 50vh;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}

.mh-totp-live__video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mh-totp-live__frame {
    position: absolute;
    inset: 50% auto auto 50%;
    width: min(60%, 60vh);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border: 3px solid rgba(255, 255, 255, 0.85);
    border-radius: 16px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

/* "Durch Smartphone entsperren" (#91): the number to type on the phone, the one thing to read while waiting. */
.mh-phone-unlock-code {
    font-size: 3.5rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-align: center;
    margin: 0.75rem 0;
    color: var(--mud-palette-primary);
    font-variant-numeric: tabular-nums;
}

/* A Speicherort file looked at in place (#93): the picture or document as large as the screen allows. */
.mh-file-viewer__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mh-file-viewer__stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

/* Takes the focus after paging to either end (FileViewerDialog), only so Escape still closes the dialog. */
.mh-file-viewer__stage:focus {
    outline: none;
}

.mh-file-viewer__stage[data-kind="pdf"], .mh-file-viewer__stage[data-kind="text"], .mh-file-viewer__stage[data-kind="markdown"],
.mh-file-viewer__stage[data-kind="textdocument"], .mh-file-viewer__stage[data-kind="spreadsheet"] {
    align-items: stretch;
    justify-content: flex-start;
}

.mh-file-viewer__picture {
    max-width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
}

.mh-file-viewer__audio {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: min(100%, 480px);
}

.mh-file-viewer__audio audio {
    width: 100%;
}

.mh-file-viewer__text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.875rem;
    margin: 0;
}

/* An Office document (#94), read-only in the editors, as wide as the dialog. */
.mh-file-viewer__office {
    width: 100%;
    min-width: 0;
}

.mh-file-viewer__document {
    max-width: 52rem;
    width: 100%;
    margin: 0 auto;
}

/* A toast with "Rückgängig" was squeezed into MudBlazor's 288 px, and "„Listen“ abgepinnt" broke inside its
   last word on a phone (#113). It takes the width its words need, up to the screen. */
.mud-snackbar {
    width: max-content;
    max-width: calc(100vw - 32px);
}

/* GreetingToggle: the chevron points down while the greeting is folded away, up while it is open. On the button,
   which MudIconButton renders, hence global. */
.mh-greeting-toggle .mud-icon-root {
    transition: transform .15s ease;
}

.mh-greeting-toggle--open .mud-icon-root {
    transform: rotate(180deg);
}

/* SectionHeading (#217): the one level of a heading inside a page, below its title. Global because it lands on
   MudText's element, which a scoped rule of SectionHeading does not reach. */
.mud-typography.mh-section-heading {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    margin: var(--mh-space-xl) 0 var(--mh-space-s);
}

.mud-typography.mh-section-heading:first-child {
    margin-top: 0;
}

/* ResourceCard, the card of every overview (lists, notebooks, albums, Speicherorte …). Global because the
   card is a MudPaper: ResourceCard.razor.css could not reach it, and for as long as these rules lived there
   no card showed the pointer, lifted under it or had its radius.
   The brand package's card: a plain surface with the 20px card radius, no frame and no resting shadow
   ("große Freiflächen und klare Gruppen statt vieler Rahmen") — it lifts only under the pointer. */
.resource-card {
    border-radius: 20px;
}

/* Only a card that opens something (ResourceCard's OnClick): the pointing hand, a lift, a tinted surface,
   and no text cursor or text selection over its words — it is a button, not a paragraph. */
.card-hover {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

/* Only under a mouse: a touch screen keeps :hover on whatever was tapped last, and a card that started another app stayed lifted (#175). */
@media (hover: hover) {
    .card-hover:hover {
        box-shadow: 0 6px 18px rgba(40, 35, 32, 0.12);
        transform: translateY(-2px);
        background-color: rgba(var(--mud-palette-tertiary-rgb), 0.06);
    }
}

.card-hover.mh-pressing {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(40, 35, 32, 0.12);
}

/* A card that is a link (ResourceCard.Href, #216): the link takes the focus, the paper inside shows it. */
.mh-resource-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    border-radius: 20px;
}

/* A group closed by the family admin (#216): still there, plainly not in use. */
.mh-group-card--closed {
    opacity: 0.7;
}

.mh-resource-card-link:focus-visible {
    outline: none;
}

.mh-resource-card-link:focus-visible > .card-hover {
    outline: 3px solid var(--mud-palette-primary);
    outline-offset: 3px;
}

/* Reachable by keyboard, so it shows where the focus is — the brand's 3px ring with 3px of air. */
.card-hover:focus-visible {
    outline: 3px solid var(--mud-palette-primary);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .card-hover,
    .card-hover:hover,
    .card-hover.mh-pressing {
        transition: none;
        transform: none;
    }
}

/* A press answers at once (#166): WP8 tilted what was touched; MienHaven presses it in a little — live tiles, cards and
   rows that open something, for as long as the finger rests. Not while a board is being arranged, where a press picks a
   tile up. With reduced motion it dims instead of moving. The class is press-feedback.js's, not :active, which stayed on a
   tile that started another app (#175). */
.live-tile-board:not(.live-tile-board--arranging) .live-tile-board-cell .live-tile,
.card-hover,
.mud-list-item-clickable {
    transition: transform 100ms ease-out, opacity 100ms ease-out;
}

.live-tile-board:not(.live-tile-board--arranging) .live-tile-board-cell.mh-pressing .live-tile {
    transform: scale(0.96);
}

.card-hover.mh-pressing {
    transform: scale(0.98);
}

.mud-list-item-clickable.mh-pressing {
    transform: scale(0.99);
}

@media (prefers-reduced-motion: reduce) {
    .live-tile-board:not(.live-tile-board--arranging) .live-tile-board-cell.mh-pressing .live-tile,
    .card-hover.mh-pressing,
    .mud-list-item-clickable.mh-pressing {
        transform: none;
        opacity: 0.8;
    }
}

/* A page coming in says where it came from (#166, WP8's directional transitions): forward it slides in from the right,
   back from the left, quickly and settling gently. Started by the App's layout once the new page has rendered; with
   reduced motion it only fades in. The page's own content is not moved by anything else while it runs. */
@keyframes mh-page-in-forward {
    from { opacity: 0; transform: translateX(32px); }
    to { opacity: 1; transform: none; }
}

@keyframes mh-page-in-back {
    from { opacity: 0; transform: translateX(-32px); }
    to { opacity: 1; transform: none; }
}

@keyframes mh-page-in-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mh-page-enter-forward {
    animation: mh-page-in-forward 260ms cubic-bezier(0.1, 0.9, 0.2, 1);
}

.mh-page-enter-back {
    animation: mh-page-in-back 260ms cubic-bezier(0.1, 0.9, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
    .mh-page-enter-forward,
    .mh-page-enter-back {
        animation: mh-page-in-fade 200ms ease-out;
    }
}

/* The pivot over a mail folder (#159, MailFilterPivot): it heads a list pane a third of the window wide on the
   Server, so its titles are smaller than a whole page's. */
.mh-pivot.mh-mail-filter .mh-pivot__title {
    font-size: clamp(1.5rem, 6vw, 2.25rem);
}

/* Its titles start where the search box above them does (#192), and beside a message they fit the list pane. */
.mh-pivot.mh-mail-filter .mh-pivot__header {
    padding-left: var(--mh-space-m);
}

@media (min-width: 960px) {
    .mh-pivot.mh-mail-filter .mh-pivot__title {
        font-size: 1.5rem;
    }
}

/* An ActionBar inside a pivot's page (#159: mails picked under "Ungelesen"). It is fixed to the screen, but a
   transformed ancestor — the pivot's track, moved to the page on screen — makes itself the frame instead, and
   the bar ended up at the foot of the list or off to the side with the pages. While one is up the pages stand
   still: the track takes no transform, the other pages take no room, and the one on screen is where the track
   is. A swipe there is turned off meanwhile (data-no-swipe on the selected list). */
.mh-pivot:has(.mh-action-bar) .mh-pivot__track {
    transform: none !important;
    will-change: auto;
}

.mh-pivot:has(.mh-action-bar) .mh-pivot__panel:not(.mh-pivot__panel--active) {
    display: none;
}

/* An upload among the page's actions (UploadButton/DirectUploadButton with InAppBar): one element, as wide as its
   button, the spinner beside the words in a header and alone in the round symbol on a phone. */
.mh-appbar-upload.mud-input-control,
.mh-direct-upload-wrap {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

.mh-appbar-button__busy {
    margin-right: var(--mh-space-s);
}

@media (max-width: 959.98px) {
    .mh-appbar .mh-appbar-button__busy {
        margin: 0;
    }
}

/* --- WP8's application bar (#162, AppBar) ------------------------------------------------------------------------
   A page's actions at the foot of a phone's screen, round symbols, the way to the start screen always in the middle
   (AppBarHome): two actions to its left, two to its right, "…" at the right edge for the rest and their names. Global
   rather than AppBar.razor.css: the actions are the page's elements, which a scoped rule never reaches. On a wide
   screen the bar is display: contents — its actions stand in the page's header — and the start button is not there. */
.mh-appbar,
.mh-appbar__actions {
    display: contents;
}

.mh-appbar__more,
.mh-appbar__backdrop,
.mh-appbar--phone-only,
.mh-appbar .mh-appbar__home {
    display: none;
}

/* A phone or a narrow window (#162): the bar docks at the foot of the screen. Five places in its middle — two actions,
   the start button, two actions — whatever the number of actions, so the start button is always in the middle; "…" at
   the right edge. */
@media (max-width: 959.98px) {
    .mh-appbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        /* Above the page and its create button, below the app bar's menus and the dialogs. */
        z-index: 1100;
        display: grid;
        grid-template-columns: minmax(0, 1fr) repeat(2, 56px) 60px repeat(2, 56px) minmax(0, 1fr);
        align-items: start;
        justify-items: center;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
        background: var(--mud-palette-surface);
        box-shadow: 0 -1px 0 var(--mud-palette-lines-default);
    }

    /* Collapsed, the actions are the grid's own items: each takes its place beside the start button. */
    .mh-appbar:not(.mh-appbar--expanded) .mh-appbar__actions {
        display: contents;
    }

    .mh-appbar__actions > * {
        grid-row: 1;
    }

    .mh-appbar .mh-appbar__home {
        display: inline-flex;
        grid-row: 1;
        grid-column: 4;
    }

    /* One action: left of the start button. Two: one on either side. Three: two left, one right. Four: two each. */
    .mh-appbar__actions > :first-child:last-child {
        grid-column: 3;
    }

    .mh-appbar__actions > :first-child:nth-last-child(2) {
        grid-column: 3;
    }

    .mh-appbar__actions > :first-child:nth-last-child(2) + * {
        grid-column: 5;
    }

    .mh-appbar__actions > :first-child:nth-last-child(3) {
        grid-column: 2;
    }

    .mh-appbar__actions > :first-child:nth-last-child(3) + * {
        grid-column: 3;
    }

    .mh-appbar__actions > :first-child:nth-last-child(3) + * + * {
        grid-column: 5;
    }

    .mh-appbar__actions > :first-child:nth-last-child(n+4) {
        grid-column: 2;
    }

    .mh-appbar__actions > :first-child:nth-last-child(n+4) + * {
        grid-column: 3;
    }

    .mh-appbar__actions > :first-child:nth-last-child(n+4) + * + * {
        grid-column: 5;
    }

    .mh-appbar__actions > :first-child:nth-last-child(n+4) + * + * + * {
        grid-column: 6;
    }

    /* The rest with "…". */
    .mh-appbar:not(.mh-appbar--expanded) .mh-appbar__actions > :nth-child(n+5) {
        display: none;
    }

    .mh-appbar__more {
        display: inline-flex;
        grid-row: 1;
        grid-column: 7;
        justify-self: end;
    }

    /* A bar with nothing on it (a page's on the start screen, without actions) is not there at all. */
    .mh-appbar:not(:has(.mh-appbar__home)):not(:has(.mh-appbar__actions > *)) {
        display: none;
    }

    /* A bar with nothing but the start button has no names to show. */
    .mh-appbar:not(:has(.mh-appbar__actions > *)) .mh-appbar__more {
        display: none;
    }

    /* WP8's round symbols. */
    .mh-appbar .mud-icon-button,
    .mh-appbar .mh-appbar-button {
        width: 44px;
        min-width: 44px;
        height: 44px;
        padding: 8px;
        border: 2px solid currentColor;
        border-radius: 50%;
    }

    /* A worded button (AppBarButton) is its symbol alone here; its name is its aria-label, shown when folded open. */
    .mh-appbar .mh-appbar-button {
        background-color: transparent;
        box-shadow: none;
    }

    /* One symbol colour in the bar, as WP8's had (#222): whatever colour a button asks for in a wide header (primary,
       error, default), here it is the text's — MudBlazor's colour classes carry !important, hence this one. Orange is
       the sign for "create" alone: the bar's "+". */
    .mh-appbar .mud-icon-button,
    .mh-appbar .mh-appbar-button {
        color: var(--mud-palette-text-primary) !important;
    }

    .mh-appbar .mh-appbar-create {
        color: var(--mud-palette-primary) !important;
    }

    .mh-appbar .mud-icon-button:disabled,
    .mh-appbar .mh-appbar-button:disabled {
        color: var(--mud-palette-action-disabled) !important;
    }

    .mh-appbar .mh-appbar-button .mh-appbar-button__text {
        display: none;
    }

    .mh-appbar .mh-appbar-button .mud-button-icon-start {
        margin: 0;
    }

    .mh-appbar__more .mud-icon-button {
        border-color: transparent;
    }

    /* Folded open: every action's name under its symbol, the start button first, and room for the names. */
    .mh-appbar--expanded {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: center;
        column-gap: 32px;
        row-gap: 42px;
        padding-bottom: calc(42px + env(safe-area-inset-bottom, 0px));
    }

    .mh-appbar--expanded .mh-appbar__actions {
        display: contents;
    }

    .mh-appbar--expanded .mh-appbar__home {
        order: -1;
    }

    .mh-appbar--expanded .mh-appbar__more {
        order: 1;
    }

    .mh-appbar--expanded .mud-icon-button,
    .mh-appbar--expanded .mh-appbar-button {
        position: relative;
        overflow: visible;
    }

    .mh-appbar--expanded .mh-appbar__actions .mud-icon-button[aria-label]::after,
    .mh-appbar--expanded .mh-appbar__actions .mh-appbar-button[aria-label]::after,
    .mh-appbar--expanded .mh-appbar__home[aria-label]::after {
        content: attr(aria-label);
        position: absolute;
        top: calc(100% + 4px);
        left: 50%;
        transform: translateX(-50%);
        width: 72px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
        text-align: center;
        font-size: 0.75rem;
        line-height: 1.25;
        font-weight: 400;
        text-transform: none;
        letter-spacing: normal;
        color: var(--mud-palette-text-primary);
    }

    .mh-appbar__backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1099;
        background: transparent;
    }
}

/* Around the bar on a phone: room for it under the page's last row; whatever a page keeps at the foot of the screen
   (the chat composer, an editor's status bar, the shopping mode's add row, mh-docked-foot) stands on top of it; the
   create button is the bar's "+" (PageScaffold), so the floating one goes; and a bar that takes over (a selection, an
   opened mail) hides every other. The layout's own bar (start button alone) only stands in for a page without one. */
@media (max-width: 959.98px) {
    :root {
        --mh-appbar-space: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    :root:has(.mh-appbar) .mud-main-content {
        padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    }

    :root:has(.mh-appbar) .mh-docked-foot:not(.mh-review__panel) {
        bottom: var(--mh-appbar-space);
    }

    :root:has(.mh-appbar) .mh-review {
        height: max(420px, calc(100dvh - 150px - var(--mh-appbar-space)));
    }

    :root:has(.mh-appbar-create) .create-fab {
        display: none;
    }

    /* Nor the room under the page that the floating one needed: the bar's own room (above) is enough, and a pivot reaches
       down to it (Pivot.razor.js), so a swipe below a short list is no swipe into nothing. */
    :root:has(.mh-appbar-create) .page-with-fab {
        padding-bottom: 0;
    }

    :root:has(.mh-appbar) .create-fab {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }

    :root:has(.mh-appbar--takeover) .mh-appbar:not(.mh-appbar--takeover),
    :root:has(.mh-appbar:not(.mh-appbar--fallback)) .mh-appbar--fallback {
        display: none;
    }
}

/* The bar's "+" (PageScaffold's create action) is the floating create button on a wide screen. */
@media (min-width: 960px) {
    .mh-appbar-create {
        display: none !important;
    }
}
