:root {
    --pico-primary: #1a5276;
    --school-blue: #1a5276;
    --school-blue-light: #2980b9;
    --school-bg: #f0f4f8;
    --school-header-bg: #1a5276;
    --school-sidebar-bg: rgba(255, 255, 255, 0.92);
    --school-border: #d5dce4;
}

[data-theme="light"],
:root:not([data-theme="dark"]) {
    --pico-primary: #1a5276;
}

html { --pico-font-size: 100% !important; }
html.font-small { font-size: 14px; }
html.font-medium { font-size: 16px; }
html.font-large { font-size: 18px; }
html.font-xlarge { font-size: 20px; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--school-bg);
}

.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--school-header-bg);
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left a {
    font-size: 1.25rem;
    font-weight: bold;
    color: #fff;
    text-decoration: none;
    letter-spacing: 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.header-left .school-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.05rem;
    min-width: 0;
    flex-shrink: 1;
}

.header-right span {
    color: rgba(255, 255, 255, 0.9);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 0.4rem 1.1rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: background 0.2s, border-color 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
    text-decoration: none;
}

/* Font size toggle */
.font-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-right: 0.5rem;
}

.font-toggle span.font-label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-right: 0.25rem;
}

.font-toggle button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    cursor: pointer;
    border-radius: 3px;
    padding: 0.25rem 0.6rem;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.font-toggle button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.font-toggle button.active {
    background: rgba(255, 255, 255, 0.35);
    font-weight: bold;
}

/* Body */
.body-wrapper {
    display: flex;
    flex: 1;
    position: relative;
    padding: 0 3rem;
}

/* Top Navigation */
.topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    background: var(--school-sidebar-bg);
    border-bottom: 1px solid var(--school-border);
    padding: 0;
    justify-content: center;
}

.topnav a {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.7rem 1.2rem;
    color: #34495e;
    text-decoration: none;
    font-size: 1rem;
    transition: background 0.2s, color 0.2s;
    border-bottom: 3px solid transparent;
}

.topnav a:hover {
    background: #eaf2f8;
    color: var(--school-blue);
}

.topnav a.active {
    color: var(--school-blue);
    border-bottom-color: var(--school-blue);
    font-weight: 600;
}

.topnav .nav-icon {
    font-size: 1rem;
}

/* Content */
.content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.content-full {
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Footer */
.footer {
    background: var(--school-header-bg);
    text-align: center;
    padding: 0.6rem;
    font-size: 0.9rem;
    color: #fff;
}

.footer p {
    color: #fff;
    margin: 0;
}

/* Version select */
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.profile-header h1 {
    margin-bottom: 0;
}

.version-select select {
    width: auto;
    min-width: 120px;
    margin-bottom: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Hint system */
.btn-hint {
    background: #f39c12;
    color: #fff;
    border: none;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    white-space: nowrap;
}
.btn-hint:hover { background: #e67e22; }

.btn-hint-appear {
    animation: hintFadeIn 0.6s ease-in;
}
@keyframes hintFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.hint-panel {
    background: #fef9e7;
    border: 1px solid #f0e6c0;
    border-radius: 6px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.hint-section-header {
    padding: 0.6rem 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: #8b6914;
    background: #fdf2d0;
    border-bottom: 1px solid #f0e6c0;
}

.hint-accordion {
    border-bottom: 1px solid #f0e6c0;
}
.hint-accordion:last-child { border-bottom: none; }

.hint-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 600;
    color: #7d6608;
    user-select: none;
}
.hint-accordion-header:hover { background: #fdf2d0; }
.hint-accordion-header .hint-arrow {
    transition: transform 0.2s;
    font-size: 0.85rem;
}
.hint-accordion.open .hint-arrow { transform: rotate(90deg); }

.hint-accordion-body {
    display: none;
    padding: 0.5rem 1rem 0.75rem;
    font-size: 1rem;
    color: #5d4e37;
    line-height: 1.6;
    border-top: 1px solid #f0e6c0;
}
.hint-accordion.open .hint-accordion-body { display: block; }

.hint-lock-btn {
    background: none;
    border: 1px solid #d4ac0d;
    color: #d4ac0d;
    padding: 0.25rem 0.6rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9rem;
}
.hint-lock-btn:hover { background: #d4ac0d; color: #fff; }

/* Profile */
.profile-avatar {
    text-align: center;
    margin-bottom: 1.5rem;
}

.profile-avatar img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--school-blue);
}

.avatar-placeholder {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 3px solid var(--school-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dfe6e9;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 150'%3E%3Ccircle cx='75' cy='55' r='30' fill='%23b2bec3'/%3E%3Cellipse cx='75' cy='130' rx='45' ry='35' fill='%23b2bec3'/%3E%3C/svg%3E");
    background-size: cover;
    color: transparent;
    overflow: hidden;
}

/* Captcha */
.captcha-group {
    margin-bottom: 0.5rem;
}

.captcha-group img {
    border-radius: var(--pico-border-radius);
    border: 1px solid var(--school-border);
    cursor: pointer;
    transition: opacity 0.2s;
}

.captcha-group img:hover {
    opacity: 0.7;
}

.captcha-hint {
    display: block;
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Alert */
.alert-success {
    padding: 0.6rem 1rem;
    border-radius: var(--pico-border-radius);
    margin-bottom: 1rem;
    background: #eafaf1;
    border: 1px solid #27ae60;
    color: #1e8449;
}

.alert-error {
    padding: 0.6rem 1rem;
    border-radius: var(--pico-border-radius);
    margin-bottom: 1rem;
    background: #fdedec;
    border: 1px solid #e74c3c;
    color: #c0392b;
}

/* Login */
.login-wrapper {
    width: 100%;
    max-width: 400px;
}

.login-box {
    padding: 2.5rem;
    box-shadow: 0 4px 24px rgba(26, 82, 118, 0.1);
    border: 1px solid rgba(213, 220, 228, 0.6);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--school-blue);
}

.hint {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.95rem;
    color: #7f8c8d;
}

/* Admin login */
.admin-login-box {
    border-top: 4px solid #c0392b;
}

.admin-badge {
    text-align: center;
    font-size: 0.95rem;
    color: #c0392b;
    margin-top: -1rem;
    margin-bottom: 1rem;
    font-weight: bold;
}

/* Role badge */
.role-badge {
    font-size: 0.85rem;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-weight: bold;
    text-transform: uppercase;
}

.role-admin {
    background: #c0392b;
    color: #fff;
}

/* Admin table */
.badge-admin {
    background: #c0392b;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.95rem;
}

.badge-student {
    background: #2980b9;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.95rem;
}

.action-cell {
    white-space: nowrap;
}

article {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 12px rgba(26, 82, 118, 0.06);
    border-left: 4px solid var(--school-blue-light);
}

article h3 {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--school-border);
    margin-bottom: 1rem;
}

article:has(table) {
    overflow-x: auto;
}

/* Table zebra + hover */
table tbody tr:nth-child(even) {
    background: #f7f9fb;
}

table tbody tr:hover {
    background: #eaf2f8;
}

table th {
    background: #f0f4f8;
}

/* Sidebar nav icons */
.nav-icon {
    display: inline-block;
    width: 1.4em;
    text-align: center;
    margin-right: 0.4rem;
    font-size: 1rem;
}

/* Welcome banner (legacy, replaced by mission-briefing) */

/* Breadcrumb */
nav.breadcrumb {
    font-size: 1rem;
    color: #7f8c8d;
    margin-bottom: 1rem;
    padding: 0;
    display: block;
    justify-content: unset;
    align-items: unset;
}

.breadcrumb a {
    color: var(--school-blue);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    margin: 0 0.4rem;
    color: #bdc3c7;
}

/* Quick action cards */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
}

.quick-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.1rem 0.5rem;
    background: #fff;
    border: 1px solid var(--school-border);
    border-radius: var(--pico-border-radius);
    text-decoration: none;
    color: #34495e;
    transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.quick-card:hover {
    border-color: var(--school-blue-light);
    box-shadow: 0 4px 12px rgba(26, 82, 118, 0.12);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--school-blue);
}

.quick-icon {
    font-size: 2rem;
    line-height: 1;
    filter: grayscale(30%) saturate(0.8);
    opacity: 0.85;
}

.quick-card:hover .quick-icon {
    filter: none;
    opacity: 1;
}

.quick-label {
    font-size: 1rem;
    font-weight: 600;
}

/* Announcement list */
.announcement-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.announcement-item {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.65rem 0.5rem;
    border-bottom: 1px solid #eef1f5;
    text-decoration: none;
    color: #34495e;
    transition: background 0.15s;
}

.announcement-item:last-child {
    border-bottom: none;
}

.announcement-item:hover {
    background: #f7f9fb;
    text-decoration: none;
}

.announcement-date {
    font-size: 1rem;
    color: #7f8c8d;
    white-space: nowrap;
    min-width: 5.5em;
}

.announcement-title {
    color: var(--school-blue);
    font-size: 1.1rem;
}

.announcement-item:hover .announcement-title {
    text-decoration: underline;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #7f8c8d;
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

button.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    color: #fff;
    margin: 0 0.25rem 0 0;
    line-height: 1.4;
    width: auto;
}

.btn-warning {
    background: #e67e22;
}

.btn-warning:hover {
    background: #d35400;
}

.btn-danger {
    background: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-danger-sm, .btn-success-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    color: #fff;
    width: auto;
    line-height: 1.4;
}

.btn-danger-sm {
    background: #e74c3c;
}

.btn-danger-sm:hover {
    background: #c0392b;
}

.btn-success-sm {
    background: #27ae60;
}

.btn-success-sm:hover {
    background: #1e8449;
}

.slots-ok {
    color: #27ae60;
    font-weight: bold;
    font-size: 1rem;
}

.slots-full {
    color: #e74c3c;
    font-weight: bold;
    font-size: 1rem;
}

.btn-disabled-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 3px;
    cursor: not-allowed;
    color: #fff;
    width: auto;
    line-height: 1.4;
    background: #bdc3c7;
    opacity: 0.7;
}

#confirmModal article,
#fullModal article {
    max-width: 400px;
    margin: 0;
}

#confirmModal footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0;
    margin-top: 1rem;
}

#confirmModal footer button {
    width: auto;
    margin: 0;
    padding: 0.5rem 1.2rem;
    font-size: 1rem;
}

/* Admin search */
.admin-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-search input[type="text"] {
    width: auto;
    min-width: 220px;
    margin: 0;
    padding: 0.3rem 0.6rem;
}

/* Simple Editor */
.editor-wrap {
    border: 1px solid var(--school-border);
    border-radius: var(--pico-border-radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

.editor-toolbar {
    display: flex;
    gap: 2px;
    padding: 0.4rem;
    background: #f5f6f7;
    border-bottom: 1px solid var(--school-border);
    flex-wrap: wrap;
}

.editor-toolbar button {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-size: 1rem;
    margin: 0;
    line-height: 1.4;
    min-width: 2rem;
    text-align: center;
    color: #333;
}

.editor-toolbar button b,
.editor-toolbar button i,
.editor-toolbar button u,
.editor-toolbar button s {
    all: revert;
    color: inherit;
    font-size: inherit;
}

.editor-toolbar button:hover {
    background: #eaf2f8;
}

.editor-body {
    min-height: 120px;
    padding: 0.75rem;
    outline: none;
    font-size: 1.05rem;
    line-height: 1.6;
    background: #fff;
}

.editor-body:empty::before {
    content: attr(data-placeholder);
    color: #999;
}

/* Vuln pages */
.vuln-form {
    margin: 1rem 0;
}

.result-box {
    background: #fff;
    border: 1px solid var(--school-border);
    border-radius: var(--pico-border-radius);
    padding: 1rem;
    margin-top: 1rem;
    font-family: var(--pico-font-family-monospace);
    white-space: pre-wrap;
    word-break: break-all;
}

/* Drawer */
.drawer-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    background: var(--school-blue);
    color: #fff;
    opacity: 0.6;
    border: none;
    border-radius: 4px 0 0 4px;
    padding: 0.6rem 0.4rem;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    box-shadow: -2px 0 6px rgba(0,0,0,0.2);
}

.drawer-toggle:hover {
    background: var(--school-blue-light);
    opacity: 1;
}

.drawer-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.drawer-badge:empty {
    display: none;
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1001;
    display: none;
}

.drawer-overlay.open {
    display: block;
}

.drawer {
    position: fixed;
    right: calc(-1 * min(320px, 100vw));
    top: 0;
    width: min(320px, 100vw);
    height: 100vh;
    background: #fff;
    z-index: 1002;
    box-shadow: -4px 0 12px rgba(0,0,0,0.15);
    transition: right 0.25s ease;
    display: flex;
    flex-direction: column;
}

.drawer.open {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--school-border);
}

.drawer-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--school-blue);
}

.drawer-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.drawer-section {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #7f8c8d;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 0.75rem 0 0.35rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.5rem;
}

.drawer-section:first-child {
    padding-top: 0;
}

.drawer-item {
    margin-bottom: 0.75rem;
}

.drawer-item a {
    display: block;
    font-size: 1rem;
    font-family: var(--pico-font-family-monospace);
    color: var(--school-blue);
    text-decoration: none;
    word-break: break-all;
}

.drawer-item a:hover {
    text-decoration: underline;
}

.drawer-item small {
    display: block;
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

.drawer-payload {
    display: block;
    background: #f5f6f7;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
    font-family: var(--pico-font-family-monospace);
    word-break: break-all;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    color: #c0392b;
}

.drawer-payload:hover {
    background: #eaf2f8;
    border-color: var(--school-blue);
}

/* Terminal Widget */
.terminal-toggle {
    position: fixed;
    right: 0;
    top: calc(50% + 50px);
    z-index: 1000;
    background: #1a1a2e;
    color: #00ff41;
    border: none;
    border-radius: 4px 0 0 4px;
    padding: 0.5rem 0.35rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    box-shadow: -2px 0 6px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-family: monospace;
    opacity: 0.7;
}

.terminal-toggle:hover {
    opacity: 1;
    background: #16213e;
}

.terminal-label {
    font-size: 0.55rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #00ff41;
}

.terminal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1003;
    display: none;
}

.terminal-overlay.open {
    display: block;
}

.terminal-panel {
    position: fixed;
    left: 50%;
    top: 45%;
    transform: translate(-50%, -50%) scale(0.95);
    width: calc(100% - 2rem);
    height: 75vh;
    background: #1a1a2e;
    z-index: 1004;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
}

.terminal-panel.open {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
    top: 45%;
}

.terminal-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
}

.terminal-panel-title {
    color: #00ff41;
    font-family: monospace;
    font-size: 0.9rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.terminal-icon {
    font-size: 1.1rem;
}

.terminal-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.terminal-btn {
    background: #0f3460;
    color: #8be9fd;
    border: 1px solid #1a5276;
    border-radius: 3px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-family: monospace;
    cursor: pointer;
}

.terminal-btn:hover {
    background: #1a5276;
}

.terminal-close {
    background: none;
    border: none;
    color: #ff5555;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.terminal-close:hover {
    color: #ff6e6e;
}

#terminal-container {
    flex: 1;
    padding: 4px;
    overflow: hidden;
}

#terminal-container .xterm {
    height: 100%;
}


/* HackBar */
.hackbar-tab {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1005;
    background: #2c3e50;
    color: #fff;
    border: 1px solid #1a252f;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 0.45rem 2rem;
    cursor: pointer;
    font-size: 1rem;
    font-family: monospace;
    font-weight: bold;
    letter-spacing: 1px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
    transition: background 0.2s, bottom 0.3s ease;
}

.hackbar-tab:hover {
    background: #34495e;
}

.hackbar-tab.open {
    bottom: 340px;
    cursor: ns-resize;
}

.hackbar {
    position: fixed;
    bottom: -340px;
    left: 0;
    right: 0;
    height: 340px;
    background: #fafafa;
    z-index: 1005;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
    transition: bottom 0.3s ease;
    display: flex;
    flex-direction: column;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 0.95rem;
    border-top: 1px solid #ddd;
}

.hackbar.open {
    bottom: 0;
}

.hackbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 1rem;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.hackbar-tabs {
    display: flex;
    gap: 0;
}

.hackbar-tab-btn {
    background: none;
    border: none;
    color: #666;
    font-family: monospace;
    font-size: 0.9rem;
    font-weight: bold;
    padding: 0.35rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.hackbar-tab-btn:hover {
    color: #333;
}

.hackbar-tab-btn.active {
    color: #c0392b;
    border-bottom-color: #c0392b;
}

.hackbar-response-empty {
    color: #999;
    text-align: center;
    padding: 2rem;
}

.hackbar-title {
    color: #c0392b;
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 1px;
}

.hackbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.hackbar-btn {
    background: #e8e8e8;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0.25rem 0.8rem;
    font-size: 0.85rem;
    font-family: monospace;
    cursor: pointer;
}

.hackbar-btn:hover {
    background: #ddd;
}

.hackbar-btn-go {
    background: #27ae60;
    border-color: #2ecc71;
    color: #fff;
    font-weight: bold;
}

.hackbar-btn-go:hover {
    background: #2ecc71;
}

.hackbar-close {
    background: none;
    border: none;
    color: #999;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.hackbar-close:hover {
    color: #c0392b;
}

.hackbar-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.hackbar-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.hackbar-row select {
    background: #fff;
    color: #c0392b;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0.3rem 0.4rem;
    font-family: monospace;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
}

.hackbar-row input {
    flex: 1;
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0.35rem 0.6rem;
    font-family: monospace;
    font-size: 0.95rem;
}

.hackbar-row input:focus,
.hackbar-kv-key:focus,
.hackbar-kv-val:focus {
    outline: none;
    border-color: #3498db;
}

.hackbar-params {
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 0.3rem 0.5rem;
    background: #f5f5f5;
}

.hackbar-params-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #888;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.hackbar-btn-sm {
    background: #e8e8e8;
    color: #555;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    font-family: monospace;
    cursor: pointer;
}

.hackbar-btn-sm:hover {
    background: #ddd;
    color: #333;
}

.hackbar-kv-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hackbar-kv-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.hackbar-kv-ck {
    flex-shrink: 0;
    accent-color: #2980b9;
}

.hackbar-kv-key,
.hackbar-kv-val {
    flex: 1;
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 2px;
    padding: 0.25rem 0.4rem;
    font-family: monospace;
    font-size: 0.9rem;
}

.hackbar-kv-key {
    color: #c0392b;
    max-width: 180px;
}

.hackbar-kv-del {
    background: none;
    border: none;
    color: #c0392b;
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
    opacity: 0.6;
}

.hackbar-kv-del:hover {
    opacity: 1;
}

.hackbar-ct-select {
    background: #fff;
    color: #555;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0.15rem 0.3rem;
    font-family: monospace;
    font-size: 0.85rem;
    cursor: pointer;
}

.hackbar-raw {
    width: 100%;
    min-height: 50px;
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0.3rem 0.5rem;
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-top: 0.3rem;
}


.hackbar-response {
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #f5f5f5;
    padding: 0.3rem 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.hackbar-status {
    font-family: monospace;
    font-size: 0.85rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.status-ok { color: #2ecc71; }
.status-redirect { color: #f39c12; }
.status-err { color: #e74c3c; }

.hackbar-resp-headers {
    color: #888;
    font-size: 0.8rem;
    white-space: pre-wrap;
    max-height: 40px;
    overflow-y: auto;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.2rem;
    margin-bottom: 0.2rem;
}

.hackbar-resp-body {
    flex: 1;
    min-height: 0;
    background: #fff;
    border: none;
    border-radius: 3px;
    width: 100%;
}

iframe.hackbar-resp-body {
    background: #fff;
}

pre.hackbar-resp-body {
    color: #333;
    font-size: 0.9rem;
    padding: 0.3rem;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}


/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    margin: 0;
    line-height: 1;
}

/* RWD */
@media (max-width: 768px) {
    .hamburger {
        display: block;
    }

    .header {
        padding: 0 0.75rem;
    }

    .header-left a {
        font-size: 1rem;
    }

    .header-right {
        gap: 0.5rem;
    }

    .header-right .font-toggle {
        display: none;
    }

    .topnav {
        flex-direction: column;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .topnav.open {
        max-height: 500px;
    }

    .topnav a {
        padding: 0.7rem 1.25rem;
        border-bottom: none;
        border-left: 3px solid transparent;
    }

    .topnav a.active {
        border-bottom: none;
        border-left-color: var(--school-blue);
        background: #eaf2f8;
    }

    .body-wrapper {
        padding: 0;
    }

    .content {
        padding: 1rem 0.75rem;
        max-width: 100%;
    }

    .profile-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .admin-search {
        flex-wrap: wrap;
    }

    .admin-search input[type="text"] {
        min-width: 0;
        flex: 1;
    }

}

@media (max-width: 480px) {
    .header-right span {
        font-size: 0.85rem;
        max-width: 6em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-right .role-badge {
        display: none;
    }
}

/* Mission Briefing — PT 任務面板（淺色） */
.mission-briefing {
    background: #fff;
    border: 1px solid var(--school-border);
    border-left: 4px solid var(--school-blue);
    border-radius: 6px;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
}
.mission-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}
.mission-id {
    font-size: 0.75rem;
    color: #7f8c8d;
    letter-spacing: 2px;
    font-family: 'Consolas', 'Fira Code', monospace;
}
.mission-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #27ae60;
    letter-spacing: 1px;
}
.mission-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #27ae60;
    animation: statusPulse 2s ease-in-out infinite;
}
@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.mission-title {
    margin: 0 0 0.4rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #2c3e50;
}
.mission-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 0.6rem;
}
.mission-meta strong {
    color: #2c3e50;
}
.mission-progress-bar {
    height: 6px;
    background: #ecf0f1;
    border-radius: 3px;
    overflow: hidden;
}
.mission-progress-fill {
    height: 100%;
    background: #27ae60;
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* Phase Timeline */
.phase-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.phase-block {
    background: #fff;
    border: 1px solid var(--school-border);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.phase-block[open] {
    border-color: var(--school-blue-light);
    box-shadow: 0 2px 8px rgba(26, 82, 118, 0.08);
}
.phase-block:hover {
    border-color: #bdc3c7;
}
.phase-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.phase-summary::-webkit-details-marker { display: none; }
.phase-summary::marker { display: none; content: ""; }
.phase-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.phase-icon {
    font-size: 1.1rem;
}
.phase-title-text {
    display: flex;
    flex-direction: column;
}
.phase-title {
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e50;
}
.phase-subtitle {
    font-size: 0.8rem;
    color: #95a5a6;
}
.phase-badge-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.phase-counter {
    font-size: 0.9rem;
    font-weight: 700;
    color: #7f8c8d;
}
.phase-status {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}
.phase-status-pending {
    background: #ecf0f1;
    color: #95a5a6;
}
.phase-status-active {
    background: #e8f8ef;
    color: #27ae60;
}
.phase-status-done {
    background: #e8f8ef;
    color: #27ae60;
}
.phase-status-info {
    background: #eaf2f8;
    color: var(--school-blue-light);
}

/* Phase Objectives */
.phase-objectives {
    border-top: 1px solid #ecf0f1;
}
.objective {
    display: flex;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #ecf0f1;
    transition: background 0.15s;
    align-items: flex-start;
}
.objective:last-child {
    border-bottom: none;
}
.objective:hover {
    background: #f8f9fa;
}
.objective-done {
    background: #f0faf4;
    opacity: 0.7;
}
.objective-check {
    flex-shrink: 0;
    width: 1.2rem;
    text-align: center;
    padding-top: 0.15rem;
}
.check-pending {
    color: #bdc3c7;
    font-size: 0.9rem;
}
.check-confirmed {
    color: #27ae60;
    font-size: 1rem;
    font-weight: 700;
}
.objective-body {
    flex: 1;
    min-width: 0;
}
.objective-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.objective-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
}
.objective-done .objective-label {
    color: #27ae60;
    text-decoration: line-through;
}
.objective-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.objective-difficulty {
    font-size: 0.75rem;
    color: #d4a017;
    letter-spacing: -1px;
}
.objective-done .objective-difficulty {
    color: #27ae60;
}
.objective-desc {
    font-size: 0.82rem;
    color: #7f8c8d;
    margin-top: 0.15rem;
    line-height: 1.4;
}
.objective-link {
    display: inline-block;
    background: var(--school-blue-light);
    color: #fff;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    transition: background 0.15s;
}
.objective-link:hover {
    background: var(--school-blue);
    color: #fff;
}

/* Phase Report section */
.phase-report-section {
    padding: 1rem 1.25rem;
    border-top: 1px solid #ecf0f1;
}
.phase-report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.phase-report-header p {
    margin: 0;
    font-size: 0.85rem;
    color: #7f8c8d;
}
.report-add-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 4px;
    background: var(--school-blue);
    color: #fff;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}
.report-add-btn:hover {
    background: var(--school-blue-light);
}
.report-count {
    font-size: 0.8rem;
    color: #95a5a6;
    margin: 0.5rem 0 0;
}
.report-empty {
    font-size: 0.85rem;
    color: #b0b8bf;
    margin: 0;
}
.report-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.report-card {
    border: 1px solid #e0e6ed;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    background: #fff;
    font-size: 0.82rem;
}
.report-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.report-risk {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}
.risk-critical { background: #8b0000; }
.risk-high { background: #e74c3c; }
.risk-mid { background: #e67e22; }
.risk-low { background: #f1c40f; color: #333; }
.report-owasp {
    font-size: 0.75rem;
    color: #7f8c8d;
    flex: 1;
}
.report-del-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #bdc3c7;
    font-size: 0.8rem;
    padding: 0;
    line-height: 1;
}
.report-del-btn:hover { color: #e74c3c; }
.report-card-body {
    line-height: 1.5;
}
.report-card-body code {
    font-size: 0.78rem;
    background: #f5f7fa;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}
.report-desc {
    margin-top: 0.25rem;
    color: #555;
    white-space: pre-wrap;
}
.report-card-footer {
    margin-top: 0.35rem;
    font-size: 0.72rem;
    color: #b0b8bf;
    text-align: right;
}
.report-dialog-content {
    min-width: min(480px, 90vw);
}
.report-dialog-content header {
    margin-bottom: 0.5rem;
}
.report-dialog-content label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}
.report-dialog-content input,
.report-dialog-content select,
.report-dialog-content textarea {
    margin-bottom: 0.6rem;
}
.report-dialog-content footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.report-dialog-content footer button {
    width: auto;
    min-width: 5rem;
}

/* Phase RWD */
@media (max-width: 600px) {
    .phase-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }
    .phase-badge-group {
        align-self: flex-end;
    }
    .mission-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Legacy progress classes kept for leaderboard compatibility */
.version-hint {
    display: block;
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.2rem;
}
/* 解題 Toast 通知 */
.exploit-toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: #0d1117;
    color: #3fb950;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    border: 1px solid #1c2a3a;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Consolas', 'Fira Code', monospace;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 0 40px rgba(63,185,80,0.1);
    z-index: 100000;
    transform: translateX(120%);
    transition: transform 0.35s ease;
    max-width: 340px;
}
.exploit-toast.show {
    transform: translateX(0);
}
.exploit-toast .toast-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #58a6ff;
    margin-bottom: 0.15rem;
}
/* VPN Indicator */
.vpn-indicator {
    display: none;
}

/* Kali 終端機身份標示 */
.terminal-identity {
    font-size: 0.7rem;
    color: #aaa;
    margin-left: 0.5rem;
    font-weight: 400;
}

/* 報修紀錄列表 */
.repair-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.repair-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}
.repair-row:hover {
    background: var(--pico-card-background-color);
}
.repair-category {
    background: var(--pico-primary-background);
    color: var(--pico-primary-inverse);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    white-space: nowrap;
}
.repair-location-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.repair-reporter {
    color: var(--pico-muted-color);
    font-size: 0.8rem;
    white-space: nowrap;
}
.repair-status {
    font-size: 0.8rem;
    white-space: nowrap;
}
.repair-dialog-content {
    min-width: min(520px, 90vw);
}
.repair-dialog-content header {
    margin-bottom: 0.5rem;
}
