:root {
    --background: #cfdaea;
    --text: #192e25;
    --primary: #0b402a;
    --accent: #733b1b;
    --paper: #e8eef6;
}

html {
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

html:has(dialog:modal) {
    overflow: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: var(--background);
    color: var(--text);
    font-size: 20px;
    font-weight: 400;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

button {
    color: inherit;
    font-size: inherit;
    font-weight: 400;
    line-height: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1,
h2,
h3 {
    font-weight: 400;
}

strong,
b {
    font-weight: 700;
}

svg {
    display: block;
    flex-shrink: 0;
}

img {
    display: block;
    max-width: 100%;
}

.travel-scrapbook {
    width: calc(100% - 44px);
    max-width: 1424px;
    margin-inline: auto;
    padding-inline: 0;
    min-width: 0;
}

.front-matter {
    position: static;
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding-block: 10px;
}

.travel-scrapbook-skip {
    position: absolute;
    top: 10px;
    left: 22px;
    z-index: 10;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.travel-scrapbook-skip:focus {
    width: auto;
    height: auto;
    max-width: calc(100% - 44px);
    padding: 12px 18px;
    overflow: visible;
    clip-path: inset(0);
    white-space: normal;
    background: var(--primary);
    color: var(--paper);
    border-radius: 12px;
}

.cover-name {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 56px;
    height: 44px;
    background: var(--primary);
    color: var(--background);
    border-radius: 14px;
    box-shadow: 3px 3px 0 var(--accent);
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.06em;
}

.front-matter > #browse-chapters {
    flex: 1;
    min-width: 0;
    margin-left: auto;
}

.chapter-menu-links,
.chapters-list,
.notebook-margin-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.chapter-menu-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    font-size: 16px;
}

.chapter-menu-links li {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.chapter-menu-links a {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    padding-block: 6px;
}

.chapter-menu-links a > span:last-child {
    min-width: 0;
}

.separator {
    flex-shrink: 0;
    color: var(--accent);
}

.active-mark {
    flex-shrink: 0;
    color: var(--accent);
    visibility: hidden;
}

a[aria-current="page"] .active-mark {
    visibility: visible;
}

.chapter-menu-toggle,
.chapter-menu-close {
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    border: 0;
    border-radius: 14px;
    background: var(--primary);
    color: var(--paper);
    font-size: 18px;
}

.chapter-menu-toggle {
    display: none;
    margin-left: auto;
}

.chapter-menu-toggle[hidden] {
    display: none;
}

.chapter-menu-toggle svg,
.chapter-menu-close svg {
    width: 18px;
    height: 18px;
}

.chapter-drawer {
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--background);
    color: var(--text);
}

.chapter-drawer::backdrop {
    background: var(--primary);
}

.chapter-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 4px double var(--primary);
}

.chapter-drawer-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.chapter-menu-close {
    display: inline-flex;
}

main.travel-scrapbook {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.opening-chapter h1 {
    max-width: 24ch;
    color: var(--primary);
    font-size: 56px;
    font-weight: 400;
    line-height: 1.12;
    letter-spacing: -0.035em;
}

.chapters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding-block: 16px;
    border-top: 4px double var(--primary);
    border-bottom: 4px double var(--primary);
}

.chapters h2 {
    font-size: 18px;
    font-weight: 700;
}

.chapters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
}

.chapters-list li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chapters-list svg,
.city-notebook-reading-time svg {
    width: 18px;
    height: 18px;
    padding: 2px;
    border-radius: 50%;
    background: var(--background);
    color: var(--primary);
    stroke-width: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chapters-list svg {
    background: var(--primary);
    color: var(--background);
}

.city-stories {
    display: grid;
    gap: 24px;
    min-width: 0;
}

.city-stories > h2 {
    font-size: 30px;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.notebook-margin-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

.notebook-margin-list > li {
    min-width: 0;
}

.town-card {
    display: grid;
    grid-template-columns: 184px minmax(0, 1fr);
    gap: 16px;
    width: 100%;
    padding: 22px;
    border-radius: 20px;
    background: var(--paper);
    box-shadow: 4px 4px 0 var(--primary);
    text-align: right;
}

.preview {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    display: block;
    width: 184px;
    max-width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    background: var(--background);
}

.preview img {
    width: 100%;
    height: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: inherit;
}

.town-card-copy {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    min-width: 0;
}

.notebook-margin-list > li:nth-child(even) .town-card {
    grid-template-columns: minmax(0, 1fr) 184px;
}

.notebook-margin-list > li:nth-child(even) .preview {
    grid-column: 2;
}

.notebook-margin-list > li:nth-child(even) .town-card-copy {
    grid-column: 1;
}

.town-card-details {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 14px;
    line-height: 1.4;
}

.town-card .town-card-details {
    justify-content: flex-end;
}

.town-card-section {
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
}

.town-card-details time {
    white-space: nowrap;
}

.city-notebook-reading-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.town-card h3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    max-width: 100%;
    color: var(--primary);
    font-size: 30px;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.town-card-summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    max-width: 100%;
}

.more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    min-height: 44px;
    margin-top: auto;
    padding: 10px 22px;
    border-radius: 24px;
    background: var(--accent);
    color: var(--paper);
    font-size: 16px;
    font-weight: 700;
}

.city-notebook {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 770px;
    min-width: 0;
    margin-left: auto;
    margin-right: 0;
}

.story-top {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 24px;
    border-bottom: 4px double var(--primary);
}

.story-top h1 {
    color: var(--primary);
    font-size: 56px;
    font-weight: 400;
    line-height: 1.12;
    letter-spacing: -0.035em;
}

.city-notebook-text {
    display: flow-root;
    min-width: 0;
    max-width: 100%;
}

.city-notebook-text > * {
    margin: 0;
}

.city-notebook-text > * + * {
    margin-top: 24px;
}

.city-notebook-text h2 {
    color: var(--primary);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.25;
}

.city-notebook-text h3 {
    color: var(--primary);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
}

.city-notebook-text p {
    line-height: 1.4;
}

.city-notebook-text a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.city-notebook-text blockquote {
    padding: 22px;
    border-radius: 16px;
    background: var(--paper);
    box-shadow: 4px 4px 0 var(--primary);
}

.city-notebook-text blockquote > * {
    margin: 0;
}

.city-notebook-text blockquote > * + * {
    margin-top: 12px;
}

.city-notebook-text cite {
    display: block;
    margin-top: 12px;
    color: var(--accent);
    font-size: 18px;
    font-weight: 400;
    font-style: italic;
}

.city-notebook-text ul,
.city-notebook-text ol {
    padding-left: 30px;
    list-style-type: decimal;
}

.city-notebook-text li + li {
    margin-top: 8px;
}

.city-notebook-text li::marker {
    color: var(--accent);
    font-weight: 700;
}

.city-notebook-text li > ul,
.city-notebook-text li > ol {
    margin-top: 12px;
}

.city-notebook-text table {
    width: 100%;
    border-collapse: collapse;
    font-size: 18px;
    line-height: 1.4;
}

.city-notebook-text caption {
    padding-bottom: 12px;
    color: var(--primary);
    font-weight: 700;
    text-align: left;
    caption-side: top;
}

.city-notebook-text th,
.city-notebook-text td {
    padding: 12px;
    border: 1px solid var(--primary);
    text-align: left;
    vertical-align: top;
}

.city-notebook-text th {
    background: var(--primary);
    color: var(--paper);
    font-weight: 700;
}

.city-notebook-text td {
    background: var(--paper);
}

.city-notebook-text hr {
    height: 0;
    border: 0;
    border-top: 4px double var(--primary);
}

.notebook-margin-related {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding-top: 24px;
    border-top: 4px double var(--primary);
}

.notebook-margin-related a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    max-width: 100%;
    padding: 12px 22px;
    border-radius: 24px;
    background: var(--primary);
    color: var(--paper);
    font-size: 16px;
    text-align: center;
}

.notebook-margin-related a:last-child {
    margin-left: auto;
}

.last-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 24px;
    padding-block: 24px;
    border-top: 4px double var(--primary);
}

.last-page-rights {
    min-width: 0;
    font-size: 16px;
}

.last-page-rights span {
    display: block;
    margin-top: 8px;
    font-size: 14px;
}

.material-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.material-links h2 {
    font-size: 16px;
    font-weight: 700;
}

@keyframes menu-slide {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@media (max-width: 702px) {
    body {
        font-size: 18px;
    }

    .front-matter {
        flex-wrap: wrap;
        gap: 16px;
    }

    .front-matter > #browse-chapters {
        order: 3;
        flex-basis: 100%;
    }

    .chapter-menu-toggle {
        display: inline-flex;
    }

    .chapter-drawer {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-width: none;
        max-height: none;
        padding: 22px;
        overflow-y: auto;
    }

    .chapter-drawer[open] {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }

    .chapter-drawer.slides-in[open] {
        animation: menu-slide 150ms ease-out;
    }

    .chapter-drawer #browse-chapters {
        min-width: 0;
    }

    .chapter-drawer .chapter-menu-links {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
        font-size: 26px;
    }

    .chapter-drawer .separator {
        display: none;
    }

    .opening-chapter h1,
    .story-top h1 {
        font-size: 36px;
    }

    .chapters-list {
        gap: 12px 16px;
    }

    .city-stories > h2 {
        font-size: 26px;
    }

    .town-card,
    .notebook-margin-list > li:nth-child(even) .town-card {
        grid-template-columns: minmax(0, 1fr);
    }

    .preview,
    .notebook-margin-list > li:nth-child(even) .preview {
        grid-column: 1;
        grid-row: 1;
        justify-self: center;
    }

    .town-card-copy,
    .notebook-margin-list > li:nth-child(even) .town-card-copy {
        grid-column: 1;
        grid-row: 2;
    }

    .town-card h3 {
        font-size: 24px;
    }

    .town-card-details {
        gap: 8px 12px;
    }

    .city-notebook-text h2 {
        font-size: 26px;
    }

    .city-notebook-text h3 {
        font-size: 22px;
    }

    .last-page {
        grid-template-columns: minmax(0, 1fr);
    }

    .last-page .chapter-menu-links {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .last-page .separator {
        display: none;
    }
}

@media (max-width: 480px) {
    .travel-scrapbook {
        width: calc(100% - 32px);
    }

    .travel-scrapbook-skip {
        left: 16px;
    }

    .travel-scrapbook-skip:focus {
        max-width: calc(100% - 32px);
    }

    .chapter-drawer {
        padding: 16px;
    }

    .opening-chapter h1,
    .story-top h1 {
        font-size: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chapter-drawer.slides-in[open] {
        animation: none;
        transition: none;
        scroll-behavior: auto;
    }
}
