/* Shared dashboard theme; scoped away from lesson content and the remaining canvas. */
.db-shell,
.db-modal,
.db-theme {
    --bg-main: #121212;
    --text-main: #f2f2ed;
    --text-muted: #a7a7a7;
    --border-color: #343434;
    --accent: #8aaa8d;
    --db-blue: #339cff;
    --db-danger: #eb8171;
    color: var(--text-main);
    font:
        15px/1.5 'Segoe UI',
        system-ui,
        sans-serif;
    color-scheme: dark;
}
.db-shell {
    background: var(--bg-main) !important;
    min-width: 0;
    overflow: hidden;
}
.db-shell *,
.db-modal *,
.db-theme * {
    box-sizing: border-box;
}
.db-icon {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
    pointer-events: none;
}
.db-sidebar {
    width: 228px;
    flex: 0 0 228px;
    display: flex;
    flex-direction: column;
    padding: 24px 16px 18px;
    border-right: 1px solid var(--border-color);
    gap: 32px;
    overflow: auto;
    background: var(--bg-main);
}
.db-brand {
    height: 39px;
    display: flex;
    align-items: center;
    padding-left: 9px;
    flex-shrink: 0;
}
.db-brand img {
    width: 161px;
    height: auto;
}
.db-nav-group + .db-nav-group {
    margin-top: 26px;
}
.db-nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.6px;
    color: #94978f;
    margin: 0 12px 11px;
}
.db-profile {
    border-top: 1px solid var(--border-color);
    padding: 20px 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
}
.db-avatar {
    width: 31px;
    height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #4c544d;
    border-radius: 50%;
    color: var(--accent);
    font-size: 12px;
    flex-shrink: 0;
}
.db-profile-text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
}
.db-profile-text small {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
}
.db-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.db-topbar {
    min-height: 68px;
    border-bottom: 1px solid var(--border-color);
    padding: 14px 38px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
.db-crumbs {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 12px;
    min-width: 0;
}
.db-current {
    color: var(--text-main);
}
.db-slash {
    color: #777;
}
#td-ai-assistant {
    margin-left: auto;
}
.db-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 40px 38px 60px;
    scrollbar-width: thin;
}
.db-content-inner {
    max-width: 1224px;
    margin: 0 auto;
    min-width: 0;
}
.db-panel {
    min-width: 0;
}
.db-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}
.db-heading h2 {
    font:
        600 32px/1.2 'Segoe UI',
        sans-serif;
    letter-spacing: -0.8px;
    margin: 0;
    color: var(--text-main);
}
.db-heading p,
.db-description {
    color: var(--text-muted);
    font-size: 14px;
    margin: 12px 0 0;
    max-width: 660px;
}
.db-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.db-heading > .db-actions {
    padding-top: 2px;
}
/* Legacy templates supply semantic button variables, while this shared rule owns their skin. */
:where(.db-shell, .db-modal, .db-theme) button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 39px;
    max-width: 100%;
    padding: 9px 14px !important;
    background: var(--db-button-fill, transparent) !important;
    color: var(--db-button-text, var(--text-main)) !important;
    border: 1px solid var(--db-button-border, var(--border-color)) !important;
    border-radius: 6px !important;
    font:
        500 13px/1.4 'Segoe UI',
        sans-serif !important;
    cursor: pointer;
    box-shadow: none;
    white-space: normal;
}
:where(.db-shell, .db-modal, .db-theme) button:hover {
    filter: brightness(1.1);
    border-color: #858585 !important;
}
:where(.db-shell, .db-modal, .db-theme) button:disabled {
    opacity: 0.4;
    cursor: default;
}
:where(.db-shell, .db-modal, .db-theme) :is(button, input, select, textarea):focus-visible {
    outline: 2px solid var(--db-blue);
    outline-offset: 3px;
}
:where(.db-shell, .db-modal, .db-theme) .db-primary {
    --db-button-fill: var(--accent);
    --db-button-text: #121812;
    --db-button-border: var(--accent);
}
:where(.db-shell, .db-modal, .db-theme) .db-danger {
    --db-button-text: var(--db-danger);
}
:where(.db-shell, .db-modal, .db-theme) .db-link,
:where(.db-shell, .db-modal, .db-theme) .db-ghost {
    --db-button-border: transparent;
    padding: 7px 4px !important;
}
.db-shell .db-ghost {
    --db-button-text: var(--text-muted);
}
.db-shell .db-link:hover {
    --db-button-text: var(--db-blue);
    border-color: transparent !important;
}
.db-shell .db-nav-link {
    position: relative;
    justify-content: flex-start;
    display: flex;
    width: 100%;
    text-align: left;
    padding: 11px 12px !important;
    min-height: 44px;
    font-size: 14px !important;
    gap: 12px;
    border: 0 !important;
    color: var(--text-muted) !important;
    border-radius: 4px !important;
}
.db-shell .db-nav-link:hover {
    background: #1c1c1c !important;
    color: var(--text-main) !important;
}
.db-shell .db-nav-link[aria-current='page'] {
    color: var(--text-main) !important;
}
.db-nav-link[aria-current='page']::before {
    content: '';
    position: absolute;
    left: -16px;
    width: 2px;
    height: 22px;
    background: var(--db-blue);
}
.db-nav-link[aria-current='page'] .db-icon {
    color: var(--db-blue);
}
.db-nav-link > span {
    min-width: 0;
}
.db-nav-count {
    margin-left: auto;
    color: var(--accent);
    font-size: 11px;
}
:where(.db-shell, .db-modal, .db-theme) .db-icon-button {
    width: 36px;
    height: 36px;
    min-height: 36px;
    flex-shrink: 0;
    padding: 7px !important;
    border-color: transparent !important;
    color: var(--text-muted) !important;
}
.db-icon-button:hover {
    background: #1c1c1c !important;
    color: var(--text-main) !important;
}
.db-list {
    border-top: 1px solid var(--border-color);
}
.db-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 104px;
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    min-width: 0;
}
.db-row-stack {
    display: block;
}
.db-row-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.db-row-marker {
    width: 34px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.db-row-body {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}
.db-row-title {
    font-size: 18px;
    font-weight: 500;
    overflow-wrap: anywhere;
}
.db-row-note {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 7px;
}
.db-row .db-row-title button {
    font-size: inherit !important;
}
.db-shell .db-course-link {
    width: 100%;
    min-height: 104px;
    justify-content: flex-start;
    gap: 20px;
    border: 0 !important;
    border-bottom: 1px solid var(--border-color) !important;
    border-radius: 0 !important;
    padding: 24px 0 !important;
    text-align: left;
}
.db-course-link > .db-icon:last-child {
    margin-left: auto;
}
.db-shell .db-course-link:hover {
    background: transparent !important;
    color: var(--db-blue) !important;
}
.db-course-link .db-row-title {
    font-size: 18px;
}
.db-empty {
    padding: 48px 0;
    border-top: 1px solid var(--border-color);
    max-width: 740px;
}
.db-empty > .db-icon {
    width: 28px;
    height: 28px;
    color: var(--text-muted);
    margin-bottom: 22px;
}
.db-empty h3 {
    font-size: 21px;
    font-weight: 500;
}
.db-empty p {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 14px;
    max-width: 500px;
}
.db-inline-form {
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    max-width: 640px;
}
.db-inline-form h3 {
    margin-bottom: 20px;
    font-weight: 500;
}
.db-notice {
    border-left: 2px solid var(--accent);
    padding: 4px 0 4px 16px;
    margin-bottom: 28px;
    font-size: 13px;
    color: var(--text-muted);
}
.db-notice strong {
    color: var(--text-main);
    font-weight: 500;
}
.db-page-tags {
    display: flex;
    gap: 6px 14px;
    flex-wrap: wrap;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}
.db-page-tags span {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    color: var(--text-muted) !important;
}
.db-status {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}
.db-status-good {
    color: var(--accent);
}
.db-status-progress {
    color: #c7aa70;
}
:where(.db-shell, .db-modal)
    :is(input:not([type='checkbox']):not([type='radio']), select, textarea) {
    color: var(--text-main) !important;
    background: transparent !important;
    border: 1px solid #505050 !important;
    border-radius: 5px !important;
    padding: 10px 12px;
    font:
        14px/1.5 'Segoe UI',
        sans-serif;
    min-width: 0;
    max-width: 100%;
    outline-offset: 3px;
}
:where(.db-shell, .db-modal) select option {
    color: #eee;
    background: #252429;
}
:where(.db-shell, .db-modal) input:is([type='checkbox'], [type='radio']) {
    accent-color: var(--accent);
}
.db-select-host {
    max-width: 100%;
    margin-bottom: 12px;
}
.db-select-host .lp-select {
    width: 100%;
}
.db-select-host .lp-select-trigger {
    display: flex;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    gap: 18px;
}
.db-shell [hidden],
.db-modal [hidden],
.db-action-menu[hidden] {
    display: none !important;
}
.db-action-menu {
    position: fixed;
    inset: auto;
    margin: 0;
    width: 225px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    overflow: auto;
    padding: 5px;
    border: 1px solid #454545;
    border-radius: 7px;
    background: #191919;
    box-shadow: 0 12px 30px #0006;
    z-index: 100001;
}
.db-action-menu button {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    border: 0 !important;
    border-radius: 4px !important;
    padding: 10px 12px !important;
    min-height: 39px;
}
.db-action-menu button:hover {
    background: #292929 !important;
}
.db-action-menu .db-danger {
    border-top: 1px solid var(--border-color) !important;
    border-radius: 0 !important;
    margin-top: 4px;
}
.db-modal > div {
    background: var(--bg-main) !important;
    border-color: var(--border-color) !important;
    border-radius: 10px !important;
}
.db-modal {
    overflow: auto;
}
.db-modal h2 {
    font-weight: 500;
}
.db-vocab-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}
.db-vocab-group {
    border-top: 1px solid var(--border-color);
}
.db-vocab-empty {
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
}
.db-student-section {
    padding: 26px 0;
    border-top: 1px solid var(--border-color);
}
.db-student-section h3 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    font-size: 17px;
    font-weight: 500;
}
.db-student-section h3 > .db-icon { color: var(--text-muted); }
.db-section-heading, .db-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 18px;
}
.db-section-heading { margin-bottom: 20px; }
.db-section-note { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }
.db-setting-controls { display: flex; align-items: center; gap: 10px; }
#td-vocab-limit-val { width: 100px; }
.db-form-message { color: var(--accent); font-size: 13px; margin: 12px 0 0; }
.db-form-message:empty { display: none; }
.db-form-error { color: var(--db-danger); font-size: 13px; }
.db-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.td-lesson-row { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--border-color); }
.td-lesson-cb { flex-shrink: 0; width: 17px; height: 17px; margin: 5px 0 0; cursor: pointer; }
.db-lesson-body { flex: 1; min-width: 150px; overflow-wrap: anywhere; }
.db-lesson-title { font-size: 15px; }
.db-lesson-done .db-lesson-title { text-decoration: line-through; color: var(--text-muted); }
.db-lesson-body .db-section-note { margin-top: 3px; }
.db-lesson-actions { gap: 4px; }
.db-lesson-actions [aria-pressed='true'] { color: var(--accent) !important; border-color: var(--accent) !important; }
.db-lesson-time-fields { display: grid; grid-template-columns: minmax(0, 1fr) 100px 100px; gap: 12px; align-items: end; margin-bottom: 12px; }
.db-lesson-edit-fields { display: grid; grid-template-columns: minmax(0, 1fr) 160px 212px; gap: 12px; align-items: end; margin-bottom: 12px; }
.db-lesson-time-fields .db-select-host, .db-lesson-edit-fields .db-select-host { margin-bottom: 0; }
.db-lesson-edit-fields > div:last-child > div { min-width: 0; flex: 1; }
.db-field-label { display: block; color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
#td-access-section > .db-select-host { max-width: 480px; }
.db-access-toggle { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 14px; cursor: pointer; }
.db-access-tree { border-top: 1px solid var(--border-color); margin-top: 16px; }
.db-access-book { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 0; }
.db-access-book-title { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.db-access-summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 16px 0; border-top: 1px solid var(--border-color); }
.db-access-summary span { overflow-wrap: anywhere; }
@media (max-width: 1000px) {
    .db-lesson-edit-fields { grid-template-columns: minmax(0, 1fr) minmax(160px, 1fr); }
    .db-lesson-edit-fields > div:first-child { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
    .db-student-section { padding: 24px 0; }
    .db-student-section h3 { font-size: 16px; }
    .db-lesson-time-fields { grid-template-columns: 1fr 1fr; }
    .db-lesson-time-fields > div:first-child { grid-column: 1 / -1; }
    .db-lesson-edit-fields { grid-template-columns: minmax(0, 1fr); }
    .db-lesson-actions { margin-left: 31px; }
}
.db-mobile-toggle {
    display: none !important;
}
.db-nav-backdrop {
    display: none !important;
}
@media (max-width: 1100px) {
    .db-sidebar {
        width: 210px;
        flex-basis: 210px;
    }
    .db-content {
        padding: 30px 26px;
    }
    .db-topbar {
        padding: 14px 26px;
    }
    .db-heading h2 {
        font-size: 29px;
    }
    .db-row {
        gap: 14px;
    }
    .db-heading {
        gap: 18px;
    }
}
@media (max-width: 740px) {
    .db-sidebar {
        display: none;
        position: absolute;
        inset: 0 auto 0 0;
        width: 240px;
        z-index: 4;
        box-shadow: 12px 0 40px #0008;
    }
    .db-nav-open .db-sidebar {
        display: flex;
    }
    .db-nav-open .db-nav-backdrop {
        display: block !important;
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        z-index: 3;
        background: #0007 !important;
        border: 0 !important;
        border-radius: 0 !important;
    }
    .db-mobile-toggle {
        display: inline-flex !important;
    }
    .db-topbar {
        padding: 12px 16px;
        min-height: 62px;
        gap: 10px;
    }
    .db-crumbs {
        font-size: 11px;
        gap: 7px;
    }
    #td-ai-assistant {
        padding: 8px !important;
    }
    #td-ai-assistant span {
        display: none;
    }
    .db-content {
        padding: 28px 20px 50px;
    }
    .db-heading {
        margin-bottom: 30px;
    }
    .db-heading p {
        font-size: 13px;
    }
    .db-row {
        flex-wrap: wrap;
        padding: 20px 0;
        gap: 12px;
    }
    .db-row-body {
        flex-basis: calc(100% - 48px);
    }
    .db-row > .db-actions {
        margin-left: 0;
        max-width: 100%;
    }
    .db-row-title {
        font-size: 17px;
    }
    .db-row-main > .db-actions {
        flex-wrap: wrap;
        flex-shrink: 1;
    }
    .db-actions {
        gap: 8px;
    }
    .db-vocab-columns {
        grid-template-columns: minmax(0, 1fr);
    }
    :where(.db-shell, .db-modal, .db-theme) button {
        min-height: 42px;
    }
    .db-icon-button {
        min-width: 42px;
        min-height: 42px !important;
    }
    .db-profile {
        margin-top: 32px;
    }
    .db-modal {
        align-items: flex-start !important;
        padding: 12px !important;
    }
    .db-modal > div {
        padding: 20px !important;
        width: 100% !important;
    }
    .db-page-set-columns {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    .db-page-set-columns > div {
        width: 100% !important;
        max-height: 40vh;
    }
    .db-content input[type='date'] {
        max-width: 100%;
    }
}

.db-list:has(> .db-empty) {
    border-top: 0;
}
.db-row-main > div:first-child {
    flex: 1;
    min-width: 0;
}
.db-modal label {
    font-size: 13px;
    color: var(--text-muted);
}
.db-inline-form label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.db-select-host:has(+ #sl-list) {
    max-width: 420px;
}
.db-vocab-group button.db-icon-button {
    width: 34px !important;
    min-width: 34px;
    padding: 6px !important;
}
.db-vocab-group > div {
    flex-wrap: wrap;
}
.db-vocab-group .sd-vocab-text {
    min-width: 100px;
}
.db-panel h3 {
    font-size: 18px;
    font-weight: 500;
}
.td-username-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 740px) {
    .db-row-main > div:first-child { flex-basis: 100%; }
}
