:root {
    --ink: #1c2420;
    --muted: #5b6b63;
    --line: #d5ddd8;
    --paper: #f7f5ef;
    --card: #fff;
    --accent: #1f6f4a;
    --mark: #ffe08a;
    --font: "Segoe UI", "Helvetica Neue", sans-serif;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--ink);
    background: var(--paper);
}

.leg-top {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.leg-home { line-height: 0; }
.leg-home img { border-radius: 50%; }

.leg-brand { flex: 1; min-width: 0; }
.leg-brand p {
    margin: 0;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}
.leg-brand h1 {
    margin: 0.1rem 0 0;
    font-size: 1.15rem;
    font-weight: 650;
}
.leg-brand h1 span {
    font-weight: 500;
    color: var(--muted);
    font-size: 0.95rem;
}

.leg-switch {
    display: flex;
    gap: 0.35rem;
}
.leg-switch a {
    text-decoration: none;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}
.leg-switch a.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.leg-wrap {
    width: min(820px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.leg-search label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
}
.leg-search-row {
    display: flex;
    gap: 0.5rem;
}
.leg-search-row input {
    flex: 1;
    font: inherit;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}
.leg-search-row button {
    font: inherit;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 0.7rem 1.1rem;
    cursor: pointer;
}
.leg-hint, .leg-syn, .leg-meta, .leg-part, .leg-current, .leg-crumb {
    color: var(--muted);
    font-size: 0.92rem;
}
.leg-hint { margin-top: 0.45rem; }
.leg-hint mark, .leg-syn mark, .leg-hits strong mark {
    background: var(--mark);
    padding: 0 0.15em;
    border-radius: 2px;
}
.leg-hint a, .leg-syn a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.12em;
}
.leg-hint a:hover, .leg-syn a:hover { text-decoration: none; }
.leg-h { font-size: 1.05rem; margin: 2rem 0 0.75rem; }
.leg-empty { color: var(--muted); }

.leg-hits, .leg-docs { list-style: none; padding: 0; margin: 0; }
.leg-hits li, .leg-docs li {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.65rem;
}
.leg-hits a, .leg-docs a, .leg-crumb a, .leg-meta a, .leg-pager a, .leg-toc-row {
    color: var(--accent);
    text-decoration: none;
}
.leg-hits a:hover, .leg-docs a:hover, .leg-toc-row:hover { text-decoration: underline; }
.leg-hit-title { margin: 0 0 0.15rem; line-height: 1.35; }
.leg-cite {
    display: inline;
    font-size: 0.8rem;
    font-weight: 500;
    margin-right: 0.4rem;
}
.leg-hit-heading { font-weight: 650; }
.leg-snip { margin: 0.4rem 0 0; line-height: 1.45; }
.leg-snip mark, .leg-hit-heading mark { background: var(--mark); padding: 0 0.1em; }
.leg-snip a, .leg-hit-heading a {
    color: var(--leg-green-dark, #1a5c3a);
    text-decoration: underline;
    font-weight: 500;
}
.leg-snip a:hover, .leg-hit-heading a:hover { text-decoration: none; }
.leg-kind {
    display: inline-block;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    background: #e7f3ec;
    color: var(--accent);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    margin-right: 0.35rem;
}

.leg-doc-title, .leg-section-title { margin: 0.2rem 0 0.4rem; line-height: 1.25; }
.leg-section-title .leg-num {
    color: var(--accent);
    margin-right: 0.35rem;
}

.leg-filter { display: grid; gap: 0.35rem; margin: 1.25rem 0 0.75rem; font-weight: 600; }
.leg-filter input {
    font: inherit;
    font-weight: 400;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.leg-toc { display: grid; gap: 0.15rem; }
.leg-toc-part {
    margin: 1rem 0 0.25rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.leg-toc-row {
    display: grid;
    grid-template-columns: 3.5rem 1fr;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    color: var(--ink);
}
.leg-toc-row:hover { background: #fff; text-decoration: none; }
.leg-num { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 650; }

.leg-body {
    font-family: var(--serif);
    font-size: 1.08rem;
    line-height: 1.6;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.25rem 1.35rem;
}
.leg-body a { color: var(--accent); }

.leg-pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.25rem;
    font-size: 0.92rem;
}

.leg-foot {
    width: min(820px, calc(100% - 2rem));
    margin: 0 auto 2rem;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
}
.leg-foot a { color: var(--accent); }

.leg-ref { cursor: pointer; }

body.leg-modal-open { overflow: hidden; }

.leg-modal[hidden] { display: none; }

.leg-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.leg-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 28, 24, 0.45);
}

.leg-modal-card {
    position: relative;
    width: min(760px, 100%);
    max-height: min(88vh, 900px);
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--line);
    box-shadow: 0 18px 50px rgba(20, 28, 24, 0.22);
    padding: 1.35rem 1.4rem 1.2rem;
}

.leg-modal-close {
    position: absolute;
    top: 0.55rem;
    right: 0.65rem;
    border: 0;
    background: transparent;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}

.leg-modal-kicker {
    margin: 0 0 0.2rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.leg-modal-title {
    margin: 0 2rem 0.35rem 0;
    font-size: 1.2rem;
    line-height: 1.3;
}

.leg-modal-meta {
    margin: 0 0 0.85rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.leg-modal-body {
    font-family: var(--serif);
    font-size: 1.05rem;
    line-height: 1.6;
}

.leg-modal-body a { color: var(--accent); }

.leg-modal-actions {
    display: flex;
    gap: 1rem;
    margin: 1rem 0 0;
    font-size: 0.9rem;
}

.leg-modal-actions a { color: var(--accent); }

.leg-report-launch { margin: 1rem 0 0; }
.leg-report-btn {
    font: inherit;
    font-size: 0.88rem;
    color: var(--accent);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 0.12em;
}
.leg-report-btn:hover { text-decoration: none; }
.leg-modal-actions .leg-report-btn { margin-left: auto; }

.leg-report-form { display: grid; gap: 0.75rem; }
.leg-report-form label {
    display: grid;
    gap: 0.3rem;
    font-weight: 600;
    font-size: 0.92rem;
}
.leg-report-form input,
.leg-report-form select,
.leg-report-form textarea {
    font: inherit;
    font-weight: 400;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    width: 100%;
}
.leg-optional { font-weight: 400; color: var(--muted); }
.leg-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}
.leg-report-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.leg-report-actions button[type="submit"] {
    font: inherit;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 0.6rem 1rem;
    cursor: pointer;
}
.leg-report-cancel {
    font: inherit;
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
}

@media (max-width: 640px) {
    .leg-top { flex-wrap: wrap; }
    .leg-search-row { flex-direction: column; }
    .leg-brand h1 span { display: block; }
}
