:root {
    --primary: #0d47a1;
    --primary-light: #1976d2;
    --primary-dark: #002171;
    --bg: #f4f7fb;
    --text: #222;
    --muted: #666;
    --card-bg: #ffffff;
    --code-bg: #0b1020;
    --code-border: #1e2a3b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, rgba(13,71,161,0.16), transparent 55%), var(--bg);
    color: var(--text);
    line-height: 1.7;
}

.ebook-wrapper {
    max-width: 1024px;
    margin: 0 auto;
    padding: 24px 16px 72px;
}

.ebook-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-radius: 24px;
    padding: 32px 28px;
    color: #fff;
    box-shadow: 0 18px 45px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
}

.ebook-header::before {
    content: "";
    position: absolute;
    inset: -40%;
    background:
        radial-gradient(circle at 10% 0%, rgba(255,255,255,0.18), transparent 55%),
        radial-gradient(circle at 80% 0%, rgba(144,202,249,0.24), transparent 55%);
    opacity: 0.8;
    pointer-events: none;
}

.ebook-header-inner {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 24px;
    align-items: center;
}

.ebook-title {
    font-size: 2.4rem;
    margin: 0 0 8px;
    letter-spacing: 0.02em;
}

.ebook-subtitle {
    font-size: 1.1rem;
    margin: 0 0 16px;
    color: rgba(255,255,255,0.85);
}

.ebook-meta {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.9);
}

.ebook-author {
    font-weight: 600;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(13,71,161,0.35);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(187,222,251,0.5);
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    box-shadow: 0 0 0 4px rgba(76,175,80,0.35);
}

.ebook-cover-graphic {
    justify-self: flex-end;
    width: 100%;
    max-width: 260px;
    aspect-ratio: 3 / 4;
    border-radius: 20px;
    background: radial-gradient(circle at top, #bbdefb, #0d47a1);
    box-shadow: 0 16px 40px rgba(0,0,0,0.45);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #e3f2fd;
}

.cover-chip {
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(13,71,161,0.55);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cover-chip span {
    font-size: 1rem;
}

.cover-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.cover-tile {
    border-radius: 10px;
    padding: 6px;
    background: rgba(13,71,161,0.9);
    border: 1px solid rgba(227,242,253,0.2);
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    text-align: center;
}

.cover-tile.accent {
    background: #e3f2fd;
    color: #0d47a1;
}

.cover-footer {
    font-size: 0.7rem;
    opacity: 0.9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chip-small {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(227,242,253,0.4);
}

.ebook-body {
    margin-top: 28px;
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(260px, 1.3fr);
    gap: 24px;
}

@media (max-width: 900px) {
    .ebook-body {
        grid-template-columns: minmax(0, 1fr);
    }
    .ebook-header-inner {
        grid-template-columns: minmax(0, 1fr);
    }
    .ebook-cover-graphic {
        justify-self: stretch;
        max-width: 100%;
    }
}

.toc {
    background: var(--card-bg);
    padding: 18px 18px 20px;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    position: sticky;
    top: 16px;
    align-self: flex-start;
    border: 1px solid rgba(13,71,161,0.12);
}

.toc h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

.toc ol {
    padding-left: 18px;
    margin: 8px 0 0;
    font-size: 0.9rem;
}

.toc a {
    color: var(--primary-dark);
    text-decoration: none;
}

.toc a:hover {
    text-decoration: underline;
}

.main-content {
    background: transparent;
}

.chapter {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 20px 20px 22px;
    margin-bottom: 18px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    border: 1px solid rgba(13,71,161,0.06);
}

.chapter h2 {
    margin-top: 0;
    color: var(--primary-dark);
}

.chapter h3 {
    margin-top: 1.2em;
    color: var(--primary);
}

.chapter p {
    margin: 0.4em 0;
}

.tip, .warning, .note {
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 0.9rem;
    margin: 10px 0;
}

.tip {
    background: #e3f2fd;
    border-left: 3px solid #1976d2;
}

.warning {
    background: #fff8e1;
    border-left: 3px solid #f9a825;
}

.note {
    background: #ede7f6;
    border-left: 3px solid #5e35b1;
}

code, pre {
    font-family: "Fira Code", "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.82rem;
}

pre {
    background: var(--code-bg);
    border-radius: 14px;
    padding: 14px 14px;
    overflow-x: auto;
    border: 1px solid var(--code-border);
    color: #e3f2fd;
    margin: 10px 0 16px;
}

pre strong {
    color: #ffeb3b;
}

ul, ol {
    padding-left: 1.2rem;
}

footer {
    margin-top: 40px;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}
