:root {
    color-scheme: light;
    --ink: #17212b;
    --muted: #657386;
    --line: #d9e1ea;
    --surface: #ffffff;
    --surface-soft: #f5f8fb;
    --teal: #0f766e;
    --teal-dark: #0b4f4a;
    --gold: #b7791f;
    --rose: #9f1239;
    --shadow: 0 18px 45px rgba(23, 33, 43, 0.13);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34%),
        linear-gradient(315deg, rgba(183, 121, 31, 0.08), transparent 30%),
        var(--surface-soft);
    color: var(--ink);
    font-family: "Cairo", "Inter", Arial, sans-serif;
    font-size: 18px;
    letter-spacing: 0;
}

body.with-site-nav {
    background:
        linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)),
        url("../assets/images/hero-bg.jpg") no-repeat center center fixed;
    background-size: cover;
    font-family: "Cairo", "Inter", Arial, sans-serif;
}

.with-site-nav {
    padding-top: 92px;
}

.with-site-nav #main-nav.nav-transparent {
    background: rgba(30, 58, 138, 0.95);
    backdrop-filter: blur(10px);
}

.with-site-nav #main-nav {
    direction: ltr;
    text-align: left;
}

.with-site-nav #main-nav > .container > .flex {
    flex-direction: row;
}

.with-site-nav #main-nav .dropdown-menu {
    left: 0;
    right: auto;
    direction: ltr;
    text-align: left;
}

.with-site-nav #mobile-menu {
    direction: ltr;
    text-align: left;
}

.with-site-nav .law-layout {
    direction: rtl;
    margin-top: 18px;
}

.reader-protected,
.reader-protected *:not(input):not(select):not(textarea) {
    -webkit-user-select: none;
    user-select: none;
}

img {
    max-width: 100%;
}

button,
input,
select {
    font: inherit;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(15, 118, 110, 0.2);
    color: var(--teal-dark);
    background: #fff;
    text-decoration: none;
    transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.icon-button:hover {
    background: rgba(15, 118, 110, 0.08);
    transform: translateY(-1px);
}

.law-layout {
    display: grid;
    grid-template-columns: minmax(290px, 330px) minmax(0, 1fr);
    gap: clamp(18px, 2.4vw, 30px);
    width: min(1760px, calc(100% - 12px));
    margin: 12px auto 52px;
    align-items: start;
}

.toc-panel {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow: auto;
    padding: 22px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.toc-head {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.eyebrow,
.toolbar-kicker {
    display: block;
    color: var(--gold);
    font-family: "Inter", Arial, sans-serif;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.toc-head h1 {
    margin: 6px 0 4px;
    color: var(--ink);
    font-size: clamp(1.55rem, 2.8vw, 2.1rem);
    line-height: 1.2;
}

.toc-head p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.control-label {
    display: block;
    margin: 18px 0 8px;
    color: var(--teal-dark);
    font-size: 1rem;
    font-weight: 800;
}

.section-select,
.search-input-wrap {
    width: 100%;
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.section-select {
    padding: 0 12px;
    color: var(--ink);
    cursor: pointer;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
}

.search-input-wrap i {
    color: var(--teal);
    font-size: 0.92rem;
}

.search-input-wrap input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
}

.search-status {
    min-height: 24px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.86rem;
}

.search-results,
.toc-list {
    display: grid;
    gap: 8px;
}

.search-results {
    margin-top: 4px;
}

.toc-list {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.toc-item,
.search-result {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 11px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    text-align: right;
    cursor: pointer;
}

.toc-item:hover,
.toc-item.is-active,
.search-result:hover {
    border-color: rgba(15, 118, 110, 0.24);
    background: rgba(15, 118, 110, 0.08);
}

.toc-item strong,
.search-result strong {
    font-size: 1.08rem;
    line-height: 1.45;
}

.toc-item span,
.search-result span,
.search-result small {
    color: var(--muted);
    font-size: 0.92rem;
}

.reader-column {
    min-width: 0;
}

.reader-toolbar {
    position: sticky;
    top: 12px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 34px rgba(23, 33, 43, 0.08);
    backdrop-filter: blur(18px);
}

.reader-toolbar h2 {
    margin: 4px 0 0;
    font-size: clamp(1.22rem, 2vw, 1.65rem);
    line-height: 1.35;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    direction: ltr;
}

.icon-button {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    cursor: pointer;
}

.page-progress {
    position: sticky;
    top: 94px;
    z-index: 19;
    height: 4px;
    margin: -1px 8px 18px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(23, 33, 43, 0.08);
}

#page-progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--teal), var(--gold));
    transition: width 120ms ease;
}

.page-rail {
    display: grid;
    gap: 22px;
}

.reader-loading {
    display: grid;
    min-height: 360px;
    place-items: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.law-page {
    position: relative;
    width: min(100%, 1180px);
    margin: 0 auto;
    padding: clamp(10px, 1.8vw, 16px);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.law-page img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
    pointer-events: none;
    -webkit-user-drag: none;
}

.page-number {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-grid;
    min-width: 38px;
    height: 32px;
    place-items: center;
    border: 1px solid rgba(15, 118, 110, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--teal-dark);
    font-family: "Inter", Arial, sans-serif;
    font-size: 0.98rem;
    font-weight: 800;
}

.return-chip {
    position: absolute;
    left: clamp(16px, 2.5vw, 28px);
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid rgba(159, 18, 57, 0.24);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--rose);
    font-size: 0.94rem;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(23, 33, 43, 0.12);
    cursor: pointer;
}

.return-chip:hover {
    background: #fff4f6;
}

mark {
    border-radius: 4px;
    background: rgba(183, 121, 31, 0.24);
    color: inherit;
}

@media (max-width: 980px) {
    .law-layout {
        grid-template-columns: 1fr;
        width: min(100% - 20px, 820px);
        margin-top: 14px;
    }

    .toc-panel,
    .reader-toolbar {
        position: static;
    }

    .toc-panel {
        max-height: none;
    }

    .page-progress {
        top: 0;
        margin-top: 14px;
    }
}

@media (max-width: 620px) {
    .with-site-nav {
        padding-top: 82px;
    }

    .reader-toolbar {
        align-items: flex-start;
        padding: 14px;
    }

    .toc-panel {
        padding: 16px;
    }

    .law-page {
        padding: 8px;
    }

    .return-chip {
        left: 14px;
        min-height: 30px;
        font-size: 0.76rem;
    }
}
