:root {
    --page-bg: #0d0d0d;
    --page-text: #e8e8e8;
    --accent: #e206ff;
    --accent-soft: #b498f1;
    --yellow: #ffff00;
    --link: #c97aff;
    --link-hover: #e206ff;
    --border: #2a2a2a;
    --muted: #888;
    --section-bg: #111;
    --green: #39d353;
    --orange: #f0a030;
    --red: #e05050;
    --sidebar-w: 260px;
}

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

body {
    background: var(--page-bg);
    color: var(--page-text);
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ── */
.site-header {
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-shrink: 0;
}

.site-header .org {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.site-header .title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.site-header .title span {
    color: var(--accent);
    border-right: 2pt solid;
    border-color: rgba(78, 11, 161, 0.496);
    padding-right: 3pt;
}

.site-header-links a {
    color: white;
    text-decoration: none;
  }

/* ── Split layout ── */
.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px 0;
    background: #0a0a0a;
}

.sidebar-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    padding: 0 16px 10px;
}

.doc-entry {
    margin-bottom: 4px;
}

.doc-link {
    display: block;
    padding: 8px 16px;
    font-size: 0.87rem;
    color: var(--page-text);
    text-decoration: none;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.3;
}

.doc-link:hover {
    background: #161616;
    color: #fff;
}

.doc-link.active {
    border-left-color: var(--accent);
    background: #161616;
    color: #fff;
}

.addendum-list {
    display: none;
}

.addendum-list.open {
    display: block;
}

.addendum-link {
    display: block;
    padding: 5px 16px 5px 28px;
    font-size: 0.78rem;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: color 0.15s, background 0.15s;
}

.addendum-link:hover {
    color: var(--accent-soft);
    background: #161616;
}

.addendum-link.active {
    color: var(--accent-soft);
    border-left-color: var(--accent-soft);
}

/* ── Content panel ── */
.content-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 40px 48px 80px;
    /* max-width: 860px; */
}

.content-panel:empty::after {
    content: 'Select a document from the sidebar.';
    color: var(--muted);
    font-size: 0.9rem;
}

/* ── Doc section rendered inside panel ── */
.doc-section {
    display: none;
}

.doc-section.visible {
    display: block;
}

.doc-header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.doc-header .doc-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.doc-header .doc-title span {
    color: var(--accent);
}

.doc-header .doc-meta {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 6px;
}

/* ── Addendum divider ── */
.addendum-block {
    margin-top: 56px;
    padding-top: 32px;
    border-top: 1px dashed var(--border);
}

.addendum-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    background: var(--section-bg);
    color: var(--accent-soft);
    border: 1px solid var(--border);
    padding: 3px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 24px;
}

/* ── Inherited doc styles ── */
.content-panel h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.content-panel .section-tag {
    font-size: 0.7rem;
    background: var(--accent);
    color: #000;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.content-panel h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-soft);
    margin: 20px 0 8px;
}

.content-panel p {
    color: #c0c0c0;
    margin-bottom: 12px;
    font-size: 0.92rem;
    line-height: 1.7;
}

.content-panel ul {
    list-style: none;
    padding: 0;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.content-panel ul li {
    font-size: 0.91rem;
    color: #c0c0c0;
    padding-left: 18px;
    position: relative;
}

.content-panel ul li::before {
    content: '▸';
    color: var(--accent);
    position: absolute;
    left: 0;
    font-size: 0.8em;
    top: 2px;
}

.content-panel a {
    color: var(--link);
    text-decoration: none;
}

.content-panel a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.content-panel .callout {
    background: var(--section-bg);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 0.88rem;
    color: #b0b0b0;
}

.content-panel .callout.yellow {
    border-color: var(--yellow);
}

.content-panel .callout.green {
    border-color: var(--green);
}

.content-panel .callout.orange {
    border-color: var(--orange);
}

.content-panel .callout.red {
    border-color: var(--red);
}

.content-panel .callout strong {
    color: var(--accent-soft);
}

.content-panel .callout.yellow strong {
    color: var(--yellow);
}

.content-panel .callout.green strong {
    color: var(--green);
}

.content-panel .callout.orange strong {
    color: var(--orange);
}

.content-panel .callout.red strong {
    color: var(--red);
}

.content-panel .rule-list,
.content-panel .sw-grid,
.content-panel .exception-list,
.content-panel .branch-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.content-panel .branch-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.content-panel .rule-card,
.content-panel .sw-card,
.content-panel .exception-item,
.content-panel .branch-card {
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
}

.content-panel .rule-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.content-panel .rule-card.must {
    border-left: 3px solid var(--green);
}

.content-panel .rule-card.must-not {
    border-left: 3px solid var(--red);
}

.content-panel .rule-card.affiliate {
    border-left: 3px solid var(--yellow);
}

.content-panel .exception-item {
    border-left: 3px solid var(--orange);
    border-radius: 0 8px 8px 0;
}

.content-panel .rule-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.content-panel .rule-title,
.content-panel .sw-title,
.content-panel .branch-name {
    font-weight: 600;
    color: #fff;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.content-panel .rule-card p,
.content-panel .sw-card p,
.content-panel .branch-desc {
    margin: 0;
    font-size: 0.84rem;
    color: var(--muted);
    line-height: 1.5;
}

.content-panel .sw-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.content-panel .sw-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.content-panel .badge-foss {
    background: var(--green);
    color: #000;
}

.content-panel .badge-oss {
    background: var(--yellow);
    color: #000;
}

.content-panel .badge-npaase {
    background: var(--orange);
    color: #000;
}

.content-panel .badge-third {
    background: #555;
    color: #fff;
}

.content-panel .branch-email {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.74rem;
    color: var(--accent-soft);
    word-break: break-all;
}

.logo-trigger {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
}

.mobile-help-banner {
    display: none;
    height: calc(fit-content - 5pt);
    background: #111111;
    color: var(--muted);
    text-align: center;
    padding: 5px 9px;
    border-bottom: 1pt solid var(--border);
    font-size: 10pt;
}

body.mobile-phone .logo-trigger {
    display: flex;
    align-items: center;
}

/* Make the logo area easier to tap on small screens */
body.mobile-phone .site-header {
    padding: 10px 16px;
}
body.mobile-phone .site-header .title {
    font-size: 1.05rem;
}

body.mobile-phone .mobile-help-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

body.mobile-phone .layout {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

body.mobile-phone .sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 950;
    width: 100%;
    height: 100%;
    max-height: none;
    border-right: none;
    border-bottom: none;
    background: rgba(13, 13, 13, 0.99);
    padding: 16px 0 32px;
    overflow-y: auto;
}

body.mobile-phone.mobile-browser-open .sidebar {
    display: block;
}

body.mobile-phone .content-panel {
    padding: 24px 18px 80px;
}

body.mobile-phone .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px 14px;
    border-bottom: 1px solid var(--border);
}

body.mobile-phone .mobile-browser-button,
body.mobile-phone .mobile-sidebar-close {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--page-text);
    border-radius: 22px;
    padding: 8px 12px;
    font-size: 9pt;
    cursor: pointer;
}

body.mobile-phone .mobile-browser-button:hover,
body.mobile-phone .mobile-sidebar-close:hover {
    background: rgba(255,255,255,0.04);
    border-color: var(--accent);
}

body.mobile-phone .mobile-sidebar-close {
    min-width: 36px;
    padding: 8px;
    line-height: 1;
}

body.mobile-phone.mobile-browser-open .content-panel {
    overflow-y: visible;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-backdrop.hidden {
    display: none;
}

.share-modal {
    width: min(520px, 100%);
    aspect-ratio: 1 / 1;
    background: #0f0f0f;
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    color: var(--page-text);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: relative;
    overflow: hidden;
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.share-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--page-text);
    font-size: 1.4rem;
    cursor: pointer;
}

.share-preview-label {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.share-preview-box {
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    min-height: 120px;
    max-height: 220px;
    color: #d9d9d9;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.share-link-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

.share-link-text {
    background: #111;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    overflow-wrap: anywhere;
    cursor: pointer;
    user-select: all;
    min-height: 48px;
    display: flex;
    align-items: center;
}

.share-link-text:hover {
    border-color: var(--accent);
}

.share-link-copy {
    padding: 12px 16px;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: #000;
    font-weight: 700;
    cursor: pointer;
}

.share-note {
    color: var(--muted);
    font-size: 0.82rem;
}

.quote-highlight {
    background: rgba(226, 6, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(226, 6, 255, 0.2);
    border-radius: 4px;
}

.highlighted-section {
    background: rgba(226, 6, 255, 0.1);
    border-left: 3px solid var(--accent);
    padding-left: 14px;
    transition: background 0.2s ease-in-out;
}

/* ── Empty state ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted);
    font-size: 0.9rem;
    gap: 8px;
}

.empty-state .icon {
    font-size: 2rem;
}

.legal-docs-header {
    color: rgba(117, 182, 208, 0.579);
    border-top: solid 3pt;
    border-radius: 2px;
    border-color: rgba(78, 11, 161, 0.496);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14pt;
}

/* ── Scrollbar styling ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #2a2a2a;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a3a3a;
}

@media (max-width: 860px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 240px;
    }

    .content-panel {
        padding: 24px 20px 60px;
    }

    .content-panel .branch-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Animations ── */
@keyframes slideInSidebarFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutSidebarToLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

@keyframes slideUpContent {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInCardFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes popBounce {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes slideInBounceQuote {
    0% {
        transform: translateX(100%) scale(0.8);
        opacity: 0;
    }
    60% {
        transform: translateX(-10px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* Animation application classes */
body.mobile-phone.mobile-browser-open .sidebar {
    animation: slideInSidebarFromLeft 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.mobile-phone:not(.mobile-browser-open) .sidebar.closing {
    animation: slideOutSidebarToLeft 0.54s ease-in forwards;
}

.doc-section.visible {
    animation: slideUpContent 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rule-card,
.sw-card,
.exception-item,
.branch-card,
.callout {
    animation: slideInCardFromRight 0.68s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.rule-card:nth-child(1) { animation-delay: 0.1s; }
.rule-card:nth-child(2) { animation-delay: 0.2s; }
.rule-card:nth-child(3) { animation-delay: 0.3s; }
.rule-card:nth-child(4) { animation-delay: 0.4s; }

.sw-card:nth-child(1) { animation-delay: 0.1s; }
.sw-card:nth-child(2) { animation-delay: 0.2s; }
.sw-card:nth-child(3) { animation-delay: 0.3s; }
.sw-card:nth-child(4) { animation-delay: 0.4s; }

.callout:nth-child(1) { animation-delay: 0.1s; }
.callout:nth-child(2) { animation-delay: 0.2s; }
.callout:nth-child(3) { animation-delay: 0.3s; }

.branch-card:nth-child(1) { animation-delay: 0.1s; }
.branch-card:nth-child(2) { animation-delay: 0.2s; }
.branch-card:nth-child(3) { animation-delay: 0.3s; }
.branch-card:nth-child(4) { animation-delay: 0.4s; }
.branch-card:nth-child(5) { animation-delay: 0.5s; }
.branch-card:nth-child(6) { animation-delay: 0.6s; }

body.mobile-phone .logo-trigger:active {
    animation: popBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quote-highlight {
    animation: slideInBounceQuote 0.58s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: rgba(226, 6, 255, 0.25);
}

/* Section numbers clickable styling */
.doc-header h2 .section-tag,
section[id] > h2 > .section-tag {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    padding: 4px 10px;
    border-radius: 12px;
}

.doc-header h2 .section-tag:hover,
section[id] > h2 > .section-tag:hover {
    background: var(--accent-soft);
    color: #000;
    transform: scale(1.08);
}

.doc-header h2 .section-tag:active,
section[id] > h2 > .section-tag:active {
    transform: scale(0.89);
}

/* Quote copy notification */
.quote-copy-notification {
    position: fixed;
    top: 80%;
    bottom: 20px;
    right: 20px;
    background: var(--accent);
    color: #000;
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 600;
    z-index: 1001;
    animation: slideInBounceQuote 0.49s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quote-copy-notification.hide {
    animation: slideOutSidebarToLeft 0.3s ease-in forwards;
}

body.mobile-phone .quote-copy-notification {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    right: 10px;
    font-size: 0.9rem;
    padding: 10px 16px;
}