:root {
    --brand-primary: #221d57;
    --brand-accent: #30bcb7;
    --ink: #14142b;
    --ink-soft: #5a5a72;
    --line: #e3e3ee;
    --surface: #ffffff;
    --surface-alt: #f6f7fb;
    --success-bg: #e8f8f4;
    --success-ink: #0f6b5c;
    --error-bg: #fdecec;
    --error-ink: #a11b1b;
    --radius: 12px;
    --header-h: 64px;
    --search-h: 168px;
    --shadow: 0 1px 2px rgba(20, 20, 43, .06), 0 8px 24px rgba(20, 20, 43, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--surface-alt);
    line-height: 1.55;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Header */
.site-header {
    background: var(--brand-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}
.header-inner { display: flex; align-items: center; gap: 28px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 18px; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center;
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--brand-accent); color: var(--brand-primary);
    font-weight: 800;
}
.brand-mark.small { width: 28px; height: 28px; font-size: 14px; }
.main-nav { display: flex; gap: 20px; flex: 1; flex-wrap: wrap; }
.main-nav a { color: rgba(255,255,255,.86); font-size: 14px; }
.main-nav a:hover { color: #fff; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.inline-form { display: inline; }
.nav-pill { color: rgba(255,255,255,.9); font-size: 14px; }
.avatar {
    display: grid; place-items: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,.16); color: #fff;
    font-size: 12px; font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
    font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand-accent); color: #10233a; }
.btn-primary:hover { background: #26a9a4; }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--brand-primary); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: #fff; border-color: #e8bcbc; color: #a11b1b; }

/* Layout blocks */
.page { padding: 28px 0 56px; }
.panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 20px; }
.panel h1 { margin-top: 0; font-size: 26px; }
.panel h2 { font-size: 19px; margin: 0 0 14px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.search-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }

@media (max-width: 900px) {
    .grid-2, .grid-3, .search-layout { grid-template-columns: 1fr; }
    .main-nav { display: none; }
}

/* Hero */
.hero {
    background: linear-gradient(135deg, var(--brand-primary), #3a3390);
    color: #fff; border-radius: 16px; padding: 44px 36px; margin-bottom: 24px;
}
.hero h1 { font-size: 34px; margin: 0 0 10px; max-width: 760px; }
.hero p { color: rgba(255,255,255,.82); max-width: 640px; margin: 0 0 22px; }
.hero-search { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-search input[type=text] {
    flex: 1; min-width: 280px; padding: 13px 16px; border-radius: 10px;
    border: none; font-size: 15px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
    background: rgba(255,255,255,.14); color: #fff; border-radius: 999px;
    padding: 6px 13px; font-size: 13px;
}
.chip:hover { background: rgba(255,255,255,.24); text-decoration: none; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat strong { display: block; font-size: 26px; color: var(--brand-primary); }
.stat span { font-size: 13px; color: var(--ink-soft); }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* Cards */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card h3 a { color: var(--ink); }
.meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--ink-soft); margin: 8px 0; }
.tag {
    display: inline-block; background: var(--surface-alt); border: 1px solid var(--line);
    border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--ink-soft); margin: 2px 4px 2px 0;
}
.tag-accent { background: var(--success-bg); border-color: #c9ece5; color: var(--success-ink); }
.badge-verified { background: var(--success-bg); color: var(--success-ink); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.score {
    text-align: right; font-size: 12px; color: var(--ink-soft); white-space: nowrap;
}
.score strong { display: block; font-size: 18px; color: var(--brand-primary); }
.reasons { font-size: 12px; color: var(--ink-soft); margin-top: 8px; }

/* Forms */
.form-row { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 9px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-accent); outline-offset: 1px; border-color: transparent; }
input[type=file] {
    width: 100%; padding: 9px 12px; border: 1px dashed var(--line);
    border-radius: 9px; font-size: 14px; font-family: inherit; background: var(--surface-alt);
}
input[type=file]::file-selector-button {
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    border-radius: 7px; padding: 6px 12px; margin-right: 12px;
    font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--brand-primary); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row label { margin: 0; font-weight: 500; }
.field-error { color: #a11b1b; font-size: 12px; display: block; margin-top: 4px; }
.validation-summary ul { margin: 0; padding-left: 18px; }

/* Skills picker */
.skill-picker { border: 1px solid var(--line); border-radius: var(--radius); max-height: 320px; overflow-y: auto; padding: 12px; background: #fff; }
.skill-group { margin-bottom: 14px; }
.skill-group h4 { margin: 0 0 8px; font-size: 13px; color: var(--brand-primary); text-transform: uppercase; letter-spacing: .04em; }
.skill-options { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-options label {
    display: inline-flex; align-items: center; gap: 6px; font-weight: 500;
    border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
    font-size: 13px; cursor: pointer; margin: 0;
}
.skill-options input { accent-color: var(--brand-primary); }

/* Sticky search bar - stays visible under the header while the results scroll */
.search-sticky {
    position: sticky;
    top: 64px;
    z-index: 12;
    margin-bottom: 16px;
    padding: 12px 20px 10px;
    box-shadow: 0 1px 2px rgba(20, 20, 43, .06), 0 10px 20px -12px rgba(20, 20, 43, .28);
}
.search-sticky .form-row { margin-bottom: 6px; }
.search-sticky label { margin-bottom: 4px; }
.search-sticky .chips { max-height: 34px; overflow-y: auto; margin-top: 2px; }

/* Filters - pinned under the header and the search bar, with its own scroll area */
.filters {
    align-self: start;
    position: sticky;
    top: calc(var(--header-h) + var(--search-h) + 10px);
    max-height: calc(100vh - var(--header-h) - var(--search-h) - 18px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #c7c7d6 transparent;
    padding-bottom: 0;
}
.filters::-webkit-scrollbar { width: 10px; }
.filters::-webkit-scrollbar-track { background: transparent; }
.filters::-webkit-scrollbar-thumb {
    background: #c7c7d6; border-radius: 999px;
    border: 3px solid var(--surface);
}
.filters::-webkit-scrollbar-thumb:hover { background: #aeaec4; }

/* Keep the Search button reachable without scrolling back down. */
.filters-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 12px 0 16px;
    margin-top: 6px;
    border-top: 1px solid var(--line);
}

/* Declared after the rules above so it actually overrides them. */
@media (max-width: 900px) {
    .search-sticky { position: static; }
    .filters { position: static; max-height: none; overflow: visible; }
    .filters-actions { position: static; }
}

.filters .form-row { margin-bottom: 13px; }
.filters h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }

/* One scrollbar per panel: the facet lists flow, the panel scrolls. */
.facet-list { list-style: none; padding: 0; margin: 0; }
.facet-list li { margin-bottom: 5px; font-size: 13px; }
.facet-list label { display: flex; align-items: center; gap: 7px; font-weight: 500; margin: 0; }
.facet-count { margin-left: auto; color: var(--ink-soft); font-size: 12px; }

/* Interpretation */
.interpretations { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
.interpretation {
    background: #eef2ff; border: 1px solid #d7ddff; color: #2f3a8f;
    border-radius: 999px; padding: 3px 11px; font-size: 12px;
}
button.example-chip {
    font-family: inherit; cursor: pointer; line-height: inherit;
}
button.example-chip:hover { border-color: var(--brand-primary); color: var(--ink); }
a.filter-chip { text-decoration: none; }
a.filter-chip:hover { background: #dde4ff; text-decoration: none; }
a.filter-chip span { margin-left: 4px; font-weight: 700; }
a.clear-all { background: #fff; border-color: var(--line); color: var(--ink-soft); }

/* Alerts */
.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: var(--success-bg); color: var(--success-ink); border: 1px solid #bfe7de; }
.alert-error { background: var(--error-bg); color: var(--error-ink); border: 1px solid #f2c9c9; }

/* Messaging */
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.bubble { max-width: 72%; padding: 12px 15px; border-radius: 14px; font-size: 14px; }
.bubble .bubble-meta { font-size: 11px; color: var(--ink-soft); margin-top: 6px; }
.bubble.incoming { background: var(--surface-alt); border: 1px solid var(--line); align-self: flex-start; }
.bubble.outgoing { background: var(--brand-primary); color: #fff; align-self: flex-end; }
.bubble.outgoing .bubble-meta { color: rgba(255,255,255,.7); }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
    border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
    font-size: 13px; background: #fff;
}
.pagination .current { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }

/* Footer */
.site-footer { background: var(--brand-primary); color: rgba(255,255,255,.82); margin-top: 40px; }
.footer-inner { display: flex; justify-content: space-between; gap: 30px; padding: 34px 0; flex-wrap: wrap; }
.footer-brand { display: flex; gap: 12px; align-items: flex-start; color: #fff; max-width: 360px; }
.footer-brand p { margin: 4px 0 0; font-size: 13px; color: rgba(255,255,255,.7); }
.footer-links { display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.footer-links a { color: rgba(255,255,255,.82); }
.footer-links a:hover { color: #fff; }
.footer-credit {
    border-top: 1px solid rgba(255,255,255,.14);
    padding: 14px 0; font-size: 13px; color: rgba(255,255,255,.72); text-align: center;
}
