* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: #222;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: #1f5fa8; text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1rem 2rem;
    border-bottom: 1px solid #eee;
}

.site-header .logo strong { font-size: 1.5rem; letter-spacing: 0.05em; }
.site-header .tagline { font-size: 0.75rem; color: #666; font-style: italic; }

.main-nav { display: flex; gap: 1.5rem; }

.account-links { text-align: right; font-size: 0.9rem; }
.account-links a { margin-left: 0.5rem; }

.site-main {
    flex: 1;
    min-height: 400px;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.site-footer {
    background: #14416d;
    color: #fff;
    padding: 1.5rem 2rem;
    font-size: 0.9rem;
}
.site-footer a { color: #fff; }
.footer-copy { margin-top: 0.5rem; }

.login-form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 320px; }
.login-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.login-form input { padding: 0.5rem; font-size: 1rem; }
.login-form button { padding: 0.5rem 1rem; font-size: 1rem; cursor: pointer; }
.login-form .error { color: #b00; margin: 0; }

.auth-links { margin-top: 1rem; max-width: 320px; }

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 1px solid transparent;
}
.flash-info  { background: #e8f1f9; border-color: #c5dcec; color: #1f4972; }
.flash-error { background: #fbeaea; border-color: #e9bdbd; color: #841d1d; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    font-size: 0.9rem;
    border: 1px solid #bbb;
    background: #f4f4f4;
    color: #222;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: #ebebeb; text-decoration: none; }
.btn-primary { background: #1f5fa8; color: #fff; border-color: #1a508f; }
.btn-primary:hover { background: #1a508f; color: #fff; }
.btn-danger { background: #b53737; color: #fff; border-color: #962d2d; }
.btn-danger:hover { background: #962d2d; color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Toolbar above the table */
.toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }

/* Email button + side-menu wrapper */
.email-btn-wrap { position: relative; display: inline-block; }
.email-choice-menu {
    position: absolute;
    top: 0;
    left: calc(100% + 0.5rem);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.35rem;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 50;
    white-space: nowrap;
}
.email-choice-menu .btn { white-space: nowrap; text-align: left; }

/* Group tree (participants page) */
.group-tree, .group-children {
    list-style: none;
    margin: 0;
    padding: 0;
}
.group-tree { border: 1px solid #e2e2e2; border-radius: 4px; background: #fff; }
.group-children { padding-left: 1.5rem; border-left: 1px dashed #ddd; margin-left: 0.85rem; }
.group-node + .group-node { border-top: 1px solid #f0f0f0; }
.group-children .group-node + .group-node { border-top: none; }
.group-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
}
.group-row:hover { background: #fafafa; }
.group-row-toggleable { cursor: pointer; }
.group-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    width: 1.2em;
    text-align: center;
    color: #555;
    padding: 0;
    line-height: 1;
}
.group-toggle:hover { color: #14416d; }
.group-toggle-empty { cursor: default; color: #bbb; font-size: 0.6rem; }
.group-name { flex: 1 1 auto; font-size: 0.95rem; }
.group-actions { display: inline-flex; gap: 0.1rem; }
.group-actions .icon-btn { font-size: 0.95rem; padding: 0.1rem 0.35rem; }

.part-node + .part-node { border-top: 1px solid #f5f5f5; }
.part-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.6rem;
    font-size: 0.9rem;
}
.part-row:hover { background: #fafafa; }
.part-marker { color: #888; font-size: 0.85rem; cursor: default; }
.part-name { flex: 0 0 auto; color: #222; }
.part-email { flex: 1 1 auto; color: #777; font-size: 0.85rem; }
.part-stats { display: inline-flex; gap: 0.25rem; flex: 0 0 auto; }
.part-actions {
    display: inline-flex;
    gap: 0.1rem;
    flex: 0 0 auto;
    min-width: 9em;
    justify-content: flex-end;
}
.part-actions .icon-btn { font-size: 0.95rem; padding: 0.1rem 0.35rem; }

.stat-pill {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    line-height: 1.4;
}
.stat-pill.stat-assigned  { background: #5DADE2; }
.stat-pill.stat-started   { background: #2DCDD8; }
.stat-pill.stat-completed { background: #28A745; }
.stat-pill.stat-revoked   { background: #DC3545; }

.assign-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 0.75rem;
    font-size: 0.92rem;
}
.assign-table th, .assign-table td {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #eee;
}
.assign-table thead th { background: #f4f4f4; font-weight: 600; }
.assign-table td.col-num,
.assign-table th.col-num { text-align: right; }
.assign-table td:last-child { text-align: right; width: 1px; white-space: nowrap; }

/* Public assessment portal (unauth participants) */
.assessment-portal { max-width: 480px; margin: 1rem auto; }
.assessment-portal h2 { margin-top: 0; }
.assessment-portal .assessment-name { font-size: 1.15rem; margin: 0.75rem 0; }
.assessment-portal-form { margin-top: 1rem; }
.assessment-portal-form input[type="text"] {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: Consolas, "Courier New", monospace;
}

/* Welcome view (after a valid code is decoded) */
.assessment-portal-welcome { max-width: 800px; }
.assessment-portal-welcome h1 { margin: 0 0 0.4rem; font-size: 1.9rem; }
.assessment-portal-welcome .assessment-for { font-weight: 600; margin: 0 0 1.25rem; font-size: 1rem; }
.assessment-portal-welcome p { line-height: 1.5; }
.assessment-instructions { margin: 0.5rem 0 1rem 1.4rem; }
.assessment-instructions li { margin: 0.3rem 0; }
.assessment-divider { border: 0; border-top: 1px solid #e5e5e5; margin: 1.25rem 0 1rem; }
.assessment-portal-begin { text-align: center; margin-top: 0.5rem; }

/* Green "go" button — used for the participant's Begin/Resume button so it
   reads as a forward-progress action, distinct from save/cancel blues. */
.btn-go {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    font-size: 1rem;
    border: 1px solid #3e8f4f;
    background: #5cb85c;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}
.btn-go:hover { background: #4cae4c; color: #fff; text-decoration: none; }

/* Assessment-taking view (Page 1 layout) */
.assessment-take { max-width: 1100px; margin: 0 auto; }
.assessment-take-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 0 0 1rem;
}
.assessment-take-title { margin: 0; font-size: 1.65rem; font-weight: 400; }
.assessment-take-page-num { margin: 0; font-size: 1.15rem; color: #555; }

.assessment-section {
    border: 1px solid #e2e2e2;
    border-radius: 4px;
    background: #fff;
    margin-bottom: 1rem;
}
.assessment-section-header {
    background: #f4f4f4;
    padding: 0.7rem 1rem;
    margin: 0;
    border-bottom: 1px solid #e2e2e2;
    font-size: 0.95rem;
}

.q-block {
    border: 0;
    margin: 0;
    padding: 1rem;
}
.q-block + .q-block { border-top: 1px solid #f0f0f0; }
.q-prompt { font-weight: 600; padding: 0; margin-bottom: 0.6rem; }
.q-paired legend.paired-labels {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    width: 100%;
    padding: 0;
    margin-bottom: 0.6rem;
    font-weight: 600;
}
.q-paired .paired-left  { text-align: left;  }
.q-paired .paired-right { text-align: right; }

/* Choice-button group: radios are hidden, labels are the visible buttons */
.choice-row { display: flex; }
.choice-paired {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}
.choice-row input[type="radio"] {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}
.choice-btn {
    display: block;
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    cursor: pointer;
    background: #fff;
    text-align: center;
    user-select: none;
    margin-left: -1px;
    line-height: 1.3;
}
.choice-btn:first-of-type {
    margin-left: 0;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}
.choice-btn:last-of-type {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}
.choice-btn:hover {
    background: #ebebeb;
    position: relative;
    z-index: 1;
}
.choice-row input[type="radio"]:checked + .choice-btn {
    background: #1f5fa8;
    color: #fff;
    border-color: #1a508f;
    position: relative;
    z-index: 2;
}
.choice-row input[type="radio"]:focus-visible + .choice-btn {
    outline: 2px solid #4a90e2;
    outline-offset: 1px;
    z-index: 3;
}

.assessment-take-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    gap: 0.5rem;
}
.assessment-take-nav-left,
.assessment-take-nav-right {
    display: flex;
    gap: 0.5rem;
    min-height: 1px; /* keep right side anchored even when left is empty */
}
.assessment-next-btn { padding: 0.55rem 1.2rem; }
.assessment-take-actions .btn-primary { padding: 0.55rem 1.2rem; }
.muted { color: #777; font-size: 0.9rem; }
.empty { color: #888; font-style: italic; }

/* Filter form */
.filter-form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: end;
    padding: 1rem;
    background: #f7f7f7;
    border: 1px solid #e2e2e2;
    border-radius: 4px;
    margin-bottom: 1rem;
}
.filter-form[hidden] { display: none; }
.filter-form label { display: flex; flex-direction: column; font-size: 0.85rem; gap: 0.2rem; }
.filter-form input, .filter-form select { padding: 0.35rem 0.5rem; font-size: 0.9rem; }

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    background: #fff;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid #eee;
}
.data-table thead th { background: #f4f4f4; font-weight: 600; border-bottom: 2px solid #ddd; }
.data-table thead a { color: #222; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table .col-icon { width: 1px; white-space: nowrap; text-align: center; }
.data-table th.col-num,
.data-table td.col-num { min-width: 3.5em; white-space: nowrap; text-align: right; }
.data-table th.col-num a { color: inherit; }
.data-table .empty { text-align: center; color: #888; font-style: italic; }

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
    padding: 0.2rem 0.4rem;
    color: #1f5fa8;
    text-decoration: none;
}
.icon-btn:hover { color: #14416d; text-decoration: none; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.pagination-pages a { margin: 0 0.4rem; }
.pagination-per label { display: inline-flex; align-items: center; gap: 0.4rem; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-dialog {
    background: #fff;
    border-radius: 6px;
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}
.modal-dialog h2 { margin-top: 0; }
.modal-form { display: flex; flex-direction: column; gap: 0.75rem; }
.modal-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.modal-form input, .modal-form select, .modal-form textarea {
    padding: 0.5rem; font-size: 1rem; font-family: inherit;
}
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem; }
.modal-actions #editDelete,
.modal-actions #groupDelete { margin-right: auto; }
.modal-form .form-row { display: flex; gap: 0.75rem; align-items: flex-end; }
.modal-form .form-row label { flex: 0 0 auto; }
.modal-form .form-row label.grow { flex: 1 1 auto; }

.delete-confirm {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}
.delete-confirm input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}
.delete-confirm code {
    background: #f4f4f4;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-family: Consolas, Monaco, monospace;
}

.init-access {
    margin: 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.init-access legend {
    font-weight: 600;
    padding: 0 0.4rem;
    font-size: 0.85rem;
}
.init-access label {
    display: block;
    padding: 0.2rem 0;
    font-size: 0.9rem;
}
.init-access input[type="radio"] {
    margin-right: 0.4rem;
}

.perms-credits .perm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.2rem 0;
}
.perms-credits .perm-row label.perm {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    margin: 0;
    flex: 0 0 auto;
}
.perms-credits .perm-row label.credits {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #555;
    margin: 0;
    padding: 0;
}
.perms-credits .perm-row label.credits input[type="number"] {
    width: 6em;
    padding: 0.3rem 0.4rem;
    font-size: 0.9rem;
    text-align: right;
}
.perms-credits .perm-row label.credits input[type="number"]:disabled {
    background: #f4f4f4;
    color: #999;
    cursor: not-allowed;
}

/* ----- Assessment-taking color schemes -----
   Base var defaults match the site theme (Aurelius). Each .assmnt-theme-*
   class only overrides the vars; the selectors below consume them. */
.assmnt-themed {
    --at-bg: #fafafa;
    --at-text: #222;
    --at-muted: #555;
    --at-section-bg: #fff;
    --at-section-border: #e2e2e2;
    --at-section-header-bg: #f4f4f4;
    --at-divider: #f0f0f0;
    --at-btn-bg: #fff;
    --at-btn-text: #222;
    --at-btn-border: #ccc;
    --at-btn-hover: #ebebeb;
    --at-sel-bg: #1f5fa8;
    --at-sel-text: #fff;
    --at-sel-border: #1a508f;
    --at-focus: #4a90e2;
}
.assmnt-theme-sepia {
    --at-bg: #f5ebd5;
    --at-text: #3b2f1d;
    --at-muted: #6b5a3a;
    --at-section-bg: #fbf5e3;
    --at-section-border: #d8c8a3;
    --at-section-header-bg: #ebdeb8;
    --at-divider: #e3d4ab;
    --at-btn-bg: #fbf5e3;
    --at-btn-text: #3b2f1d;
    --at-btn-border: #c5b289;
    --at-btn-hover: #ede0b8;
    --at-sel-bg: #8b6914;
    --at-sel-text: #fff;
    --at-sel-border: #6e5310;
    --at-focus: #c2992b;
}
.assmnt-theme-forest {
    --at-bg: #e6efe7;
    --at-text: #1f3a2a;
    --at-muted: #4a6555;
    --at-section-bg: #f4f9f4;
    --at-section-border: #c1d7c5;
    --at-section-header-bg: #d6e6d8;
    --at-divider: #d4e2d6;
    --at-btn-bg: #fff;
    --at-btn-text: #1f3a2a;
    --at-btn-border: #b5cdb8;
    --at-btn-hover: #ddebde;
    --at-sel-bg: #2e6b4d;
    --at-sel-text: #fff;
    --at-sel-border: #235539;
    --at-focus: #5a9b78;
}
.assmnt-theme-lavender {
    --at-bg: #efeaf6;
    --at-text: #2e2540;
    --at-muted: #5a4f70;
    --at-section-bg: #f8f5fc;
    --at-section-border: #d0c5e0;
    --at-section-header-bg: #e3dbef;
    --at-divider: #ddd2ec;
    --at-btn-bg: #fff;
    --at-btn-text: #2e2540;
    --at-btn-border: #c4b9d8;
    --at-btn-hover: #e6ddf2;
    --at-sel-bg: #6648a4;
    --at-sel-text: #fff;
    --at-sel-border: #503685;
    --at-focus: #8d72bf;
}
.assmnt-theme-slate {
    --at-bg: #1f2530;
    --at-text: #e4e7ee;
    --at-muted: #9aa3b2;
    --at-section-bg: #2a3140;
    --at-section-border: #3a4254;
    --at-section-header-bg: #313a4d;
    --at-divider: #3a4254;
    --at-btn-bg: #2a3140;
    --at-btn-text: #e4e7ee;
    --at-btn-border: #4a5468;
    --at-btn-hover: #3a4254;
    --at-sel-bg: #5b8def;
    --at-sel-text: #fff;
    --at-sel-border: #4172cf;
    --at-focus: #7eaaff;
}
.assmnt-theme-sand {
    --at-bg: #faefe0;
    --at-text: #463124;
    --at-muted: #7a5c45;
    --at-section-bg: #fef9f1;
    --at-section-border: #e5cfb5;
    --at-section-header-bg: #f1ddc3;
    --at-divider: #ebd6bd;
    --at-btn-bg: #fff;
    --at-btn-text: #463124;
    --at-btn-border: #d8bea1;
    --at-btn-hover: #f0dec5;
    --at-sel-bg: #c2562b;
    --at-sel-text: #fff;
    --at-sel-border: #9d4322;
    --at-focus: #e6905b;
}

/* Apply vars to the assessment-take page */
.assmnt-themed.assessment-take {
    background: var(--at-bg);
    color: var(--at-text);
    padding: 1.5rem;
    border-radius: 8px;
}
.assmnt-themed .assessment-take-title,
.assmnt-themed .assessment-take-page-num { color: var(--at-text); }
.assmnt-themed .assessment-take-page-num { color: var(--at-muted); }
.assmnt-themed .assessment-section {
    background: var(--at-section-bg);
    border-color: var(--at-section-border);
    color: var(--at-text);
}
.assmnt-themed .assessment-section-header {
    background: var(--at-section-header-bg);
    border-bottom-color: var(--at-section-border);
    color: var(--at-text);
}
.assmnt-themed .q-block + .q-block { border-top-color: var(--at-divider); }
.assmnt-themed .choice-btn {
    background: var(--at-btn-bg);
    color: var(--at-btn-text);
    border-color: var(--at-btn-border);
}
.assmnt-themed .choice-btn:hover { background: var(--at-btn-hover); }
.assmnt-themed .choice-row input[type="radio"]:checked + .choice-btn {
    background: var(--at-sel-bg);
    color: var(--at-sel-text);
    border-color: var(--at-sel-border);
}
.assmnt-themed .choice-row input[type="radio"]:focus-visible + .choice-btn {
    outline-color: var(--at-focus);
}

/* Theme picker swatches (on the welcome page) */
.theme-picker { border: 0; padding: 0; margin: 1.25rem 0 1rem; }
.theme-picker legend { font-weight: 600; padding: 0; margin-bottom: 0.6rem; }
.theme-picker-intro { margin: 0 0 0.6rem; color: #555; font-size: 0.9rem; }
.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
}
.theme-picker-grid > input[type="radio"] {
    position: absolute;
    width: 0; height: 0;
    opacity: 0;
    pointer-events: none;
}
.theme-swatch {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.55rem;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    background: var(--at-bg);
    color: var(--at-text);
    box-shadow: inset 0 0 0 1px #ddd;
    transition: box-shadow 0.1s ease;
}
.theme-swatch-preview {
    height: 56px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--at-section-bg);
    border: 1px solid var(--at-section-border);
    display: flex;
    flex-direction: column;
}
.theme-swatch-header {
    height: 14px;
    background: var(--at-section-header-bg);
    border-bottom: 1px solid var(--at-section-border);
}
.theme-swatch-buttons {
    flex: 1;
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    align-items: center;
    justify-content: center;
}
.theme-swatch-btn {
    width: 22px;
    height: 14px;
    background: var(--at-btn-bg);
    border: 1px solid var(--at-btn-border);
    border-radius: 2px;
}
.theme-swatch-btn.sel {
    background: var(--at-sel-bg);
    border-color: var(--at-sel-border);
}
.theme-swatch-name {
    font-size: 0.85rem;
    text-align: center;
    color: var(--at-text);
    font-weight: 600;
}
.theme-picker-grid > input[type="radio"]:checked + .theme-swatch {
    border-color: #1f5fa8;
    box-shadow: 0 0 0 1px #1f5fa8, 0 2px 6px rgba(31,95,168,0.18);
}
.theme-picker-grid > input[type="radio"]:focus-visible + .theme-swatch {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}
