* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    width: 100%;
    font-family: var(--font-main);
    font-size: var(--text-base);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--surface-sunken);
}

::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    margin: 0 auto 0.75rem;
    border: 2px solid var(--line-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Workspace Layout */
.workspace-grid {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Control Panel (Resizable Sidebar) */
.control-panel {
    width: var(--sidebar-width, 440px);
    min-width: 320px;
    max-width: 800px;
    flex-shrink: 0;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    container-type: inline-size;
    container-name: sidebar;
    box-sizing: border-box;
}

/* Draggable Resizer Gutter */
.sidebar-resizer {
    width: 10px;
    margin-left: -5px;
    margin-right: -5px;
    z-index: 60;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    user-select: none;
    touch-action: none;
    transition: background-color 0.15s ease;
}

.sidebar-resizer:hover,
.sidebar-resizer.is-dragging {
    background-color: var(--tint-accent-strong);
}

.sidebar-resizer .resizer-handle {
    width: 4px;
    height: 36px;
    border-radius: 2px;
    background-color: var(--line-strong);
    transition: all 0.2s ease;
}

.sidebar-resizer:hover .resizer-handle,
.sidebar-resizer.is-dragging .resizer-handle {
    background-color: var(--accent-blue);
    height: 54px;
    box-shadow: none;
}

.visualizer-container {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-base);
    position: relative;
    overflow: hidden;
}

.mode-panel {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.mode-panel.active {
    display: flex;
}

.panel-card {
    background-color: var(--bg-surface-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
}

.card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin-bottom: 6px;
}

.card-header h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-primary);
    flex: 1 1 auto;
    min-width: 0;
}

.card-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Form Inputs */
.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-input,
.form-textarea {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.75rem;
    padding: 7px 10px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: none;
    outline: 2px solid var(--focus-ring);
    outline-offset: 1px;
}

.form-textarea {
    resize: vertical;
}

/* Presets */
.presets-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-item {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-item:hover {
    border-color: var(--accent-blue);
    background-color: var(--bg-surface-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
}

.preset-item.active {
    border-color: var(--accent-blue);
    background-color: var(--tint-accent-weak);
}

.preset-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.preset-name {
    font-size: 0.7812rem;
    font-weight: 600;
    color: var(--text-primary);
}

.preset-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.35;
    margin-bottom: 6px;
}

.preset-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.load-btn-text {
    color: var(--accent-blue);
    font-weight: 500;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border-highlight);
    border-radius: var(--radius-sm);
    padding: 18px 12px;
    text-align: center;
    cursor: pointer;
    background-color: var(--surface-sunken);
    transition: all 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent-blue);
    background-color: var(--tint-accent-weak);
}

.upload-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.dropzone-text {
    font-size: 0.75rem;
    color: var(--text-primary);
}

.dropzone-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
}

/* File Preview List */
.file-preview-list {
    margin-top: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.file-preview-list ul {
    list-style: none;
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.file-preview-list li {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-primary);
    padding: 3px 6px;
    border-radius: 4px;
    background: var(--tint-neutral-weak);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Instructions Header & Variant Selector */
.instructions-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.inst-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--surface-sunken);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.inst-tab-btn {
    padding: 5px 12px;
    font-size: var(--text-xs);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.inst-tab-btn:hover {
    color: var(--text);
}

.inst-tab-btn.active {
    background: var(--surface);
    color: var(--text);
}

.inst-variant-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.inst-variant-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.inst-variant-btn {
    padding: 4px 10px;
    font-size: var(--text-xs);
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-base);
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.inst-variant-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.inst-variant-btn.active {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
}

/* Instructions Preview Box (Teacher Studio) */
.instructions-preview-box {
    background-color: var(--bg-base);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-sm);
    padding: 10px;
    max-height: 380px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.instructions-preview-box pre {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
}

/* Rendered Instructions Container */
.instructions-rendered-view {
    color: var(--text);
    font-family: var(--font-main);
    font-size: var(--text-sm);
    line-height: 1.6;
}

.instructions-rendered-view .inst-h1 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text);
    margin: 1.125rem 0 0.625rem 0;
    line-height: 1.3;
}

.instructions-rendered-view .inst-h2 {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--accent);
    margin: 1.125rem 0 0.5rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--line);
    line-height: 1.3;
}

.instructions-rendered-view .inst-h3 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
    margin: 0.875rem 0 0.375rem 0;
    line-height: 1.3;
}

.instructions-rendered-view .inst-h4 {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0.75rem 0 0.25rem 0;
}

.instructions-rendered-view .inst-p {
    margin: 0.5rem 0;
    color: var(--text);
}

.instructions-rendered-view .inst-divider {
    border: none;
    border-top: 1px solid var(--line);
    margin: 1rem 0;
}

.instructions-rendered-view .inst-callout {
    border-left: 3px solid var(--accent);
    background: var(--tint-accent-weak);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 0.625rem 0.875rem;
    margin: 0.75rem 0;
    color: var(--text);
    font-size: var(--text-sm);
}

.instructions-rendered-view .inst-ul,
.instructions-rendered-view .inst-ol {
    margin: 0.5rem 0;
    padding-left: 1.375rem;
}

.instructions-rendered-view li {
    margin-bottom: 0.3125rem;
    line-height: 1.45;
}

.instructions-rendered-view .inst-code {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    background: var(--surface-sunken);
    color: var(--accent);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 1px 4px;
}

/* Responsive Table Wrapper & Styled Tables */
.instructions-table-wrap {
    overflow-x: auto;
    margin: 0.75rem 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

.instructions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
    text-align: left;
}

.instructions-table thead th {
    background: var(--surface-sunken);
    color: var(--text);
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--line-strong);
    white-space: nowrap;
}

.instructions-table tbody td {
    padding: 0.4375rem 0.75rem;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    vertical-align: middle;
}

.instructions-table tbody tr:nth-child(even) {
    background: var(--surface-sunken);
}

.instructions-table tbody tr:hover {
    background: var(--surface-raised);
}

/* Code Blocks & Mermaid Topology Previews */
.inst-code-box,
.inst-mermaid-box {
    margin: 0.75rem 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    overflow: hidden;
}

.inst-code-header,
.inst-mermaid-header {
    background: var(--surface);
    padding: 0.375rem 0.625rem;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.inst-code-lang {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.inst-code-block {
    margin: 0;
    padding: 0.625rem 0.75rem;
    background: transparent;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text);
    line-height: 1.45;
    overflow-x: auto;
    white-space: pre;
}

.instructions-raw-view pre,
pre.instructions-raw-txt {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
    margin: 0;
}

.card-actions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Criteria Info Box (Student Portal) */
.criteria-info-box {
    margin-top: 10px;
    background: var(--tint-ok-weak);
    border: 1px solid var(--tint-ok-strong);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.criteria-info-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 4px;
}

.criteria-info-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Score Hero Banner */
.score-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
}

.score-pct-badge {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-green);
    color: var(--on-accent);
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    flex-shrink: 0;
}

.score-pct-badge.pct-low {
    background: var(--accent-red);
    box-shadow: none;
}

.score-pct-badge.pct-mid {
    background: var(--accent-amber);
    box-shadow: none;
}

.score-details {
    flex: 1;
    min-width: 0;
}

.score-points {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.score-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.score-progress-bar {
    height: 6px;
    background-color: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.score-progress-fill {
    height: 100%;
    background-color: var(--accent-green);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.score-progress-fill.fill-red {
    background-color: var(--accent-red);
}

.score-progress-fill.fill-amber {
    background-color: var(--accent-amber);
}

.score-meta-counts {
    display: flex;
    gap: 8px;
}

/* Report Filters Row */
.report-filters-row {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.filter-chip {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-chip:hover {
    color: var(--text-primary);
    border-color: var(--border-highlight);
}

.filter-chip.active {
    background: var(--accent-blue);
    color: var(--on-accent);
    border-color: var(--accent-blue);
}

/* Itemized Report Checklist */
.report-results-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
}

.rule-result-card {
    background-color: var(--tint-ok-weak);
    border: 1px solid var(--tint-ok-strong);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 0.75rem;
}

.rule-result-card.failed {
    background-color: var(--tint-bad-weak);
    border-color: var(--tint-bad-strong);
}

.rule-res-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.rule-res-desc {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    margin-right: 8px;
}

.rule-res-pts {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-green);
    white-space: nowrap;
}

.rule-result-card.failed .rule-res-pts {
    color: var(--accent-red);
}

.rule-res-feedback {
    color: var(--text-secondary);
    line-height: 1.35;
    margin-top: 2px;
}

.rule-result-card.failed .rule-res-feedback {
    color: var(--status-bad);
}

.rule-res-actual {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--surface-sunken);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--text);
    display: inline-block;
    margin-top: 4px;
}

/* Conflict Items List */
.conflict-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
}

.conflict-item-card {
    background-color: var(--tint-bad-weak);
    border: 1px solid var(--tint-bad-strong);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.conflict-item-card.warning {
    background-color: var(--tint-warn-weak);
    border-color: var(--tint-warn-strong);
}

.conflict-item-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--status-bad);
    margin-bottom: 3px;
}

.conflict-item-card.warning .conflict-item-title {
    color: var(--status-warn);
}

.conflict-item-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.35;
    margin-bottom: 4px;
}

.evidence-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--surface-sunken);
    padding: 2px 5px;
    border-radius: 3px;
    color: var(--text);
    display: block;
    margin-top: 2px;
}

/* Visualizer Container */
.visualizer-container {
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-base);
    height: 100%;
    min-height: 0;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* Visualizer Header Bar */
.visualizer-header {
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    flex-shrink: 0;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
    z-index: 10;
}

.canvas-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    overflow: hidden;
}

.canvas-title {
    font-size: 0.7812rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.graph-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.green {
    background-color: var(--accent-green);
}

.legend-dot.amber {
    background-color: var(--accent-amber);
}

.legend-dot.red {
    background-color: var(--accent-red);
}

/* Cable key floats over the map; shown only once a drawn link has a known cable. */
.cable-legend {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 6px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    pointer-events: none;
}

/* Canvas Notes & Labels placed inside the topology SVG */
.graph-canvas-note {
    user-select: none;
    transition: opacity var(--transition-fast);
}

.graph-canvas-note:hover rect:first-child {
    stroke-opacity: 0.85;
}

.canvas-label-chip {
    display: inline-block;
    padding: 2px 7px;
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    color: var(--text);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
}

.topology-svg:not([data-cables])~.cable-legend {
    display: none;
}

/* Cable swatches mirror how topology.js strokes each cable kind. */
.legend-line {
    width: 18px;
    height: 0;
    border-top: 2.5px solid var(--map-link-ok);
}

.legend-line.crossover {
    border-top-style: dashed;
}

.legend-line.console {
    border-top-color: var(--map-link-console);
}

/* Canvas Actions & Toggles (strictly flex row, no wrap) */
.canvas-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.toggle-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 9px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

.toggle-btn:hover {
    color: var(--text-primary);
    background: var(--tint-neutral-mid);
}

.toggle-btn.active {
    background: var(--accent-blue);
    color: var(--on-accent);
    font-weight: 600;
    box-shadow: none;
}

.toggle-icon {
    font-size: 0.75rem;
}

/* SVG Badge Styles for Ports and IPs */
.port-label-badge {
    pointer-events: none;
    user-select: none;
}

.port-label-badge text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    fill: var(--map-port);
}

.port-label-badge rect {
    fill: var(--map-badge-bg);
    stroke: var(--accent);
    stroke-width: 1px;
    rx: 3px;
    ry: 3px;
}

.ip-label-badge {
    pointer-events: none;
    user-select: none;
}

.ip-label-badge text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    fill: var(--map-ip);
}

.ip-label-badge rect {
    fill: var(--map-badge-bg);
    stroke: var(--status-ok);
    stroke-width: 1px;
    rx: 3px;
    ry: 3px;
}

/* Canvas Viewport */
.canvas-viewport {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: var(--surface-sunken);
}

.topology-svg {
    width: 100%;
    height: 100%;
    cursor: grab;
    display: block;
    user-select: none;
}

.topology-svg:active {
    cursor: grabbing;
}

/* Node hostname labels outline for maximum contrast */
.node-hostname-label {
    paint-order: stroke fill;
    stroke: var(--surface-sunken);
    stroke-width: 3px;
    stroke-linejoin: round;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    fill: var(--text);
    pointer-events: none;
    user-select: none;
}

/* Empty State */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    max-width: 380px;
    padding: 20px;
    pointer-events: none;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Diagnostic Drawer */
.diagnostic-drawer {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 440px;
    max-height: calc(100% - 24px);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    z-index: 50;
    animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.drawer-header {
    padding: 12px 14px;
    background-color: var(--bg-surface-subtle);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-title-group {
    min-width: 0;
    overflow: hidden;
}

.drawer-badge {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 2px 5px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 3px;
}

.drawer-title-group h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1;
}

.drawer-close-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-hover);
}

.drawer-body {
    padding: 14px;
    overflow-y: auto;
    font-size: 0.75rem;
    max-height: 400px;
}

.diag-section {
    margin-bottom: 14px;
}

.diag-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.signal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface-subtle);
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 5px;
    font-size: 0.75rem;
}

.signal-type {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

.signal-weight {
    color: var(--accent-green);
    font-weight: 700;
}

/* Badges & Buttons */
.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-green {
    background-color: var(--tint-ok-mid);
    color: var(--accent-green);
    border: 1px solid var(--tint-ok-strong);
}

.badge-red {
    background-color: var(--tint-bad-mid);
    color: var(--accent-red);
    border: 1px solid var(--tint-bad-strong);
}

.badge-amber {
    background-color: var(--tint-warn-mid);
    color: var(--accent-amber);
    border: 1px solid var(--tint-warn-strong);
}

.badge-blue {
    background-color: var(--tint-accent-mid);
    color: var(--accent-blue);
    border: 1px solid var(--tint-accent-strong);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    font-family: var(--font-main);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    user-select: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: none;
}

.btn-primary:hover {
    background: var(--accent-strong);
    box-shadow: none;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-highlight);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.btn-sm {
    padding: 4px 9px;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-text:hover {
    color: var(--accent-red);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 68px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background-color: var(--bg-surface);
    border: 1px solid var(--accent-green);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    animation: toastFadeIn 0.2s ease;
}

@keyframes toastFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Policy Control Center Styling */
.policy-control-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-card);
}

.policy-panel-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.policy-title-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.policy-header-title {
    font-weight: 700;
    font-size: 0.7812rem;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.policy-badge-info {
    font-size: 0.75rem;
    background: var(--tint-ok-mid);
    color: var(--accent-green);
    border: 1px solid var(--tint-ok-strong);
    padding: 2px 7px;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.policy-profile-quickbar {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.policy-profile-btn {
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-highlight);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.policy-profile-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--line-strong);
}

.policy-profile-btn.active {
    background: var(--tint-accent-mid);
    border-color: var(--accent-blue);
    color: var(--accent);
    font-weight: 600;
    box-shadow: none;
}

.policy-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.policy-group-card {
    background: var(--tint-neutral-weak);
    border: 1px solid var(--tint-neutral-mid);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.2s ease;
}

.policy-group-card:hover {
    border-color: var(--tint-neutral-strong);
}

.policy-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.policy-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.policy-group-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--tint-neutral-weak);
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.policy-group-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Clean Full-Width Toggle Rows with Right-Aligned Switches */
.toggle-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 8px;
    background: var(--surface-sunken);
    border: 1px solid var(--tint-neutral-weak);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.toggle-control:hover {
    background: var(--tint-neutral-weak);
    border-color: var(--tint-accent-strong);
}

.toggle-control:active {
    transform: scale(0.99);
}

.toggle-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.toggle-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.toggle-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
    display: block;
}

.toggle-switch-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.toggle-switch-wrapper input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 19px;
    background-color: var(--line-strong);
    border-radius: 20px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--tint-neutral-strong);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 13px;
    width: 13px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text);
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-card);
}

.toggle-switch-wrapper input:checked+.toggle-slider {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: none;
}

.toggle-switch-wrapper input:checked+.toggle-slider:before {
    transform: translateX(15px);
}

.toggle-control:focus-within .toggle-slider {
    box-shadow: 0 0 0 2px var(--accent-blue);
}

/* ============================================================
   Batch Grading & Gradebook Export
   ============================================================ */
/* Hints everywhere (sections, activities, attempts), not only in the batch card. */
.form-hint,
.batch-card .form-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.batch-results {
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.batch-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.batch-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    background: var(--surface-raised);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.batch-stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.batch-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-top: 2px;
    text-align: center;
}

.batch-stat-error .batch-stat-value {
    color: var(--status-bad);
}

.batch-table-wrap {
    max-height: 560px;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.batch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.batch-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-raised);
    text-align: left;
    padding: 8px 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.batch-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.batch-table tbody tr:last-child td {
    border-bottom: none;
}

.batch-student {
    font-weight: 600;
}

.batch-pct {
    font-variant-numeric: tabular-nums;
}

.batch-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.batch-row-error {
    background: var(--tint-bad-weak);
}

.batch-row-error .batch-status {
    color: var(--status-bad);
}

.batch-row-missing {
    color: var(--text-muted);
}

.batch-student-number {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.gradebook-overview-btn {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    font-weight: normal;
}

.section-overview-title {
    margin: 0 0 10px;
}

@media (max-width: 520px) {
    .batch-status {
        display: none;
    }

    .batch-table thead th:nth-child(5) {
        display: none;
    }
}

/* Per-student review: "where did this student go wrong?" */
.batch-review-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.batch-review-toolbar .form-hint {
    margin-top: 0;
}

.batch-review-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.batch-review-cell {
    white-space: nowrap;
}

.batch-review-btn {
    padding: 3px 8px;
    font-size: 0.75rem;
}

.batch-row-open td {
    background: var(--tint-accent-weak);
}

.batch-table tbody tr.batch-detail-row td {
    padding: 0;
    background: var(--bg-base);
}

.batch-review {
    padding: 12px;
    border-left: 3px solid var(--accent-blue);
    /* Never wider than the visible table area, even when the table itself
       scrolls sideways in a narrow left panel. */
    box-sizing: border-box;
    max-width: 100cqw;
    position: sticky;
    left: 0;
}

/* The left panel is often narrow on a wide screen, so size columns by the
   table's own width, not the viewport's. */
.batch-table-wrap {
    container-type: inline-size;
}

@container (max-width: 460px) {

    .batch-status,
    .batch-table thead th:nth-child(5) {
        display: none;
    }
}

.batch-review-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.batch-review-title {
    font-weight: 700;
    color: var(--status-bad);
}

.batch-review-title.ok {
    color: var(--status-ok);
}

.batch-review-topics {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.batch-review-label {
    font-weight: 600;
}

.batch-review-cost {
    color: var(--status-bad);
    font-variant-numeric: tabular-nums;
}

.batch-review-device+.batch-review-device {
    margin-top: 10px;
}

.batch-review-device-name {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.batch-review-device-count {
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--status-bad);
}

.batch-review-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Map: devices where the reviewed student made mistakes */
.node-mistake-ring {
    fill: none;
    stroke: var(--status-bad);
    stroke-width: 3;
    stroke-dasharray: 6 4;
}

/* Failure and diagnostic text inside the topology panel */
.empty-state .empty-error {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--tint-bad-weak);
    border: 1px solid var(--tint-bad-strong);
    color: var(--status-bad);
    font-size: 0.82rem;
    max-width: 460px;
    text-align: left;
    word-break: break-word;
}

.empty-state .empty-hint {
    margin-top: 10px;
    max-width: 460px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.empty-state .empty-hint code {
    background: var(--bg-base);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.92em;
}

/* ============================================================
   Pedagogical Guidance & Study Topics
   ============================================================ */
.rule-res-guidance {
    margin-top: 8px;
    padding: 9px 11px;
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
    background: var(--tint-accent-weak);
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.rule-res-guidance .guidance-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
}

.report-study-topics {
    margin: 12px 0 14px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-raised);
}

.study-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.study-topic {
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

.study-topic:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.study-topic-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.study-topic-name {
    font-weight: 600;
    font-size: 0.83rem;
    color: var(--text-primary);
}

.study-topic-cost {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--status-bad);
}

.study-topic-why {
    margin-top: 3px;
    font-size: 0.76rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.study-topic-count {
    margin-top: 3px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================================
   Narrative Layer (student summary & class briefing)
   ============================================================ */
.report-narrative,
.batch-briefing {
    margin: 12px 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--tint-accent-weak);
}

.narrative-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.narrative-src {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid transparent;
}

/* The badge is deliberately honest about who wrote the text. */
.narrative-src.model {
    color: var(--map-host);
    background: var(--tint-host-mid);
    border-color: var(--tint-host-strong);
}

.narrative-src.template {
    color: var(--text-muted);
    background: var(--tint-neutral-strong);
    border-color: var(--tint-neutral-strong);
}

.narrative-text {
    margin: 0;
    font-size: 0.83rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.narrative-loading {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

.concept-list {
    margin-top: 10px;
    border-top: 1px solid var(--line);
    padding-top: 8px;
}

.concept-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    font-size: 0.78rem;
}

.concept-name {
    color: var(--text-secondary);
}

.concept-count {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

/* ============================================================
   Local AI status indicator (header)
   ============================================================ */
.ai-status-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    color: var(--text-secondary);
    background: var(--tint-neutral-mid);
    border: 1px solid var(--tint-neutral-strong);
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.ai-status-indicator[data-state="ready"] {
    color: var(--map-host);
    background: var(--tint-host-weak);
    border-color: var(--tint-host-strong);
}

.ai-status-indicator[data-state="ready"] .ai-status-dot {
    background: var(--map-host);
}

.ai-status-indicator[data-state="missing"] {
    color: var(--accent-amber);
    background: var(--tint-warn-weak);
    border-color: var(--tint-warn-strong);
}

.ai-status-indicator[data-state="missing"] .ai-status-dot {
    background: var(--accent-amber);
}

.ai-status-indicator[data-state="checking"] .ai-status-dot {
    animation: ai-blink 1s infinite;
}

@keyframes ai-blink {
    50% {
        opacity: 0.3;
    }
}

/* ============================================================
   Follow-up chat
   ============================================================ */
.ai-chat {
    margin: 12px 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--tint-host-strong);
    border-radius: 10px;
    background: var(--tint-host-weak);
}

.ai-chat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.ai-chat-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.ai-chat-log:not(:empty) {
    margin-bottom: 10px;
}

.ai-msg {
    max-width: 92%;
    padding: 8px 11px;
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-msg-user {
    align-self: flex-end;
    background: var(--accent-blue);
    color: var(--on-accent);
    border-bottom-right-radius: 3px;
}

.ai-msg-assistant {
    align-self: flex-start;
    background: var(--bg-surface-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 3px;
}

.ai-msg-pending {
    align-self: flex-start;
    color: var(--text-muted);
    font-style: italic;
}

.ai-msg-error {
    align-self: stretch;
    max-width: none;
    color: var(--status-bad);
    background: var(--tint-bad-weak);
    border: 1px solid var(--tint-bad-strong);
}

.ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.ai-chat-chip {
    font: inherit;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    color: var(--map-host);
    background: var(--tint-host-weak);
    border: 1px solid var(--tint-host-strong);
}

.ai-chat-chip:hover:not(:disabled) {
    background: var(--tint-host-mid);
}

.ai-chat-chip:disabled {
    opacity: 0.5;
    cursor: default;
}

.ai-chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    min-width: 0;
    resize: vertical;
    font: inherit;
    font-size: 0.8rem;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-primary);
    background: var(--bg-base);
    border: 1px solid var(--border-highlight);
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--map-host);
}

.ai-chat-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-note {
    margin-top: 8px;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.ai-chat-note-off {
    color: var(--accent-amber);
}

/* Batch table: names under Highest / Lowest, and sortable headers */
.batch-stat-who {
    margin-top: 4px;
    font-size: 0.75rem;
    line-height: 1.3;
    text-align: center;
    color: var(--text-secondary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.batch-sort {
    font: inherit;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    white-space: nowrap;
}

.batch-sort:hover {
    color: var(--text-primary);
}

.batch-sort.active {
    color: var(--accent-blue);
}

.batch-sort[data-dir="asc"]::after {
    content: " \25B2";
    font-size: 0.75rem;
}

.batch-sort[data-dir="desc"]::after {
    content: " \25BC";
    font-size: 0.75rem;
}

/* Grading weights panel (Teacher Studio) */
.weights-panel {
    margin: 12px 0 16px;
    padding: 14px;
    background-color: var(--bg-surface-subtle);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.weights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.weights-title {
    font-weight: 600;
    color: var(--text-primary);
}

.weights-total {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent-green);
}

.weights-total.is-off {
    color: var(--accent-red);
}

.weights-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Two lines per topic: the Teacher Studio column is narrow even on desktop. */
.weight-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto auto;
    grid-template-areas: "topic topic topic topic" "input bar points focus";
    align-items: center;
    gap: 4px 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.weight-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.weight-topic {
    grid-area: topic;
}

.weight-input {
    grid-area: input;
}

.weight-range {
    grid-area: bar;
}

.weight-points {
    grid-area: points;
}

.weight-focus {
    grid-area: focus;
}

.weight-row.is-zero .weight-label {
    color: var(--text-muted);
}

.weight-topic {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.weight-label {
    color: var(--text-primary);
    font-weight: 500;
}

.weight-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.weight-input {
    width: 76px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.weight-range {
    width: 100%;
    min-width: 0;
    margin: 0;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.weight-points {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.weights-detected,
.weights-warnings,
.weights-error {
    margin-top: 12px;
    font-size: 0.85rem;
}

.weights-detected {
    color: var(--text-secondary);
}

.weights-detected-title {
    color: var(--text-muted);
    margin-right: 4px;
}

.weights-chip {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 2px 8px;
    border: 1px solid var(--border-highlight);
    border-radius: 999px;
}

.weights-warnings {
    color: var(--accent-amber);
}

.weights-error {
    color: var(--accent-red);
}

.weights-stale {
    margin-bottom: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
    color: var(--accent-amber);
    background-color: var(--accent-amber-glow);
    border-radius: 6px;
}

.weights-actions {
    margin-top: 14px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 400px) {
    .weight-row {
        grid-template-columns: 76px minmax(0, 1fr) auto;
        grid-template-areas: "topic topic topic" "input bar focus";
    }

    .weight-points {
        display: none;
    }
}

/* --- Accounts, activities and grades (spec 2026-11-08) --- */
/* Sign-in page: same navbar, switcher and panel cards as the app. The app shell
   locks html/body scrolling; this page must scroll. */
.form-error {
    color: var(--status-bad);
    font-size: 0.85rem;
    min-height: 1em;
}

.user-badge {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-right: 8px;
}

.inline-form {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.join-code {
    font-family: monospace;
    letter-spacing: 0.15em;
    font-size: 1.1rem;
}

.activity-list {
    display: grid;
    gap: 10px;
}

.activity-card,
.activity-row {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: left;
    background: transparent;
    color: inherit;
}

.activity-row {
    cursor: pointer;
}

.activity-head {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.checkbox-inline {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin: 6px 10px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.attempt-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.grade-grid td,
.grade-grid th {
    white-space: nowrap;
}

.grade-empty {
    opacity: 0.5;
}

a.btn {
    text-decoration: none;
}

.student-add-form {
    margin: 12px 0;
}

.student-add-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto;
    gap: 8px;
    align-items: end;
}

.student-add-row .form-group {
    margin-bottom: 0;
}

.student-add-row .btn {
    height: 34px;
}

@media (max-width: 520px) {
    .student-add-row {
        grid-template-columns: 1fr;
    }
}

.topic-progress {
    margin: 10px 0;
}

.topic-progress-label {
    font-weight: 600;
    margin-bottom: 4px;
}

.topic-bar-row {
    display: grid;
    grid-template-columns: 1fr 2fr 3.5rem;
    gap: 8px;
    align-items: center;
    font-size: 0.85rem;
}

.topic-bar {
    height: 8px;
    background: var(--tint-neutral-mid);
    border-radius: 4px;
    overflow: hidden;
}

.topic-bar-fill {
    display: block;
    height: 100%;
    background: var(--accent);
}

.sub-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.sub-tab.active {
    border-color: var(--accent);
}

/* Shown by boot-check.js when the app could not start. */
.unsupported-browser {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    padding: 12px 16px;
    border-radius: 10px;
    border-radius: var(--radius-md);
    background: red;
    background: var(--status-bad);
    color: white;
    color: var(--on-accent);
    font-size: 1rem;
    z-index: 1000;
}

.dropzone-accepts {
    display: block;
    margin-top: 0.25rem;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    font-size: var(--text-xs);
    font-weight: 600;
    flex: none;
}

.upload-icon .icon {
    width: 1.75rem;
    height: 1.75rem;
    color: var(--accent);
}

.empty-icon .icon {
    width: 3rem;
    height: 3rem;
    color: var(--text-muted);
}

.card-icon .icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* Close report: back to the student's activity list and upload step. */
.report-back-btn {
    margin-bottom: 12px;
}

/* Sidebar Responsive Container Adaptations (Narrow Sidebar Resilience) */
@container sidebar (max-width: 380px) {
    .panel-card {
        padding: 10px;
    }

    .card-header {
        gap: 4px 6px;
    }

    .card-header .badge {
        font-size: var(--text-xs);
        padding: 1px 6px;
    }

    .policy-control-panel {
        padding: 10px;
    }

    .policy-profile-quickbar {
        gap: 4px;
    }

    .policy-profile-btn {
        flex: 1 1 calc(50% - 4px);
        text-align: center;
        padding: 4px 6px;
    }

    .policy-group-card {
        padding: 6px 8px;
    }

    .toggle-control {
        padding: 5px 6px;
        gap: 6px;
    }

    .toggle-title {
        font-size: var(--text-xs);
    }

    .toggle-desc {
        font-size: 0.75rem;
    }

    .inst-tabs {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .inst-tab-btn {
        width: 100%;
        text-align: center;
        padding: 6px 8px;
    }

    .inst-variant-group {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .inst-variant-btn {
        padding: 4px 6px;
        font-size: var(--text-xs);
        flex: 1 1 auto;
        text-align: center;
    }

    .card-actions-row .btn {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
        text-align: center;
    }

    .weight-row {
        grid-template-columns: 68px minmax(0, 1fr) auto;
        grid-template-areas:
            "topic topic points"
            "input bar focus";
        gap: 4px 6px;
    }

    .weight-input {
        width: 68px;
    }

    .weight-points {
        text-align: right;
    }

    .weights-actions .btn {
        flex: 1 1 calc(50% - 4px);
        text-align: center;
        justify-content: center;
    }

    .weights-actions #teacher-finalize-btn {
        flex: 1 1 100%;
    }

    .student-add-row {
        grid-template-columns: 1fr;
    }

    .topic-bar-row {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "label pct"
            "bar bar";
        gap: 4px 6px;
    }

    .topic-progress-label {
        grid-area: label;
    }

    .topic-bar {
        grid-area: bar;
    }

    .dropzone {
        padding: 12px 8px;
    }
}

@container sidebar (max-width: 340px) {
    .card-actions-row .btn {
        flex: 1 1 100%;
        width: 100%;
    }

    .weights-actions .btn {
        flex: 1 1 100%;
        width: 100%;
    }
}