/* Base Styles & Variables */
:root {
    --primary-color: #e59a9a; /* Soft Rose */
    --primary-dark: #cc7a7a;
    --accent-color: #d4a373; /* Elegant Gold/Tan */
    --bg-color: #ffffff;
    --content-bg: #fff;
    --text-main: #333333;
    --text-muted: #666666;
    --border-color: #f0e6e6;
    --section-spacing: 40px;
    --border-radius: 12px;
    --container-max-width: 1050px;
    --article-max-width: 780px; /* Slightly wider for single column */
    --sidebar-width: 300px;
    --font-heading: 'Outfit', 'Noto Sans JP', sans-serif;
    --font-body: 'Noto Sans JP', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px; /* Adjust for sticky header */
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-main);
    background-color: var(--bg-color);
    -webkit-text-size-adjust: 100%;
    word-break: break-all;
}

/* Typography */
h1, h2, h3 {
    font-family: var(--font-heading);
    line-height: 1.4;
    color: var(--text-main);
}

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 24px;
}

h2 {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 12px 16px;
    border-left: 6px solid var(--primary-color);
    background: linear-gradient(to right, #fff5f5, transparent);
    margin: 48px 0 24px;
}

h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 32px 0 16px;
    color: var(--primary-dark);
}

p {
    margin-bottom: 24px;
}

/* Layout */
.main-header {
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    text-align: center;
}

.header-logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.05em;
}

.content-wrapper {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 30px 20px 100px;
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.content-wrapper.single-column {
    justify-content: center;
}

.article-container {
    flex: 1;
    max-width: var(--article-max-width);
    background: #fff;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    position: sticky;
    top: 90px; /* Below header */
}

@media (max-width: 900px) {
    .content-wrapper {
        flex-direction: column;
        padding: 20px 15px 100px;
    }
    .sidebar {
        width: 100%;
        position: static;
        margin-top: 40px;
    }
    .article-container {
        width: 100%;
    }
}

.sidebar-box {
    background: #fffafa;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 30px;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.sidebar-nav-list {
    list-style: none;
    padding: 0;
    margin: 0 !important;
}

.sidebar-nav-item {
    margin-bottom: 12px;
}

.sidebar-nav-item a {
    display: block;
    padding: 10px 15px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-nav-item a:hover {
    background: #fff5f5;
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.sidebar-nav-item.active a {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Table of Contents */
.toc-box {
    background: #fdfaf7;
    border: 1px solid #e9d8c4;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 40px;
}

.toc-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
    color: var(--accent-color);
}

.toc-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.toc-list li {
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
}

.toc-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-weight: bold;
}

.toc-list a {
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: color 0.2s;
}

.toc-list a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Article Parts */
.article-header {
    text-align: left;
    margin-bottom: 30px;
}

.section-image {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin-bottom: 24px;
    display: block;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* UI Elements */
.summary-box {
    background-color: #fff9f9;
    border: 2px dashed var(--primary-color);
    border-radius: var(--border-radius);
    padding: 24px;
    margin: 30px 0;
}

.summary-box ul {
    list-style: none;
}

.summary-box li {
    position: relative;
    padding-left: 28px;
    margin-bottom: 12px;
    font-weight: 500;
}

.summary-box li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.balloon {
    background-color: #fefefe;
    border: 1px solid #eee;
    border-radius: 20px;
    padding: 20px;
    position: relative;
    margin: 30px 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.balloon p {
    margin-bottom: 0;
    font-style: italic;
    color: var(--text-muted);
}

.balloon::after {
    content: "";
    position: absolute;
    bottom: -15px;
    left: 40px;
    border-width: 15px 15px 0;
    border-style: solid;
    border-color: #fefefe transparent;
    display: block;
    width: 0;
}

.note {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    font-size: 0.95rem;
    color: var(--text-muted);
    border-left: 3px solid #ccc;
    margin: 24px 0;
}

ul:not(.summary-box ul) {
    margin: 0 0 24px 24px;
}

li {
    margin-bottom: 8px;
}

.mk {
    background: linear-gradient(transparent 70%, #ffdfdf 70%);
    font-weight: bold;
}

/* Related Articles (Internal Links) */
.related-articles {
    background: #fffafa;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 30px 20px;
    margin: 40px 0;
}

.related-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.related-title::before {
    content: "📖";
    margin-right: 8px;
}

.related-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.related-item {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 15px;
    transition: transform 0.2s ease;
}

.related-item:hover {
    transform: translateX(5px);
    border-color: var(--primary-color);
}

.related-item a {
    display: block;
    padding: 15px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
}

/* CTA Styles */
.cta-area {
    background: linear-gradient(135deg, #fffafa, #fff0f0);
    border-radius: var(--border-radius);
    padding: 40px 24px;
    text-align: center;
    margin: 50px 0;
    border: 1px solid #ffebeb;
}

.cta-area p {
    font-weight: bold;
    color: var(--primary-dark);
    margin-bottom: 20px;
}

.cta-button {
    display: inline-block;
    background: linear-gradient(to right, #ff6b6b, #ff8e8e);
    color: white;
    padding: 20px 35px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
    max-width: 450px;
    border: none;
}

.cta-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(229, 154, 154, 0.6);
}

/* Floating CTA */
.floating-cta {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 0 20px;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.floating-cta.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.floating-cta-button {
    display: block;
    width: 100%;
    max-width: 500px;
    background: linear-gradient(to right, #ff7e7e, #ff9999);
    color: white;
    text-align: center;
    padding: 15px;
    border-radius: 40px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 8px 30px rgba(255, 0, 0, 0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Side Floating CTA */
.side-cta {
    position: fixed;
    right: 20px;
    bottom: 120px; /* Above bottom floating CTA */
    z-index: 998;
    opacity: 0;
    transform: translateX(40px);
    transition: all 0.4s ease;
    pointer-events: none;
}

.side-cta.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.side-cta-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1.2;
    text-align: center;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    transition: transform 0.2s ease;
}

.side-cta-button:hover {
    transform: scale(1.1);
    background: #ff5252;
}

@media (min-width: 901px) {
    .side-cta {
        bottom: 50%;
        transform: translateY(50%) translateX(40px);
    }
    .side-cta.visible {
        transform: translateY(50%) translateX(0);
    }
}

/* Footer */
.main-footer {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.25rem; }
    .content-wrapper { padding: 15px 15px 100px; }
}