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

body {
    background: #faf8f5;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    line-height: 1.75;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background: #1a1a1a;
    color: #e0e0e0;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 60px 20px;
}

header {
    margin-bottom: 56px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

body.dark-mode header,
body.dark-mode .back-link,
body.dark-mode footer {
    border-color: #333;
}

header h1 {
    margin-bottom: 10px;
    font-size: 2em;
    font-weight: 600;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

body.dark-mode .subtitle,
body.dark-mode .essay-meta,
body.dark-mode .source-note,
body.dark-mode .section-note {
    color: #999;
}

.header-controls,
.header-actions,
.language-toggle {
    display: flex;
    align-items: center;
}

.header-controls {
    justify-content: space-between;
    gap: 20px;
    margin-top: 20px;
}

.header-actions {
    gap: 15px;
}

.language-toggle {
    gap: 10px;
}

nav a,
.back-link a,
.source-note a {
    color: #0066cc;
    text-decoration: none;
}

nav a {
    margin-right: 20px;
    font-size: 0.95em;
}

body.dark-mode nav a,
body.dark-mode .back-link a,
body.dark-mode .source-note a {
    color: #4a9eff;
}

nav a:hover,
.back-link a:hover,
.source-note a:hover {
    text-decoration: underline;
}

.lang-btn {
    padding: 4px;
    border: 0;
    background: none;
    cursor: pointer;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 1.5em;
    line-height: 1;
    opacity: 0.5;
}

.lang-btn:hover {
    opacity: 0.8;
}

.lang-btn.active {
    cursor: default;
    opacity: 1;
}

.theme-toggle {
    position: relative;
    width: 48px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: #e8e4dd;
    cursor: pointer;
}

body.dark-mode .theme-toggle {
    background: #2a2a2a;
}

.toggle-circle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #333;
    transition: transform 0.3s ease;
}

body.dark-mode .toggle-circle {
    background: #faf8f5;
    transform: translateX(24px);
}

.essay-header {
    margin-bottom: 42px;
    text-align: center;
}

.essay-title {
    margin-bottom: 18px;
    font-family: Georgia, "Times New Roman", "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: clamp(2rem, 7vw, 3rem);
    font-weight: 500;
    line-height: 1.3;
}

.essay-meta {
    color: #777;
    font-size: 0.95em;
}

.dek {
    margin: 0 auto 24px;
    max-width: 690px;
    font-family: Georgia, "Times New Roman", "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: 1.06rem;
}

.source-note {
    margin: 0 auto 48px;
    padding: 18px 20px;
    border-left: 3px solid #aaa;
    color: #666;
    background: rgba(127, 127, 127, 0.06);
    font-size: 0.93rem;
}

.source-note p + p {
    margin-top: 0.7em;
}

.section-title {
    margin-bottom: 10px;
    font-family: Georgia, "Times New Roman", "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: 1.8rem;
    font-weight: 500;
}

.section-note {
    margin-bottom: 30px;
    color: #777;
    font-size: 0.92rem;
}

.essay-content {
    font-family: Georgia, "Times New Roman", "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: 1.04rem;
}

.essay-content p {
    margin-bottom: 1.45em;
}

.dialogue-transcript .dialogue {
    display: block;
    margin-bottom: 1.4em;
    border-radius: 4px;
    scroll-margin-top: 24px;
}

.speaker {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
    font-size: 0.94em;
    font-weight: 700;
    letter-spacing: 0.015em;
}

.speaker::after {
    content: "：";
}

html[lang="fr"] .speaker::after {
    content: "\00a0:";
}

.speaker-link {
    display: inline;
    margin-inline-end: 0.45em;
    color: #555;
    text-decoration: none;
    text-underline-offset: 0.18em;
}

.speaker-link:hover,
.speaker-link:focus-visible {
    color: #0066cc;
    text-decoration: underline;
}

body.dark-mode .speaker-link {
    color: #bbb;
}

body.dark-mode .speaker-link:hover,
body.dark-mode .speaker-link:focus-visible {
    color: #4a9eff;
}

.dialogue.parallel-target {
    animation: parallel-highlight 2.6s ease-out;
}

body.dark-mode .dialogue.parallel-target {
    animation-name: parallel-highlight-dark;
}

@keyframes parallel-highlight {
    0%, 38% {
        background-color: #fff0a8;
        box-shadow: 0 0 0 7px #fff0a8;
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0 7px transparent;
    }
}

@keyframes parallel-highlight-dark {
    0%, 38% {
        background-color: #584d18;
        box-shadow: 0 0 0 7px #584d18;
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0 7px transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dialogue.parallel-target,
    body.dark-mode .dialogue.parallel-target {
        animation-duration: 0.01ms;
    }
}

.essay-content h3 {
    margin: 2.3em 0 1em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    font-size: 1.05rem;
    letter-spacing: 0.04em;
}


.back-link {
    margin-top: 70px;
    padding-top: 30px;
    border-top: 1px solid #e0e0e0;
}

footer {
    margin-top: 80px;
    padding-top: 30px;
    border-top: 1px solid #e0e0e0;
    color: #999;
    font-size: 0.9em;
    text-align: center;
}

@media (max-width: 640px) {
    .container {
        padding: 40px 18px;
    }

    header {
        margin-bottom: 44px;
    }

    .header-controls {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        align-self: flex-end;
    }

    nav {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 18px;
    }

    nav a {
        margin-right: 0;
    }

    .essay-content {
        font-size: 1rem;
    }
}
