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;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --touch-min: 44px;
    --input-height: 48px;
    --radius: 12px;
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.5;
    -webkit-tap-highlight-color: rgba(61, 126, 239, 0.15);
    text-transform: capitalize;
}

/* Preserve literals, ids, and user entry (capitalize is word-wise on surrounding copy only) */
input,
textarea,
select,
option,
code,
pre,
kbd,
samp,
.file-input,
.nav-user {
    text-transform: none;
}

a {
    color: #7eb8ff;
}

.page-head {
    margin-bottom: 1.1rem;
}

.page-head h1 {
    margin: 0 0 0.35rem;
    font-size: 1.4rem;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

@media (min-width: 641px) {
    .page-head {
        margin-bottom: 1.5rem;
    }

    .page-head h1 {
        font-size: 1.75rem;
    }
}

.muted {
    color: #8a9bb0;
    margin: 0;
}

.muted.small {
    font-size: 0.85rem;
}

.empty-state {
    padding: 2rem 1.25rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 12px;
}

.card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 1rem 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 641px) {
    .card {
        padding: 1.25rem 1.35rem;
        margin-bottom: 1.25rem;
    }
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #c5d4e8;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-grid .span-2 {
    grid-column: 1 / -1;
}

.field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #9eb0c4;
    margin-bottom: 0.35rem;
}

.input-block,
.input-grow,
.input-inline,
.input-narrow {
    width: 100%;
    max-width: 100%;
    padding: 0.65rem 0.75rem;
    min-height: var(--input-height);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    color: #e8edf4;
    font: inherit;
    font-size: 1rem;
}

/* 16px+ avoids iOS zoom-on-focus */
.input-touch {
    font-size: 1rem;
}

@media (min-width: 641px) {
    .input-block,
    .input-grow,
    .input-inline,
    .input-narrow {
        padding: 0.5rem 0.65rem;
        min-height: auto;
        border-radius: 8px;
    }
}

.input-inline {
    width: auto;
    min-width: 8rem;
}

.input-inline.narrow {
    min-width: 4rem;
    width: 5rem;
}

.input-narrow {
    max-width: 6rem;
}

/* Request-access code: wider field + larger placeholder so e.g. KFT6EK fits clearly */
.input-narrow.input-request-code {
    max-width: none;
    min-width: 13.5rem;
    width: auto;
    flex: 1 1 13.5rem;
    font-size: 1.125rem;
}

.input-narrow.input-request-code::placeholder {
    font-size: 1.125rem;
    letter-spacing: 0.04em;
    opacity: 0.72;
}

.input-block:focus,
.input-grow:focus,
.input-inline:focus,
.input-narrow:focus {
    outline: 2px solid rgba(61, 126, 239, 0.45);
    border-color: #3d7eef;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1.1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1rem;
    min-height: var(--touch-min);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #e8edf4;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-touch {
    min-height: var(--touch-min);
}

/* QR scan actions (Scan page, Groups, new box) — icon-only */
.btn-qr-scan {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-qr-scan-icon {
    gap: 0;
    padding: 0.45rem 0.5rem;
    min-width: var(--touch-min);
}

.btn-qr-scan .qr-scan-icon {
    width: 1.35rem;
    height: 1.35rem;
    flex-shrink: 0;
    opacity: 0.95;
}

@media (min-width: 641px) {
    .btn-qr-scan-icon {
        padding: 0.4rem 0.45rem;
        min-width: 2.5rem;
    }
}

.btn:active:not(:disabled) {
    filter: brightness(0.92);
    transform: scale(0.99);
}

@media (min-width: 641px) {
    .btn {
        padding: 0.5rem 1rem;
        min-height: auto;
        border-radius: 8px;
    }

    .btn:active:not(:disabled) {
        transform: none;
    }
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: linear-gradient(135deg, #3d7eef 0%, #2563c9 100%);
    border-color: transparent;
    color: #fff;
}

.btn.danger.ghost {
    border-color: rgba(255, 100, 100, 0.35);
    color: #ff9a9a;
    background: rgba(180, 40, 40, 0.15);
}

.btn.link {
    border: none;
    background: none;
    padding: 0.15rem 0.4rem;
    font-weight: 500;
    color: #7eb8ff;
}

.btn.link.danger {
    color: #ff8a8a;
}

.btn:hover:not(:disabled) {
    filter: brightness(1.06);
}

a.btn:not(.link) {
    text-decoration: none;
    color: #e8edf4;
}

a.btn:not(.link):visited {
    color: #e8edf4;
}

a.btn.primary:not(.link),
a.btn.primary:not(.link):visited {
    color: #fff;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8a9bb0;
    background: rgba(0, 0, 0, 0.2);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.data-table .table-empty-msg {
    padding: 0.85rem 0.85rem;
    font-size: 0.95rem;
    line-height: 1.45;
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .actions {
    text-align: right;
    white-space: nowrap;
}

code.box-id {
    font-size: 0.88em;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: rgba(61, 126, 239, 0.15);
    color: #b8d4ff;
}

.banner {
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.banner-error {
    background: rgba(200, 60, 60, 0.2);
    border: 1px solid rgba(255, 120, 120, 0.25);
    color: #ffc8c8;
}

.banner-ok {
    background: rgba(40, 140, 80, 0.2);
    border: 1px solid rgba(100, 200, 140, 0.25);
    color: #b8f0d0;
}

.banner-warn {
    background: rgba(200, 150, 40, 0.15);
    border: 1px solid rgba(255, 200, 100, 0.25);
    color: #ffe4b0;
}

.qrcode-hint {
    margin: 0.85rem 0 0;
    line-height: 1.45;
}

.qrcode-hint strong {
    color: #c5d4e8;
    font-weight: 600;
}

.qr-new-box-hint {
    margin-top: 0.5rem;
}

.qr-new-box-scan-row {
    margin-top: 0.35rem;
}

.qrcode-row {
    margin-top: 0.5rem;
}

.qr-reader-wrap {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #0a0e12;
}

.qr-reader-wrap .qr-scan-video {
    display: block;
    width: 100%;
    height: auto;
    min-height: 220px;
    vertical-align: middle;
}

.scan-panel {
    max-width: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 1rem;
}

@media (min-width: 641px) {
    .scan-panel {
        max-width: 640px;
        padding: 1.25rem;
    }
}

.scan-row {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.35rem;
}

.scan-row .input-grow {
    flex: 1 1 200px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin-top: 1rem;
}

.inline-form .input-grow {
    flex: 1 1 180px;
}

.group-picker-select {
    font-variant-numeric: tabular-nums;
    /* Slightly smaller than default inputs so the 6-char code reads lighter */
    font-size: 0.875rem;
    letter-spacing: -0.02em;
}

@media (min-width: 641px) {
    .group-picker-select {
        font-size: 0.9rem;
        letter-spacing: -0.015em;
    }
}

/* Long / short CTA next to group pickers (e.g. new box page) */
.group-picker-action-short {
    display: none;
}

@media (max-width: 640px) {
    .group-picker-action-long {
        display: none;
    }

    .group-picker-action-short {
        display: inline;
    }
}

.workspace-picker-hint {
    margin-bottom: 0.5rem;
}

/* Groups page: create group — one row on mobile (matches home group picker) */
.create-group-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.create-group-toolbar .create-group-name {
    flex: 1 1 auto;
    min-width: 0;
}

.create-group-toolbar .create-group-submit {
    flex: 0 0 auto;
    width: auto;
}

@media (max-width: 640px) {
    .create-group-card {
        padding: 0.5rem 0.65rem;
    }

    .create-group-toolbar {
        gap: 0.45rem;
        margin-top: 0.5rem;
    }
}

/* ——— Home: compact group picker (mobile) ——— */
.group-picker-label-short {
    display: none;
}

.group-picker-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.group-picker-field-label {
    margin-bottom: 0;
}

.group-picker-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.group-picker-controls .input-grow {
    flex: 1 1 180px;
}

.group-picker-new {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.45rem 0.5rem;
    min-width: var(--touch-min);
    text-decoration: none;
}

.group-picker-new .new-box-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

@media (min-width: 641px) {
    .group-picker-new {
        padding: 0.4rem 0.45rem;
        min-width: 2.5rem;
    }
}

@media (max-width: 640px) {
    .page-head--boxes-home {
        margin-bottom: 0.65rem;
    }

    .page-head--boxes-home .muted {
        font-size: 0.82rem;
        line-height: 1.35;
    }

    .group-picker-label-long {
        display: none;
    }

    .group-picker-label-short {
        display: inline;
    }

    /* Single-row toolbar: label + dropdown + action stay on one line */
    .group-picker-toolbar {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.5rem;
    }

    .group-picker-field-label {
        flex: 0 0 auto;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .group-picker-controls {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        gap: 0.45rem;
        min-width: 0;
    }

    .group-picker-controls .group-picker-select {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
        max-width: none;
    }

    .group-picker-controls .group-picker-manage,
    .group-picker-controls .group-picker-new {
        flex: 0 0 auto;
        width: auto;
        min-width: 0;
    }

    .group-picker-card {
        padding: 0.5rem 0.65rem;
        margin-bottom: 0.65rem;
    }

    /* More room for the box list */
    .box-group-title {
        margin: 0.75rem 0 0.35rem;
    }

    .box-group-title:first-of-type {
        margin-top: 0;
    }

    .box-group-table .data-table--responsive tbody tr {
        margin-bottom: 0.5rem;
    }

    .box-group-table .data-table--responsive tbody td {
        padding: 0.45rem 0.75rem;
    }
}

.data-table--groups .col-group-code {
    width: 1%;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.data-table--groups .col-group-role {
    width: 1%;
    white-space: nowrap;
}

.group-code-qr-link {
    display: inline;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: inherit;
    font-variant-numeric: tabular-nums;
    color: #7eb8ff;
    text-decoration: underline;
    cursor: pointer;
    text-transform: none;
}

.group-code-qr-link:hover {
    filter: brightness(1.08);
}

.app-modal-root {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.app-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 22rem;
    padding: 1.25rem;
    border-radius: var(--radius);
    background: #121820;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.app-modal-title {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: #e8eef5;
}

.app-modal-hint {
    margin: 0 0 1rem;
}

.app-modal-qr-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.group-invite-qr-modal {
    display: block;
    width: 220px;
    height: 220px;
    max-width: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.group-code-modal-code {
    margin: 0 0 1rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.app-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.app-modal-actions--split {
    justify-content: space-between;
}

.data-table--groups .groups-table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    justify-content: flex-end;
    align-items: center;
}

.btn-delete-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.btn-delete-group-icon {
    gap: 0;
    padding: 0.35rem 0.45rem;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}

.btn-delete-group .trash-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    opacity: 0.95;
}

@media (min-width: 641px) {
    .btn-delete-group-icon {
        min-width: 2.25rem;
        min-height: auto;
        padding: 0.25rem 0.35rem;
    }
}

.rename-group-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.rename-group-modal-head .app-modal-title {
    margin: 0;
    flex: 1;
    min-width: 0;
}

.rename-group-modal-head-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    flex-shrink: 0;
}

.rename-group-modal-head-actions .group-code-modal-code {
    margin: 0;
    text-align: left;
}

.rename-group-modal .field-label {
    margin-top: 0.25rem;
}

.rename-group-modal .input-block {
    margin-bottom: 0.25rem;
}

.groups-request-scan-hint {
    margin-top: 0.65rem;
}

/* Groups: Request access — code + QR on one row; Send full width on narrow screens */
.request-access-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    margin-top: 1rem;
}

.request-access-toolbar {
    display: flex;
    flex: 1 1 14rem;
    min-width: 0;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.45rem;
}

.request-access-toolbar .request-access-code.input-request-code {
    min-width: 0;
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    font-size: 1.125rem;
}

.request-access-toolbar .request-access-code.input-request-code::placeholder {
    font-size: 1.125rem;
    letter-spacing: 0.04em;
    opacity: 0.72;
}

.request-access-send {
    flex: 0 0 auto;
}

@media (max-width: 640px) {
    .request-access-card .request-access-row {
        flex-direction: column;
        align-items: stretch;
    }

    .request-access-toolbar {
        flex: none;
        width: 100%;
    }

    .request-access-send {
        width: 100%;
    }
}

.request-qr-scan-modal .request-qr-scan-reader {
    min-height: 220px;
    margin-bottom: 0.35rem;
}

.speech-inventory-block {
    margin-bottom: 1.25rem;
}

.speech-inventory-row {
    display: flex;
    gap: 0.65rem;
    align-items: stretch;
}

.speech-inventory-row .speech-textarea {
    flex: 1;
    min-width: 0;
    align-self: stretch;
}

.speech-inventory-row .speech-mic-start-btn {
    flex-shrink: 0;
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-min);
}

.speech-textarea {
    min-height: 6rem;
    resize: vertical;
}

.speech-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin-top: 0.65rem;
}

.speech-inventory-actions {
    justify-content: flex-start;
}

.speech-mic-start-btn .mic-icon {
    width: 1.35rem;
    height: 1.35rem;
    flex-shrink: 0;
    opacity: 0.95;
}

.speech-modal-root .speech-modal-panel {
    max-width: min(36rem, calc(100vw - 2rem));
}

.speech-modal-textarea {
    min-height: 10rem;
}

.speech-modal-listening {
    margin: 0.35rem 0 0;
}

.speech-modal-actions {
    justify-content: flex-start;
    align-items: center;
    margin-top: 0.75rem;
}

.speech-modal-actions--solo {
    justify-content: center;
}

.speech-modal-actions .stop-mic-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.box-contents-intro strong {
    font-weight: 600;
}

.no-capitalize {
    text-transform: none;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.photo-card {
    margin: 0;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.photo-card img {
    display: block;
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.photo-card figcaption {
    padding: 0.5rem 0.65rem;
}

.photo-camera-panel {
    margin-top: 1rem;
}

.photo-camera-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.photo-camera-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin-top: 0.75rem;
}

.photo-camera-wrap {
    margin-top: 0.35rem;
}

.upload-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.file-input {
    font-size: 0.9rem;
    color: #a8b8cc;
}

#blazor-error-ui {
    background: #3a1414;
    color: #fff;
    padding: 0.5rem 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* ——— Mobile-first: scan ——— */
.scan-row--stack {
    flex-direction: column;
    align-items: stretch;
}

@media (min-width: 641px) {
    .scan-row--stack {
        flex-direction: row;
        align-items: center;
    }
}

.scan-row--stack .input-grow {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

.btn-block-sm {
    width: 100%;
}

@media (min-width: 641px) {
    .btn-block-sm {
        width: auto;
    }
}

/* ——— Responsive tables → stacked cards (narrow viewports) ——— */
.table-wrap--mobile-cards {
    margin: 0 -0.25rem;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    .data-table--responsive thead {
        display: none;
    }

    .data-table--responsive tbody tr {
        display: block;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: var(--radius);
        margin-bottom: 0.75rem;
        padding: 0.25rem 0;
        background: rgba(0, 0, 0, 0.22);
        overflow: hidden;
    }

    .data-table--responsive tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        padding: 0.6rem 1rem;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        text-align: right;
        font-size: 0.95rem;
    }

    .data-table--responsive tbody td:last-child {
        border-bottom: none;
    }

    .data-table--responsive tbody td::before {
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #8a9bb0;
        text-align: left;
        flex-shrink: 0;
        max-width: 38%;
    }

    .data-table--responsive .num {
        font-variant-numeric: tabular-nums;
    }

    .data-table--items .actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .data-table--items .actions::before {
        align-self: flex-start;
        padding-top: 0.2rem;
    }

    .data-table--items .actions .btn {
        min-height: 40px;
        padding: 0.4rem 0.65rem;
    }
}

.table-open-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    background: rgba(61, 126, 239, 0.2);
    color: #b8d4ff !important;
    font-weight: 600;
    text-decoration: none;
}

.actions--home-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.75rem;
    justify-content: flex-end;
}

.home-add-photo-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.45rem 0.5rem;
    min-width: var(--touch-min);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #9eb0c4;
}

.home-add-photo-icon-btn:hover:not(:disabled) {
    color: #c5d4e8;
    background: rgba(255, 255, 255, 0.08);
}

.home-add-photo-icon-btn .photo-camera-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    opacity: 0.95;
}

@media (min-width: 641px) {
    .home-add-photo-icon-btn {
        padding: 0.4rem 0.45rem;
        min-width: 2.5rem;
    }
}

.home-photo-modal .home-photo-video-wrap {
    max-width: 100%;
    margin: 0.5rem 0;
}

.home-photo-modal-start {
    margin: 0.75rem 0;
}

.home-photo-modal-actions {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.table-open-link:active {
    background: rgba(61, 126, 239, 0.35);
}

/* ——— Inline add row: stack on phone ——— */
@media (max-width: 640px) {
    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form .input-grow,
    .inline-form .input-narrow {
        width: 100%;
        max-width: none;
    }

    .inline-form .btn {
        width: 100%;
    }

    .speech-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .speech-actions .btn {
        width: 100%;
    }

    .btn-row {
        flex-direction: column;
    }

    .btn-row .btn {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .empty-state {
        padding: 1.5rem 1rem;
    }

    .empty-state .btn.primary {
        margin-top: 0.5rem;
        width: 100%;
        max-width: 280px;
    }
}

@media (max-width: 480px) {
    .photo-grid {
        grid-template-columns: 1fr;
    }
}

/* ——— QR print labels (4 per row) ——— */
.qr-print-controls {
    margin-top: 0;
    align-items: flex-end;
}

.qr-print-qty-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.65rem 1rem;
    flex: 1 1 auto;
    min-width: 0;
}

.qr-print-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 0;
    min-width: 0;
}

.qr-print-field .field-label {
    margin-bottom: 0;
}

.qr-print-field .qr-print-select {
    width: 100%;
    min-width: 0;
}

@media (max-width: 640px) {
    .qr-print-qty-row {
        gap: 0.5rem;
    }

    .qr-print-field .field-label {
        white-space: nowrap;
    }

    .qr-print-field .qr-print-select {
        min-height: max(var(--touch-min, 44px), 3rem);
        padding: 0.65rem 0.85rem;
        font-size: 1.125rem;
        box-sizing: border-box;
    }
}

.qr-print-summary {
    margin: 0.75rem 0 0;
}

.qr-print-select {
    min-width: 5rem;
    min-height: var(--input-height);
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.25);
    color: #e8eef5;
    font-size: 1rem;
}

.qr-print-root {
    margin-top: 1rem;
}

.qr-print-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-flow: row;
    gap: 0.75rem;
    width: 100%;
}

.qr-print-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.2);
}

.qr-print-img {
    display: block;
    width: 100%;
    max-width: 200px;
    height: auto;
    margin: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

@media (max-width: 900px) {
    .qr-print-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media print {
    @page {
        margin: 0.35in;
    }

    html {
        background: #fff !important;
        color-scheme: light !important;
    }

    .print-hide,
    .app-header {
        display: none !important;
    }

    /* Shell / main: drop dark theme flex + full viewport height (avoids blank 2nd page on mobile). */
    .app-shell {
        display: block !important;
        min-height: 0 !important;
        height: auto !important;
        background: #fff !important;
        color: #111 !important;
    }

    .app-main {
        flex: none !important;
        min-height: 0 !important;
        padding: 0.15in !important;
        padding-bottom: 0 !important;
        max-width: none !important;
        margin: 0 !important;
        background: #fff !important;
    }

    body {
        background: #fff !important;
        color: #111 !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: economy;
        print-color-adjust: economy;
    }

    .qr-print-root {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .qr-print-grid {
        gap: 0.12in;
        margin: 0 !important;
        padding: 0 !important;
    }

    .qr-print-cell {
        background: #fff !important;
        border-color: #ccc !important;
        break-inside: avoid;
        page-break-inside: avoid;
        padding: 0.08in !important;
    }

    .qr-print-img {
        max-width: 1.5in;
        height: auto !important;
    }
}

/* ——— Box list grouping & name emphasis ——— */
.page-head-title-emphasis {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.04em;
}

.box-group-title {
    margin: 1.25rem 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8a9bb0;
}

.box-group-title:first-of-type {
    margin-top: 0;
}

.box-group-table {
    margin-bottom: 0.5rem;
}

/* Home: filter chips + per-row hashtags (group tag tokens) */
.box-tag-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
}

.box-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: #9eb0c4;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.box-tag:hover {
    color: #c5d4e8;
    background: rgba(255, 255, 255, 0.09);
}

.box-tag:focus-visible {
    outline: 2px solid rgba(100, 180, 255, 0.5);
    outline-offset: 2px;
}

.box-tag.is-active {
    color: #e8edf4;
    border-color: rgba(100, 160, 255, 0.45);
    background: rgba(60, 120, 220, 0.2);
}

.box-tag--all {
    font-weight: 600;
}

/* Tag cloud: spiral layout (JS) — bold uppercase, SEO-style palette on dark UI */
.tag-cloud-layout-host {
    position: relative;
    width: 100%;
    min-height: 220px;
    margin: 0 auto;
    overflow: hidden;
}

.tag-cloud--home-wrap {
    margin-top: 0.35rem;
}

.tag-cloud-placed {
    display: inline-block;
    font-weight: 800;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.05;
    transform-origin: center center;
    transition: filter 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.tag-cloud-placed:hover {
    filter: brightness(1.15) saturate(1.08);
    z-index: 3;
}

.tag-cloud-placed:focus-visible {
    outline: 2px solid rgba(180, 210, 255, 0.65);
    outline-offset: 4px;
    border-radius: 4px;
    z-index: 4;
}

/* Reference palette: dark blue, medium blue, teal, orange, grey-violet */
.tag-cloud-tone--0 {
    color: hsl(215 72% 68%);
}

.tag-cloud-tone--1 {
    color: hsl(205 82% 62%);
}

.tag-cloud-tone--2 {
    color: hsl(172 58% 52%);
}

.tag-cloud-tone--3 {
    color: hsl(32 92% 58%);
}

.tag-cloud-tone--4 {
    color: hsl(265 28% 72%);
}

button.tag-cloud-placed.tag-cloud-link--btn {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    text-align: inherit;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.tag-cloud-link--active {
    filter: brightness(1.22) saturate(1.18);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.home-tag-cloud-actions {
    margin-bottom: 0.55rem;
}

.home-tag-cloud-module .new-box-module-body {
    padding-top: 0.35rem;
}

.box-tags-cell {
    font-size: 0.88rem;
    line-height: 1.5;
}

.box-row-hashtag {
    display: inline;
    margin-right: 0.4rem;
    color: #7eb8ff;
    font-weight: 500;
    white-space: nowrap;
}

.data-table .box-name-cell {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.35;
    color: #e8eef5;
}

.box-editor-cat-hint {
    margin-top: 0.35rem;
}

/* Groups page: collapsible bodies — align spacing with box editor modules */
.new-box-module-body > .create-group-toolbar {
    margin-top: 0;
}

/* ——— Groups page: long collapsible title ——— */
.groups-section-grant-access .new-box-module-title {
    font-size: 1rem;
    line-height: 1.35;
}

@media (min-width: 641px) {
    .groups-section-grant-access .new-box-module-title {
        font-size: 1.08rem;
    }
}

/* ——— New box: collapsible workload modules ——— */
.new-box-module {
    padding: 0;
    overflow: hidden;
}

.new-box-module-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem 0.75rem;
    flex-wrap: wrap;
    width: 100%;
    margin: 0;
    padding: 1rem 1rem;
    text-align: left;
    font: inherit;
    color: inherit;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: inherit;
}

@media (min-width: 641px) {
    .new-box-module-toggle {
        padding: 1.15rem 1.35rem;
    }
}

.new-box-module-toggle:hover {
    background: rgba(255, 255, 255, 0.04);
}

.new-box-module-toggle:focus-visible {
    outline: 2px solid rgba(100, 180, 255, 0.55);
    outline-offset: -2px;
}

.new-box-module-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #c5d4e8;
    margin: 0;
}

.new-box-module-meta {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
}

.new-box-module-chevron {
    flex-shrink: 0;
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid #8a9bb0;
    border-bottom: 2px solid #8a9bb0;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
}

.new-box-module-toggle[aria-expanded="true"] .new-box-module-chevron {
    transform: rotate(-135deg);
    margin-top: 0.15rem;
}

.new-box-module-body {
    padding: 0 1rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

@media (min-width: 641px) {
    .new-box-module-body {
        padding: 0 1.35rem 1.25rem;
    }
}

.new-box-module-body .form-grid,
.new-box-module-body .btn-row:first-of-type {
    margin-top: 0;
}

.new-box-module-body > .group-picker-toolbar,
.new-box-module-body > .form-grid {
    padding-top: 0.75rem;
}

.new-box-submodule {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin-top: 0.85rem;
    overflow: hidden;
}

.new-box-submodule:first-child {
    margin-top: 0.35rem;
}

.new-box-submodule-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
    margin: 0;
    padding: 0.65rem 0.85rem;
    text-align: left;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #b4c4d8;
    background: rgba(0, 0, 0, 0.15);
    border: none;
    cursor: pointer;
}

.new-box-submodule-toggle:hover {
    background: rgba(255, 255, 255, 0.04);
}

.new-box-submodule-toggle:focus-visible {
    outline: 2px solid rgba(100, 180, 255, 0.45);
    outline-offset: -2px;
}

.new-box-submodule-meta {
    flex: 1;
    text-align: right;
    font-weight: 500;
}

.new-box-submodule-chevron {
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid #7a8b9f;
    border-bottom: 2px solid #7a8b9f;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
}

.new-box-submodule-toggle[aria-expanded="true"] .new-box-submodule-chevron {
    transform: rotate(-135deg);
    margin-top: 0.12rem;
}

.new-box-submodule-body {
    padding: 0.75rem 0.85rem 0.95rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.08);
}

.new-box-submodule-body .speech-inventory-block {
    margin-bottom: 0;
}

.new-box-contents-inner .box-contents-intro {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

/* New box Details: Box Id row matches group picker (field + QR on the right); info icon by label */
.box-id-toolbar {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .box-id-toolbar.group-picker-toolbar {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
    }
}

.box-id-controls .input-grow {
    flex: 1 1 180px;
    min-width: 0;
}

/* New box: QR scanner modal */
.qr-scan-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.65);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.qr-scan-modal-dialog {
    width: min(100%, 440px);
    max-height: min(90vh, 720px);
    display: flex;
    flex-direction: column;
    background: #121820;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.qr-scan-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.qr-scan-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #c5d4e8;
}

.qr-scan-modal-close {
    flex-shrink: 0;
    min-width: 2.5rem;
    padding: 0.35rem 0.5rem;
    font-size: 1.35rem;
    line-height: 1;
    font-weight: 400;
    border-radius: 8px;
}

.qr-scan-modal-reader {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: min(55vh, 420px);
    width: 100%;
    max-width: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
}

.qr-scan-modal-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
}