:root {
    --ink: #121820;
    --muted: #5A6570;
    --ground: #E6ECF0;
    --surface: #F4F7F9;
    --line: rgba(18, 24, 32, 0.14);
    --accent: #1B6B63;
    --accent-ink: #F3FAF8;
    --danger: #9f1239;
    --radius: 8px;
    --radius-sm: 6px;
    --font-display: "Syne", "Avenir Next", "Segoe UI", sans-serif;
    --font-body: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    font-family: var(--font-body);
    background:
        linear-gradient(165deg, #dfe7ee 0%, var(--ground) 42%, #d8e2e9 100%);
    background-attachment: fixed;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.045;
    background-image: var(--grain);
    z-index: 0;
}

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

/* —— App shell —— */
.shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.shell.landing,
.shell.auth {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
}

.rail {
    padding: 1.75rem 1.35rem;
    border-right: 1px solid var(--line);
    background: rgba(244, 247, 249, 0.72);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.brand {
    font-family: var(--font-display);
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.brand-tag {
    margin: 0;
    color: var(--muted);
    line-height: 1.4;
    font-size: 0.88rem;
}

.rail-archive {
    margin: 0.85rem 0 0;
    display: grid;
    gap: 0.15rem;
    font-size: 0.88rem;
}

.rail-archive a {
    color: var(--accent);
    font-weight: 600;
    width: fit-content;
    border-bottom: 2px solid transparent;
}

.rail-archive a:hover {
    border-bottom-color: var(--accent);
}

.empty-hint {
    color: var(--muted);
    margin: 0 0 0.75rem;
    line-height: 1.45;
    max-width: 36rem;
}

.check-list {
    display: grid;
    gap: 0.35rem;
    max-height: 10rem;
    overflow: auto;
    padding: 0.35rem 0;
}

.check-list label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 500;
}

.check-list input {
    width: auto;
}

.filter-row .btn.secondary.is-active {
    border-color: var(--accent);
    color: var(--accent);
}

.page-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}

.page-flow a {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.92rem;
}

.page-trail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0 0.65rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.page-trail a {
    color: var(--accent);
    font-weight: 600;
}

.page-trail__sep {
    opacity: 0.55;
}

.page-trail__current {
    color: var(--ink);
    font-weight: 600;
}

.hub-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}

.hub-links a {
    color: var(--ink);
}

.hub-links a:hover {
    color: var(--accent);
}

.hub-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.15rem;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    transition: color 160ms ease, border-color 160ms ease;
}

.hub-link:hover {
    border-bottom-color: var(--accent);
}

.hub-link__text {
    display: grid;
    gap: 0.15rem;
}

.hub-link__chev {
    color: var(--muted);
    font-weight: 600;
    flex-shrink: 0;
}

.hub-link:hover .hub-link__chev {
    color: var(--accent);
}

.hub-grid .section {
    padding: 0.25rem 0 0.75rem;
}

.hub-grid .section > .muted {
    margin: 0 0 0.5rem;
}

.rail nav {
    display: grid;
    gap: 1.1rem;
}

.nav-group {
    display: grid;
    gap: 0.2rem;
}

.nav-group__label {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.15rem;
    font-weight: 600;
}

.rail nav a,
.landing-chrome nav a,
.auth-chrome nav a {
    padding: 0.4rem 0.15rem;
    color: var(--ink);
    border-bottom: 2px solid transparent;
    transition: border-color 180ms ease, color 180ms ease;
    width: fit-content;
}

.rail nav a:hover,
.landing-chrome nav a:hover,
.auth-chrome nav a:hover {
    color: var(--accent);
}

.rail nav a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.rail-foot {
    margin-top: auto;
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.stage {
    padding: 2rem clamp(1.25rem, 4vw, 3rem);
    max-width: 1100px;
}

.shell.landing .stage,
.shell.auth .stage {
    max-width: none;
    padding: 0;
    flex: 1;
}

/* —— Landing chrome —— */
.landing-chrome,
.auth-chrome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem clamp(1.25rem, 4vw, 2.5rem);
    position: relative;
    z-index: 2;
}

.shell.landing .landing-chrome {
    position: absolute;
    inset: 0 0 auto 0;
    color: #f4f7f9;
}

.shell.landing .landing-chrome .brand,
.shell.landing .landing-chrome a {
    color: #f4f7f9;
}

.shell.landing .landing-chrome a:hover {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.55);
}

.auth-chrome {
    border-bottom: 1px solid var(--line);
    background: rgba(244, 247, 249, 0.85);
}

.auth-chrome nav {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.auth-stage {
    padding: 2.5rem clamp(1.25rem, 4vw, 3rem);
    display: grid;
    justify-items: center;
}

.auth-stage .page-header,
.auth-stage .panel {
    width: 100%;
    max-width: 420px;
}

/* —— Full-bleed home hero —— */
.landing-hero {
    min-height: 100vh;
    display: grid;
    align-content: end;
    padding: clamp(5.5rem, 14vh, 8rem) clamp(1.25rem, 5vw, 4rem) clamp(2.5rem, 8vh, 4.5rem);
    background-color: #1a222c;
    background-image:
        linear-gradient(180deg, rgba(18, 24, 32, 0.35) 0%, rgba(18, 24, 32, 0.62) 48%, rgba(18, 24, 32, 0.84) 100%),
        url("/images/hero.jpg");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    color: #f4f7f9;
    animation: hero-fade 900ms ease both;
}

.landing-hero__inner {
    max-width: 36rem;
    display: grid;
    gap: 1rem;
}

.landing-hero h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(3.2rem, 9vw, 5.6rem);
    line-height: 0.92;
    letter-spacing: -0.04em;
    font-weight: 700;
}

.landing-hero p {
    margin: 0;
    font-size: clamp(1.05rem, 2.2vw, 1.25rem);
    line-height: 1.45;
    color: rgba(244, 247, 249, 0.88);
    max-width: 28rem;
}

.landing-hero .actions {
    margin-top: 0.35rem;
}

.landing-hero .btn {
    background: var(--accent);
    color: var(--accent-ink);
}

.landing-hero .btn.secondary {
    background: transparent;
    color: #f4f7f9;
    border-color: rgba(244, 247, 249, 0.45);
}

.landing-hero .btn.secondary:hover {
    border-color: #fff;
    color: #fff;
}

/* —— Page headers & sections —— */
.page-header {
    margin: 0 0 1.5rem;
    display: grid;
    gap: 0.35rem;
    animation: rise 500ms ease both;
}

.page-header h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--ink);
}

.page-header p {
    margin: 0;
    color: var(--muted);
    max-width: 40rem;
    line-height: 1.45;
}

.section {
    animation: rise 500ms ease both;
}

.section + .section,
.panel + .section,
.section + .panel {
    margin-top: 1.75rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
    align-items: center;
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0.7rem 1.15rem;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.btn:hover { background: #155851; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.secondary {
    background: #fff;
    color: var(--ink);
    border-color: rgba(18, 24, 32, 0.28);
}

.btn.secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #fff;
}

/* Interaction surfaces only */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.35rem;
    animation: rise 500ms ease both;
}

.panel h2,
.panel h3 {
    font-family: var(--font-display);
    margin-top: 0;
    letter-spacing: -0.02em;
}

.grid {
    display: grid;
    gap: 1.25rem;
}

.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-items: start;
}

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink);
}

label:has(> input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 500;
}

label:has(> input[type="checkbox"]) input {
    width: auto;
}

label .hint,
label.muted {
    font-weight: 500;
    color: var(--muted);
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.85rem;
    background: #fff;
    font: inherit;
    color: var(--ink);
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid rgba(27, 107, 99, 0.35);
    outline-offset: 1px;
}

textarea { min-height: 120px; resize: vertical; }

.list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0;
}

.list li {
    padding: 0.95rem 0;
    border-bottom: 1px solid var(--line);
}

.list li:first-child { padding-top: 0.25rem; }

.muted { color: var(--muted); font-weight: 500; }
.error { color: var(--danger); }
.success { color: var(--accent); }

.linkish {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    text-align: left;
    font-weight: 600;
}

.chat {
    display: grid;
    gap: 0.55rem;
    max-height: min(52vh, 520px);
    overflow: auto;
    padding-right: 0.25rem;
}

.bubble {
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius);
    max-width: 48rem;
    border: 1px solid var(--line);
    background: #fff;
    animation: rise 280ms ease both;
}

.bubble strong {
    display: block;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.bubble.user {
    background: rgba(27, 107, 99, 0.08);
    border-color: rgba(27, 107, 99, 0.2);
    justify-self: end;
}

.bubble.assistant {
    background: var(--surface);
    justify-self: start;
}

.recording-on {
    color: var(--danger);
    font-weight: 600;
}

.meter {
    height: 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(18, 24, 32, 0.08);
    overflow: hidden;
}

.meter > span {
    display: block;
    height: 100%;
    background: var(--accent);
    transition: width 600ms ease;
}

.thumb {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 1rem 0;
    border: 1px solid var(--line);
}

h1:focus { outline: none; }
main.stage:focus { outline: none; }
main.stage:focus-visible {
    outline: 2px solid rgba(27, 107, 99, 0.35);
    outline-offset: 4px;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes hero-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.settings-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1.15rem;
    margin: 0 0 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
}

.settings-toc a {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.92rem;
}

#profile,
#security,
#archives,
#export {
    scroll-margin-top: 1.25rem;
}

@media (max-width: 900px) {
    .shell:not(.landing):not(.auth) {
        grid-template-columns: 1fr;
    }

    .rail {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding-bottom: 1rem;
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: start;
        gap: 0.75rem 1rem;
    }

    .brand-tag,
    .nav-group__label {
        display: none;
    }

    .rail nav {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.15rem;
        overflow-x: auto;
        padding-bottom: 0.35rem;
        -webkit-overflow-scrolling: touch;
        grid-column: 1 / -1;
    }

    .nav-group {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.75rem;
        align-items: center;
        flex-shrink: 0;
        padding-right: 0.75rem;
        margin-right: 0.35rem;
        border-right: 1px solid var(--line);
    }

    .nav-group:last-child {
        border-right: 0;
        margin-right: 0;
        padding-right: 0;
    }

    .rail nav a {
        white-space: nowrap;
    }

    .rail-foot {
        margin-top: 0;
        justify-self: end;
        text-align: right;
        font-size: 0.82rem;
    }

    .rail-foot span {
        display: none;
    }

    .stage {
        padding: 1.5rem 1.15rem 2.5rem;
    }
}

/* —— Home feed —— */
.home-capture {
    margin-bottom: 1.25rem;
}

.home-capture--secondary {
    opacity: 0.98;
}

.home-quiet-capture {
    margin: 0 0 1.25rem;
}

.home-families {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1.25rem;
}

.home-family-chip {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--stroke, rgba(0, 0, 0, 0.12));
    border-radius: 999px;
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--ink);
}

.home-family-chip:hover {
    border-color: var(--accent, #2a6f6a);
}

.feed-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

.feed-tabs button {
    appearance: none;
    border: 1px solid var(--stroke, rgba(0, 0, 0, 0.12));
    background: transparent;
    color: var(--muted);
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
}

.feed-tabs button.active {
    color: var(--ink);
    border-color: var(--ink);
    font-weight: 600;
}

.home-feed-list p {
    margin: 0.35rem 0 0;
}

.home-families {
    align-items: center;
}

.home-families__label {
    font-size: 0.82rem;
    font-weight: 600;
    margin-right: 0.25rem;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1.1rem;
    border-left: 2px solid var(--line);
    display: grid;
    gap: 1.35rem;
}

.timeline__year h3 {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.timeline__year .list li:first-child {
    padding-top: 0.15rem;
}

.media-row {
    display: flex;
    gap: 0.85rem;
    align-items: center;
}

.thumb--list {
    width: 4.5rem;
    height: 4.5rem;
    object-fit: cover;
    margin: 0;
    flex-shrink: 0;
}

.narrative-preview {
    margin-top: 0.5rem;
}

.narrative-preview summary {
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
}

.filter-row .btn.secondary.is-active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(27, 107, 99, 0.08);
}
