html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--body-font);
    background: var(--neutral-layer-1);
}

:root {
    --app-header-height: 56px;
    --app-secondary-bar-height: 48px;
}

h1:focus {
    outline: none;
}

/* <FluentHeader> renders a plain <header class="header">, not a custom element — this
   has to be unscoped (here, not a component's own .razor.css) to reach it at all: Blazor
   CSS isolation only scopes a stylesheet to elements its own component renders directly,
   never into a nested child component's internal markup, no matter the selector.
   Pins the header at the top on small displays, paired with .secondary-bar's own sticky
   rule (MainLayout.razor.css) so both stay visible while scrolling.
   overflow-x: hidden guards against the header row (title + theme/file-command icons)
   having no room to shrink below its content's minimum width once the display gets
   narrow enough — flex items default to min-width: auto, so instead of wrapping/shrinking
   they overflow the header's box past the viewport edge, which on mobile Chrome/Safari
   widens the whole page's layout viewport and zooms the entire page out to fit it.
   Paired with the title's own ellipsis + min-width: 0 in MainLayout.razor. */
@media (max-width: 900px) {
    header.header {
        position: sticky;
        top: 0;
        z-index: 1003;
        overflow-x: hidden;
    }
}

.page-loading-state {
    padding: 4rem 0;
    justify-content: center;
}

.page-empty-state {
    padding: 4rem 0;
    text-align: center;
    align-items: center;
}

.welcome-page {
    padding: 4rem 0;
    align-items: center;
    text-align: center;
}

.page-error-state {
    padding: 4rem 0;
    text-align: center;
    align-items: center;
}

.people-grid-column {
    flex: 1 1 auto;
    min-width: 0;
}

.person-details-panel {
    flex: 0 0 420px;
    max-width: 420px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 16px;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: var(--control-corner-radius, 4px);
    background: var(--neutral-layer-2);
}

.details-field {
    display: flex;
    flex-direction: column;
    min-width: 160px;
    flex: 1 1 160px;
}

.details-field-switch {
    flex-direction: row;
    align-items: center;
    min-width: auto;
    flex: 0 0 auto;
    padding-top: 20px;
}

.relationship-row {
    padding: 4px 0;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
}

.relationship-row:last-child {
    border-bottom: none;
}

.photo-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.photo-thumb {
    position: relative;
    width: 96px;
    height: 96px;
    border-radius: var(--control-corner-radius, 4px);
    overflow: hidden;
    border: 2px solid transparent;
}

.photo-thumb.is-avatar {
    border-color: var(--accent-fill-rest);
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-thumb-actions {
    position: absolute;
    inset: auto 0 0 0;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}

.photo-thumb:hover .photo-thumb-actions,
.photo-thumb:focus-within .photo-thumb-actions {
    opacity: 1;
}

.story-toolbar {
    padding: 4px 0;
}

.story-editor {
    min-height: 160px;
    padding: 8px 12px;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: var(--control-corner-radius, 4px);
    background: var(--neutral-layer-1);
}

.story-editor:focus {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: -1px;
}

.story-view {
    padding: 8px 0;
    line-height: 1.5;
}

.avatar-thumbnail {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.tree-viewport {
    position: relative;
    width: 100%;
    height: calc(100vh - 220px);
    min-height: 420px;
    overflow: hidden;
    touch-action: none;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: var(--control-corner-radius, 4px);
    background: var(--neutral-layer-1);
    background-image: radial-gradient(var(--neutral-stroke-divider-rest) 1px, transparent 1px);
    background-size: 24px 24px;
}

.connector {
    stroke: var(--neutral-stroke-strong-rest);
    stroke-width: 1.5px;
}

.connector.former-connector {
    stroke-dasharray: 4 3;
    opacity: 0.7;
}

.connector-label {
    font-size: 11px;
    fill: var(--neutral-foreground-hint);
}

.tree-node {
    cursor: pointer;
}

.tree-node .node-shape {
    fill: var(--neutral-fill-secondary-rest);
    stroke: var(--neutral-stroke-strong-rest);
    stroke-width: 1.5px;
}

.tree-node.male .node-shape {
    fill: var(--accent-fill-rest, #ddeeff);
}

.tree-node.female .node-shape {
    fill: #ffe1ee;
}

.tree-node.deceased .node-shape {
    opacity: 0.65;
}

.tree-node.primary .node-shape {
    stroke-width: 3px;
    stroke: var(--accent-fill-rest);
}

.tree-node.spouse .node-shape,
.tree-node.sibling .node-shape {
    stroke-dasharray: none;
}

.tree-node:hover .node-shape {
    filter: brightness(0.95);
}

.tree-node .node-name {
    font-size: 13px;
    font-weight: 600;
    fill: var(--neutral-foreground-rest);
}

.tree-node .node-avatar {
    clip-path: circle(50%);
}

.tree-node .node-dates {
    font-size: 11px;
    fill: var(--neutral-foreground-hint);
}

.statistics-page {
    max-width: 1100px;
}

.stat-card {
    padding: 16px;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: var(--control-corner-radius, 4px);
    background: var(--neutral-layer-2);
}

.tagcloud-row {
    flex-wrap: wrap;
}

.tagcloud-card {
    flex: 1 1 260px;
    min-width: 0;
}

.histogram-chart-wrapper {
    width: 100%;
    max-width: 480px;
}

.histogram-chart {
    width: 100%;
    height: auto;
}

.histogram-axis {
    stroke: var(--neutral-stroke-strong-rest);
    stroke-width: 1px;
}

.histogram-bar {
    fill: var(--accent-fill-rest);
}

.histogram-count {
    font-size: 12px;
    font-weight: 600;
    fill: var(--neutral-foreground-rest);
}

.histogram-label {
    font-size: 11px;
    fill: var(--neutral-foreground-hint);
}

.birthday-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.birthday-group {
    min-width: 160px;
}

.birthday-group ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
}

.tag-cloud-item {
    color: var(--neutral-foreground-rest);
    line-height: 1;
}

@media (max-width: 900px) {
    html {
        overflow-x: hidden;
    }

    .people-page {
        flex-direction: column;
    }

    .person-details-panel {
        flex: 1 1 auto;
        max-width: none;
    }
}
