html { color-scheme: light }
.theme-toggle { display:grid; place-items:center; flex:none; width:38px; height:38px; padding:0; border:1px solid var(--line); border-radius:50%; background:var(--surface); color:var(--muted); cursor:pointer }
.theme-toggle:hover { color:var(--text) }
.theme-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px }
.theme-icon { width:17px; height:17px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:1.7 }
.theme-icon-sun { display:none }
html[data-theme="dark"] .theme-icon-sun { display:block }
html[data-theme="dark"] .theme-icon-moon { display:none }
.app-content { position:relative }
.theme-toggle-desktop { position:absolute; top:18px; right:24px; z-index:5 }
.theme-toggle-mobile { display: none }
.theme-toggle-admin { white-space: nowrap }
@media (max-width: 700px) {
  .theme-toggle-desktop { display: none }
  .theme-toggle-mobile { display: grid; margin-left: auto; margin-right: 8px }
  .mobile-bar .theme-toggle-mobile { width:38px; height:38px; padding:0; border:1px solid var(--line) }
}
@media print { .theme-toggle { display: none !important } }

html[data-theme="dark"] { color-scheme: dark }
html[data-theme="dark"] #editor-dialog::backdrop { background:#000b }
#editor-dialog { position:fixed; inset:0; margin:auto; }
#editor-dialog #lesson-form { max-width:740px; margin:0 auto; }
html[data-theme="dark"] .answer-result.good { color:#a1d096 }
html[data-theme="dark"] .answer-result.bad { color:#d29090 }
html[data-theme] .answer-result.neutral { color:var(--soft-text) }

/* Shared palette from the MyList landing: soft neutral surfaces in both modes. */
html[data-theme="dark"] {
  --bg:#191919; --surface:#202020; --surface-2:#242424; --card:#292929;
  --text:#dcdcdc; --soft-text:#b8b8b8; --muted:#8f8f8f; --quiet:#5d5d5d;
  --line:rgba(255,255,255,.085); --primary:#a1d096; --header:rgba(25,25,25,.87);
  --green:#a1d096; --pale:#303c2e;
}
html[data-theme="light"] {
  --bg:#e6e6e6; --surface:#dfdfdf; --surface-2:#e6e6e6; --card:#eeeeee;
  --text:#333333; --soft-text:#666666; --muted:#757575; --quiet:#999999;
  --line:rgba(0,0,0,.105); --primary:#a1d096; --header:rgba(230,230,230,.88);
  --green:#3b7545; --pale:#d6e8d1;
}
html[data-theme] body { background:var(--bg); color:var(--text); transition:background-color .18s ease,color .18s ease }
html[data-theme] .app-side, html[data-theme] .mobile-bar { background:var(--surface); border-color:var(--line) }
html[data-theme] .side-brand, html[data-theme] .app-side nav .tree-home,
html[data-theme] .app-side nav a.active { color:var(--text) }
html[data-theme] .app-side nav a, html[data-theme] .tree-toggle,
html[data-theme] .mobile-bar button { color:var(--soft-text) }
html[data-theme] .app-side nav a:hover, html[data-theme] .app-side nav a.active,
html[data-theme] .app-side nav .tree-home.active, html[data-theme] .tree-toggle:hover,
html[data-theme] .mobile-bar button:hover { background:var(--card); color:var(--text) }
html[data-theme] .tree-children { border-color:var(--line) }
html[data-theme] .module-group>summary { color:var(--muted) }
html[data-theme] .module-group>summary:hover { background:var(--card); color:var(--text) }
html[data-theme] .theme-toggle, html[data-theme] .mobile-bar .theme-toggle-mobile { background:var(--surface); border-color:var(--line); color:var(--muted) }
html[data-theme] .theme-toggle:hover { color:var(--text); background:var(--card) }

html[data-theme] .course-card, html[data-theme] .lesson-row, html[data-theme] .practical-card,
html[data-theme] .module-overview-card, html[data-theme] .deadline-card,
html[data-theme] .deadline-panel.deadline-empty, html[data-theme] .reader,
html[data-theme] .question-card, html[data-theme] .empty-card,
html[data-theme] .empty-training { background:var(--card); border-color:var(--line); color:var(--text) }
html[data-theme] .course-card:hover, html[data-theme] .lesson-row:not(.empty):hover,
html[data-theme] .practical-card:not(.empty):hover, html[data-theme] .module-overview-card:hover,
html[data-theme] .deadline-card:hover { border-color:var(--muted); box-shadow:0 16px 38px #0002 }
html[data-theme] .lesson-row.empty { background:var(--surface); color:var(--muted) }
html[data-theme] .practical-card.empty { background:var(--surface); border-style:dashed; color:var(--muted); box-shadow:none; cursor:default }
html[data-theme] .practical-card.empty .practical-num { background:var(--surface-2); color:var(--muted) }
html[data-theme] .practical-card.empty .practical-main em { color:var(--soft-text) }
html[data-theme] .course-counts span, html[data-theme] .lesson-number,
html[data-theme] .practical-num, html[data-theme] .training-tabs button span,
html[data-theme] .lesson-row.empty .lesson-number,
html[data-theme] .status-gray { background:var(--surface-2); color:var(--soft-text) }
html[data-theme] .course-counts strong, html[data-theme] .reader h1,
html[data-theme] .reader h2, html[data-theme] .reader h3 { color:var(--text) }
html[data-theme] .course-top, html[data-theme] .course-foot,
html[data-theme] .course-card p, html[data-theme] .chronology-head span,
html[data-theme] .lesson-name small, html[data-theme] .lesson-row time,
html[data-theme] .practical-main small, html[data-theme] .practical-main em,
html[data-theme] .section-heading p, html[data-theme] .subject-coverage,
html[data-theme] .module-overview-card span, html[data-theme] .deadline-panel p,
html[data-theme] .page-header>p, html[data-theme] .training-header p,
html[data-theme] .reader-header p { color:var(--muted) }
html[data-theme] .course-card .course-foot .work-upcoming,
html[data-theme] .practical-end b, html[data-theme] .lesson-row b,
html[data-theme] .reader-next { color:var(--green) }
html[data-theme] .course-card .course-foot .work-count { color:var(--muted) }
html[data-theme="light"] .course-card .course-foot .deadline-count { color:#8b5300 }
html[data-theme="dark"] .course-card .course-foot .deadline-count { color:#c6ad8b }
html[data-theme="dark"] .course-card .course-foot .deadline-count::before { background:#aa8c67 }
html[data-theme] .course-card .course-foot, html[data-theme] .chronology-head,
html[data-theme] .period-control, html[data-theme] .section-tabs,
html[data-theme] .training-tabs { border-color:var(--line) }
html[data-theme] .eyebrow, html[data-theme] .period-caption,
html[data-theme] .period-menu-label { color:var(--muted) }
html[data-theme] .section-tabs a, html[data-theme] .training-tabs button { color:var(--muted) }
html[data-theme] .section-tabs a:first-child, html[data-theme] .section-tabs a:hover,
html[data-theme] .training-tabs button.active { color:var(--text); border-color:var(--primary) }
html[data-theme] .module-badge { border-color:var(--line) }
html[data-theme] .module-badge i { background:var(--quiet) }
html[data-theme] .module-badge i.on { background:var(--primary) }

html[data-theme] .period-menu, html[data-theme] .deadline-dialog,
html[data-theme] #editor-dialog { background:var(--surface); border-color:var(--line) !important; color:var(--text) }
html[data-theme] .period-picker>summary { color:var(--text) }
html[data-theme] .period-picker>summary:hover,
html[data-theme] .period-picker[open]>summary,
html[data-theme] .period-arrow:not(:disabled):hover { background:var(--card); border-color:var(--line) }
html[data-theme] .period-arrow { color:var(--muted) }
html[data-theme] .period-course-options button,
html[data-theme] .period-module-options button { background:var(--surface-2); border-color:var(--line); color:var(--text) }
html[data-theme] .period-course-options button:hover,
html[data-theme] .period-module-options button:hover,
html[data-theme] .period-course-options button.active,
html[data-theme] .period-module-options button.active { background:var(--card); border-color:var(--primary); color:var(--text) }
html[data-theme] .period-module-options small,
html[data-theme] .period-course-options small,
html[data-theme] .period-picker-copy small { color:var(--muted) }
html[data-theme] .deadline-card time, html[data-theme] .deadline-card>span,
html[data-theme] .deadline-dialog time, html[data-theme] .deadline-dialog p { color:var(--soft-text) }
html[data-theme] .deadline-dialog-details { color:var(--soft-text) }

html[data-theme] .reader { color:var(--soft-text) }
html[data-theme] .reader a { color:var(--green) }
html[data-theme] .reader blockquote, html[data-theme] .reader pre,
html[data-theme] .reader code, html[data-theme] .math-formula,
html[data-theme] .solution-html .formula { background:var(--surface-2); color:var(--text) }
html[data-theme] .reader th, html[data-theme] .reader td,
html[data-theme] .reader .notion-toggle-body { border-color:var(--line) }
html[data-theme] .reader .resource-card,
html[data-theme] .reader .notion-toggle { background:var(--surface-2); border-color:var(--line); color:var(--text) }
html[data-theme] .reader .notion-toggle>summary { color:var(--text) }
html[data-theme] .resource-icon { background:var(--surface); color:var(--green) }
html[data-theme] .resource-copy small, html[data-theme] .resource-action,
html[data-theme] .math-inline { color:var(--soft-text) }

html[data-theme] .answer-option { border-color:var(--line) }
html[data-theme] .answer-option:hover { background:var(--surface-2) }
html[data-theme] .question-card textarea,
html[data-theme] .admin-wrap input, html[data-theme] .admin-wrap select,
html[data-theme] .admin-wrap textarea { background:var(--surface); border-color:var(--line); color:var(--text) }
html[data-theme] .question-card details { color:var(--soft-text) }
html[data-theme] .question-card summary { color:var(--soft-text) }
html[data-theme] .question-card .correct-answer { background:var(--surface-2); color:var(--green) }
html[data-theme] .check-button { background:var(--primary); color:#192019 }
html[data-theme] .check-button:hover { background:#b8dfad }
html[data-theme] .admin-card, html[data-theme] .admin-item,
html[data-theme] .admin-list, html[data-theme] .subject-order-item { background:var(--card); border-color:var(--line); color:var(--text) }
html[data-theme] .admin-card p, html[data-theme] .admin-note { color:var(--muted) }
html[data-theme] .admin-wrap button.ghost { background:var(--surface); color:var(--text) }
html[data-theme] .admin-wrap button.danger { background:var(--surface-2); color:#b36767 }
html[data-theme] .admin-wrap button:not(.ghost):not(.danger):not(.theme-toggle) { background:var(--primary); color:#192019 }
html[data-theme] .admin-block, html[data-theme] .admin-list>div { border-color:var(--line) }
html[data-theme] .admin-top a { color:var(--soft-text) }
html[data-theme="light"] .app-side nav a.active,
html[data-theme="light"] .app-side nav .tree-home.active { background:transparent; color:var(--text) }
html[data-theme="light"] .app-side nav a.active:hover,
html[data-theme="light"] .app-side nav .tree-home.active:hover { background:#d8d8d8 }

/* Compact, one-question-at-a-time practice on phones. */
.training-intro { margin:18px 0 0; font-size:14px; line-height:1.65; max-width:850px }
.training-intro>summary { cursor:pointer; color:var(--text); font-weight:650 }
.training-intro>.solution-html { margin-top:14px }
.training-panel[hidden], .training-question-list[hidden] { display:none !important }
.training-mobile-nav, .training-question-list { display:none }
.question-check-row { display:flex; align-items:center; flex-wrap:wrap; column-gap:14px; row-gap:3px; margin-top:14px }
.question-check-row .check-button { margin-top:0 }
.question-check-row .answer-result { flex:1 1 150px; margin:0; line-height:1.4 }
.question-check-row .answer-result:empty { display:none }
@media (max-width:700px) {
  .training-header { padding-bottom:18px }
  .training-header h1 { margin-bottom:8px }
  .training-tabs { margin-top:6px; scroll-margin-top:18px }
  .training-mobile-nav { display:grid; grid-template-columns:44px minmax(0,1fr) 44px; align-items:center; gap:8px; margin:17px 0 12px }
  .training-mobile-nav button { display:grid; place-items:center; min-height:44px; padding:0; border:1px solid var(--line); border-radius:10px; background:var(--card); color:var(--text); font-weight:650; text-align:center }
  .training-mobile-nav button:disabled { color:var(--muted); opacity:.4; cursor:default }
  .training-mobile-nav button:focus-visible, .training-question-link:focus-visible { outline:2px solid var(--primary); outline-offset:2px }
  .training-arrow { position:relative; width:44px; height:44px; font-size:0; line-height:1 }
  .training-arrow::before { content:""; position:absolute; top:50%; left:50%; width:9px; height:9px; border-top:2px solid currentColor; border-right:2px solid currentColor; transform:translate(-65%,-50%) rotate(45deg) }
  #training-prev::before { transform:translate(-35%,-50%) rotate(-135deg) }
  .training-position { font-size:13px }
  .training-question-list:not([hidden]) { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; max-height:215px; overflow:auto; padding:12px; margin-bottom:12px; border:1px solid var(--line); border-radius:12px; background:var(--surface) }
  .training-question-link { min-height:41px; padding:7px 5px; border:1px solid var(--line); border-radius:8px; background:var(--card); color:var(--soft-text); font-size:11px; line-height:1.2 }
  .training-question-link.active { border-color:var(--text); color:var(--text); font-weight:700 }
  .training-panel .question-card { display:none; margin:0; padding:22px 19px 24px; min-height:340px; border-radius:13px }
  .training-panel .question-card.training-current { display:block }
  .training-panel .question-card h3 { font-size:19px; line-height:1.4 }
  .training-panel .answer-option { min-height:48px; align-items:center; padding:12px }
  .training-panel .answer-option input { margin-top:0 }
  .training-panel .check-button { min-height:44px; padding:9px 19px }
  .training-panel .question-check-row { flex-wrap:nowrap }
  .training-panel .question-check-row .answer-result { flex:1 1 auto; min-width:0 }
}
