:root {
    --brand: #00af9e;
    --brand-strong: #00af9e;
    --brand-tint: #e0f4f1;
    --on-brand: #ffffff;
    --bg: #fff;
    --surface: #ffffff;
    --surface-2: #eef3f2;
    --border: #dde5e3;
    --border-strong: #c7d2cf;
    --text: #16211f;
    --muted: #56625f;
    --warn: #9a4b00;
    --shadow: 0 1px 2px rgba(22, 33, 31, 0.04), 0 8px 24px rgba(22, 33, 31, 0.05);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
    --mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --radius: 14px;
}

/* @media (prefers-color-scheme: dark) {
    :root {
        --brand: #00af9e;
        --brand-strong: #3fd0bf;
        --brand-tint: #123330;
        --on-brand: #04201c;
        --bg: #fff;
        --surface: #151f1d;
        --surface-2: #1c2826;
        --border: #263533;
        --border-strong: #344643;
        --text: #e5eeec;
        --muted: #9aaba7;
        --warn: #f0a35e;
        --shadow: none;
    }
} */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-strong); }
a:hover { color: var(--text); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

button { font: inherit; color: inherit; cursor: pointer; }

kbd {
    font-family: var(--mono);
    font-size: 0.85em;
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

[hidden] { display: none !important; }

/* Header & footer */

.site-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 40px 0;
}

.site-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.site-header p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.site-footer {
    padding: 12px 40px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

/* Layout */

/* Index of the HRA on the left; search with the chosen link below it on the right.
   The search bar stays in the same place: typing only filters the index. */
.workbench {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
        "index search"
        "index detail";
    gap: 16px 24px;
    padding: 24px 40px 8px;
}

.search-area {
    grid-area: search;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.index-pane, .detail-pane {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.index-pane { grid-area: index; }

.detail-pane {
    grid-area: detail;
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.field-label span { font-weight: 400; }

/* Search */

.search-field {
    position: relative;
    color: var(--muted);
}

.search-field svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.search-field input {
    width: 100%;
    height: 56px;
    padding: 0 16px 0 46px;
    font: inherit;
    font-size: 17px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.search-field input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}

.results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.result-group + .result-group { margin-top: 8px; }

.group-title {
    padding: 10px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.result {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    text-align: left;
}

.result:hover { background: var(--surface-2); }

.result.is-active {
    background: var(--brand-tint);
    font-weight: 600;
}

.result-code {
    flex-shrink: 0;
    min-width: 56px;
    padding-top: 1px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.result.is-active .result-code { color: var(--brand-strong); }

.result-title { font-size: 14px; }

.no-results {
    padding: 32px 16px;
    text-align: center;
    color: var(--muted);
}

/* Empty state */

.empty-state { padding: 28px; }

.empty-state h2 {
    margin: 0 0 8px;
    font-size: 22px;
}

.empty-state p {
    margin: 0 0 16px;
    max-width: 75ch;
    color: var(--muted);
}

.empty-state ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 10px;
    color: var(--muted);
}

/* Link card */

.link-card {
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.link-heading {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.eyebrow {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-strong);
}

.eyebrow:empty { display: none; }

.link-heading h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.url-box {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--mono);
    font-size: 15px;
    color: var(--text);
    text-align: left;
    cursor: copy;
}

.url-box:hover { border-color: var(--border-strong); }

.url-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.url-base { color: var(--muted); }

.url-para {
    color: var(--brand-strong);
    font-weight: 600;
}

/* Quiet affordance: only shows on hover/focus, or to confirm a copy */
.url-hint {
    flex-shrink: 0;
    font-family: var(--font);
    font-size: 12px;
    color: var(--muted);
    opacity: 0;
    transition: opacity 0.15s;
}

.url-box:hover .url-hint,
.url-box:focus-visible .url-hint { opacity: 1; }

.url-box.is-copied .url-hint {
    opacity: 1;
    color: var(--brand-strong);
    font-weight: 600;
}

.link-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn {
    height: 48px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    border: 1px solid var(--brand-strong);
    background: var(--brand-strong);
    color: var(--on-brand);
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-outline {
    border: 1px solid var(--brand-strong);
    background: var(--surface);
    color: var(--brand-strong);
}

.btn-outline:hover {
    background: var(--brand-tint);
    color: var(--brand-strong);
}

.btn-secondary {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    font-size: 13px;
}

.btn-text {
    padding: 6px 0;
    border: 0;
    background: none;
    font-weight: 600;
    color: var(--brand-strong);
}

.link-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    font-size: 14px;
}

/* Paragraph TOC */

.toc-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
}

.toc-toolbar input {
    width: 200px;
    height: 40px;
    padding: 0 12px;
    font-family: var(--mono);
    font-size: 15px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
}

.toc-toolbar input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}

.warn {
    font-size: 13px;
    color: var(--warn);
}

.toolbar-hint {
    margin-left: auto;
    font-size: 13px;
    color: var(--muted);
}

.toc {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 28px 28px;
}

.toc-message {
    padding: 24px 0;
    color: var(--muted);
}

.toc-node {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toc > .toc-node { padding-top: 16px; }

.toc-children {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0 6px 14px;
    border-left: 1px solid var(--border);
    margin-left: 2px;
}

.toc-head {
    align-self: flex-start;
    margin-left: -10px;
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.toc-children .toc-head { margin-left: 0; }

.toc > .toc-node > .toc-head {
    font-size: 17px;
    font-weight: 700;
}

.toc-head:hover { background: var(--surface-2); }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    min-width: 44px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-family: var(--mono);
    font-size: 13px;
}

.chip:hover { border-color: var(--brand); }

.toc-head.is-active, .chip.is-active {
    background: var(--brand-strong);
    border-color: var(--brand-strong);
    color: var(--on-brand);
    font-weight: 600;
}

/* Small screens: stack the panes and let the page scroll */

@media (max-width: 860px) {
    html, body { height: auto; }

    .site-header { padding: 20px 16px 0; }
    .site-footer { padding: 12px 16px 16px; }

    .workbench {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas:
            "search"
            "index"
            "detail";
        padding: 20px 16px 8px;
    }

    .results { max-height: 50vh; }

    .link-card { padding: 20px; }

    .toc-toolbar { padding: 14px 20px; }
    .toc-toolbar input { flex: 1; width: auto; min-width: 120px; }
    .toolbar-hint { display: none; }
    .toc { padding: 8px 20px 20px; }
}

/* Clickable examples in the welcome card */

.example {
    height: 30px;
    margin-right: 8px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-family: var(--mono);
    font-size: 13px;
}

.example:hover { border-color: var(--brand); }
