* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #142033;
    background:
        radial-gradient(circle at 12% 10%, rgba(62, 129, 246, .18), transparent 34%),
        radial-gradient(circle at 88% 5%, rgba(20, 184, 166, .16), transparent 30%),
        linear-gradient(135deg, #eef6ff 0%, #f7fbff 45%, #eaf7f4 100%);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(460px, 100%);
    display: grid;
    gap: 16px;
    padding: 28px;
    border: 1px solid rgba(119, 145, 185, .3);
    border-radius: 22px;
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 24px 80px rgba(37, 60, 102, .16);
    backdrop-filter: blur(18px);
}

.login-card h1 {
    margin-bottom: 0;
    font-size: 32px;
}

.login-card label {
    display: grid;
    gap: 7px;
    color: #475569;
    font-size: 13px;
    font-weight: 800;
}

.login-card input {
    width: 100%;
    min-height: 48px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 0 14px;
    color: #142033;
    background: rgba(248, 250, 252, .92);
    font: inherit;
    font-weight: 700;
}

.login-card input:focus {
    border-color: #2563eb;
    outline: 3px solid rgba(37, 99, 235, .16);
}

.login-meta {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border: 1px dashed rgba(37, 99, 235, .32);
    border-radius: 12px;
    background: rgba(239, 246, 255, .72);
}

.login-meta span {
    color: #64748b;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.login-meta strong {
    color: #0f3f91;
    overflow-wrap: anywhere;
}

.login-submit {
    width: 100%;
    margin-top: 4px;
}

button,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: .65;
}

.workspace-shell {
    display: grid;
    grid-template-columns: minmax(420px, 34vw) minmax(620px, 1fr);
    gap: 18px;
    min-height: 100vh;
    padding: 22px;
}

.tool-rail,
.import-surface {
    border: 1px solid rgba(119, 145, 185, .28);
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 22px 70px rgba(37, 60, 102, .12);
    backdrop-filter: blur(18px);
}

.tool-rail {
    border-radius: 22px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100vh - 44px);
    max-height: calc(100vh - 44px);
    overflow: hidden;
}

.tool-rail > div:first-of-type {
    display: grid;
    grid-template-columns: 54px 1fr;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #fff;
    font-weight: 900;
    letter-spacing: .04em;
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    box-shadow: 0 18px 38px rgba(37, 99, 235, .24);
}

.eyebrow {
    margin: 0 0 7px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #2563eb;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: 25px;
    line-height: 1.05;
}

h2 {
    margin-bottom: 0;
    font-size: 30px;
}

h3 {
    margin-bottom: 4px;
    font-size: 18px;
}

.muted,
.panel-title p {
    color: #64748b;
}

.muted {
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.35;
}

.tool-menu {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.tool-rail .tool-menu {
    display: none;
}

.tool-menu button {
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 10px;
    min-height: 58px;
    padding: 9px;
    color: #1e293b;
    background: rgba(241, 245, 249, .78);
}

.tool-menu button.active {
    border-color: rgba(37, 99, 235, .35);
    background: #eaf2ff;
    color: #0f3f91;
}

.tool-menu span {
    display: block;
    font-size: 13px;
    font-weight: 800;
}

.tool-menu small {
    color: #64748b;
    display: block;
    font-size: 11px;
    line-height: 1.2;
    margin-top: 4px;
}

.workspace-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.workspace-tabs button {
    min-height: 58px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: left;
    color: #475569;
    background: rgba(248, 250, 252, .86);
}

.workspace-tabs button.active {
    color: #0f3f91;
    border-color: rgba(37, 99, 235, .42);
    background: #eaf2ff;
}

.workspace-tabs span {
    display: block;
    color: inherit;
    font-size: 14px;
    font-weight: 900;
}

.workspace-tabs small {
    display: block;
    margin-top: 5px;
    color: #64748b;
    font-size: 12px;
}

.import-type-tabs {
    margin: 16px 20px 0;
}

.question-management-panel {
    display: grid;
    gap: 14px;
    margin-top: 18px;
    min-height: 0;
}

.management-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 12px;
    background: rgba(248, 250, 252, .82);
}

.management-header-row h2 {
    margin-bottom: 4px;
    font-size: 22px;
}

.management-header-row span {
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}

.management-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.content-tabs {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    border-bottom: 1px solid #cbd5e1;
    overflow-x: auto;
    padding: 0 2px;
}

.content-tabs button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 138px;
    min-height: 46px;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px;
    padding: 10px 13px;
    color: #475569;
    background: transparent;
}

.content-tabs button.active {
    color: #0f3f91;
    border-color: #cbd5e1;
    border-top-color: rgba(37, 99, 235, .55);
    border-bottom-color: #fff;
    background: #fff;
    box-shadow: 0 -2px 0 #2563eb inset;
}

.content-tabs span {
    overflow: hidden;
    font-size: 13px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content-tabs strong {
    display: grid;
    min-width: 24px;
    min-height: 24px;
    place-items: center;
    border-radius: 999px;
    color: #172554;
    background: #f1f5f9;
    font-size: 13px;
    font-weight: 900;
}

.content-tabs button.active strong {
    color: #fff;
    background: #2563eb;
}

.tab-action-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.management-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.management-stats article {
    min-height: 78px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 14px;
    background: #fff;
}

.management-stats span {
    display: block;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.management-stats strong {
    display: block;
    margin-top: 4px;
    color: #0f3f91;
    font-size: 26px;
}

.management-list {
    display: grid;
    gap: 10px;
    overflow: auto;
    max-height: calc(100vh - 355px);
    padding-right: 4px;
}

.question-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: max-content;
    align-items: stretch;
}

.management-card {
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 14px;
    background: #fff;
}

.question-list-item header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}

.question-list-item {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
}

.question-list-item .pill-row {
    padding-right: 4px;
}

.question-card-html {
    margin: 0;
    color: #172554;
    font-size: 15px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.question-card-html p,
.question-card-html ul,
.question-card-html ol,
.question-card-html blockquote {
    margin: 0 0 8px;
}

.question-card-html p:last-child,
.question-card-html ul:last-child,
.question-card-html ol:last-child,
.question-card-html blockquote:last-child {
    margin-bottom: 0;
}

.question-card-html img,
.question-card-html table,
.question-card-html video,
.question-card-html iframe {
    max-width: 100%;
}

.material-list-item header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}

.material-list-item h3 {
    margin: 0 0 8px;
    color: #172554;
    font-size: 16px;
    line-height: 1.35;
}

.material-list-item p {
    margin: 0;
    color: #475569;
    font-size: 14px;
    line-height: 1.45;
}

.material-url {
    margin-bottom: 8px !important;
    color: #2563eb !important;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.topic-material-modal {
    width: min(1480px, calc(100vw - 44px));
    height: min(920px, calc(100vh - 44px));
}

.topic-material-editor {
    display: grid;
    gap: 16px;
}

.topic-title-field {
    display: grid;
    gap: 7px;
}

.topic-title-field input {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0 12px;
    color: #142033;
    background: #fff;
    font: inherit;
}

.topic-editor-tabs {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    border-bottom: 1px solid #cbd5e1;
}

.topic-editor-tabs button {
    min-height: 42px;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px;
    padding: 0 18px;
    color: #475569;
    background: transparent;
    font-weight: 900;
}

.topic-editor-tabs button.active {
    color: #0f3f91;
    border-color: #cbd5e1;
    border-top-color: rgba(37, 99, 235, .55);
    border-bottom-color: #fff;
    background: #fff;
    box-shadow: 0 -2px 0 #2563eb inset;
}

.topic-editor-pane {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.topic-editor-pane > header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.topic-editor-pane h3,
.topic-editor-pane p {
    margin: 0;
}

.topic-editor-pane p {
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}

.topic-html-source {
    min-height: 460px;
    border-radius: 10px;
}

.topic-preview-box {
    display: grid;
    gap: 8px;
    min-height: 220px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 14px;
    background: #fff;
}

.topic-preview-box h4 {
    margin: 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.topic-preview-box div {
    min-width: 0;
    color: #142033;
    overflow-wrap: anywhere;
}

.topic-preview-box img,
.topic-preview-box table,
.topic-preview-box video,
.topic-preview-box iframe {
    max-width: 100%;
}

.addmaterial-topic-card {
    margin: 16px 0;
    padding: 32px 34px;
    border-radius: 18px;
    color: #fff;
    background: linear-gradient(135deg, #493066 0%, #245f78 52%, #158b7f 100%);
    box-shadow: 0 18px 46px rgba(15, 23, 42, .18);
}

.addmaterial-topic-card > div:first-child {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    margin: 0 0 16px;
    padding: 8px 15px;
    border: 1px solid rgba(255, 255, 255, .36);
    border-radius: 999px;
    color: #fff;
    background: rgba(255, 255, 255, .16);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.15;
}

.addmaterial-topic-card h2 {
    margin: 0 0 14px;
    color: #fff;
    font-size: 46px;
    font-weight: 900;
    line-height: 1.05;
}

.addmaterial-topic-card p {
    margin: 0;
    color: #eef6ff;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.65;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.management-card-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.quick-node-choice,
.quick-correct-choice {
    display: grid;
    grid-template-columns: auto 62px;
    align-items: center;
    gap: 6px;
}

.quick-node-choice {
    grid-template-columns: auto minmax(160px, 240px);
}

.quick-node-choice span,
.quick-correct-choice span {
    margin: 0;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.quick-node-choice select,
.quick-correct-choice select {
    width: 62px;
    min-height: 34px;
    border-radius: 8px;
    padding: 0 8px;
    font-size: 13px;
    font-weight: 900;
}

.quick-node-choice select {
    width: 100%;
}

.edit-icon-button {
    display: inline-grid;
    place-items: center;
    min-height: 42px;
    width: 46px;
    border-radius: 10px;
    color: #172554;
    line-height: 1;
}

.edit-icon-button .bi {
    font-size: 18px;
}

.management-empty {
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 22px;
    color: #64748b;
    background: rgba(248, 250, 252, .8);
    font-weight: 800;
}

.node-settings-panel {
    display: grid;
    gap: 16px;
    max-width: 940px;
}

.node-settings-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 14px 16px;
    background: #fff;
}

.node-settings-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.node-settings-actions .ghost-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.node-settings-toolbar h3 {
    margin: 0;
    color: #172554;
    font-size: 18px;
    font-weight: 900;
}

.node-settings-toolbar span {
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
}

.node-settings-form {
    display: grid;
    gap: 12px;
}

.node-settings-form label {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    min-height: 48px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

.node-settings-form label > span {
    color: #172554;
    font-size: 13px;
    font-weight: 900;
}

.node-settings-form input,
.node-settings-form select,
.node-settings-form textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    color: #0f172a;
    background: #fff;
    font-weight: 700;
}

.node-settings-form textarea {
    min-height: 92px;
    resize: vertical;
}

.node-settings-form .node-settings-html {
    min-height: 150px;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 13px;
}

.node-settings-form .toggle-settings-field {
    grid-template-columns: minmax(160px, 220px) 24px;
    justify-content: start;
}

.node-settings-form .toggle-settings-field input {
    width: 20px;
    min-height: 20px;
    accent-color: #2563eb;
}

.material-placeholder {
    min-height: 280px;
    display: grid;
    place-items: center;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 28px;
    color: #64748b;
    background: rgba(248, 250, 252, .72);
    text-align: center;
}

.material-placeholder h3 {
    color: #172554;
}

.import-surface,
.log-panel {
    border-radius: 24px;
    padding: 22px;
}

.curriculum-tree-panel {
    border: 1px solid rgba(119, 145, 185, .34);
    border-radius: 14px;
    background: rgba(255, 255, 255, .78);
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 14px;
}

.panel-title.compact {
    align-items: flex-start;
}

.tree-exam-select {
    display: block;
    margin-bottom: 12px;
}

.tree-empty {
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    color: #64748b;
    padding: 14px;
    background: #f8fafc;
}

.selected-node-chip {
    max-width: 360px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #172554;
    background: #fff;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button {
    min-height: 34px;
    width: 38px;
    padding: 0;
}

.tree-view {
    color: #172554;
    flex: 1 1 auto;
    list-style: none;
    margin: 0;
    overflow: auto;
    padding: 4px 4px 8px 0;
}

.tree-view-branch {
    border-left: 1px solid #dbeafe;
    margin-left: 1.17rem;
    overflow: visible;
    padding-left: .2rem;
}

.tree-view-item {
    margin: .08rem 0;
}

.tree-view-row {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #172554;
    display: flex;
    flex-direction: row;
    gap: .45rem;
    min-height: 2.35rem;
    padding: .25rem .45rem;
    transition: background .16s ease, border-color .16s ease;
}

.tree-view-row:hover {
    background: #f0f9ff;
    border-color: #dbeafe;
}

.tree-view-row.active {
    background: #eef4ff;
    border-color: #7aa2ff;
    color: #0f172a;
}

.tree-view-row.group-node .tree-view-label span {
    font-weight: 700;
}

.tree-view-toggle,
.tree-view-label {
    background: transparent;
    border: 0;
    color: inherit;
}

.tree-view-toggle {
    align-items: center;
    display: inline-flex;
    flex: 0 0 1.45rem;
    font-size: 1.1rem;
    height: 1.45rem;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 1.45rem;
}

.tree-view-toggle-placeholder {
    flex: 0 0 1.45rem;
    height: 1px;
    width: 1.45rem;
}

.tree-view-chevron {
    display: inline-block;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform .16s ease;
}

.tree-view-chevron.expanded {
    transform: rotate(90deg);
}

.tree-view-label {
    display: grid;
    flex: 1 1 auto;
    gap: .05rem;
    justify-content: stretch;
    min-height: 2.15rem;
    min-width: 0;
    padding: .2rem 0;
    text-align: left;
}

.tree-view-label span {
    color: #172554;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-view-label small {
    color: #47658f;
    display: block;
    font-size: .75rem;
    font-weight: 500;
    line-height: 1.15;
}

.surface-header,
.panel-title,
.action-row,
.preview-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.status-line {
    margin: 18px 0;
    padding: 13px 15px;
    border-radius: 12px;
    font-weight: 700;
}

.status-line.success {
    color: #12623f;
    background: #dff8ed;
}

.status-line.error {
    color: #991b1b;
    background: #fee2e2;
}

.status-line.info {
    color: #1d4ed8;
    background: #dbeafe;
}

.control-grid {
    display: none;
    grid-template-columns: 270px 1fr;
    gap: 14px;
    margin-top: 22px;
}

label span {
    display: block;
    margin-bottom: 7px;
    font-weight: 800;
    color: #334155;
}

select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: rgba(255, 255, 255, .84);
    color: #142033;
}

select {
    min-height: 44px;
    padding: 0 12px;
}

textarea {
    min-height: 330px;
    resize: vertical;
    padding: 16px;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
}

.editor-panel,
.preview-panel {
    margin-top: 18px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 20px;
    padding: 18px;
    background: rgba(248, 250, 252, .76);
}

.import-surface > .control-grid,
.import-surface > .editor-panel,
.import-surface > .preview-panel {
    display: none;
}

.import-modal {
    width: min(1180px, calc(100vw - 44px));
}

.import-modal-body {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
    gap: 16px;
    min-height: 0;
    overflow: auto;
    padding: 18px 20px 22px;
}

.modal-editor-panel,
.modal-preview-panel {
    display: block;
    margin-top: 0;
}

.modal-editor-panel textarea {
    min-height: 440px;
}

.modal-preview-panel .preview-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.action-row {
    justify-content: flex-start;
    margin-top: 14px;
}

.primary-button,
.commit-button,
.danger-button,
.ghost-button {
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 0 16px;
    font-weight: 800;
}

.primary-button {
    color: #fff;
    background: #2563eb;
}

.commit-button {
    color: #fff;
    background: #0f766e;
}

.danger-button {
    color: #991b1b;
    background: #fee2e2;
}

.ghost-button {
    color: #334155;
    border-color: #cbd5e1;
    background: rgba(255, 255, 255, .75);
}

.preview-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.preview-summary div {
    min-height: 82px;
    padding: 16px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #dbe4f0;
}

.preview-summary strong {
    display: block;
    font-size: 24px;
    color: #0f3f91;
}

.preview-summary span {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 13px;
}

.preview-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(15, 23, 42, .45);
}

.swal2-container {
    z-index: 10000 !important;
}

.ck.ck-balloon-panel,
.ck.ck-dropdown__panel {
    z-index: 3000 !important;
}

.question-modal {
    display: flex;
    flex-direction: column;
    width: min(1120px, calc(100vw - 44px));
    height: min(820px, calc(100vh - 44px));
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, .42);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 28px 90px rgba(15, 23, 42, .28);
}

.node-child-modal {
    width: min(760px, calc(100vw - 44px));
    height: auto;
    max-height: min(820px, calc(100vh - 44px));
}

.node-child-editor {
    overflow: auto;
}

.node-child-editor .question-edit-actions {
    margin-top: 16px;
}

.question-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.question-modal-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
}

.question-title-edit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 4px;
}

.question-title-edit h2 {
    margin: 0;
}

.question-title-edit input {
    width: 96px;
    min-height: 34px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 0 8px;
    color: #0f172a;
    font-size: 18px;
    font-weight: 900;
}

.question-modal-header span {
    display: block;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}

.question-modal-body {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    min-height: 0;
    flex: 1 1 auto;
}

.modal-question-list {
    overflow: auto;
    border-right: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 12px;
}

.modal-question-item {
    display: grid;
    gap: 5px;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 11px 12px;
    color: #1e293b;
    background: transparent;
    text-align: left;
}

.modal-question-item:hover {
    border-color: #dbeafe;
    background: #fff;
}

.modal-question-item.active {
    border-color: rgba(37, 99, 235, .45);
    background: #eaf2ff;
}

.modal-question-item strong {
    color: #2563eb;
    font-size: 12px;
}

.modal-question-item span {
    overflow: hidden;
    color: #172554;
    font-weight: 800;
    line-height: 1.25;
    text-overflow: ellipsis;
}

.modal-question-item small {
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.modal-question-detail {
    overflow: auto;
    padding: 18px 20px 24px;
}

.single-detail {
    flex: 1 1 auto;
}

.compact-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.modal-question-detail > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    color: #334155;
    background: #f1f5f9;
    font-size: 12px;
    font-weight: 900;
}

.status-pill.active {
    color: #12623f;
    background: #dcfce7;
}

.status-pill.passive {
    color: #475569;
    background: #e2e8f0;
}

.status-pill.danger {
    color: #991b1b;
    background: #fee2e2;
}

.status-pill.correct-answer-pill {
    color: #1d4ed8;
    background: #dbeafe;
}

.detail-metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.question-state-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.question-state-controls > label {
    display: grid;
    grid-template-columns: auto minmax(120px, 170px);
    align-items: center;
    gap: 7px;
    min-height: 42px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 8px;
    background: #fff;
}

.question-state-controls > label > span {
    margin: 0;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
}

.question-state-controls select {
    min-height: 30px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 800;
}

.question-state-controls .toggle-field {
    grid-template-columns: 18px auto;
    min-width: 92px;
}

.question-state-controls .toggle-field input {
    width: 18px;
    height: 18px;
    accent-color: #0f766e;
}

.detail-metrics > span,
.detail-metrics label {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 8px;
    color: #475569;
    font-size: 12px;
    font-weight: 800;
}

.detail-metrics label {
    display: grid;
    grid-template-columns: auto 54px;
    align-items: center;
    gap: 7px;
    background: #fff;
}

.detail-metrics label span {
    margin: 0;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
}

.detail-metrics input {
    width: 54px;
    min-height: 30px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 0 8px;
    color: #0f172a;
    font-weight: 800;
}

.detail-section {
    border-top: 1px solid #e2e8f0;
    padding-top: 15px;
    margin-top: 15px;
}

.detail-section h3 {
    margin-bottom: 8px;
    color: #0f172a;
    font-size: 15px;
}

.warning-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.warning-list div {
    padding: 12px 14px;
    border-radius: 12px;
    color: #854d0e;
    background: #fef3c7;
    font-weight: 700;
}

.question-list {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.question-card {
    border: 1px solid #dbe4f0;
    border-radius: 18px;
    padding: 16px;
    background: #fff;
}

.question-card header {
    display: flex;
    justify-content: space-between;
    color: #2563eb;
    font-weight: 800;
}

.question-text,
.question-prompt,
.explanation {
    white-space: pre-wrap;
}

.question-text {
    color: #334155;
}

.question-prompt {
    font-weight: 800;
}

.choices {
    display: grid;
    gap: 8px;
}

.choice {
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
}

.choice b {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    background: #334155;
}

.choice.correct {
    border-color: #22c55e;
    background: #f0fdf4;
}

.choice.correct b {
    background: #16a34a;
}

.explanation {
    margin: 12px 0 0;
    color: #475569;
}

.question-edit-form {
    padding-bottom: 0;
}

.question-edit-form .detail-section {
    overflow: visible;
}

.rich-editor-shell {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.rich-editor-actions {
    display: flex;
    justify-content: flex-end;
}

.rich-source-toggle {
    min-height: 32px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0 10px;
    color: #334155;
    background: #fff;
    font-size: 12px;
    font-weight: 900;
}

.ckeditor-wrapper {
    min-width: 0;
}

.ckeditor-wrapper .ck.ck-editor {
    min-width: 0;
}

.ckeditor-wrapper .ck.ck-toolbar {
    border-color: #cbd5e1;
    border-radius: 10px 10px 0 0;
    background: #f8fafc;
}

.ckeditor-wrapper .ck.ck-toolbar .ck-toolbar__items {
    flex-wrap: wrap;
}

.ckeditor-wrapper .ck.ck-editor__main > .ck-editor__editable {
    min-height: var(--rich-editor-min-height, 180px);
    border-color: #cbd5e1;
    border-radius: 0 0 10px 10px;
    color: #142033;
    line-height: 1.6;
}

.ckeditor-wrapper .ck.ck-editor__main > .ck-editor__editable:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.rich-source-area {
    min-height: var(--rich-editor-min-height, 180px);
    border-radius: 10px;
    font-family: "Cascadia Mono", Consolas, monospace;
}

.choice-edit-list {
    display: grid;
    gap: 12px;
}

.choice-edit-row {
    display: grid;
    grid-template-columns: 48px 36px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    background: #fff;
}

.choice-edit-row.correct {
    border-color: #86efac;
    background: #f0fdf4;
}

.choice-correct-toggle {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    min-width: 0;
}

.choice-correct-toggle input {
    margin: 0;
}

.choice-correct-toggle span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin: 0;
    border-radius: 50%;
    color: #fff;
    background: #334155;
    font-weight: 900;
}

.choice-edit-row.correct .choice-correct-toggle span {
    background: #16a34a;
}

.choice-order-controls {
    display: grid;
    align-content: center;
    gap: 6px;
}

.choice-order-controls button {
    display: grid;
    place-items: center;
    width: 32px;
    height: 30px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.choice-order-controls button:hover:not(:disabled),
.choice-order-controls button:focus-visible:not(:disabled) {
    border-color: #2563eb;
    color: #1d4ed8;
    background: #eff6ff;
}

.choice-order-controls button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.compact-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.question-edit-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    padding: 14px 0 0;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.log-panel {
    display: none;
}

.log-stream {
    display: grid;
    gap: 8px;
    overflow: auto;
    padding-right: 4px;
}

.empty-log {
    padding: 18px;
    border-radius: 14px;
    color: #64748b;
    background: #f8fafc;
}

.log-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 13px;
}

@media (max-width: 760px) {
    .node-settings-form label,
    .node-settings-form .toggle-settings-field {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

.log-row time {
    color: #64748b;
}

.log-row.success {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.log-row.warning {
    border-color: #fde68a;
    background: #fffbeb;
}

.log-row.error {
    border-color: #fecaca;
    background: #fef2f2;
}

#blazor-error-ui {
    color-scheme: light only;
    background: #fef3c7;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media (max-width: 1250px) {
    .workspace-shell {
        grid-template-columns: 230px minmax(0, 1fr);
    }

    .log-panel {
        grid-column: 1 / -1;
        position: static;
        height: 340px;
    }
}

@media (max-width: 820px) {
    .workspace-shell,
    .control-grid,
    .preview-summary,
    .question-card-grid {
        grid-template-columns: 1fr;
    }

    .workspace-shell {
        padding: 12px;
    }
}
