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

:root {
    --bg: #ffffff;
    --text: #13131f;
    --text-muted: rgba(19, 19, 31, 0.45);
    --border: rgba(19, 19, 31, 0.1);
    --accent: #e80e3f;
    --highlight: #00dec2;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family:
        "Inter",
        -apple-system,
        sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
}

/* Top Header */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.header-brand {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.header-tagline {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.2;
}

/* Audio Player */
.audio-player {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(19, 19, 31, 0.04);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px;
    width: 260px;
    overflow: hidden;
    cursor: pointer;
}

#audioPlayer-ui {
    display: none !important;
}

.audio-progress {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    background: rgba(19, 19, 31, 0.06);
    border-radius: 999px;
    pointer-events: none;
    transition: width 0.1s linear;
    z-index: 0;
}

.play-button {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.play-button:hover {
    opacity: 0.75;
}

.play-button svg {
    width: 14px;
    height: 14px;
}

.play-button .pause-icon {
    display: none;
}

.play-button.playing .play-icon {
    display: none;
}

.play-button.playing .pause-icon {
    display: block;
}

.audio-info {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.audio-title {
    font-size: 12px;
    font-weight: 400;
    color: var(--text);
    white-space: nowrap;
    line-height: 1.2;
}

.audio-title strong {
    font-weight: 700;
}

.audio-time {
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    line-height: 1.2;
}

.speed-button {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(19, 19, 31, 0.08);
    color: var(--text);
    border: none;
    border-radius: 50%;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    font-size: 9px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
    text-transform: uppercase;
}

.speed-button:hover {
    background: rgba(19, 19, 31, 0.14);
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 120px 24px 120px;
    overflow-x: hidden;
}

/* Title */
.title-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.title-group h1 {
    margin-bottom: 0;
}

h1 {
    font-family: "Inter", sans-serif;
    font-size: clamp(3rem, 9vw, 6rem);
    font-weight: 800;
    font-style: italic;
    line-height: 1.0;
    letter-spacing: -0.03em;
}

h1.light {
    font-weight: 300;
    font-style: italic;
    font-size: clamp(2.2rem, 6.2vw, 4.2rem);
}

h2 {
    font-family: "Inter", sans-serif;
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    font-style: italic;
    line-height: 1.1;
    margin-top: 80px;
    margin-bottom: 32px;
    letter-spacing: -0.025em;
    scroll-margin-top: 80px;
}

.light-text {
    color: var(--text-muted);
    font-size: 16px;
    font-style: italic;
    line-height: 1.6;
    margin-top: 24px;
}

h3 {
    display: inline-block;
    font-family: "Inter", sans-serif;
    font-size: 19px;
    font-weight: 700;
    font-style: italic;
    letter-spacing: -0.01em;
    margin-top: 48px;
    margin-bottom: 16px;
    line-height: 1.3;
    color: var(--text);
    scroll-margin-top: 80px;
}

h4 {
    font-family: "Inter", sans-serif;
    font-size: 1rem;
    font-weight: 700;
    display: block;
    width: fit-content;
    margin-top: 28px;
    margin-bottom: 10px;
    padding-bottom: 2px;
    border-bottom: 2px solid rgba(19, 19, 31, 0.28);
}

p {
    margin-bottom: 20px;
    line-height: 1.75;
}

ul,
ol {
    margin: 0 0 20px;
    padding-left: 1.45em;
}

li {
    margin-bottom: 8px;
}

.lead {
    font-size: 1.2rem;
    font-style: italic;
    line-height: 1.65;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.subtitle {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

strong {
    font-weight: 700;
}

code,
pre,
kbd,
samp {
    font-size: 1rem;
}

hr {
    border: none;
    border-top: 2px solid var(--accent);
    margin: 64px 0;
    width: 48px;
}

/* Tables */
.table-scroll-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    margin-top: 40px;
    letter-spacing: 0.02em;
}

.ia-accordion {
    margin: 24px 0 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(19, 19, 31, 0.02);
    overflow: hidden;
}

.ia-accordion[open] {
    /* Match table full-width expansion on desktop */
    width: calc(100vw - max(0px, (100vw - 1100px) / 2) - 288px);
}

.ia-accordion summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
    font-size: 14px;
    font-weight: 700;
    padding: 14px 16px;
}

.ia-accordion summary::after {
    content: "";
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg) translateY(-1px);
    transition:
        transform 180ms ease,
        border-color 180ms ease;
    flex-shrink: 0;
}

.ia-accordion summary::-webkit-details-marker {
    display: none;
}

.ia-accordion[open] summary {
    border-bottom: 1px solid var(--border);
}

.ia-accordion[open] summary::after {
    transform: rotate(-135deg) translateY(-1px);
    border-color: var(--text);
}

.ia-accordion > table {
    margin-left: 14px;
    width: calc(100% - 14px);
}

.table-wrapper {
    overflow-x: auto;
    margin: 0 0 40px;
    /* Extend right to the viewport edge.
       Left offset = centering margin of .page-layout (max 1100px)
                   + sidebar width (240px)
                   + .main-content left padding (48px) = 288px */
    width: calc(100vw - max(0px, (100vw - 1100px) / 2) - 288px);
}

table {
    border-collapse: collapse;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    width: 100%;
}

th,
td {
    padding: 14px 16px 14px 0;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background-color: #f4f4f6;
}

td {
    color: var(--text);
}

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

th:last-child,
td:last-child {
    text-align: left;
}

/* Prototype Cards */
.prototype-cards {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-top: 24px;
}

.prototype-card {
    flex: 1;
    text-decoration: none;
    color: inherit;
    background: #f5f5f7;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition:
        transform 200ms ease-out,
        box-shadow 200ms ease-out;
}

.prototype-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(19, 19, 31, 0.08);
}

.prototype-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.prototype-tag {
    display: inline-block;
    margin-top: 12px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 4px 10px;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
}

.prototype-card-content {
    padding: 16px;
}

.prototype-card-content h4 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--text);
}

.prototype-card-content p {
    font-size: 13px;
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

@media (max-width: 768px) {
    .prototype-cards {
        flex-direction: column;
    }
}


/* Page Layout */
.page-layout {
    display: flex;
    max-width: 1100px;
    margin: 0 auto;
    padding-top: 60px;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 40px 24px 40px 0;
    border-right: 1px solid var(--border);
}

.main-content {
    flex: 1;
    max-width: 720px;
    padding: 80px 48px 120px;
}

/* Sidebar links (below TOC) */
.sidebar-links {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidebar-link {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 0;
    line-height: 1.4;
    transition: color 150ms;
}

.sidebar-link:hover {
    color: var(--text);
}


/* Sidebar TOC */
.toc-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

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

.toc-item {
    margin: 0;
}

.toc-link {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 0;
    line-height: 1.4;
    transition: color 150ms;
}

.toc-link:hover {
    color: var(--text);
}

.toc-link.active {
    color: var(--text);
    font-weight: 600;
}

.toc-link.level-3 {
    padding-left: 12px;
    font-size: 12px;
}

/* Mobile TOC FAB */
.toc-fab {
    position: fixed;
    right: 16px;
    bottom: 20px;
    z-index: 170;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
    padding: 0 18px;
    border: none;
    border-radius: 999px;
    background: var(--text);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 12px 28px rgba(19, 19, 31, 0.3);
    cursor: pointer;
    transition:
        transform 180ms ease,
        box-shadow 180ms ease,
        opacity 180ms ease;
}

.toc-fab svg {
    width: 18px;
    height: 18px;
}

.toc-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(19, 19, 31, 0.32);
}

.toc-overlay {
    position: fixed;
    inset: 0;
    z-index: 160;
    background: rgba(19, 19, 31, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
}

.mobile-toc-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 165;
    background: #fff;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    border-top: 1px solid var(--border);
    padding: 18px 16px 24px;
    max-height: min(72vh, 560px);
    overflow-y: auto;
    transform: translateY(102%);
    opacity: 0;
    pointer-events: none;
    transition:
        transform 220ms ease,
        opacity 220ms ease;
}

.mobile-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.mobile-toc-header .toc-title {
    margin-bottom: 0;
}

.mobile-toc-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: rgba(19, 19, 31, 0.03);
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

body.mobile-toc-open {
    overflow: hidden;
}

body.mobile-toc-open .toc-overlay {
    opacity: 1;
    pointer-events: auto;
}

body.mobile-toc-open .mobile-toc-sheet {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

body.mobile-toc-open .toc-fab {
    opacity: 0;
    pointer-events: none;
}


@media (max-width: 1024px) {
    .page-layout {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .subpage-mobile-back {
        display: inline-flex;
    }

    .subpage-sidebar-back {
        display: none;
    }

    .toc-fab {
        display: inline-flex;
    }

    .main-content {
        max-width: 100%;
        padding: 80px 24px 100px;
    }

    .table-wrapper {
        /* No sidebar: left offset = 24px main-content padding */
        width: calc(100vw - 24px);
    }

    .ia-accordion[open] {
        width: calc(100vw - 24px);
    }
}

/* Notes Grid */
.notes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 40px 0;
}

.note {
    background: rgba(19, 19, 31, 0.03);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 8px;
    font-size: 14px;
}

.note p {
    margin-bottom: 8px;
}

.note p:last-child {
    margin-bottom: 0;
}

.note-title {
    font-weight: 700;
}

/* Footer */
.footer {
    margin-top: 100px;
    padding-top: 40px;
    padding-bottom: 64px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 14px;
}

.footer p {
    margin-bottom: 4px;
}

.footer strong {
    color: var(--text);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 32px;
    flex-wrap: wrap;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.footer-descriptor {
    font-size: 13px;
    color: var(--text-muted);
}

.footer-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    text-align: right;
    font-size: 13px;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .footer-meta {
        align-items: flex-start;
        text-align: left;
    }
}

/* Subpages */
.subpage-header {
    justify-content: space-between;
}

.subpage-sidebar-back {
    margin-bottom: 18px;
}

.subpage-mobile-back {
    display: none;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    text-decoration: none;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: rgba(255, 255, 255, 0.92);
    transition:
        background 150ms ease-out,
        transform 150ms ease-out;
}

.back-button:hover {
    background: #fff;
    transform: translateY(-1px);
}

.subpage-main {
    max-width: 780px;
}

.summary-meta {
    margin: 28px 0 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(19, 19, 31, 0.03);
}

.summary-meta p {
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.6;
}

.summary-meta p:last-child {
    margin-bottom: 0;
}

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

.chapter-list li {
    margin-bottom: 12px;
    line-height: 1.7;
}

.chapter-list li:last-child {
    margin-bottom: 0;
}

.placeholder-grid {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.placeholder-item {
    padding: 16px;
    border: 1px dashed rgba(19, 19, 31, 0.24);
    border-radius: 10px;
    background: rgba(19, 19, 31, 0.02);
}

.placeholder-item h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 17px;
}

.placeholder-item p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

.placeholder-tag {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

/* Priority Guide link (from main doc → subpage) */
.pg-link {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 1px;
    transition: opacity 150ms;
}

.pg-link:hover {
    opacity: 0.65;
}

/* Mobile */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        line-height: 26px;
    }

    h2 {
        font-size: clamp(1.5rem, 8vw, 2rem);
        margin-top: 60px;
        margin-bottom: 24px;
    }

    h3 {
        font-size: 17px;
        margin-top: 36px;
        margin-bottom: 14px;
    }

    h4 {
        font-size: 15px;
    }

    ul,
    ol {
        padding-left: 1.3em;
        margin-left: 0.2rem;
    }

    .top-header {
        padding: 12px 16px;
        align-items: center;
    }

    hr {
        margin: 48px 0;
    }

    .header-left {
        gap: 0;
    }

    .header-brand {
        font-size: 12px;
    }

    .header-tagline {
        font-size: 11px;
    }

    .audio-player {
        width: auto;
        gap: 6px;
        padding: 4px;
        padding-right: 10px;
    }

    .play-button {
        width: 26px;
        height: 26px;
    }

    .play-button svg {
        width: 12px;
        height: 12px;
    }

    .audio-info {
        display: flex;
    }

    .audio-title {
        font-size: 11px;
    }

    .audio-time {
        font-size: 10px;
    }

    .speed-button {
        width: 26px;
        height: 26px;
        font-size: 8px;
        display: none;
    }

    .container {
        padding: 90px 16px 100px;
    }

    .main-content {
        padding: 80px 16px 100px;
    }

    .table-wrapper {
        /* Mobile: left offset = 16px main-content padding */
        width: calc(100vw - 16px);
    }

    .ia-accordion[open] {
        width: calc(100vw - 16px);
    }

    .notes-grid {
        grid-template-columns: 1fr;
    }

    .back-button {
        padding: 8px 10px;
        font-size: 11px;
        gap: 6px;
    }

    .subpage-main {
        padding-top: 88px;
    }

    .summary-meta {
        margin-top: 20px;
        padding: 14px;
    }

    .summary-meta p {
        font-size: 14px;
    }

    .placeholder-grid {
        grid-template-columns: 1fr;
    }
}
