:root {
    --orange: #FF4500;
    --orange-light: #FF6A35;
    --bg: #0A0A0A;
    --surface: #111111;
    --surface2: #161616;
    --surface3: #202020;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #F5F5F5;
    --text-secondary: rgba(255, 255, 255, 0.72);
    --muted: #888888;
    --font: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 110px;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 69, 0, 0.18), transparent 70%),
        linear-gradient(180deg, #0A0A0A 0%, #0d0d0d 50%, #080808 100%);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

.skip-link {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 2000;
    transform: translateY(-160%);
    border-radius: 12px;
    padding: 10px 16px;
    background: var(--orange);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.container {
    width: min(1320px, calc(100% - 64px));
    margin: 0 auto;
}

.contract-shell {
    padding: 130px 0 90px;
}

/* ── CONTRACT HEADER ── */
.contract-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 32px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border);
}

.label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--orange-light);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.label::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--orange);
}

h1 {
    font-size: clamp(34px, 4.5vw, 62px);
    line-height: 1.05;
    letter-spacing: -0.04em;
    font-weight: 900;
    color: #fff;
}

.lead {
    max-width: 760px;
    margin-top: 14px;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.65;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    border: 1px solid rgba(255, 69, 0, 0.35);
    border-radius: 999px;
    padding: 0 24px;
    color: var(--orange-light);
    background: rgba(255, 69, 0, 0.08);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.25s ease;
}

.back-link:hover {
    background: var(--orange);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 69, 0, 0.25);
}

/* ── METADATA BAR ── */
.contract-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.meta-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.025);
    backdrop-filter: blur(12px);
    transition: border-color 0.2s ease;
}

.meta-card:hover {
    border-color: var(--border-strong);
}

.meta-card span {
    display: block;
    color: rgba(255, 255, 255, 0.45);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.meta-card strong {
    display: block;
    margin-top: 6px;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
}

/* ── DOCUMENT VIEWER CONTAINER ── */
.document-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 36px;
    align-items: start;
}

/* Sticky Table of Contents */
.doc-toc {
    position: sticky;
    top: 120px;
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(17, 17, 17, 0.85);
    backdrop-filter: blur(20px);
}

.toc-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 16px;
}

.toc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
}

.toc-list a {
    display: block;
    padding: 8px 12px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-list a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.toc-list a.is-active {
    background: rgba(255, 69, 0, 0.14);
    color: var(--orange-light);
    font-weight: 700;
}

/* Main Viewer Shell */
.document-viewer {
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
        var(--surface);
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.5);
}

.viewer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(20, 20, 20, 0.9);
}

.viewer-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 0 10px var(--orange);
}

.viewer-status p {
    color: rgba(255, 255, 255, 0.65);
    font-size: 13px;
    font-weight: 600;
}

.viewer-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-btn:hover {
    border-color: var(--orange);
    color: #fff;
    background: rgba(255, 69, 0, 0.12);
}

.source-link {
    color: var(--orange-light);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

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

/* ── RENDERED MARKDOWN TYPOGRAPHY (DARK THEMING) ── */
.markdown-rendered {
    padding: 48px;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.8;
}

.markdown-rendered h1,
.markdown-rendered h2,
.markdown-rendered h3,
.markdown-rendered h4 {
    color: #fff;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin-top: 36px;
    margin-bottom: 16px;
    scroll-margin-top: 120px;
}

.markdown-rendered h1 {
    font-size: 32px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--orange);
}

.markdown-rendered h2 {
    font-size: 24px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.markdown-rendered h3 {
    font-size: 19px;
    color: rgba(255, 255, 255, 0.95);
}

.markdown-rendered h4 {
    font-size: 16px;
    color: var(--orange-light);
}

.markdown-rendered p {
    margin-bottom: 20px;
}

.markdown-rendered p strong,
.markdown-rendered li strong {
    color: #fff;
}

.markdown-rendered ul,
.markdown-rendered ol {
    margin-bottom: 24px;
    padding-left: 24px;
    display: grid;
    gap: 10px;
}

.markdown-rendered li {
    color: var(--text-secondary);
}

.markdown-rendered blockquote {
    margin: 28px 0;
    padding: 20px 24px;
    border-left: 4px solid var(--orange);
    border-radius: 0 16px 16px 0;
    background: rgba(255, 69, 0, 0.06);
    color: rgba(255, 255, 255, 0.88);
    font-style: italic;
}

.markdown-rendered table {
    width: 100%;
    margin: 28px 0;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.markdown-rendered th {
    background: rgba(255, 69, 0, 0.12);
    color: #fff;
    font-weight: 800;
    text-align: left;
    padding: 14px 18px;
    border: 1px solid var(--border);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.markdown-rendered td {
    padding: 14px 18px;
    border: 1px solid var(--border);
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
}

.markdown-rendered tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.markdown-rendered hr {
    margin: 40px 0;
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.markdown-rendered code {
    background: rgba(255, 255, 255, 0.08);
    color: var(--orange-light);
    padding: 2px 7px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
}

.markdown-rendered pre {
    margin: 24px 0;
    padding: 20px;
    border-radius: 16px;
    background: #080808;
    border: 1px solid var(--border);
    overflow-x: auto;
}

.markdown-rendered pre code {
    background: transparent;
    padding: 0;
}

/* Raw Markdown Container */
.markdown-raw {
    padding: 40px;
    background: #080808;
    color: #00ff88;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 700px;
    overflow-y: auto;
}

.hidden {
    display: none !important;
}

/* ── FOOTER ── */
footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: min(1320px, calc(100% - 64px));
    margin: 0 auto;
    padding: 40px 0;
    border-top: 1px solid var(--border);
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}

.footer-link {
    color: rgba(255, 255, 255, 0.65);
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--orange);
}

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
    .document-layout {
        grid-template-columns: 1fr;
    }

    .doc-toc {
        display: none;
    }

    .contract-meta {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .container, footer {
        width: min(100% - 32px, 520px);
    }

    .contract-shell {
        padding-top: 100px;
    }

    .contract-top {
        flex-direction: column;
        align-items: stretch;
    }

    .contract-meta {
        grid-template-columns: 1fr;
    }

    .markdown-rendered {
        padding: 24px;
    }

    .viewer-bar {
        flex-direction: column;
        align-items: stretch;
    }
}
