/* dark theme kit for lessonkit (matches new.gimrostok dark2 feel) */
:root{color-scheme:light}
html.dark{color-scheme:dark}

html.dark{
  --bg:#0f172a;
  --card:#1e293b;
  --ink:#e2e8f0;
  --muted:#94a3b8;
  --line:rgba(255,255,255,.1);
  --accent:#2dd4bf;
  --accent-soft:rgba(45,212,191,.14);
  --plus:#4ade80;
  --minus:#f87171;
  --x:#93c5fd;
  --n:#fdba74;
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 18px 40px -24px rgba(0,0,0,.6);
}

@media (prefers-color-scheme:dark){
  html:not(.light){
    color-scheme:dark;
    --bg:#0f172a;
    --card:#1e293b;
    --ink:#e2e8f0;
    --muted:#94a3b8;
    --line:rgba(255,255,255,.1);
    --accent:#2dd4bf;
    --accent-soft:rgba(45,212,191,.14);
    --plus:#4ade80;
    --minus:#f87171;
    --x:#93c5fd;
    --n:#fdba74;
    --shadow:0 1px 2px rgba(0,0,0,.4), 0 18px 40px -24px rgba(0,0,0,.6);
  }
}

html.dark body{background:#0f172a;color:#e2e8f0}

/* hardcoded surfaces -> dark-aware */
html.dark .lk-index .module,
html.dark .lk-index .lesson-item,
html.dark .wizard__progress,
html.dark .wizard .step,
html.dark .wizard__nav,
html.dark .theme-toggle,
html.dark .theme-toggle__btn,
html.dark .quiz__opt,
html.dark .answer-block__input,
html.dark .lk-search__input,
html.dark .btn--ghost,
html.dark .definition,
html.dark .callout,
html.dark .example-block,
html.dark .summary-block,
html.dark .homework,
html.dark .answer-block__solution{background:#1e293b;border-color:rgba(255,255,255,.1);color:#e2e8f0}

html.dark .lk-index .module{background:#172132;border-color:rgba(255,255,255,.1)}
html.dark .lk-index .lesson-item{background:#1e293b;border-color:rgba(255,255,255,.1)}
html.dark .lk-index .lesson-item:hover{border-color:rgba(255,255,255,.18);background:#243447}
html.dark .lk-index .lesson-type--theory{background:rgba(45,212,191,.12);color:#2dd4bf;border-color:rgba(45,212,191,.25)}
html.dark .lk-index .lesson-type--practice{background:#243447;color:#cbd5e1;border-color:rgba(255,255,255,.1)}
html.dark .lesson-type{background:#243447;border-color:rgba(255,255,255,.1);color:#cbd5e1}
html.dark .lk-index .lesson-type:hover,html.dark .lesson-type:hover{background:rgba(45,212,191,.12);border-color:rgba(45,212,191,.35);color:#2dd4bf}

html.dark .stage,html.dark .cmp,html.dark .rule-card,html.dark .table,html.dark .code-block__pre{background:#172132;border-color:rgba(255,255,255,.1)}
html.dark .code-block__pre{color:#e2e8f0}
html.dark .table th{background:rgba(45,212,191,.08);color:#e2e8f0}
html.dark .cmp--hl{background:rgba(45,212,191,.08);border-color:#2dd4bf}
html.dark .feedback--ok{background:rgba(22,101,52,.25);color:#bbf7d0}
html.dark .feedback--no{background:rgba(153,27,27,.25);color:#fecaca}
html.dark .answer-block__explain--correct{background:rgba(22,101,52,.18);border-color:rgba(34,197,94,.25);color:#bbf7d0}
html.dark .answer-block__explain--incorrect{background:rgba(153,27,27,.18);border-color:rgba(248,113,113,.25);color:#fecaca}
html.dark .answer-block__input{background:#172132}
html.dark .answer-block__input:focus{background:#1e293b}
html.dark .answer-block__reveal{color:#94a3b8}
html.dark .answer-block__reveal:hover{color:#e2e8f0}
html.dark .wizard__next:disabled,html.dark .wizard__next[disabled]{background:#334155;color:#7f9488;border-color:#334155}
html.dark .wizard__bar{background:#334155}
html.dark .wizard__step-back{color:#94a3b8}
html.dark .wizard .step{border-color:rgba(255,255,255,.1)}
html.dark .wizard__nav{border-color:rgba(255,255,255,.1)}
html.dark .readbar{background:#334155}
html.dark .keypoint{background:rgba(45,212,191,.10)}
html.dark .callout--warning{background:rgba(251,146,60,.10)}
html.dark .callout--tip,html.dark .callout--success{background:rgba(74,222,128,.08)}
html.dark .callout--danger{background:rgba(248,113,113,.10)}
html.dark .quiz__opt--correct{background:rgba(22,101,52,.25);border-color:#4ade80;color:#bbf7d0}
html.dark .quiz__opt--wrong{background:rgba(153,27,27,.25);border-color:#f87171;color:#fecaca}
html.dark .quiz__opt--selected{background:rgba(45,212,191,.10);border-color:#2dd4bf}
html.dark .lk-empty{background:#172132;border-color:rgba(255,255,255,.1);color:#94a3b8}

/* theme toggle — minimal single icon, no color, no rectangle hover */
.theme-toggle{flex:0 0 auto;width:40px;height:40px;padding:0;margin:0;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:999px;background:transparent;color:var(--muted);cursor:pointer;box-shadow:none;-webkit-tap-highlight-color:transparent;transition:color var(--dur-base,.18s) var(--ease-soft,ease),opacity var(--dur-base,.18s) var(--ease-soft,ease)}
.theme-toggle .icon{width:22px;height:22px;position:relative;z-index:1;transition:transform var(--dur-slow,.28s) var(--ease-spring,cubic-bezier(.16,.84,.24,1)),opacity var(--dur-base,.18s) var(--ease-soft,ease)}
.theme-toggle__sun{display:inline-flex;align-items:center;justify-content:center;color:inherit}
.theme-toggle__moon{display:none;align-items:center;justify-content:center;color:inherit}
.theme-toggle:hover{color:var(--ink);background:transparent;box-shadow:none}
.theme-toggle:hover .icon{transform:rotate(-10deg) scale(1.04);opacity:1}
.theme-toggle:active .icon{transform:scale(.94)}
.theme-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:3px;border-radius:999px}
.theme-toggle[aria-pressed="true"]{color:var(--muted);background:transparent;box-shadow:none}

html.dark .theme-toggle__sun{display:none}
html.dark .theme-toggle__moon{display:inline-flex}
html.light .theme-toggle__sun{display:inline-flex}
html.light .theme-toggle__moon{display:none}
@media (prefers-color-scheme:dark){html:not(.light) .theme-toggle__sun{display:none}html:not(.light) .theme-toggle__moon{display:inline-flex}}
html.dark .theme-toggle{color:var(--muted);background:transparent;box-shadow:none}
html.dark .theme-toggle:hover{color:var(--ink);background:transparent;box-shadow:none}
@media (prefers-reduced-motion:reduce){.theme-toggle,.theme-toggle .icon{transition:none!important;animation:none!important}.theme-toggle:hover .icon,.theme-toggle:active .icon{transform:none}}

/* smooth theme switching */
html{transition:background-color var(--dur-slow,.28s) var(--ease-soft,ease),color var(--dur-slow,.28s) var(--ease-soft,ease)}
body,.module,.lesson-item,.wizard .step,.wizard__nav,.lk-search__input,.answer-block__input{transition:background-color var(--dur-slow,.28s) var(--ease-soft,ease),border-color var(--dur-slow,.28s) var(--ease-soft,ease),color var(--dur-slow,.28s) var(--ease-soft,ease)}
@media (prefers-reduced-motion:reduce){html{transition:none}body,.module,.lesson-item,.wizard .step,.wizard__nav,.lk-search__input,.answer-block__input{transition:none}}

/* layout for toggle on index + nav */
.index-hero{position:relative}
.index-hero .theme-toggle{position:absolute;top:0;right:0}
@media (max-width:900px){.index-hero .theme-toggle{position:static;margin-top:12px}}


/* print stays readable in dark mode */
@media print{
  html.dark body,html.dark{background:#fff;color:#000;color-scheme:light}
  html.dark .module,html.dark .lesson-item,html.dark .wizard .step,html.dark .wizard__nav{background:#fff;color:#000;border-color:#ccc;box-shadow:none}
}

/* smooth theme view-transition (falls back to CSS transitions) */
::view-transition-old(root){animation:lkFade .18s var(--ease-soft,ease) reverse both}
::view-transition-new(root){animation:lkFade .18s var(--ease-soft,ease) both}
@media (prefers-reduced-motion:reduce){::view-transition-old(root),::view-transition-new(root){animation:none}}


/* complete dark coverage for hardcoded light surfaces */
html.dark .hero__kicker{color:#94a3b8}
html.dark .cmp--hl{background:rgba(45,212,191,.08)}
html.dark .chips.highlight .chip--x{background:rgba(37,99,235,.18);color:#93c5fd}
html.dark .chips.highlight .chip--n{background:rgba(251,146,60,.15);color:#fdba74}
html.dark .cheat__row{background:#172132;border-color:rgba(255,255,255,.1)}
html.dark .quiz__opt:hover:not(:disabled){background:#243447;border-color:rgba(255,255,255,.18)}
html.dark .quiz__opt:hover{background:#243447}
html.dark .homework{background:#172132;border-color:rgba(255,255,255,.1)}
html.dark .toggle__btn{background:#1e293b;border-color:rgba(255,255,255,.1);color:#e2e8f0}
html.dark .toggle__btn--active{background:rgba(45,212,191,.12);border-color:#2dd4bf;color:#2dd4bf}
html.dark .changed{color:#f87171}
html.dark .callout--warning{background:rgba(251,146,60,.10);color:#e2e8f0}
html.dark .callout--tip,html.dark .callout--success{background:rgba(74,222,128,.08);color:#e2e8f0}
html.dark .callout--danger{background:rgba(248,113,113,.10);color:#e2e8f0}
html.dark .callout--note{border-left-color:#94a3b8}
html.dark .example-block{background:#172132;border-color:rgba(255,255,255,.1)}
html.dark .quote-block{background:#172132;border-color:rgba(255,255,255,.1);color:#e2e8f0}
html.dark .quote-block__meta{color:#94a3b8}
html.dark .checklist__mark{color:#94a3b8}
html.dark .checklist__item--done .checklist__mark{color:#4ade80}
html.dark .checklist__item--done .checklist__text{color:#94a3b8}
html.dark .table td{border-color:rgba(255,255,255,.1)}
html.dark .table tr:nth-child(even) td{background:rgba(127,127,127,.04)}
html.dark .video-block__frame{background:#0f172a;border-color:rgba(255,255,255,.1)}
html.dark .video-block__link{background:#1e293b;border-color:rgba(255,255,255,.1);color:#2dd4bf}
html.dark .video-block__link:hover{background:rgba(45,212,191,.12)}
html.dark .lesson-divider{border-top-color:rgba(255,255,255,.1)}
html.dark .details-block{background:#1e293b;border-color:rgba(255,255,255,.1)}
html.dark .details-block__summary{color:#e2e8f0}
html.dark .lk-index .module__meta{color:#94a3b8}
html.dark .lk-index .lesson-item__arrow{color:#94a3b8}
html.dark .lk-index .lesson-item__link{color:#e2e8f0}
html.dark .lesson-item__link:hover{color:#2dd4bf}
html.dark .lesson-type{background:#243447;border-color:rgba(255,255,255,.1);color:#cbd5e1}
html.dark .lk-index .lk-search__input{background:#172132;border-color:rgba(255,255,255,.1)}
html.dark .lk-index .lk-search__input:hover{border-color:rgba(255,255,255,.18);background:#1e293b}
html.dark .lk-index .lk-search__input:focus{border-color:#2dd4bf;background:#1e293b;box-shadow:0 0 0 3px rgba(45,212,191,.14)}
html.dark .lk-search__icon{color:#94a3b8}
html.dark .wizard__progress-label{color:#94a3b8}
html.dark .wizard__step-back{color:#94a3b8}
html.dark .wizard__step-back:hover{color:#2dd4bf}
html.dark .wizard .screen-block .step__lead{color:#cbd5e1}
html.dark .answer-block__reveal{color:#94a3b8}
html.dark .answer-block__reveal:hover{color:#e2e8f0}
html.dark .answer-block__input{border-color:rgba(255,255,255,.1);background:#172132;color:#e2e8f0}
html.dark .answer-block__row:focus-within .answer-block__input{border-color:#2dd4bf;background:#1e293b}
html.dark .answer-block__row:focus-within .answer-block__check{border-color:#2dd4bf}
html.dark .answer-block__check{border-color:transparent}
html.dark .answer-block__solution{background:#172132;border-color:rgba(255,255,255,.1);color:#e2e8f0}
html.dark .badge-draft{color:#fbbf24}
html.dark .badge-dur{color:#94a3b8}
html.dark .page-footer{color:#94a3b8}
html.dark .back-link{color:#94a3b8;background:#1e293b;border-color:rgba(255,255,255,.1)}
html.dark .back-link:hover{color:#2dd4bf;border-color:#2dd4bf}
html.dark .lk-skeleton{background:linear-gradient(90deg,#243447 25%,#334155 37%,#243447 63%)}
html.dark .hero__goal{background:#1e293b;border-color:rgba(255,255,255,.1)}
html.dark .step__num{color:#2dd4bf}
html.dark .module__meta{color:#94a3b8}


/* KaTeX dark mode */
html.dark .katex { color: var(--ink); }
html.dark .math-block { background: var(--card); border-color: rgba(255,255,255,.1); }
html.dark .math-expr { color: var(--ink); }
