/* ---------------------------------------------------------------------------
   Tokens
   --------------------------------------------------------------------------- */
:root {
    color-scheme: light;
    --bg: #FCF9FA;
    --surface: #ffffff;
    --surface-sunken: #F4EAEE;
    --surface-raised: #ffffff;
    --border: #dde3ea;
    --border-strong: #c3ccd7;
    --ink: #171b21;
    --ink-soft: #454d59;
    --ink-muted: #6e7681;
    --accent: #891843;
    --accent-soft: #F4EAEE;
    --accent-ink: #320918;
    --good: #1a6b45;
    --good-soft: #e3f3ea;
    --info: #1c5f96;
    --info-soft: #e6f0f9;
    --warn: #f0c36d;
    --warn-soft: #fff8e1;
    --critical: #9a2f2f;
    --critical-soft: #fbe9e9;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px -12px rgba(16, 24, 40, .25);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #0f1216;
        --surface: #171b21;
        --surface-sunken: #12161b;
        --surface-raised: #1c222a;
        --border: #2a313a;
        --border-strong: #3a434e;
        --ink: #dddddd;
        --ink-soft: #dddddd;
        --ink-muted: #dddddd;
        --accent: #891843;
        --accent-soft: #891843;
        --accent-ink: #dddddd;
        --good: #6dd39b;
        --good-soft: #12291d;
        --info: #82b9e8;
        --info-soft: #14242f;
        --warn: #e0b263;
        --warn-soft: #2b2113;
        --critical: #ef8a8a;
        --critical-soft: #2e1717;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -14px rgba(0, 0, 0, .8);
    }
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
}

h1, h2, h3, h4 {
    margin: 0;
    line-height: 1.25;
    letter-spacing: -.01em;
}

/*
   FocusOnNavigate moves focus to the page's h1 after each navigation so assistive
   technology announces the new page. The heading is given tabindex="-1", so it can only
   be focused programmatically — never by tabbing — and hiding the ring costs no one
   a focus indicator.
*/
h1:focus,
h1:focus-visible {
    outline: none;
}

p {
    margin: 0;
}

a {
    color: var(--accent);
}

img {
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

.boot {
    display: grid;
    place-items: center;
    gap: 16px;
    min-height: 100vh;
    color: #6e7681;
    font-family: system-ui, sans-serif;
}

.boot-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #dde3ea;
    border-top-color: #154a87;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .boot-spinner { animation-duration: 3s; }
}

/* ---------------------------------------------------------------------------
   Shell
   --------------------------------------------------------------------------- */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    align-items: center;
    justify-content: space-between;
    padding: 12px max(16px, calc((100% - 1120px) / 2));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.brand-mark img {    
    display: block;
}

@media (prefers-color-scheme: dark) {
    .brand-mark {
        background-color: #fff;        
        border-radius: 10px;
        padding: 5px;
    }
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 14px;
}

.brand-text small {
    color: var(--ink-muted);
    font-size: 11.5px;
}

.app-nav {
    display: flex;
    gap: 4px;
}

.app-nav a {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
}

.app-nav a:hover {
    background: var(--surface-sunken);
    color: var(--ink);
}

.app-nav a.active {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 16px 56px;
}

.app-footer {
    padding: 18px max(16px, calc((100% - 1120px) / 2));
    border-top: 1px solid var(--border);
    color: var(--ink-muted);
    font-size: 12.5px;
}

/* ---------------------------------------------------------------------------
   Buttons and controls
   --------------------------------------------------------------------------- */

    .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover:not(:disabled) {
    background: var(--surface-sunken);
}

.button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.button.primary {
    border-color: transparent;
    background: var(--accent);
    color: #fff;
}

.button.primary:hover:not(:disabled) {
    background: var(--accent);
    filter: brightness(1.08);
}

.button.danger {
    border-color: transparent;
    background: transparent;
    color: var(--critical);
}

.button.danger:hover:not(:disabled) {
    background: var(--critical-soft);
}

.button.small {
    padding: 5px 10px;
    font-size: 12.5px;
}

input[type="text"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
}

textarea {
    min-height: 70px;
    resize: vertical;
    line-height: 1.5;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field > label,
.field > .field-label {
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 600;
}

.field .hint {
    color: var(--ink-muted);
    font-size: 12.5px;
}

/* ---------------------------------------------------------------------------
   Page header
   --------------------------------------------------------------------------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-head h1 {
    font-size: 26px;
}

.page-head .lede {
    margin-top: 6px;
    max-width: 62ch;
    color: var(--ink-muted);
    font-size: 14px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------------------------------------------------------------------------
   Cards / list
   --------------------------------------------------------------------------- */

.card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.submission-list {
    display: grid;
    gap: 12px;
}

.submission {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px 24px;
    align-items: start;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.submission h2 {
    font-size: 17px;
}

.submission h2 a {
    color: inherit;
    text-decoration: none;
}

.submission h2 a:hover {
    text-decoration: underline;
}

.submission-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 6px;
    color: var(--ink-muted);
    font-size: 12.5px;
}

.submission-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.progress {
    margin-top: 12px;
    max-width: 420px;
}

.progress-track {
    height: 6px;
    border-radius: 999px;
    background: var(--surface-sunken);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width .2s ease;
}

.progress-fill.complete {
    background: var(--good);
}

.progress-label {
    margin-top: 5px;
    color: var(--ink-muted);
    font-size: 12px;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
}

.tag.framework {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.tag.good { background: var(--good-soft); color: var(--good); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.critical { background: var(--critical-soft); color: var(--critical); }
.tag.muted { background: var(--surface-sunken); color: var(--ink-muted); }

.empty-state {
    display: grid;
    gap: 12px;
    justify-items: center;
    padding: 56px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
}

.empty-state h1,
.empty-state h2 {
    font-size: 19px;
}

.empty-state p {
    max-width: 48ch;
    color: var(--ink-muted);
    font-size: 14px;
}

/* ---------------------------------------------------------------------------
   Framework picker
   --------------------------------------------------------------------------- */

.framework-choices {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.framework-choice {
    position: relative;
    display: block;
    padding: 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}

.framework-choice:hover {
    border-color: var(--accent);
}

.framework-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.framework-choice.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent) inset;
    background: var(--accent-soft);
}

.framework-choice h3 {
    font-size: 15px;
}

.framework-choice .pub {
    margin-top: 2px;
    color: var(--ink-muted);
    font-size: 12px;
}

.framework-choice p {
    margin-top: 8px;
    color: var(--ink-soft);
    font-size: 13px;
}

.framework-choice .counts {
    margin-top: 10px;
    color: var(--ink-muted);
    font-size: 12px;
    font-weight: 600;
}

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.details-panel {
    margin-bottom: 20px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.details-panel > summary {
    padding: 12px 0;
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.details-panel[open] > summary {
    margin-bottom: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.details-panel .form-grid {
    padding: 14px 0 18px;
}

.details-panel .hint {
    padding-bottom: 16px;
    color: var(--ink-muted);
    font-size: 12.5px;
}

/* ---------------------------------------------------------------------------
   Assessment editor
   --------------------------------------------------------------------------- */

.editor-bar {
    position: sticky;
    top: 59px;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.editor-bar .status {
    color: var(--ink-muted);
    font-size: 12.5px;
}

.function-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}

.function-nav button {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-soft);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.function-nav button:hover {
    border-color: var(--border-strong);
}

.function-nav button.active {
    border-color: transparent;
    background: var(--accent);
    color: #fff;
}

.function-nav button .count {
    font-weight: 500;
    opacity: .75;
}

.function-nav button .complete {
    flex: none;
    align-self: center;
    color: var(--good);
}

.function-nav button.active .complete {
    color: #fff;
}

.function-nav button.active .complete path {
    stroke: var(--accent);
}

.function-head {
    margin-bottom: 20px;
    padding: 18px 20px;
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.function-head .eyebrow {
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.function-head h2 {
    margin-top: 4px;
    font-size: 21px;
}

.function-head p {
    margin-top: 6px;
    max-width: 78ch;
    color: var(--ink-soft);
    font-size: 13.5px;
}

.category {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.category-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-sunken);
}

.category-head h3 {
    font-size: 15px;
}

.category-head .id {
    color: var(--accent);
    font-weight: 700;
}

.category-head p {
    margin-top: 5px;
    max-width: 88ch;
    color: var(--ink-muted);
    font-size: 12.5px;
}

.question {
    border-top: 1px solid var(--border);
    scroll-margin-top: 140px;
}

.question-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.question-toggle:hover {
    background: var(--surface-sunken);
}

.question-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.question-text {
    flex: 1 1 auto;
    min-width: 0;
}

.question-toggle .tag {
    flex: none;
    white-space: nowrap;
}

.question-toggle .chevron {
    flex: none;
    color: var(--ink-muted);
    transition: transform .15s ease;
}

.question.expanded .chevron {
    transform: rotate(180deg);
}

.question-body {
    padding: 0 18px 18px;
}

.question-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.question:first-of-type {
    border-top: none;
}

.question.unanswered {
    box-shadow: inset 3px 0 0 var(--warn);
}

.question.flagged {
    box-shadow: inset 3px 0 0 var(--critical);
    background: var(--critical-soft);
}

.question-id {
    display: block;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}

.question-prompt {
    display: block;
    margin-top: 4px;
    max-width: 86ch;
    font-size: 14.5px;
}

.answer-row {
    display: grid;
    gap: 14px;
}

/* Segmented control: one row of bordered buttons with no gaps; adjacent borders overlap so they read as single lines. */
.choice-group {
    display: flex;
}

.choice {
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink-soft);
    font: inherit;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
}

.choice + .choice {
    margin-left: -1px;
}

.choice:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.choice:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.choice:hover:not(.selected) {
    background: var(--surface-sunken);
    color: var(--ink);
}

.choice.selected {
    position: relative;
    z-index: 1;
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.choice:focus-visible {
    position: relative;
    z-index: 2;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 720px) {
    .choice-group {
        flex-direction: column;
    }

    .choice + .choice {
        margin-left: 0;
        margin-top: -1px;
    }

    .choice:first-child {
        border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    }

    .choice:last-child {
        border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    }
}

.answer-row .required {
    color: var(--critical);
}

.option-hint {
    margin-top: 6px;
    color: var(--ink-muted);
    font-size: 12px;
    min-height: 1.2em;
}

.comment-count {
    color: var(--ink-muted);
    font-size: 12px;
    font-weight: 400;
}

.editor-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.banner {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
}

.banner.warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.banner.good {
    background: var(--good-soft);
    color: var(--good);
}

.banner strong {
    font-weight: 700;
}

/* ---------------------------------------------------------------------------
   Dialog
   --------------------------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(16, 24, 40, .5);
}

.modal {
    width: 100%;
    max-width: 440px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .5);
}

.modal h2 {
    font-size: 17px;
}

.modal p {
    margin-top: 6px;
    color: var(--ink-muted);
    font-size: 13.5px;
}

.modal .field {
    margin-top: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ---------------------------------------------------------------------------
   Blazor error UI
   --------------------------------------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 12px 16px;
    background: #fbf0dc;
    color: #5c3d05;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .2);
    font-family: system-ui, sans-serif;
    font-size: 14px;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 8px;
    right: 12px;
    cursor: pointer;
}

/* ---------------------------------------------------------------------------
   Alerts
   --------------------------------------------------------------------------- */
.alert {
    padding: 6px 10px;
}

.alert-warning {
    background-color: var(--warn-soft);
    border: 1px solid var(--warn);
    color: var(--ink);
    margin: 12px 0px;
}