/* The Little Archive of Us — a paper, ink, and keepsake visual system */
:root {
    --ink: #45382f;
    --ink-soft: #74665b;
    --ink-faint: #9b8d80;
    --paper: #fffaf0;
    --paper-deep: #f5ead5;
    --paper-aged: #e8d8bc;
    --desk: #cbbb9f;
    --rose: #b96474;
    --rose-dark: #95495a;
    --rose-wash: #f4dce0;
    --sage: #7f9275;
    --sage-dark: #63745b;
    --sage-wash: #e4eadc;
    --mustard: #d4aa52;
    --mustard-wash: #f5e9bd;
    --blue: #738b98;
    --blue-wash: #dce8eb;
    --red-line: rgba(185, 100, 116, 0.36);
    --blue-line: rgba(115, 139, 152, 0.18);

    /* Legacy aliases used by existing dynamic content. */
    --primary: var(--rose);
    --primary-light: #cc8190;
    --primary-dark: var(--rose-dark);
    --secondary: var(--sage);
    --secondary-light: #a5b49c;
    --secondary-dark: var(--sage-dark);
    --accent: var(--rose);
    --warning: var(--mustard);
    --error: #a94646;
    --success: #687f61;
    --background: var(--paper-deep);
    --surface: var(--paper);
    --surface-light: #faf2e3;
    --text-primary: var(--ink);
    --text-secondary: var(--ink-soft);
    --text-muted: var(--ink-faint);
    --border: #d7c7ad;

    --shadow-sm: 0 2px 5px rgba(68, 50, 35, 0.1);
    --shadow: 0 6px 18px rgba(68, 50, 35, 0.12);
    --shadow-md: 0 10px 28px rgba(68, 50, 35, 0.14);
    --shadow-lg: 0 18px 45px rgba(68, 50, 35, 0.18);
    --shadow-xl: 0 25px 65px rgba(68, 50, 35, 0.22);
    --radius-sm: 5px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --sidebar-width: 304px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.26), transparent 22%),
        radial-gradient(circle at 80% 88%, rgba(102, 79, 54, 0.12), transparent 30%),
        repeating-linear-gradient(93deg, rgba(255, 255, 255, 0.02) 0 2px, rgba(66, 48, 29, 0.018) 2px 4px),
        var(--desk);
    font-family: "DM Sans", sans-serif;
    line-height: 1.55;
}

button,
input,
select {
    font: inherit;
}

button,
a,
select {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

a {
    color: inherit;
}

::selection {
    color: var(--ink);
    background: var(--mustard-wash);
}

:focus-visible {
    outline: 3px solid rgba(185, 100, 116, 0.45);
    outline-offset: 3px;
}

.desk-decoration {
    position: fixed;
    z-index: 0;
    color: rgba(69, 56, 47, 0.16);
    font-family: "Caveat", cursive;
    pointer-events: none;
    user-select: none;
}

.desk-decoration--flower {
    right: 1.5vw;
    bottom: 1vh;
    font-size: clamp(4rem, 8vw, 8rem);
    transform: rotate(13deg);
}

.desk-decoration--heart {
    right: 3vw;
    top: 5vh;
    font-size: clamp(3rem, 5vw, 5rem);
    transform: rotate(-10deg);
}

.container,
.container-fluid {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0;
}

/* Book spine / chapter navigation */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(74, 50, 34, 0.13), transparent 10px),
        linear-gradient(90deg, transparent calc(100% - 8px), rgba(91, 64, 40, 0.12)),
        repeating-linear-gradient(0deg, rgba(69, 56, 47, 0.018) 0 1px, transparent 1px 5px),
        #eee1c9;
    border-right: 1px solid rgba(82, 59, 40, 0.24);
    box-shadow: 8px 0 30px rgba(62, 44, 28, 0.17);
}

.sidebar::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 12px;
    width: 1px;
    background: rgba(185, 100, 116, 0.35);
}

.sidebar::after {
    content: "";
    position: absolute;
    right: -1px;
    top: 0;
    width: 9px;
    height: 100%;
    background: repeating-linear-gradient(0deg, transparent 0 14px, rgba(69, 56, 47, 0.1) 14px 15px);
    pointer-events: none;
}

.sidebar-header {
    position: relative;
    padding: 28px 28px 20px 34px;
}

.bookplate {
    position: relative;
    padding: 20px 18px 17px;
    text-align: center;
    background: rgba(255, 250, 240, 0.68);
    border: 1px solid rgba(119, 91, 66, 0.32);
    outline: 1px solid rgba(119, 91, 66, 0.19);
    outline-offset: -6px;
    box-shadow: var(--shadow-sm);
    transform: rotate(-0.6deg);
}

.bookplate-kicker,
.letter-kicker,
.section-kicker,
.page-eyebrow,
.chapter-label,
.field-label {
    display: block;
    font-size: 0.69rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.bookplate-kicker {
    color: var(--rose-dark);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 4px 0 0;
}

.logo-icon {
    color: var(--rose);
    font-size: 1.6rem;
}

.logo-text {
    font-family: "Caveat", cursive;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.logo-subtitle {
    margin-top: 4px;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.78rem;
    font-style: italic;
}

.sidebar-intro {
    max-width: 220px;
    margin: 17px auto 0;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.78rem;
    font-style: italic;
    text-align: center;
}

.chapter-label {
    margin: 2px 32px 9px;
    color: var(--ink-faint);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 0 14px 8px 26px;
    overflow-y: auto;
}

.nav-item {
    position: relative;
    display: grid;
    grid-template-columns: 24px 27px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    min-height: 61px;
    margin: 0 0 5px;
    padding: 8px 12px 8px 8px;
    color: var(--ink-soft);
    text-decoration: none;
    border: 1px solid transparent;
    transition: transform 180ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.nav-item::after {
    content: "";
    position: absolute;
    right: -15px;
    top: 8px;
    width: 16px;
    height: calc(100% - 16px);
    border-radius: 0 5px 5px 0;
    background: transparent;
}

.nav-item:hover {
    color: var(--ink);
    background: rgba(255, 250, 240, 0.52);
    transform: translateX(2px);
}

.nav-item.active {
    color: var(--ink);
    background: var(--paper);
    border-color: rgba(121, 91, 66, 0.25);
    box-shadow: 0 4px 10px rgba(68, 50, 35, 0.09);
    transform: rotate(-0.35deg);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 4px;
    background: var(--rose);
}

.nav-item.active::after {
    background: var(--rose-wash);
    border: 1px solid rgba(121, 91, 66, 0.2);
    border-left: 0;
}

.nav-number {
    color: var(--ink-faint);
    font-family: "Lora", serif;
    font-size: 0.68rem;
}

.nav-icon {
    color: var(--rose);
    font-family: "Lora", serif;
    font-size: 1.25rem;
    text-align: center;
}

.nav-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.nav-label {
    color: inherit;
    font-family: "Lora", serif;
    font-size: 0.88rem;
    font-weight: 600;
}

.nav-copy small {
    overflow: hidden;
    color: var(--ink-faint);
    font-family: "Caveat", cursive;
    font-size: 0.94rem;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer {
    position: relative;
    padding: 12px 25px 22px 34px;
    background: linear-gradient(0deg, rgba(101, 71, 45, 0.08), transparent);
}

.sidebar-footer::before {
    content: "";
    display: block;
    height: 1px;
    margin-bottom: 12px;
    background: repeating-linear-gradient(90deg, rgba(69, 56, 47, 0.25) 0 5px, transparent 5px 9px);
}

.margin-note {
    margin-bottom: 7px;
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 1rem;
}

.quick-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-item {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.stat-number {
    overflow: hidden;
    color: var(--ink);
    font-family: "Lora", serif;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.2;
    text-overflow: ellipsis;
}

.stat-label {
    color: var(--ink-faint);
    font-size: 0.6rem;
    font-weight: 600;
}

.stat-divider {
    color: var(--rose);
}

.help-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 11px;
    color: var(--ink-soft);
    background: rgba(255, 250, 240, 0.54);
    border: 1px dashed rgba(69, 56, 47, 0.3);
    border-radius: 3px;
    cursor: pointer;
    transition: 180ms ease;
}

.help-btn:hover {
    color: var(--ink);
    background: var(--paper);
    transform: rotate(-0.4deg);
}

.help-icon {
    color: var(--rose);
}

.help-text {
    font-family: "Caveat", cursive;
    font-size: 0.98rem;
    font-weight: 600;
}

.sidebar-close {
    display: none;
    position: absolute;
    z-index: 3;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
}

.sidebar-scrim {
    display: none;
}

.close-icon {
    font-size: 1.5rem;
    line-height: 1;
}

/* Open notebook page */
.main-content {
    position: relative;
    z-index: 1;
    width: calc(100% - var(--sidebar-width));
    min-height: calc(100vh - 32px);
    margin: 16px 16px 16px calc(var(--sidebar-width) + 16px);
    overflow: hidden;
    background:
        linear-gradient(90deg, transparent 72px, var(--red-line) 72px 73px, transparent 73px),
        repeating-linear-gradient(0deg, transparent 0 31px, var(--blue-line) 31px 32px),
        linear-gradient(90deg, rgba(75, 52, 34, 0.035), transparent 15px),
        var(--paper);
    border: 1px solid rgba(104, 74, 49, 0.23);
    border-radius: 4px 13px 13px 4px;
    box-shadow: var(--shadow-lg);
}

.main-content::before {
    content: "";
    position: fixed;
    top: 16px;
    bottom: 16px;
    left: calc(var(--sidebar-width) + 16px);
    z-index: 55;
    width: 14px;
    border-radius: 3px 0 0 3px;
    background: linear-gradient(90deg, rgba(65, 43, 25, 0.13), rgba(255, 255, 255, 0.12), transparent);
    pointer-events: none;
}

.top-header {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 116px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 46px 19px 94px;
    background: rgba(255, 250, 240, 0.91);
    border-bottom: 1px solid rgba(117, 89, 66, 0.18);
    box-shadow: 0 8px 18px rgba(69, 56, 47, 0.045);
    backdrop-filter: blur(14px);
}

.header-left {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-titles {
    min-width: 0;
}

.page-eyebrow {
    margin-bottom: 2px;
    color: var(--rose-dark);
}

.page-title {
    color: var(--ink);
    font-family: "Caveat", cursive;
    font-size: clamp(2.25rem, 4vw, 3.3rem);
    font-weight: 700;
    line-height: 0.98;
}

.page-subtitle {
    margin-top: 6px;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.86rem;
    font-style: italic;
}

.mobile-menu-toggle {
    display: none;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.menu-label {
    font-family: "Caveat", cursive;
    font-size: 1rem;
}

.random-btn {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 17px 10px 14px;
    color: var(--ink);
    background: var(--mustard-wash);
    border: 1px solid #c5a454;
    border-radius: 2px;
    box-shadow: 2px 3px 0 rgba(91, 67, 43, 0.13);
    cursor: pointer;
    transform: rotate(0.7deg);
    transition: 180ms ease;
}

.random-btn::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 43%;
    width: 46px;
    height: 12px;
    background: rgba(240, 220, 172, 0.72);
    transform: rotate(-4deg);
}

.random-btn:hover {
    transform: rotate(-0.4deg) translateY(-2px);
    box-shadow: 3px 6px 0 rgba(91, 67, 43, 0.12);
}

.random-btn .btn-icon {
    color: var(--rose);
    font-size: 1.2rem;
}

.btn-copy {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.btn-copy small {
    color: var(--ink-soft);
    font-family: "Caveat", cursive;
    font-size: 0.82rem;
    line-height: 1;
}

.btn-text {
    font-family: "Lora", serif;
    font-size: 0.82rem;
    font-weight: 600;
}

.content-wrapper {
    min-height: calc(100vh - 116px);
    padding: 34px 44px 72px 94px;
}

.content-section {
    display: none;
    width: 100%;
    animation: page-in 300ms ease both;
}

.content-section.active {
    display: block;
}

@keyframes page-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* First-time guidance */
.welcome-note {
    position: relative;
    margin-bottom: 25px;
    background: #f6e7e5;
    border: 1px solid rgba(154, 88, 98, 0.26);
    box-shadow: var(--shadow-sm);
    transform: rotate(-0.2deg);
}

.welcome-note::after {
    content: "for V.";
    position: absolute;
    right: 24px;
    bottom: 12px;
    color: rgba(149, 73, 90, 0.53);
    font-family: "Caveat", cursive;
    font-size: 1.3rem;
    transform: rotate(-6deg);
}

.welcome-note summary {
    min-height: 75px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 15px 22px;
    list-style: none;
    cursor: pointer;
}

.welcome-note summary::-webkit-details-marker {
    display: none;
}

.welcome-note summary > span:nth-child(2) {
    display: flex;
    flex: 1;
    flex-direction: column;
}

.welcome-note summary small {
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 0.94rem;
}

.welcome-note summary strong {
    font-family: "Lora", serif;
    font-size: 1rem;
    font-weight: 500;
}

.welcome-pin {
    width: 13px;
    height: 13px;
    align-self: flex-start;
    margin-top: 2px;
    background: var(--rose);
    border: 2px solid #d99aa5;
    border-radius: 50%;
    box-shadow: 1px 2px 2px rgba(69, 56, 47, 0.22);
}

.summary-action {
    color: var(--ink-soft);
    font-family: "Caveat", cursive;
    font-size: 0.93rem;
}

.summary-action::after {
    content: " ↓";
}

.welcome-note[open] .summary-action::after {
    content: " ↑";
}

.welcome-note-body {
    padding: 2px 31px 25px 48px;
    border-top: 1px dashed rgba(149, 73, 90, 0.24);
}

.welcome-letter {
    max-width: 850px;
    margin: 16px 0;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.89rem;
    font-style: italic;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 900px;
}

.guide-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 12px;
}

.guide-step > span {
    width: 28px;
    height: 28px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: var(--rose-dark);
    background: rgba(255, 250, 240, 0.65);
    border: 1px solid rgba(149, 73, 90, 0.32);
    border-radius: 50%;
    font-family: "Caveat", cursive;
    font-weight: 700;
}

.guide-step div {
    display: flex;
    flex-direction: column;
}

.guide-step strong {
    font-family: "Lora", serif;
    font-size: 0.76rem;
}

.guide-step small {
    color: var(--ink-soft);
    font-size: 0.68rem;
}

/* Form controls */
.filters-bar,
.controls-card {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 15px;
    margin-bottom: 25px;
    padding: 21px 23px 17px;
    background:
        repeating-linear-gradient(0deg, transparent 0 26px, rgba(115, 139, 152, 0.09) 26px 27px),
        rgba(255, 252, 244, 0.93);
    border: 1px solid rgba(107, 80, 57, 0.23);
    box-shadow: var(--shadow-sm);
}

.filters-bar::before,
.controls-card::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 8%;
    width: 64px;
    height: 13px;
    background: rgba(222, 200, 151, 0.52);
    transform: rotate(-2deg);
}

.filter-heading {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

.filter-heading-icon {
    color: var(--rose);
    font-size: 1.45rem;
}

.filter-heading div {
    display: flex;
    flex-direction: column;
}

.filter-heading strong {
    font-family: "Lora", serif;
    font-size: 0.9rem;
    font-weight: 600;
}

.filter-heading small {
    color: var(--ink-faint);
    font-family: "Caveat", cursive;
    font-size: 0.92rem;
}

.search-container,
.filter-group label,
.search-filters label {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.search-container {
    min-width: 260px;
    flex: 1 1 330px;
}

.search-container.large {
    flex-basis: 410px;
}

.field-label {
    color: var(--ink-faint);
    font-size: 0.59rem;
    letter-spacing: 0.11em;
}

.input-wrap {
    position: relative;
    display: block;
}

.search-input,
.filter-select,
.month-filter,
.date-filter,
.sort-filter,
.form-control {
    width: 100%;
    min-height: 42px;
    color: var(--ink);
    background: rgba(255, 250, 240, 0.78);
    border: 0;
    border-bottom: 1px solid rgba(69, 56, 47, 0.42);
    border-radius: 0;
    transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.search-input,
.form-control {
    padding: 8px 38px 7px 7px;
}

.filter-select,
.month-filter,
.date-filter,
.sort-filter {
    min-width: 130px;
    padding: 7px 29px 7px 7px;
    cursor: pointer;
}

.search-input::placeholder,
.form-control::placeholder {
    color: #a39385;
}

.search-input:focus,
.filter-select:focus,
.month-filter:focus,
.date-filter:focus,
.sort-filter:focus,
.form-control:focus {
    outline: 0;
    background: var(--paper);
    border-color: var(--rose);
    box-shadow: 0 2px 0 rgba(185, 100, 116, 0.12);
}

.search-icon {
    position: absolute;
    top: 50%;
    right: 10px;
    color: var(--rose);
    font-size: 1.1rem;
    transform: translateY(-50%);
    pointer-events: none;
}

.filter-group {
    display: flex;
    flex: 2 1 530px;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-group label {
    flex: 1 1 118px;
}

.filter-foot {
    width: 100%;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-top: 4px;
    color: var(--ink-faint);
    border-top: 1px dashed rgba(69, 56, 47, 0.17);
    font-family: "Caveat", cursive;
    font-size: 0.95rem;
}

.text-button {
    padding: 3px 0;
    color: var(--rose-dark);
    background: transparent;
    border: 0;
    border-bottom: 1px dotted currentColor;
    cursor: pointer;
    font-family: "Caveat", cursive;
}

.text-button:hover {
    color: var(--ink);
}

/* Conversation paper */
.messages-area,
.search-results-area {
    position: relative;
    min-height: 380px;
    background:
        linear-gradient(90deg, transparent 48px, rgba(185, 100, 116, 0.26) 48px 49px, transparent 49px),
        repeating-linear-gradient(0deg, transparent 0 35px, rgba(115, 139, 152, 0.14) 35px 36px),
        rgba(255, 252, 245, 0.8);
    border: 1px solid rgba(112, 84, 60, 0.19);
    box-shadow: inset 8px 0 20px rgba(69, 56, 47, 0.025), var(--shadow-sm);
}

.messages-area::before,
.search-results-area::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 17px;
    width: 9px;
    background: radial-gradient(circle, var(--desk) 0 3px, transparent 3.5px) center top / 9px 42px repeat-y;
    opacity: 0.75;
}

.paper-heading {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 24px 6px 65px;
    border-bottom: 1px dashed rgba(69, 56, 47, 0.18);
}

.paper-heading span {
    font-family: "Lora", serif;
    font-size: 0.83rem;
    font-weight: 600;
}

.paper-heading small {
    color: var(--ink-faint);
    font-family: "Caveat", cursive;
    font-size: 0.94rem;
}

.messages-container,
.search-results {
    max-height: 68vh;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 19px 26px 30px 67px;
    overflow-y: auto;
    scrollbar-color: rgba(185, 100, 116, 0.4) transparent;
    scrollbar-width: thin;
}

.messages-container::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(185, 100, 116, 0.35);
    border-radius: 10px;
}

.message {
    position: relative;
    width: min(76%, 760px);
    padding: 13px 15px 14px;
    color: var(--ink);
    background: #f8e8c7;
    border: 1px solid rgba(108, 77, 50, 0.16);
    border-radius: 1px 3px 3px 1px;
    box-shadow: 2px 3px 8px rgba(65, 47, 32, 0.1);
    cursor: pointer;
    transform: rotate(-0.18deg);
    transition: transform 170ms ease, box-shadow 170ms ease;
}

.message:nth-child(5n + 2) {
    transform: rotate(0.2deg);
}

.message:nth-child(7n + 3) {
    transform: rotate(-0.38deg);
}

.message::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 22%;
    width: 42px;
    height: 10px;
    background: rgba(232, 211, 166, 0.55);
    transform: rotate(-2deg);
}

.message:hover {
    z-index: 2;
    box-shadow: 4px 8px 16px rgba(65, 47, 32, 0.15);
    transform: rotate(0deg) translateY(-2px);
}

.message.harshiv {
    align-self: flex-start;
    background: #f7e4c5;
    border-left: 3px solid var(--mustard);
}

.message.vrunda {
    align-self: flex-end;
    background: #e2ebdf;
    border-right: 3px solid var(--sage);
}

.message.vrunda::before {
    left: auto;
    right: 20%;
    background: rgba(197, 210, 187, 0.62);
}

.message-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px dotted rgba(69, 56, 47, 0.25);
}

.message-sender {
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 1.13rem;
    font-weight: 700;
}

.message.vrunda .message-sender {
    color: var(--sage-dark);
}

.message-timestamp {
    color: var(--ink-faint);
    font-family: "Lora", serif;
    font-size: 0.58rem;
    text-align: right;
}

.message-text {
    overflow-wrap: anywhere;
    font-family: "Lora", serif;
    font-size: 0.82rem;
    line-height: 1.65;
    white-space: pre-wrap;
}

.load-more-wrap {
    align-self: center;
    margin-top: 10px;
    text-align: center;
}

.load-more-wrap p {
    margin-bottom: 8px;
    color: var(--ink-faint);
    font-family: "Caveat", cursive;
    font-size: 0.95rem;
}

.load-more-btn,
.search-btn,
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 43px;
    padding: 9px 18px;
    color: var(--paper);
    background: var(--rose);
    border: 1px solid var(--rose-dark);
    border-radius: 3px;
    box-shadow: 2px 3px 0 rgba(69, 56, 47, 0.14);
    cursor: pointer;
    font-family: "Lora", serif;
    font-size: 0.79rem;
    font-weight: 600;
    transition: 170ms ease;
}

.load-more-btn:hover,
.search-btn:hover,
.btn-primary:hover {
    background: var(--rose-dark);
    transform: translateY(-1px);
    box-shadow: 3px 5px 0 rgba(69, 56, 47, 0.12);
}

.empty-state {
    max-width: 430px;
    margin: auto;
    padding: 60px 20px;
    color: var(--ink-soft);
    text-align: center;
}

.empty-state > span {
    color: var(--rose);
    font-family: "Caveat", cursive;
    font-size: 2.5rem;
}

.empty-state h3 {
    margin-bottom: 7px;
    font-family: "Lora", serif;
    font-size: 1rem;
    font-weight: 500;
}

.empty-state p {
    font-family: "Caveat", cursive;
    font-size: 1rem;
}

/* Chapter introductions */
.section-intro {
    position: relative;
    min-height: 126px;
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 22px;
    padding: 20px 26px;
    background: rgba(255, 250, 240, 0.56);
    border-bottom: 1px solid rgba(69, 56, 47, 0.2);
}

.section-intro::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: -5px;
    width: 110px;
    height: 12px;
    background: rgba(230, 207, 157, 0.48);
    transform: rotate(-1.5deg);
}

.section-stamp {
    width: 67px;
    height: 67px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: var(--rose-dark);
    border: 2px solid rgba(185, 100, 116, 0.5);
    border-radius: 50%;
    font-family: "Lora", serif;
    font-size: 1.2rem;
    transform: rotate(-8deg);
}

.section-kicker {
    margin-bottom: 4px;
    color: var(--rose-dark);
}

.section-intro h2 {
    font-family: "Caveat", cursive;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1;
}

.section-intro p {
    max-width: 720px;
    margin-top: 8px;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.84rem;
    font-style: italic;
}

.help-strip {
    margin: 0 0 18px;
    padding: 8px 13px;
    color: var(--ink-soft);
    background: var(--mustard-wash);
    border-left: 3px solid var(--mustard);
    font-family: "Caveat", cursive;
    font-size: 1.01rem;
    transform: rotate(-0.15deg);
}

.help-strip span {
    margin-right: 7px;
    color: var(--rose-dark);
}

.photos-controls,
.files-controls,
.search-controls {
    justify-content: space-between;
}

.photos-grid,
.files-grid,
.memories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 22px;
}

.photo-card {
    position: relative;
    padding: 11px 11px 18px;
    background: #fffdf8;
    border: 1px solid rgba(101, 74, 50, 0.2);
    box-shadow: 3px 5px 12px rgba(62, 45, 30, 0.13);
    cursor: pointer;
    transform: rotate(-0.5deg);
    transition: transform 190ms ease, box-shadow 190ms ease;
}

.photo-card:nth-child(even) {
    transform: rotate(0.65deg);
}

.photo-card::before,
.file-card::before,
.memory-card::before {
    content: "";
    position: absolute;
    z-index: 2;
    top: -7px;
    left: 50%;
    width: 56px;
    height: 14px;
    background: rgba(223, 201, 155, 0.57);
    transform: translateX(-50%) rotate(-2deg);
}

.photo-card:hover {
    z-index: 2;
    transform: rotate(0deg) translateY(-4px);
    box-shadow: 5px 10px 20px rgba(62, 45, 30, 0.17);
}

.photo-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: block;
    object-fit: cover;
    background: var(--paper-deep);
    filter: saturate(0.86) sepia(0.06);
    transition: filter 190ms ease;
}

.photo-card:hover .photo-image {
    filter: saturate(1);
}

.photo-info {
    padding: 12px 5px 0;
}

.photo-title,
.file-name {
    font-family: "Caveat", cursive;
    font-size: 1.23rem;
    font-weight: 700;
    line-height: 1.1;
}

.photo-date,
.photo-size {
    display: inline-block;
    margin: 5px 8px 0 0;
    color: var(--ink-faint);
    font-size: 0.62rem;
    text-transform: uppercase;
}

.photo-description,
.file-description {
    margin-top: 8px;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.7rem;
    font-style: italic;
    line-height: 1.5;
}

.file-card {
    position: relative;
    min-height: 190px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 26px 20px 20px;
    background: #f2e7ce;
    border: 1px solid rgba(101, 74, 50, 0.21);
    border-radius: 2px 2px 10px 2px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: 180ms ease;
}

.file-card:nth-child(3n + 2) {
    background: var(--sage-wash);
    transform: rotate(0.4deg);
}

.file-card:nth-child(3n + 3) {
    background: var(--rose-wash);
    transform: rotate(-0.35deg);
}

.file-card:hover {
    z-index: 2;
    transform: rotate(0deg) translateY(-4px);
    box-shadow: var(--shadow);
}

.file-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    background: rgba(255, 250, 240, 0.62);
    border: 1px dashed rgba(69, 56, 47, 0.25);
    border-radius: 50%;
    font-size: 1.65rem;
}

.file-info {
    flex: 1;
}

.file-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 7px;
    color: var(--ink-faint);
    font-size: 0.63rem;
    text-transform: uppercase;
}

.album-link,
.drive-link {
    grid-column: 1 / -1;
}

.album-link > div,
.drive-link > div {
    color: var(--ink) !important;
    background: var(--mustard-wash) !important;
    border: 1px dashed rgba(69, 56, 47, 0.34) !important;
    border-radius: 2px !important;
    box-shadow: var(--shadow-sm);
}

.album-link h3,
.album-link p,
.drive-link h3,
.drive-link p {
    color: var(--ink) !important;
}

.album-link a,
.drive-link a {
    color: var(--paper) !important;
    background: var(--rose) !important;
    border-radius: 2px !important;
}

.photos-loading,
.files-loading {
    grid-column: 1 / -1;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--ink-soft);
    font-family: "Caveat", cursive;
    font-size: 1.08rem;
}

.loading-spinner {
    width: 33px;
    height: 33px;
    border: 2px solid rgba(185, 100, 116, 0.2);
    border-top-color: var(--rose);
    border-radius: 50%;
    animation: spin 900ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Search chapter */
.search-prompt-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    padding: 11px 14px;
    color: var(--ink-soft);
    background: var(--sage-wash);
    border-left: 3px solid var(--sage);
    font-family: "Caveat", cursive;
}

.search-prompt-note strong {
    color: var(--ink);
}

.search-prompt-note span {
    padding: 2px 8px;
    background: rgba(255, 250, 240, 0.58);
    border-radius: 10px;
    font-size: 0.88rem;
}

.search-filters {
    display: flex;
    flex: 0 1 330px;
    align-items: end;
    gap: 12px;
}

.search-filters label {
    flex: 1;
}

.search-btn {
    min-width: 100px;
}

.search-results-area {
    min-height: 420px;
}

.search-results {
    max-height: none;
    min-height: 420px;
}

/* Memory cards */
.memories-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.memory-card {
    position: relative;
    min-height: 210px;
    display: flex;
    flex-direction: column;
    padding: 28px 27px 23px;
    background: #f5e7be;
    border: 1px solid rgba(105, 77, 52, 0.2);
    box-shadow: 3px 5px 13px rgba(65, 47, 32, 0.12);
    cursor: pointer;
    transform: rotate(-0.4deg);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.memory-card:nth-child(2) {
    background: var(--sage-wash);
    transform: rotate(0.5deg);
}

.memory-card:nth-child(3) {
    background: var(--rose-wash);
    transform: rotate(0.35deg);
}

.memory-card:nth-child(4) {
    background: var(--blue-wash);
    transform: rotate(-0.5deg);
}

.memory-card:hover {
    z-index: 2;
    box-shadow: 6px 12px 22px rgba(65, 47, 32, 0.16);
    transform: rotate(0deg) translateY(-4px);
}

.memory-card h3 {
    margin-bottom: 14px;
    color: var(--ink);
    font-family: "Caveat", cursive;
    font-size: 1.55rem;
    line-height: 1.05;
}

.memory-card p {
    flex: 1;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.79rem;
    line-height: 1.65;
}

.memory-card small {
    margin-top: 17px;
    padding-top: 10px;
    color: var(--rose-dark);
    border-top: 1px dotted rgba(69, 56, 47, 0.3);
    font-family: "Caveat", cursive;
    font-size: 1rem;
}

/* Modals / letters */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(55, 43, 33, 0.63);
    backdrop-filter: blur(5px);
}

#message-modal[style*="block"] {
    display: flex !important;
}

.modal-content {
    position: relative;
    width: min(760px, 94vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--ink);
    background:
        repeating-linear-gradient(0deg, transparent 0 31px, rgba(115, 139, 152, 0.12) 31px 32px),
        var(--paper);
    border: 1px solid rgba(85, 61, 42, 0.35);
    border-radius: 2px;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 24px;
    background: rgba(255, 250, 240, 0.93);
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-family: "Caveat", cursive;
    font-size: 1.7rem;
    line-height: 1;
}

.letter-kicker {
    margin-bottom: 3px;
    color: var(--rose-dark);
    font-size: 0.6rem;
}

.close-btn {
    width: 39px;
    height: 39px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: var(--ink-soft);
    background: var(--paper-deep);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    transition: 160ms ease;
}

.close-btn:hover {
    color: var(--paper);
    background: var(--rose);
    transform: rotate(5deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-body .message {
    width: 100%;
    max-width: none;
}

.shortcuts-modal {
    display: flex;
}

.shortcuts-content {
    width: min(780px, 94vw) !important;
    max-width: 780px !important;
    background: var(--paper) !important;
    border: 1px solid rgba(85, 61, 42, 0.35) !important;
    border-radius: 2px !important;
}

.shortcuts-content .shortcuts-header,
.mobile-shortcuts-header {
    text-align: center;
}

.shortcuts-section h4,
.quotes-preview h4 {
    margin: 20px 0 10px;
    font-family: "Caveat", cursive;
    font-size: 1.25rem;
}

.shortcuts-grid,
.mobile-shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.shortcut-item,
.mobile-shortcut-btn {
    padding: 11px !important;
    color: var(--ink) !important;
    background: var(--paper-deep) !important;
    border: 1px dashed rgba(69, 56, 47, 0.25) !important;
    border-radius: 2px !important;
}

.shortcut-key {
    color: var(--rose-dark) !important;
    font-family: "Caveat", cursive;
}

.shortcut-desc,
.shortcut-action {
    color: var(--ink-soft) !important;
    font-size: 0.75rem;
}

.quotes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.quote-item {
    white-space: normal !important;
    color: var(--ink-soft) !important;
    background: var(--sage-wash) !important;
    border: 0 !important;
    border-radius: 2px !important;
}

.mobile-shortcut-btn {
    cursor: pointer;
}

.mobile-shortcuts-footer,
.shortcuts-footer {
    margin-top: 15px;
    color: var(--ink-soft);
    text-align: center;
    font-family: "Caveat", cursive;
}

/* Login letter */
.login-modal {
    z-index: 2000;
    background:
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.14), transparent 25%),
        rgba(70, 53, 40, 0.78);
}

.login-letter {
    width: min(500px, 92vw);
    overflow: visible;
    background:
        linear-gradient(90deg, transparent 38px, rgba(185, 100, 116, 0.24) 38px 39px, transparent 39px),
        repeating-linear-gradient(0deg, transparent 0 31px, rgba(115, 139, 152, 0.1) 31px 32px),
        #fff8e9;
    transform: rotate(-0.35deg);
}

.login-letter::before {
    content: "";
    position: absolute;
    z-index: 4;
    top: -9px;
    left: 30%;
    width: 88px;
    height: 18px;
    background: rgba(225, 205, 163, 0.68);
    transform: rotate(-3deg);
}

.letter-fold {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #e3d3b7 50%, rgba(93, 68, 47, 0.12) 51%);
}

.wax-seal {
    position: absolute;
    z-index: 3;
    top: 55px;
    right: -23px;
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    color: #ebc5cc;
    background:
        radial-gradient(circle at 35% 30%, #c87786, var(--rose-dark) 68%);
    border: 3px double rgba(255, 229, 233, 0.35);
    border-radius: 48% 52% 44% 56%;
    box-shadow: 2px 5px 10px rgba(69, 56, 47, 0.24);
    font-family: "Lora", serif;
    font-size: 1.2rem;
    transform: rotate(8deg);
}

.login-letter .modal-header {
    padding: 31px 48px 18px 58px;
    background: transparent;
    border: 0;
}

.login-letter .modal-header h3 {
    font-size: 2.15rem;
}

.login-letter .modal-body {
    padding: 0 48px 34px 58px;
}

.login-intro {
    margin-bottom: 20px;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.82rem;
    font-style: italic;
}

.form-group {
    margin-bottom: 17px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 1rem;
    font-weight: 600;
}

.form-control {
    padding-right: 8px;
    background: rgba(255, 250, 240, 0.55);
}

#login-error {
    display: none;
    margin: 4px 0 11px;
    padding: 8px 10px;
    color: #8d3d42;
    background: #f7dddd;
    border-left: 3px solid #a94646;
    font-size: 0.76rem;
}

.login-letter .btn-primary {
    width: 100%;
    justify-content: space-between;
    margin-top: 5px;
}

.privacy-note {
    margin-top: 16px;
    color: var(--ink-faint);
    font-family: "Caveat", cursive;
    font-size: 0.9rem;
    text-align: center;
}

/* Opening sequence */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at center, rgba(255, 250, 240, 0.96), rgba(232, 216, 188, 0.98)),
        var(--paper-deep);
    transition: opacity 300ms ease, visibility 300ms ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    color: var(--ink-soft);
    text-align: center;
    font-family: "Lora", serif;
}

.loading-flower {
    margin-bottom: 11px;
    color: var(--rose);
    font-size: 2.3rem;
    animation: gentle-turn 1.6s ease-in-out infinite;
}

.loading-content p {
    font-family: "Caveat", cursive;
    font-size: 1.5rem;
    font-weight: 600;
}

.loading-content small {
    color: var(--ink-faint);
    font-size: 0.68rem;
    font-style: italic;
}

@keyframes gentle-turn {
    0%, 100% { transform: rotate(-10deg) scale(1); }
    50% { transform: rotate(10deg) scale(1.08); }
}

/* Easter egg palette — still paper-first */
.b99-theme {
    --rose: #506f91;
    --rose-dark: #365474;
    --rose-wash: #dce8f1;
    --sage: #c79a3a;
    --sage-dark: #9a7221;
    --sage-wash: #f1e5c6;
    --mustard: #cf6d5e;
    --mustard-wash: #f2d7d1;
}

/* Story table of contents */
.story-index {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 22px;
    padding: 8px;
    background: rgba(232, 216, 188, 0.46);
    border: 1px dashed rgba(69, 56, 47, 0.2);
}

.story-index a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    color: var(--ink-soft);
    background: rgba(255, 250, 240, 0.62);
    border: 1px solid transparent;
    font-family: "Caveat", cursive;
    font-size: 1rem;
    text-decoration: none;
    transition: 160ms ease;
}

.story-index a:hover {
    color: var(--ink);
    background: var(--paper);
    border-color: var(--border);
    transform: translateY(-1px);
}

.story-index span {
    color: var(--rose-dark);
    font-family: "Lora", serif;
    font-size: 0.63rem;
}

.story-anchor,
.story-feature {
    scroll-margin-top: 135px;
}

/* Data-driven story chapters */
.story-opening {
    display: grid;
    grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.75fr);
    gap: 18px;
    margin-bottom: 24px;
}

.story-summary {
    position: relative;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 27px;
    background: var(--rose-wash);
    border: 1px solid rgba(149, 73, 90, 0.24);
    box-shadow: var(--shadow-sm);
    transform: rotate(-0.35deg);
}

.story-summary::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 50%;
    width: 70px;
    height: 15px;
    background: rgba(224, 201, 155, 0.6);
    transform: translateX(-50%) rotate(-2deg);
}

.story-opening-label {
    color: var(--rose-dark);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.story-summary > strong {
    margin: 6px 0 12px;
    font-family: "Caveat", cursive;
    font-size: clamp(2.7rem, 5vw, 4.3rem);
    line-height: 0.95;
}

.story-summary p {
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.78rem;
    line-height: 1.65;
}

.story-then-now {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.then-now-card {
    position: relative;
    min-height: 220px;
    padding: 25px 23px 20px;
    color: var(--ink);
    background: var(--paper-deep);
    border: 1px solid rgba(101, 74, 50, 0.2);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-align: left;
    transition: 180ms ease;
}

.then-now-card:nth-child(2) {
    background: var(--sage-wash);
    transform: rotate(0.4deg);
}

.then-now-card:hover {
    transform: translateY(-3px) rotate(0deg);
    box-shadow: var(--shadow);
}

.then-now-card > span {
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 1.24rem;
    font-weight: 700;
}

.then-now-card blockquote {
    margin: 16px 0;
    font-family: "Lora", serif;
    font-size: 0.78rem;
    font-style: italic;
    line-height: 1.65;
}

.then-now-card small {
    color: var(--ink-faint);
    font-size: 0.62rem;
}

.story-timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-left: 34px;
}

.story-timeline::before {
    content: "";
    position: absolute;
    top: 7px;
    bottom: 7px;
    left: 10px;
    width: 1px;
    background: var(--red-line);
}

.story-chapter {
    position: relative;
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    background:
        repeating-linear-gradient(0deg, transparent 0 31px, rgba(115, 139, 152, 0.1) 31px 32px),
        rgba(255, 252, 245, 0.9);
    border: 1px solid rgba(101, 74, 50, 0.2);
    box-shadow: var(--shadow-sm);
}

.story-chapter::before {
    content: "";
    position: absolute;
    top: 28px;
    left: -30px;
    width: 13px;
    height: 13px;
    background: var(--paper);
    border: 3px solid var(--rose);
    border-radius: 50%;
}

.chapter-spine {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px;
    background: var(--paper-deep);
    border-right: 1px solid rgba(101, 74, 50, 0.18);
}

.chapter-spine span {
    color: var(--ink-faint);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.chapter-spine strong {
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 2.6rem;
    line-height: 1;
}

.chapter-body {
    padding: 20px 23px;
}

.chapter-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    color: var(--ink-faint);
    font-size: 0.64rem;
    text-transform: uppercase;
}

.chapter-facts strong {
    color: var(--ink);
}

.chapter-body blockquote {
    margin: 17px 0 8px;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.78rem;
    font-style: italic;
    line-height: 1.65;
}

.chapter-body > small {
    display: block;
    margin-bottom: 13px;
    color: var(--ink-faint);
    font-family: "Caveat", cursive;
    font-size: 0.88rem;
}

/* The Dictionary of Us */
.story-feature {
    position: relative;
    margin-top: 54px;
    padding-top: 29px;
    border-top: 1px solid rgba(69, 56, 47, 0.2);
}

.story-feature::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 8%;
    width: 100px;
    height: 14px;
    background: rgba(224, 201, 155, 0.55);
    transform: rotate(-2deg);
}

.feature-title {
    display: flex;
    align-items: flex-start;
    gap: 17px;
    margin-bottom: 22px;
}

.feature-number {
    width: 52px;
    height: 52px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: var(--rose-dark);
    border: 2px solid rgba(185, 100, 116, 0.48);
    border-radius: 50%;
    font-family: "Lora", serif;
    font-size: 0.9rem;
    transform: rotate(-7deg);
}

.feature-title h3 {
    font-family: "Caveat", cursive;
    font-size: clamp(1.9rem, 4vw, 2.7rem);
    line-height: 1;
}

.feature-title p {
    max-width: 760px;
    margin-top: 7px;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.78rem;
    font-style: italic;
    line-height: 1.6;
}

.dictionary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.dictionary-card {
    position: relative;
    min-height: 270px;
    display: flex;
    flex-direction: column;
    padding: 23px;
    background:
        repeating-linear-gradient(0deg, transparent 0 30px, rgba(115, 139, 152, 0.09) 30px 31px),
        var(--paper);
    border: 1px solid rgba(101, 74, 50, 0.2);
    box-shadow: var(--shadow-sm);
}

.dictionary-card:nth-child(4n + 2) {
    background:
        repeating-linear-gradient(0deg, transparent 0 30px, rgba(115, 139, 152, 0.08) 30px 31px),
        #f7efdc;
    transform: rotate(0.25deg);
}

.dictionary-card:nth-child(4n + 3) {
    background:
        repeating-linear-gradient(0deg, transparent 0 30px, rgba(115, 139, 152, 0.08) 30px 31px),
        var(--sage-wash);
    transform: rotate(-0.2deg);
}

.dictionary-card::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 50%;
    width: 60px;
    height: 14px;
    background: rgba(222, 199, 153, 0.59);
    transform: translateX(-50%) rotate(-2deg);
}

.dictionary-card-top {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: baseline;
    gap: 3px 8px;
    padding-bottom: 10px;
    border-bottom: 1px dashed rgba(69, 56, 47, 0.22);
}

.dictionary-card-top > span {
    grid-row: 1 / 3;
    color: var(--ink-faint);
    font-family: "Lora", serif;
    font-size: 0.62rem;
}

.dictionary-card-top strong {
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 1.75rem;
    line-height: 1;
}

.dictionary-card-top small {
    color: var(--ink-faint);
    font-size: 0.59rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dictionary-definition {
    flex: 1;
    padding: 14px 0;
}

.dictionary-definition > span {
    color: var(--ink-faint);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.dictionary-definition blockquote {
    margin: 8px 0;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.74rem;
    font-style: italic;
    line-height: 1.6;
}

.dictionary-definition small {
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 0.9rem;
}

.dictionary-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 11px;
    border-top: 1px dotted rgba(69, 56, 47, 0.25);
}

.dictionary-trace-button {
    padding: 7px 10px;
    color: var(--paper);
    background: var(--rose);
    border: 1px solid var(--rose-dark);
    cursor: pointer;
    font-family: "Caveat", cursive;
    font-size: 0.9rem;
}

/* Same date, different years */
.on-this-date-title {
    align-items: center;
}

.on-this-date-title > div {
    flex: 1;
}

.date-picker-note {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 12px;
    background: var(--mustard-wash);
    border: 1px solid rgba(147, 116, 47, 0.3);
    transform: rotate(0.6deg);
}

.date-picker-note span {
    color: var(--ink-soft);
    font-family: "Caveat", cursive;
    font-size: 0.9rem;
}

.date-picker-note input {
    color: var(--ink);
    background: transparent;
    border: 0;
    border-bottom: 1px solid rgba(69, 56, 47, 0.45);
    cursor: pointer;
}

.on-this-date-summary {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 16px;
    padding: 9px 13px;
    color: var(--ink-soft);
    background: var(--rose-wash);
    border-left: 3px solid var(--rose);
}

.on-this-date-summary strong {
    color: var(--ink);
    font-family: "Caveat", cursive;
    font-size: 1.2rem;
}

.on-this-date-summary span {
    font-family: "Lora", serif;
    font-size: 0.7rem;
    font-style: italic;
}

.on-this-date-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 17px;
}

.on-date-year {
    position: relative;
    min-height: 290px;
    display: flex;
    flex-direction: column;
    padding: 22px;
    background: #f6e8c9;
    border: 1px solid rgba(101, 74, 50, 0.21);
    box-shadow: var(--shadow-sm);
}

.on-date-year:nth-child(even) {
    background: var(--sage-wash);
    transform: rotate(0.3deg);
}

.on-date-year::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 35%;
    width: 55px;
    height: 13px;
    background: rgba(224, 201, 155, 0.61);
    transform: rotate(-3deg);
}

.on-date-year-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(69, 56, 47, 0.25);
}

.on-date-year-heading span {
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 2rem;
    font-weight: 700;
}

.on-date-year-heading small {
    color: var(--ink-faint);
    font-size: 0.58rem;
    text-align: right;
    text-transform: uppercase;
}

.on-date-exchange {
    flex: 1;
}

.on-date-exchange p {
    margin: 0 0 9px;
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.7rem;
    line-height: 1.5;
}

.on-date-exchange strong {
    display: block;
    color: var(--ink);
    font-family: "Caveat", cursive;
    font-size: 1rem;
}

.on-date-year .load-more-btn {
    align-self: flex-start;
    margin-top: 10px;
}

/* Context-first search */
.contextual-search-area,
.contextual-search-area .search-results {
    max-height: none;
}

.search-result-summary {
    width: 100%;
    padding: 7px 12px;
    color: var(--ink-soft);
    background: var(--mustard-wash);
    border-left: 3px solid var(--mustard);
    font-family: "Caveat", cursive;
    font-size: 1rem;
}

.search-memory-result {
    width: 100%;
    padding: 21px;
    background: rgba(255, 250, 240, 0.91);
    border: 1px solid rgba(101, 74, 50, 0.21);
    box-shadow: var(--shadow-sm);
}

.search-memory-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(69, 56, 47, 0.22);
}

.search-memory-heading span {
    color: var(--rose-dark);
    font-family: "Caveat", cursive;
    font-size: 1.2rem;
    font-weight: 700;
}

.search-memory-heading small {
    color: var(--ink-faint);
    font-size: 0.61rem;
    text-align: right;
}

.context-preview {
    margin: 9px 0;
    padding: 10px 13px;
    color: var(--ink-soft);
    background: rgba(232, 216, 188, 0.35);
    border-left: 2px solid var(--paper-aged);
}

.context-preview-label,
.matched-message-label {
    display: block;
    margin-bottom: 5px;
    color: var(--ink-faint);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.context-preview p {
    margin: 3px 0;
    font-family: "Lora", serif;
    font-size: 0.7rem;
    line-height: 1.5;
}

.context-preview strong {
    color: var(--ink);
}

.search-memory-result .message {
    width: min(88%, 780px);
    margin: 7px 0 10px;
}

.search-memory-actions,
.context-modal-actions,
.case-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 13px;
    padding-top: 12px;
    border-top: 1px dashed rgba(69, 56, 47, 0.21);
}

.context-modal-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 10px 13px;
    color: var(--ink-soft);
    background: var(--mustard-wash);
    font-family: "Caveat", cursive;
}

.context-modal-intro strong {
    color: var(--ink);
    font-family: "Lora", serif;
    font-size: 0.72rem;
}

.journey-target {
    animation: found-memory 3.1s ease !important;
}

@keyframes found-memory {
    0%, 100% { box-shadow: 2px 3px 8px rgba(65, 47, 32, 0.1); }
    18%, 68% { box-shadow: 0 0 0 6px rgba(212, 170, 82, 0.42), 5px 10px 20px rgba(65, 47, 32, 0.18); transform: scale(1.015); }
}

/* The 99th Case — B99 interpreted through real archive data */
.case-folder {
    position: relative;
    padding: 24px;
    background: #d7b97e;
    border: 1px solid #a98b55;
    box-shadow: 7px 10px 24px rgba(67, 48, 30, 0.18);
}

.case-folder::before {
    content: "";
    position: absolute;
    top: -18px;
    left: 24px;
    width: 180px;
    height: 20px;
    background: #d7b97e;
    border: 1px solid #a98b55;
    border-bottom: 0;
    border-radius: 5px 10px 0 0;
}

.case-folder-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 17px;
    color: #604927;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.case-folder-label strong {
    padding: 4px 7px;
    color: #864b43;
    border: 2px solid rgba(134, 75, 67, 0.6);
    transform: rotate(-2deg);
}

.case-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: -1px;
    padding: 0 11px;
}

.case-tab {
    min-height: 65px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 9px;
    color: var(--ink-soft);
    background: #eadbbd;
    border: 1px solid rgba(93, 67, 38, 0.28);
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
}

.case-tab span {
    font-family: "Caveat", cursive;
    font-size: 1.2rem;
    font-weight: 700;
}

.case-tab small {
    font-size: 0.58rem;
}

.case-tab.active {
    z-index: 2;
    color: var(--ink);
    background: var(--paper);
    transform: translateY(1px);
}

.casefile-content {
    min-height: 400px;
    padding: 27px;
    background:
        linear-gradient(90deg, transparent 42px, rgba(185, 100, 116, 0.22) 42px 43px, transparent 43px),
        repeating-linear-gradient(0deg, transparent 0 31px, rgba(115, 139, 152, 0.11) 31px 32px),
        var(--paper);
    border: 1px solid rgba(93, 67, 38, 0.28);
    box-shadow: inset 0 4px 13px rgba(67, 48, 30, 0.05);
}

.detective-note {
    margin: 0 0 22px 22px;
    padding: 15px 18px;
    background: var(--blue-wash);
    border-left: 3px solid var(--blue);
}

.detective-note > span {
    color: var(--blue);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.detective-note h3 {
    margin: 4px 0;
    font-family: "Caveat", cursive;
    font-size: 1.55rem;
}

.detective-note p {
    color: var(--ink-soft);
    font-family: "Lora", serif;
    font-size: 0.72rem;
    font-style: italic;
}

.jake-note {
    background: var(--mustard-wash);
    border-color: var(--mustard);
}

.amy-note {
    background: var(--rose-wash);
    border-color: var(--rose);
}

.boyle-note {
    background: var(--sage-wash);
    border-color: var(--sage);
}

.case-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 11px;
    margin: 0 0 22px 22px;
}

.case-stat-grid > div {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 15px;
    background: rgba(255, 250, 240, 0.84);
    border: 1px solid rgba(69, 56, 47, 0.2);
}

.case-stat-grid strong {
    font-family: "Caveat", cursive;
    font-size: 1.8rem;
}

.case-stat-grid span {
    color: var(--ink-faint);
    font-size: 0.59rem;
    text-transform: uppercase;
}

.case-evidence-button {
    display: block;
    margin-left: auto;
    padding: 9px 14px;
    color: var(--ink);
    background: transparent;
    border: 2px solid var(--rose);
    cursor: pointer;
    font-family: "Caveat", cursive;
    font-size: 1rem;
    font-weight: 700;
    transform: rotate(-0.6deg);
}

.case-exchange {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding-left: 22px;
}

.case-exchange .message {
    width: min(82%, 720px);
}

.binder-chart {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 0 0 22px 22px;
}

.binder-row {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 70px;
    align-items: center;
    gap: 10px;
    padding: 6px 9px;
    color: var(--ink);
    background: rgba(255, 250, 240, 0.55);
    border: 0;
    cursor: pointer;
    text-align: left;
}

.binder-row i {
    height: 9px;
    background: linear-gradient(90deg, var(--rose) var(--bar), rgba(185, 100, 116, 0.12) var(--bar));
}

.binder-row strong {
    font-size: 0.7rem;
    text-align: right;
}

.care-evidence-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 20px 22px;
}

.care-exhibit {
    min-height: 175px;
    padding: 18px;
    color: var(--ink);
    background: var(--paper-deep);
    border: 1px solid rgba(69, 56, 47, 0.2);
    cursor: pointer;
    text-align: left;
    transform: rotate(-0.3deg);
}

.care-exhibit:nth-child(even) {
    background: var(--sage-wash);
    transform: rotate(0.35deg);
}

.care-exhibit > span {
    color: var(--rose-dark);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.care-exhibit blockquote {
    margin: 12px 0;
    font-family: "Lora", serif;
    font-size: 0.74rem;
    font-style: italic;
    line-height: 1.55;
}

.care-exhibit small {
    color: var(--ink-faint);
    font-family: "Caveat", cursive;
}

/* The archive writes a random memory back in ink */
body.diary-open {
    overflow: hidden;
}

.random-diary-overlay {
    position: fixed;
    inset: 0;
    z-index: 2400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    opacity: 0;
    visibility: hidden;
    background:
        radial-gradient(circle at 50% 45%, rgba(67, 51, 37, 0.28), rgba(20, 15, 12, 0.9)),
        rgba(28, 21, 16, 0.88);
    backdrop-filter: blur(7px);
    pointer-events: none;
    transition: opacity 350ms ease, visibility 350ms ease;
}

.random-diary-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.random-diary-overlay::before,
.random-diary-overlay::after {
    content: "";
    position: absolute;
    width: 190px;
    height: 190px;
    opacity: 0.12;
    background: radial-gradient(circle, #d6b276 0 1px, transparent 2px) 0 0 / 13px 13px;
    border-radius: 50%;
    filter: blur(0.3px);
    pointer-events: none;
}

.random-diary-overlay::before {
    top: 4%;
    left: 3%;
}

.random-diary-overlay::after {
    right: 4%;
    bottom: 3%;
}

.diary-close {
    position: absolute;
    z-index: 4;
    top: 22px;
    right: 26px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: #d8c8ad;
    background: rgba(27, 20, 15, 0.5);
    border: 1px solid rgba(225, 205, 172, 0.35);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.6rem;
}

.diary-book {
    position: relative;
    width: min(1050px, 92vw);
    min-height: min(650px, 80vh);
    display: grid;
    grid-template-columns: 0.82fr 1.18fr;
    color: #34291f;
    filter: drop-shadow(0 28px 35px rgba(0, 0, 0, 0.42));
    perspective: 1000px;
    transform: scale(0.94) rotateX(2deg);
    transition: transform 500ms cubic-bezier(.2, .8, .2, 1);
}

.random-diary-overlay.open .diary-book {
    transform: scale(1) rotateX(0deg);
}

.diary-book::before {
    content: "";
    position: absolute;
    z-index: 5;
    top: 1.5%;
    bottom: 1.5%;
    left: calc(41% - 9px);
    width: 20px;
    background: linear-gradient(90deg, rgba(65, 42, 25, 0.28), rgba(255, 245, 222, 0.55), rgba(58, 37, 23, 0.3));
    border-radius: 50%;
    box-shadow: 0 0 17px rgba(42, 27, 17, 0.28);
    pointer-events: none;
}

.diary-page {
    position: relative;
    min-height: 620px;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 22%, rgba(111, 75, 43, 0.075) 0 1px, transparent 2px),
        radial-gradient(circle at 78% 70%, rgba(111, 75, 43, 0.055) 0 1px, transparent 2px),
        repeating-linear-gradient(0deg, transparent 0 32px, rgba(94, 75, 56, 0.075) 32px 33px),
        #eadbbd;
    border: 10px solid #4b3020;
}

.diary-page-left {
    display: flex;
    align-items: center;
    justify-content: center;
    border-right-width: 5px;
    border-radius: 13px 1px 1px 13px;
    box-shadow: inset -25px 0 36px rgba(68, 43, 25, 0.16), inset 12px 0 19px rgba(255, 249, 231, 0.15);
}

.diary-page-left::after {
    content: "";
    position: absolute;
    inset: 30px;
    border: 1px solid rgba(67, 47, 31, 0.22);
    outline: 1px solid rgba(67, 47, 31, 0.13);
    outline-offset: -8px;
}

.diary-page-right {
    padding: 72px 68px 55px;
    overflow-y: auto;
    border-left-width: 5px;
    border-radius: 1px 13px 13px 1px;
    box-shadow: inset 25px 0 36px rgba(68, 43, 25, 0.16), inset -12px 0 19px rgba(255, 249, 231, 0.15);
}

.diary-page-right::before {
    content: "";
    position: absolute;
    top: 8%;
    right: 6%;
    width: 45px;
    height: 30px;
    opacity: 0.13;
    background: #21180f;
    border-radius: 44% 56% 37% 63%;
    filter: blur(7px);
}

.diary-ex-libris {
    z-index: 1;
    width: 72%;
    padding: 35px 22px;
    text-align: center;
    border: 1px solid rgba(67, 47, 31, 0.35);
    outline: 1px solid rgba(67, 47, 31, 0.2);
    outline-offset: -8px;
}

.diary-ex-libris span,
.diary-ex-libris small {
    display: block;
    color: rgba(52, 41, 31, 0.67);
    font-family: "Lora", serif;
    font-size: 0.7rem;
    font-style: italic;
}

.diary-ex-libris strong {
    display: block;
    margin: 10px 0;
    font-family: "Caveat", cursive;
    font-size: 4.5rem;
    line-height: 1;
}

.diary-flourish {
    position: absolute;
    bottom: 70px;
    color: rgba(52, 41, 31, 0.35);
    font-size: 2rem;
}

.diary-kicker {
    display: block;
    color: rgba(52, 41, 31, 0.62);
    font-family: "Lora", serif;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.diary-page-right h2 {
    margin-top: 9px;
    font-family: "Caveat", cursive;
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    line-height: 1;
}

.diary-rule {
    width: 100%;
    height: 1px;
    margin: 18px 0 26px;
    background: linear-gradient(90deg, rgba(52, 41, 31, 0.42), transparent);
}

.diary-handwriting {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-wrap: anywhere;
    color: #33261d;
    font-family: "Caveat", cursive;
    font-size: clamp(1.05rem, 1.8vw, 1.35rem);
    font-weight: 600;
    line-height: 1.35;
}

.diary-thread-message {
    width: min(92%, 520px);
    padding: 8px 11px 9px;
    background: rgba(255, 248, 226, 0.28);
    border-left: 2px solid rgba(75, 48, 32, 0.45);
}

.diary-thread-message.vrunda {
    align-self: flex-end;
    background: rgba(199, 211, 188, 0.28);
    border-left: 0;
    border-right: 2px solid rgba(75, 48, 32, 0.45);
    text-align: right;
}

.diary-thread-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 2px;
    color: rgba(52, 41, 31, 0.6);
    font-family: "Lora", serif;
}

.diary-thread-heading strong {
    color: #5f3e2b;
    font-family: "Caveat", cursive;
    font-size: 0.92rem;
}

.diary-thread-heading span {
    font-size: 0.5rem;
    font-weight: 400;
}

.diary-thread-message p {
    min-height: 1.35em;
    white-space: pre-wrap;
}

.diary-thread-message p.is-writing::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 3px;
    vertical-align: -0.12em;
    background: currentColor;
    animation: ink-cursor 700ms steps(1) infinite;
}

@keyframes ink-cursor {
    50% { opacity: 0; }
}

.diary-signature {
    min-height: 35px;
    opacity: 0;
    color: rgba(52, 41, 31, 0.69);
    font-family: "Caveat", cursive;
    font-size: 1rem;
    text-align: right;
    transform: translateY(5px);
    transition: 450ms ease;
}

.diary-signature.written {
    opacity: 1;
    transform: translateY(0);
}

.diary-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 17px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: 400ms ease;
}

.diary-actions.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.diary-context-button {
    padding: 10px 14px;
    color: #eadbbd;
    background: #4b3020;
    border: 1px solid #2f1d12;
    cursor: pointer;
    font-family: "Lora", serif;
    font-size: 0.73rem;
}

.diary-actions .text-button {
    color: #513c2c;
}

/* Responsive notebook */
@media (max-width: 1100px) {
    :root {
        --sidebar-width: 270px;
    }

    .sidebar-header {
        padding-left: 31px;
        padding-right: 22px;
    }

    .top-header {
        padding-right: 30px;
        padding-left: 85px;
    }

    .content-wrapper {
        padding-right: 30px;
        padding-left: 85px;
    }

    .guide-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .welcome-note::after {
        display: none;
    }

    .case-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    body {
        display: block;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    .sidebar {
        z-index: 101;
        width: min(330px, calc(100vw - 52px));
        max-width: calc(100vw - 52px);
        height: 100vh;
        height: 100dvh;
        overscroll-behavior: contain;
        transform: translateX(-105%);
        transition: transform 240ms ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-scrim {
        position: fixed;
        inset: 0;
        z-index: 100;
        display: block;
        width: 100%;
        height: 100%;
        padding: 0;
        opacity: 0;
        background: rgba(55, 43, 33, 0.48);
        border: 0;
        backdrop-filter: blur(2px);
        cursor: pointer;
        pointer-events: none;
        transition: opacity 220ms ease;
    }

    body.mobile-nav-open .sidebar-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-close {
        display: grid;
        place-items: center;
        width: 44px;
        height: 44px;
    }

    .main-content {
        width: calc(100% - 20px);
        min-height: calc(100vh - 20px);
        margin: 10px;
        background:
            linear-gradient(90deg, transparent 48px, var(--red-line) 48px 49px, transparent 49px),
            repeating-linear-gradient(0deg, transparent 0 31px, var(--blue-line) 31px 32px),
            var(--paper);
    }

    .main-content::before {
        top: 10px;
        bottom: 10px;
        left: 10px;
    }

    .top-header {
        min-height: 105px;
        padding: 18px 20px 16px 59px;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    button,
    input,
    select,
    textarea {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }

    .search-input,
    .filter-select,
    .month-filter,
    .date-filter,
    .sort-filter,
    .form-control,
    .date-picker-note input {
        min-height: 46px;
    }

    .mobile-menu-toggle,
    .random-btn,
    .help-btn,
    .load-more-btn,
    .search-btn,
    .btn-primary,
    .text-button,
    .dictionary-trace-button,
    .case-evidence-button,
    .diary-context-button,
    .close-btn,
    .story-index a {
        min-height: 44px;
    }

    .text-button {
        display: inline-flex;
        align-items: center;
    }

    .content-wrapper {
        padding: 26px 20px 60px 59px;
    }

    .page-eyebrow {
        display: none;
    }

    .page-title {
        font-size: 2.3rem;
    }

    .page-subtitle {
        max-width: 380px;
        font-size: 0.74rem;
    }

    .message {
        width: 86%;
    }

    .memories-grid {
        grid-template-columns: 1fr;
    }

    .story-opening {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .main-content {
        background:
            linear-gradient(90deg, transparent 35px, var(--red-line) 35px 36px, transparent 36px),
            repeating-linear-gradient(0deg, transparent 0 31px, var(--blue-line) 31px 32px),
            var(--paper);
    }

    .top-header {
        min-height: 86px;
        align-items: center;
        gap: 9px;
        padding: 12px 12px 12px 40px;
    }

    .header-left {
        align-items: center;
        gap: 9px;
    }

    .mobile-menu-toggle {
        width: 44px;
        height: 44px;
        justify-content: center;
        padding: 0;
    }

    .menu-label {
        display: none;
    }

    .page-title {
        font-size: 1.95rem;
    }

    .page-subtitle {
        display: none;
    }

    .random-btn {
        min-height: 44px;
        padding: 8px 11px;
    }

    .random-btn .btn-copy small {
        display: none;
    }

    .random-btn .btn-text {
        font-size: 0.72rem;
    }

    .content-wrapper {
        padding: 18px 11px 48px 40px;
    }

    .welcome-note summary {
        padding: 13px 14px;
    }

    .summary-action {
        display: none;
    }

    .welcome-note-body {
        padding: 2px 17px 20px;
    }

    .guide-grid {
        gap: 12px;
    }

    .filters-bar,
    .controls-card {
        padding: 19px 15px 15px;
    }

    .search-container,
    .search-container.large {
        min-width: 100%;
        flex-basis: 100%;
    }

    .search-input,
    .filter-select,
    .month-filter,
    .date-filter,
    .sort-filter,
    .form-control,
    .date-picker-note input {
        font-size: 1rem;
    }

    .filter-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-select,
    .month-filter,
    .date-filter,
    .sort-filter {
        min-width: 0;
    }

    .messages-area,
    .search-results-area {
        background:
            linear-gradient(90deg, transparent 29px, rgba(185, 100, 116, 0.26) 29px 30px, transparent 30px),
            repeating-linear-gradient(0deg, transparent 0 35px, rgba(115, 139, 152, 0.14) 35px 36px),
            rgba(255, 252, 245, 0.8);
    }

    .messages-area::before,
    .search-results-area::before {
        left: 8px;
    }

    .paper-heading {
        height: auto;
        min-height: 54px;
        gap: 8px;
        padding-right: 10px;
        padding-left: 32px;
    }

    .messages-container,
    .search-results {
        padding-right: 9px;
        padding-left: 32px;
    }

    .message {
        width: 100%;
    }

    .message-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 1px;
    }

    .message-timestamp {
        text-align: left;
    }

    .section-intro {
        align-items: flex-start;
        gap: 10px;
        padding: 14px 2px 18px;
    }

    .section-stamp {
        width: 42px;
        height: 42px;
        font-size: 0.84rem;
    }

    .section-intro h2 {
        font-size: 2rem;
    }

    .photos-grid,
    .files-grid {
        grid-template-columns: 1fr;
    }

    .search-filters {
        width: 100%;
        flex: 1 1 100%;
    }

    .story-then-now {
        grid-template-columns: 1fr;
    }

    .story-index,
    .dictionary-grid {
        grid-template-columns: 1fr;
    }

    .story-index a {
        padding: 10px 12px;
    }

    .story-feature {
        padding-right: 15px;
        padding-left: 15px;
    }

    .feature-title,
    .on-this-date-title,
    .on-this-date-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .date-picker-note {
        width: 100%;
    }

    .date-picker-note input {
        width: 100%;
    }

    .dictionary-card {
        min-height: 0;
        padding: 19px 17px;
    }

    .dictionary-card-actions,
    .search-memory-actions,
    .context-modal-actions,
    .case-actions {
        align-items: stretch;
    }

    .dictionary-card-actions button,
    .search-memory-actions button,
    .context-modal-actions button,
    .case-actions button {
        flex: 1 1 auto;
        justify-content: center;
        text-align: center;
    }

    .random-diary-overlay {
        padding: 12px;
    }

    .diary-close {
        top: 10px;
        right: 10px;
    }

    .diary-book {
        display: block;
        width: 96vw;
        min-height: 0;
    }

    .diary-book::before,
    .diary-page-left {
        display: none;
    }

    .diary-page-right {
        min-height: min(700px, 91vh);
        max-height: 91vh;
        padding: 55px 28px 30px;
        overflow-y: auto;
        border-width: 8px;
        border-radius: 10px;
    }

    .diary-handwriting {
        min-height: 300px;
        font-size: 1.05rem;
    }

    .diary-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .story-chapter {
        grid-template-columns: 88px minmax(0, 1fr);
    }

    .chapter-spine {
        padding: 17px 12px;
    }

    .chapter-spine strong {
        font-size: 2rem;
    }

    .chapter-facts {
        flex-direction: column;
        gap: 4px;
    }

    .search-memory-result {
        padding: 14px;
    }

    .search-memory-heading,
    .context-modal-intro {
        align-items: flex-start;
        flex-direction: column;
    }

    .search-memory-result .message {
        width: 100%;
    }

    .case-folder {
        padding: 12px;
    }

    .case-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-bottom: 8px;
    }

    .case-tab {
        border-bottom: 1px solid rgba(93, 67, 38, 0.28);
        border-radius: 3px;
    }

    .casefile-content {
        padding: 18px 12px;
    }

    .detective-note,
    .case-stat-grid,
    .case-exchange,
    .binder-chart,
    .care-evidence-grid {
        margin-left: 0;
    }

    .case-stat-grid,
    .care-evidence-grid {
        grid-template-columns: 1fr;
    }

    .case-exchange .message {
        width: 95%;
    }

    .modal {
        padding: 8px;
    }

    .modal-content {
        width: 100%;
        max-height: calc(100dvh - 16px);
    }

    .modal-header,
    .modal-body {
        padding: 17px;
    }

    .wax-seal {
        top: 44px;
        right: -7px;
        width: 48px;
        height: 48px;
    }

    .login-letter .modal-header {
        padding: 26px 33px 15px 42px;
    }

    .login-letter .modal-body {
        padding: 0 27px 27px 42px;
    }

    .shortcuts-grid,
    .mobile-shortcuts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 390px) {
    .main-content {
        width: calc(100% - 8px);
        margin: 4px;
    }

    .main-content::before {
        top: 4px;
        bottom: 4px;
        left: 4px;
    }

    .content-wrapper {
        padding-right: 9px;
        padding-left: 36px;
    }

    .top-header {
        padding-right: 9px;
        padding-left: 36px;
    }

    .page-title {
        font-size: 1.78rem;
    }

    .random-btn .btn-icon {
        display: none;
    }

    .diary-page-right {
        padding-right: 21px;
        padding-left: 21px;
    }

    .diary-handwriting {
        font-size: 1rem;
        line-height: 1.4;
    }

    .filter-group {
        grid-template-columns: 1fr;
    }

    .filter-foot {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    body {
        display: block;
        background: white;
    }

    .sidebar,
    .top-header,
    .filters-bar,
    .welcome-note,
    .loading-overlay {
        display: none !important;
    }

    .main-content {
        width: 100%;
        margin: 0;
        border: 0;
        box-shadow: none;
    }

    .content-wrapper {
        padding: 20px;
    }

    .messages-container {
        max-height: none;
        overflow: visible;
    }
}
