/* 原生模态层位于导航之上。只滚动表单正文，始终保留关闭和提交操作。 */
dialog.assignment-editor {
    --editor-paper: #282824;
    --editor-field: #242420;
    --editor-soft: #30302a;
    --editor-line: #4d4b42;
    --editor-rule: #403f38;
    --editor-ink: #f1efe6;
    --editor-muted: #b6b2a6;
    --editor-accent: #edac8f;
    --editor-tint: #44332a;
    --editor-action: #ab5035;
    --editor-action-hover: #93432d;
    --editor-error: #ffac96;
    --editor-edge: 36px;
    --editor-gutter: 26px;
    --editor-list-height: clamp(148px, 23vh, 216px);
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    width: min(760px, calc(100% - var(--editor-edge)));
    min-width: 0;
    max-width: none;
    max-height: calc(100vh - var(--editor-edge));
    max-height: calc(100dvh - var(--editor-edge));
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--editor-line);
    border-radius: 16px;
    background: var(--editor-paper);
    color: var(--editor-ink);
    color-scheme: dark;
    box-shadow: 0 18px 64px rgb(18 15 11 / 22%);
    font: 14px/1.5 'IBM Plex Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    text-align: start;
}

.theme-light dialog.assignment-editor {
    --editor-paper: #faf9f5;
    --editor-field: #fffefa;
    --editor-soft: #f2f0e9;
    --editor-line: #d7d3c9;
    --editor-rule: #e4e0d6;
    --editor-ink: #302e28;
    --editor-muted: #6d695f;
    --editor-accent: #92492f;
    --editor-tint: #f4e9e1;
    --editor-error: #ab392e;
    color-scheme: light;
}

.assignment-editor::backdrop { background: rgb(20 18 15 / 45%); }
.theme-light .assignment-editor::backdrop { background: rgb(44 39 30 / 36%); }
.assignment-editor :where(*, *::before, *::after) { box-sizing: border-box; }
.assignment-editor [hidden] { display: none !important; }

.assignment-editor-form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--editor-edge) - 2px);
    max-height: calc(100dvh - var(--editor-edge) - 2px);
    min-width: 0;
    margin: 0;
}

.assignment-editor-header,
.assignment-editor-footer {
    display: flex;
    flex: none;
    align-items: center;
    gap: 10px;
    padding-inline: var(--editor-gutter);
}

.assignment-editor-header {
    justify-content: space-between;
    padding-block: 19px 16px;
    border-bottom: 1px solid var(--editor-rule);
}

.assignment-editor-header h2 {
    margin: 0;
    color: var(--editor-ink);
    font: 600 clamp(22px, 2vw, 27px)/1.35 'Songti SC', 'Noto Serif CJK SC', 'STSong', 'SimSun', serif;
    overflow-wrap: anywhere;
}

.assignment-editor-body {
    display: grid;
    flex: 1 1 auto;
    align-content: start;
    grid-template-columns: minmax(0, 1fr);
    gap: 17px;
    min-height: 0;
    padding: 19px var(--editor-gutter) 22px;
    overflow: auto;
    overscroll-behavior: contain;
}

.assignment-editor-footer {
    justify-content: flex-end;
    padding-block: 13px 14px;
    border-top: 1px solid var(--editor-rule);
}

.assignment-editor-basics {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 18px;
}

.assignment-field {
    display: grid;
    gap: 6px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.assignment-field > :is(span, legend) {
    padding: 0;
    color: var(--editor-ink);
    font-size: 13px;
    font-weight: 600;
}

.assignment-field small {
    margin-inline-start: 5px;
    color: var(--editor-muted);
    font-size: 12px;
    font-weight: 400;
}

.assignment-editor :is(input:not([type="radio"]):not([type="hidden"]), textarea) {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid var(--editor-line);
    border-radius: 7px;
    background: var(--editor-field);
    color: var(--editor-ink);
    font: inherit;
    line-height: 1.45;
}

.assignment-editor textarea {
    min-height: 54px;
    max-height: 128px;
    resize: vertical;
}

.assignment-editor ::placeholder { color: var(--editor-muted); opacity: 1; }

.assignment-mode-field { display: block; }
.assignment-mode-field > legend { margin-block-end: 6px; }

.assignment-mode-options {
    display: inline-flex;
    align-items: stretch;
    max-width: 100%;
    min-height: 38px;
    padding: 3px;
    border: 1px solid var(--editor-line);
    border-radius: 8px;
    background: var(--editor-soft);
}

.assignment-mode-options label { position: relative; min-width: 0; cursor: pointer; }

.assignment-mode-options input {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
}

.assignment-mode-options span,
.assignment-field .assignment-mode-value {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 4px 11px;
    border-radius: 5px;
    color: var(--editor-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.assignment-mode-options :checked + span {
    background: var(--editor-field);
    color: var(--editor-accent);
    box-shadow: 0 0 0 1px var(--editor-line);
}

.assignment-field .assignment-mode-value {
    justify-content: flex-start;
    height: auto;
    min-height: 38px;
    padding-inline: 0;
}

.assignment-duration-field {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.assignment-editor .assignment-duration-field input { width: 85px; }

.assignment-picker { display: grid; min-width: 0; gap: 9px; }

.assignment-picker-heading,
.assignment-chosen-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.assignment-picker-heading { justify-content: space-between; }
.assignment-picker-heading h3,
.assignment-chosen-heading h4 { margin: 0; color: var(--editor-ink); font-weight: 600; }
.assignment-picker-heading h3 { font-size: 16px; }
.assignment-chosen-heading h4 { font-size: 14px; }

.assignment-luogu-panel { display: grid; gap: 8px; min-width: 0; }
.assignment-luogu-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.assignment-luogu-status { margin: 0; color: var(--editor-muted); font-size: 13px; overflow-wrap: anywhere; }

.assignment-picker-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--editor-line);
    border-radius: 9px;
}

.assignment-library,
.assignment-chosen { display: flex; flex-direction: column; min-width: 0; }
.assignment-library { background: var(--editor-field); }
.assignment-chosen { border-inline-start: 1px solid var(--editor-line); background: var(--editor-soft); }

.assignment-search {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 9px 10px 5px;
    padding-inline: 10px 3px;
    border: 1px solid var(--editor-line);
    border-radius: 6px;
    background: var(--editor-paper);
    color: var(--editor-muted);
}

.assignment-search-icon {
    position: relative;
    flex: none;
    width: 12px;
    height: 12px;
    margin-inline-end: 2px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
}

.assignment-search-icon::after {
    position: absolute;
    right: -4px;
    bottom: -2px;
    width: 5px;
    height: 1.5px;
    border-radius: 1px;
    background: currentColor;
    content: "";
    transform: rotate(45deg);
}

.assignment-editor .assignment-search input[type="search"] {
    flex: 1 1 0;
    width: 0;
    min-height: 34px;
    padding: 5px 0;
    border: 0;
    background: transparent;
}

.assignment-search > button,
.assignment-text-button {
    flex: none;
    min-height: 30px;
    padding: 3px 6px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--editor-accent);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
}

.assignment-search > button:hover:not(:disabled),
.assignment-text-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }

.assignment-results,
.assignment-selected-list {
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--editor-line) transparent;
}

.assignment-results { height: var(--editor-list-height); }

.assignment-option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 8px 13px;
    border: 0;
    border-bottom: 1px solid var(--editor-rule);
    border-radius: 0;
    background: transparent;
    color: var(--editor-ink);
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.assignment-option:last-child { border-block-end-color: transparent; }
.assignment-option:hover:not(:disabled) { background: var(--editor-soft); }
.assignment-option[aria-pressed="true"] { background: var(--editor-tint); }
.assignment-option-copy { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.assignment-option-copy strong { font-size: 14px; font-weight: 550; line-height: 1.45; }
.assignment-option-copy small { color: var(--editor-muted); font-size: 12px; line-height: 1.4; }
.assignment-option-copy small:empty { display: none; }

.assignment-option-check {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    color: var(--editor-muted);
    font-size: 17px;
    line-height: 1;
}

.assignment-option[aria-pressed="true"] .assignment-option-check { color: var(--editor-accent); }

.assignment-chosen-heading {
    min-height: 51px;
    padding: 10px 14px;
    border-block-end: 1px solid var(--editor-rule);
}

.assignment-chosen-heading > span {
    color: var(--editor-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.assignment-selected-list {
    max-height: var(--editor-list-height);
    margin: 0;
    padding: 0 12px;
    list-style: none;
    counter-reset: selected-question;
}

.assignment-selected-list li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 41px;
    padding: 3px 0;
    border-block-end: 1px solid var(--editor-rule);
    counter-increment: selected-question;
}

.assignment-selected-list li:last-child { border-block-end: 0; }

.assignment-selected-list li::before {
    min-width: 12px;
    color: var(--editor-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    content: counter(selected-question);
}

.assignment-selected-title { min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.assignment-picker-state { margin: 0; padding: 16px 14px; color: var(--editor-muted); font-size: 13px; }

.assignment-icon-button,
.assignment-remove {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--editor-muted);
    font-family: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.assignment-remove { width: 30px; height: 30px; font-size: 17px; }
.assignment-icon-button:hover:not(:disabled) { background: var(--editor-soft); color: var(--editor-ink); }
.assignment-remove:hover:not(:disabled) { background: var(--editor-tint); color: var(--editor-accent); }

.assignment-button {
    min-height: 37px;
    padding: 7px 15px;
    border: 1px solid var(--editor-line);
    border-radius: 7px;
    background: var(--editor-field);
    color: var(--editor-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 550;
    line-height: 1.45;
    cursor: pointer;
}

.assignment-button:hover:not(:disabled) { border-color: var(--editor-muted); }
.assignment-button.assignment-primary { border-color: transparent; background: var(--editor-action); color: #fff; }
.assignment-primary:hover:not(:disabled) { border-color: transparent; background: var(--editor-action-hover); }
.assignment-editor :disabled { opacity: .55; cursor: default; }
.assignment-error { margin: 0; color: var(--editor-error); font-size: 13px; overflow-wrap: anywhere; }
.assignment-error:empty { display: none; }

.assignment-editor :is(button, input, textarea, summary, a):focus-visible,
.assignment-mode-options input:focus-visible + span {
    outline: 2px solid var(--editor-accent);
    outline-offset: 2px;
}

.assignment-editor .assignment-option:focus-visible { outline-offset: -3px; }
.assignment-search:focus-within { border-color: var(--editor-accent); }
.assignment-editor .assignment-search input[type="search"]:focus-visible { outline: none; }

@media (max-width: 620px) {
    dialog.assignment-editor {
        --editor-edge: 16px;
        --editor-gutter: 17px;
        --editor-list-height: 154px;
        border-radius: 12px;
    }

    .assignment-editor-header { padding-block: 14px 12px; }
    .assignment-editor-body { gap: 14px; padding-block: 14px 17px; }
    .assignment-editor-footer { padding-block: 10px; }
    .assignment-editor-basics { grid-template-columns: minmax(0, 1fr); gap: 13px; }
    .assignment-picker-columns { grid-template-columns: minmax(0, 1fr); }
    .assignment-chosen { order: -1; border-inline-start: 0; border-block-end: 1px solid var(--editor-line); }
    .assignment-chosen-heading { min-height: 35px; padding-block: 7px; }
    .assignment-chosen .assignment-picker-state { padding-block: 8px; }
    .assignment-selected-list { max-height: 118px; }
    .assignment-selected-list li { min-height: 38px; }
    .assignment-remove { width: 34px; height: 32px; }
}

@media (max-height: 530px) {
    dialog.assignment-editor { --editor-edge: 12px; --editor-list-height: 135px; }
    .assignment-editor-header, .assignment-editor-footer { padding-block: 8px; }
    .assignment-editor-body { gap: 12px; padding-block: 12px; }
}
