:root {
    --bg: #f4efe6;
    --panel: #fffaf3;
    --ink: #2b241c;
    --muted: #6f6456;
    --accent: #8a4b2f;
    --line: #e4d8c8;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

@media (min-width: 801px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }
}

a { color: inherit; }

.app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
}

@media (min-width: 801px) {
    .app-shell {
        height: 100vh;
        overflow: hidden;
    }

    .sidebar {
        position: sticky;
        top: 0;
        align-self: start;
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
    }

    .content {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
}

.sidebar {
    box-sizing: border-box;
    background: #2b241c;
    color: #f7f1e8;
    padding: 1.5rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
}

.sidebar > a.brand:first-child {
    font-size: 1.38rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar nav a {
    text-decoration: none;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    color: #f7f1e8;
}

.sidebar nav a.active,
.sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-note,
.gpu-note {
    color: #cbbca8;
    font-size: 0.85rem;
    line-height: 1.4;
}

.sidebar .module-back {
    color: #cbbca8;
    font-size: 0.85rem;
    text-decoration: none;
}

.sidebar .module-back:hover {
    color: #f7f1e8;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    max-width: 720px;
}

a.module-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 9.5rem;
    padding: 1.25rem 1.2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
}

a.module-card:hover {
    border-color: var(--accent);
}

a.module-card strong {
    font-size: 2rem;
}

a.module-card span {
    color: var(--muted);
    line-height: 1.45;
}

.content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 2rem;
}

.app-version {
    margin: 1.5rem 0 0;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.2;
}

.content > .app-version {
    margin-top: auto;
    padding-top: 1.5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-end;
}

.header-actions .button {
    font: inherit;
    font-size: 1rem;
    line-height: 1.25;
    text-align: center;
}

.search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.5rem;
}

.search-bar input {
    flex: 1 1 260px;
    min-width: 200px;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.search-results {
    margin-bottom: 2rem;
}

.search-results h2 {
    margin: 0 0 0.75rem;
}

h1 { margin: 0 0 0.35rem; }
p { color: var(--muted); }

.button {
    display: inline-block;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    text-decoration: none;
    cursor: pointer;
}

.button.secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.button.danger {
    background: #9a2f2f;
}

.button.danger.secondary {
    background: transparent;
    color: #9a2f2f;
    border-color: #9a2f2f;
}

.empty, .upload-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.25rem;
}

.upload-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
}

.upload-picker label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--ink);
    font-size: 0.95rem;
}

.upload-picker select {
    min-width: 12rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    font: inherit;
}

.button:disabled {
    opacity: 0.55;
    cursor: default;
}

.upload-overall {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1.1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
}

.upload-overall-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.upload-overall progress {
    width: 100%;
    height: 0.95rem;
    accent-color: var(--accent);
}

.upload-error {
    color: #9a2f2f;
    font-weight: 700;
}

.upload-jobs {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 1.1rem;
}

.upload-job {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.35rem 0.75rem;
    align-items: center;
}

.upload-job progress {
    grid-column: 1 / -1;
    width: 100%;
    height: 0.75rem;
    accent-color: var(--accent);
}

.upload-complete {
    color: #2f7d32;
    font-weight: 700;
}

.upload-phase,
.upload-percent {
    color: var(--muted);
    font-size: 0.9rem;
}

.manual-import-progress {
    margin-top: 0.75rem;
}

.manual-import-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.manual-import-errors {
    margin-top: 0.75rem;
    max-height: 12rem;
    overflow-y: auto;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.35rem;
    background: color-mix(in srgb, var(--line) 25%, transparent);
}

.manual-import-errors ul {
    margin: 0.45rem 0 0;
    padding-left: 1.25rem;
}

.manual-import-errors li {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.photo-grid, .people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.people-grid {
    grid-template-columns: repeat(auto-fill, 165px);
    gap: 0.85rem;
}

.people-grid .person-card strong,
.people-grid .other-card-link strong {
    font-size: 0.85rem;
}

.people-grid .person-card span,
.people-grid .other-card-link span {
    font-size: 0.75rem;
}

.photo-card, .person-card {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.person-card {
    position: relative;
}

.person-card > a {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.card-delete {
    position: absolute;
    top: 0.4rem;
    right: 0.45rem;
    z-index: 2;
    border: 0;
    border-radius: 6px;
    background: rgba(255, 250, 243, 0.92);
    color: #9a2f2f;
    padding: 0.2rem 0.45rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.confirm-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    background: #fff3f0;
    border: 1px solid #e3b4ae;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: rgba(43, 36, 28, 0.45);
}

.confirm-dialog {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.25rem 1.35rem;
    max-width: 28rem;
    width: min(100%, 28rem);
    box-shadow: 0 16px 40px rgba(43, 36, 28, 0.2);
}

.confirm-dialog p {
    margin: 0 0 1rem;
    line-height: 1.45;
}

.confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.person-card.dragging {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
}

.people-grid .person-card.person-card-drag-source-hidden {
    visibility: hidden !important;
    pointer-events: none;
}

.people-grid .person-card.dragging {
    pointer-events: none;
}

.person-card-drag-floater {
    position: fixed;
    z-index: 100000;
    margin: 0;
    pointer-events: none;
    filter: none;
}

.person-card-drag-floater * {
    filter: none;
}

.person-card-drag-ghost-shell {
    border-radius: 12px 12px 0 0;
}

.person-card.drop-target {
    outline: 3px solid var(--accent);
}

.other-card-link img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #1b1611;
}

.photo-card img, .photo-card video, .media-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #1b1611;
}

.media-thumb {
    position: relative;
}

.photo-card .play-badge {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.72);
    color: white;
    border-radius: 999px;
    padding: 0.63rem 1.19rem;
    font-size: 1.19rem;
    letter-spacing: 0.056em;
}

.media-viewer-wrap {
    position: relative;
    margin-bottom: 1.5rem;
}

.media-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    place-items: center;
    padding: 1.25rem 4.75rem;
    background: rgba(17, 14, 11, 0.78);
    outline: none;
    pointer-events: auto;
    overscroll-behavior: contain;
}

.media-viewer-overlay .media-viewer-wrap {
    position: relative;
    z-index: 1;
    width: min(1100px, 100%);
    margin: 0;
    pointer-events: auto;
}

.media-viewer-overlay .media-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
}

.viewer-close {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    z-index: 3;
    width: 2.2rem;
    height: 2.2rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 250, 243, 0.92);
    color: var(--ink);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.media-nav {
    position: absolute;
    top: calc(50% - 2rem);
    z-index: 2;
    width: 2.6rem;
    height: 2.6rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 250, 243, 0.9);
    color: var(--ink);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

.media-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.media-nav.prev {
    left: 0.75rem;
}

.media-nav.next {
    right: 0.75rem;
}

.media-viewer-wrap .media-viewer {
    margin-bottom: 0;
}

.media-viewer {
    background: #111;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid var(--line);
}

.viewer-video {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    width: 100%;
}

.viewer-video-controls {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.85rem 0.85rem;
    background: #1a1816;
}

.viewer-play {
    flex: 0 0 auto;
    width: 3.5rem;
    height: 3.5rem;
    border: 0;
    border-radius: 999px;
    background: #f7f1e8;
    color: #1a1816;
    font-size: 1.45rem;
    line-height: 1;
    cursor: pointer;
}

.viewer-seek {
    flex: 1 1 auto;
    min-width: 0;
    height: 2.75rem;
    margin: 0;
    background: transparent;
    accent-color: #f7f1e8;
    touch-action: none;
    -webkit-appearance: none;
    appearance: none;
}

.viewer-seek::-webkit-slider-runnable-track {
    height: 0.85rem;
    background: #6d665e;
    border-radius: 999px;
}

.viewer-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 2rem;
    height: 2rem;
    margin-top: -0.575rem;
    border: 0;
    border-radius: 50%;
    background: #fff;
}

.viewer-seek::-moz-range-track {
    height: 0.85rem;
    background: #6d665e;
    border: 0;
    border-radius: 999px;
}

.viewer-seek::-moz-range-thumb {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 50%;
    background: #fff;
}

.viewer-time {
    flex: 0 0 auto;
    color: #f7f1e8;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    min-width: 6.5rem;
    text-align: right;
}

.media-viewer img,
.media-viewer video {
    display: block;
    width: 100%;
    max-height: min(80vh, 920px);
    height: auto;
    object-fit: contain;
    background: #000;
    aspect-ratio: auto;
}

.media-viewer-overlay .media-viewer img,
.media-viewer-overlay .media-viewer video {
    max-height: calc(100vh - 13rem);
}

.media-viewer--overlay .viewer-zoom-target {
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
}

.media-viewer-wrap:fullscreen,
.media-viewer:fullscreen {
    background: #000;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.media-viewer-wrap:fullscreen .media-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    border: 0;
    border-radius: 0;
    min-height: 0;
}

.media-viewer-wrap:fullscreen img,
.media-viewer-wrap:fullscreen video,
.media-viewer:fullscreen img,
.media-viewer:fullscreen video {
    flex: 1;
    max-height: none;
    height: 100%;
    min-height: 0;
}

.media-viewer-wrap:fullscreen .viewer-video,
.media-viewer:fullscreen .viewer-video {
    flex: 1;
    min-height: 0;
    height: 100%;
}

.media-viewer-wrap:fullscreen .viewer-video video,
.media-viewer:fullscreen .viewer-video video {
    height: auto;
}

.media-viewer-bar {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--panel);
    flex-wrap: wrap;
}

.media-viewer-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.media-viewer-info span {
    color: var(--ink);
    font-size: 0.9rem;
}

.media-viewer-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.person-cover {
    aspect-ratio: 1;
    overflow: hidden;
    position: relative;
    background: #1b1611;
}

.person-cover img {
    position: absolute;
    inset: 0;
    margin: auto;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    pointer-events: none;
}

.person-cover.cropped img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
}

.profile-editor {
    display: grid;
    grid-template-columns: minmax(96px, 168px) 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
    align-items: start;
}

.profile-editor + h2 {
    margin-top: -20px;
}

.profile-editor-stage {
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    touch-action: pan-y;
    user-select: none;
    border: 1px solid var(--line);
}

.profile-editor-stage.cover-selected {
    cursor: grab;
    outline: 3px solid var(--accent);
    touch-action: none;
}

.profile-editor-stage:active {
    cursor: grabbing;
}

.pick-card {
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
    padding: 0;
    width: 100%;
    border: 0;
    background: transparent;
}

.pick-card.selected,
.photo-card.selected,
.person-card.selected {
    outline: 4px solid var(--accent);
    box-shadow: 0 0 0 4px rgba(138, 75, 47, 0.22);
}

.photo-card.selected::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(138, 75, 47, 0.28);
    pointer-events: none;
}

.photo-card.viewing:not(.selected),
.person-card.viewing:not(.selected) {
    outline: 2px solid var(--muted);
}

.unnamed-preview {
    margin-top: 0.25rem;
}

.assign-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

.assign-bar select,
.assign-bar input {
    min-width: 180px;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-right: 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.sort-control select {
    min-width: 12rem;
}

.location-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: -0.35rem 0 1rem;
}

.location-chip {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    font: inherit;
}

.location-chip span {
    color: var(--muted);
    margin-left: 0.3rem;
}

.location-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.location-chip.active span {
    color: rgba(255, 255, 255, 0.85);
}

.location-heading {
    margin: 0.35rem 0 0.65rem;
    font-size: 1.05rem;
}

.photo-card.selectable,
.person-card.selectable {
    cursor: pointer;
    position: relative;
}

.person-open {
    color: var(--accent);
    font-size: 0.85rem;
    text-decoration: none;
}

.photo-card.selectable input[type="checkbox"],
.person-card.selectable input[type="checkbox"] {
    position: absolute;
    top: 0.55rem;
    left: 0.55rem;
    z-index: 2;
    accent-color: var(--accent);
}

.photo-card.selectable input[type="checkbox"] {
    width: calc(1.35rem * 0.75);
    height: calc(1.35rem * 0.75);
}

.person-card.selectable input[type="checkbox"] {
    width: 1.35rem;
    height: 1.35rem;
}

@media (max-width: 800px) {
    .profile-editor {
        grid-template-columns: 1fr;
    }

    .profile-editor-stage {
        justify-self: start;
        width: 40%;
    }

    .media-viewer-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .media-viewer-actions {
        width: 100%;
    }

    .media-viewer-actions::before {
        content: "";
        order: 1;
        flex-basis: 100%;
        height: 0;
    }

    .fullscreen-button {
        order: 2;
        margin-inline: auto;
    }

    .media-viewer-overlay {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 4.25rem 0 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        height: 100dvh;
        max-height: 100dvh;
    }

    .media-viewer-overlay .media-viewer-wrap {
        width: 100%;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        max-height: 100%;
    }

    .media-viewer-overlay .media-nav {
        top: 0.55rem;
        transform: none;
    }

    .media-viewer-overlay .media-viewer {
        border-radius: 0;
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        margin-bottom: 0;
        overflow: hidden;
    }

    .media-viewer-overlay .media-viewer > img,
    .media-viewer-overlay .media-viewer > .viewer-video {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        max-height: 100%;
        overflow: hidden;
    }

    .media-viewer-overlay .media-viewer > .viewer-video {
        display: flex;
        flex-direction: column;
    }

    .media-viewer-overlay .media-viewer img,
    .media-viewer-overlay .media-viewer video {
        width: 100%;
        height: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    .media-viewer-overlay .media-viewer-bar {
        flex-shrink: 0;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }
}

.photo-meta, .person-card {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.photo-meta span {
    font-size: 0.85rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.other-placeholder {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    background: #efe2d2;
    color: var(--muted);
    font-weight: 600;
}

.other-card {
    outline: 1px dashed var(--line);
}

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.chip {
    background: #efe2d2;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.8rem;
    text-decoration: none;
}

.rename-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.rename-row.compact {
    margin-bottom: 0;
}

.rename-row input {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    min-width: 220px;
}

.rename-save-status,
.cover-save-status {
    color: var(--muted);
    font-size: 0.85rem;
}

#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

@media (max-width: 800px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }

    .app-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        max-width: 100%;
    }

    .sidebar,
    .content {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.65rem 0.85rem;
        padding: 0.85rem 1rem;
    }

    .sidebar .module-back,
    .sidebar .brand {
        flex: 0 0 auto;
    }

    .sidebar nav {
        flex: 1 1 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .logout-form {
        flex: 0 0 auto;
        margin-top: 0;
        margin-left: auto;
    }

    .logout-button {
        width: auto;
    }

    .sidebar-note {
        flex: 1 1 100%;
        min-width: 0;
        max-width: 100%;
        margin: 0;
    }

    .content {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        min-width: 0;
    }

    .header-actions,
    .rename-row,
    .search-bar {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        justify-content: flex-start;
        box-sizing: border-box;
    }

    .rename-row {
        flex-wrap: wrap;
    }

    .rename-row input,
    .search-bar input,
    .assign-bar select,
    .assign-bar input,
    .sort-control select {
        min-width: 0;
        max-width: 100%;
        flex: 1 1 8rem;
        width: auto;
        box-sizing: border-box;
    }

    .rename-row .button,
    .header-actions > .button,
    .search-bar > .button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .people-grid,
    .photo-grid,
    .module-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
        min-width: 0;
        max-width: 100%;
    }
}

.auth-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem 2.5rem;
}

@media (min-width: 801px) {
    .auth-shell {
        height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }
}

.auth-shell > .app-version {
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: 0.75rem;
    margin: 0;
    text-align: center;
}

.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.75rem 1.6rem;
    width: min(100%, 26rem);
    box-shadow: 0 16px 40px rgba(43, 36, 28, 0.12);
}

.auth-brand {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--accent);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 1rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.92rem;
}

.auth-form input {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.auth-error {
    color: #9a2f2f;
    margin: 0.75rem 0 0;
}

.auth-form button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.auth-alt {
    margin: 1rem 0 0;
    color: var(--muted);
}

.logout-form {
    margin-top: auto;
}

.logout-button {
    width: 100%;
    background: transparent;
    color: #f7f1e8;
    border-color: rgba(255, 255, 255, 0.28);
}

.media-properties-overlay {
    z-index: 50;
}

.media-properties-sheet {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    width: min(100%, 32rem);
    max-height: min(90vh, 42rem);
    overflow: auto;
    padding: 0 0 1rem;
    box-shadow: 0 18px 48px rgba(43, 36, 28, 0.28);
    outline: none;
}

.media-properties-header {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding: 1rem 1.15rem 0.85rem;
}

.media-properties-header img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    aspect-ratio: auto;
    background: #1b1611;
}

.media-properties-header h2 {
    margin: 0;
    font-size: 1rem;
}

.media-properties-header p {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
}

.media-properties-tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
    padding: 0 1rem;
}

.media-properties-tabs button {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 0.55rem 0.85rem;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
}

.media-properties-tabs button.active {
    color: var(--ink);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.media-properties-list {
    margin: 0;
    padding: 0.75rem 1.15rem;
}

.media-properties-row {
    display: grid;
    grid-template-columns: 8.5rem 1fr;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
}

.media-properties-row dt {
    color: var(--muted);
}

.media-properties-row dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.media-properties-actions {
    padding: 0.65rem 1.15rem 0;
    justify-content: flex-end;
}

.media-properties-loading {
    padding: 1rem 1.15rem;
}
