:root {
    --primary: #0066cc;
    --primary-hover: #0071e3;
    --bg: #f5f5f7;
    --surface: #ffffff;
    --text: #1d1d1f;
    --text-muted: #86868b;
    --border: #d2d2d7;
    --code-bg: #1d1d1f;
    --code-text: #f5f5f7;
    --accent-warm: #ff9500;
    --good: #34c759;
    --radius-lg: 18px;
    --radius-pill: 9999px;
    --wing-width: 260px;
}

body, * {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Noto Sans KR", sans-serif;
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ── Wing TOC ─────────────────────────────── */
.toc-wing {
    position: fixed;
    top: 0;
    left: calc(var(--wing-width) * -1);
    width: var(--wing-width);
    height: 100vh;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    padding: 70px 20px 20px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
}

.toc-wing.open {
    transform: translateX(var(--wing-width));
}

.toc-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.toc-toggle:hover {
    background: var(--bg);
}

.toc-wing ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-wing li {
    margin-bottom: 6px;
}

.toc-wing a {
    text-decoration: none;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    opacity: 0.7;
    transition: opacity 0.2s;
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
}

.toc-wing a:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

/* ── Slide Layout ─────────────────────────── */
.section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s;
    overflow-y: auto;
    background-color: var(--bg);
}

.section.active {
    opacity: 1;
    visibility: visible;
}

.apple-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 50px;
    max-width: 1000px;
    width: 100%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    margin: auto 0;
}

.apple-box.wide {
    max-width: 1120px;
}

/* ── Typography ───────────────────────────── */
.title-hero {
    font-size: 56px;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: 16px;
    line-height: 1.15;
}

.subtitle {
    font-size: 24px;
    font-weight: 400;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 40px;
    line-height: 1.5;
}

.chapter-label {
    color: var(--primary);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

h2 {
    font-size: 34px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 12px;
}

h3 {
    font-size: 22px;
    font-weight: 600;
    margin-top: 28px;
    margin-bottom: 12px;
}

p {
    font-size: 17px;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 16px;
}

/* 교과서식 리드 문장 */
.lead {
    font-size: 20px;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 24px;
    word-break: keep-all;
}

.bullet-list {
    margin: 0 0 16px;
    padding-left: 22px;
}

.bullet-list li {
    font-size: 17px;
    line-height: 1.65;
    margin-bottom: 10px;
    word-break: keep-all;
}

.bullet-list b {
    font-weight: 700;
}

/* ── 용어 카드 (비유 정의) ─────────────────── */
.term-card {
    background: #f0f6ff;
    border: 1px solid #cfe3ff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-top: 20px;
}

.term-card .term-name {
    color: var(--primary);
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}

.term-card p {
    margin: 0;
    font-size: 15px;
    color: #33445c;
}

/* ── 주의/팁 콜아웃 ────────────────────────── */
.callout {
    background: #fff8ec;
    border: 1px solid #ffd9a0;
    border-radius: 12px;
    padding: 14px 18px;
    margin-top: 20px;
    font-size: 15px;
    line-height: 1.6;
    color: #6b4b12;
}

.callout.blue {
    background: #f0f6ff;
    border-color: #cfe3ff;
    color: #33445c;
}

/* ── 코드 블록 ─────────────────────────────── */
.code-card {
    position: relative;
    margin-top: 20px;
}

pre.code-block {
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: 14px;
    padding: 22px;
    margin: 0;
    font-family: "JetBrains Mono", "D2Coding", Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
    overflow: auto;
    max-height: 56vh;
    white-space: pre;
    tab-size: 4;
}

pre.code-block.small {
    max-height: 34vh;
    font-size: 13.5px;
}

.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-pill);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.2s ease;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.copy-btn.done {
    background: var(--good);
    border-color: var(--good);
}

.code-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.code-toolbar .hint {
    font-size: 14px;
    color: var(--text-muted);
}

.download-link {
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.download-link:hover {
    text-decoration: underline;
}

/* 명령 한 줄 (검은 창용) */
.cmd-line {
    position: relative;
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: 12px;
    padding: 16px 120px 16px 20px;
    font-family: "JetBrains Mono", "D2Coding", Consolas, monospace;
    font-size: 15px;
    margin-top: 16px;
    overflow-x: auto;
    white-space: nowrap;
}

.cmd-line .copy-btn {
    top: 50%;
    transform: translateY(-50%);
}

/* ── 단계 목록 ─────────────────────────────── */
.step-list {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}

.step-list li {
    counter-increment: step;
    position: relative;
    padding: 12px 16px 12px 56px;
    background: #fbfbfd;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 16px;
    line-height: 1.6;
    word-break: keep-all;
}

.step-list li::before {
    content: counter(step);
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kbd {
    display: inline-block;
    background: #eceef1;
    border: 1px solid #d0d3d8;
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 1px 8px;
    font-family: Consolas, monospace;
    font-size: 13px;
    font-weight: 600;
}

/* ── 그리드/카드 ───────────────────────────── */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.card-small {
    background: #fbfbfd;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.card-small h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
}

.card-small p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
    word-break: keep-all;
}

.card-small .card-badge {
    display: inline-block;
    background: #f0f6ff;
    color: var(--primary);
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    margin-bottom: 10px;
}

.card-small code {
    font-family: Consolas, monospace;
    font-size: 13px;
    background: #eceef1;
    border-radius: 5px;
    padding: 1px 6px;
    color: #1d1d1f;
}

/* ── 표 ────────────────────────────────────── */
.apple-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 24px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

.apple-table th, .apple-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    line-height: 1.5;
    word-break: keep-all;
}

.apple-table th {
    background: #fbfbfd;
    font-weight: 600;
    color: var(--text-muted);
}

.apple-table tr:last-child td {
    border-bottom: none;
}

.apple-table td:first-child {
    font-weight: 600;
    background: #fbfbfd;
    white-space: nowrap;
}

/* ── 다이어그램 ────────────────────────────── */
.diagram-box {
    background: #fbfbfd;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.diagram-box svg {
    max-width: 100%;
    height: auto;
}

.diagram-row {
    display: grid;
    grid-template-columns: minmax(260px, 420px) 1fr;
    gap: 24px;
    align-items: start;
    margin-top: 20px;
}

@media (max-width: 820px) {
    .diagram-row {
        grid-template-columns: 1fr;
    }
}

/* ── 버튼 ──────────────────────────────────── */
.btn-group {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.apple-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 12px 24px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.apple-btn:hover {
    border-color: var(--text-muted);
}

.apple-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.apple-btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* ── 내비게이션 ────────────────────────────── */
.nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 900;
    color: var(--text);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    font-size: 18px;
}

.nav-arrow:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.nav-arrow.prev {
    left: 30px;
}

.nav-arrow.next {
    right: 30px;
}

.slide-pos {
    position: fixed;
    bottom: 18px;
    right: 22px;
    z-index: 900;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-pill);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .apple-box {
        padding: 28px 20px;
    }

    .title-hero {
        font-size: 36px;
    }

    .subtitle {
        font-size: 18px;
    }

    h2 {
        font-size: 26px;
    }

    .nav-arrow {
        width: 40px;
        height: 40px;
        left: 10px;
    }

    .nav-arrow.next {
        right: 10px;
    }

    .cmd-line {
        padding-right: 20px;
        padding-bottom: 52px;
    }

    .cmd-line .copy-btn {
        top: auto;
        bottom: 10px;
        transform: none;
    }
}
