/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* NOTE: body base styles are minimal here; each page adds its own */
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-ui);
}
body::-webkit-scrollbar { width: 4px; }
body::-webkit-scrollbar-thumb { background: var(--c-muted2); border-radius: 2px; }

/* ── Canvas & scanlines ─────────────────────────── */
#bg-canvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
}
.scanlines {
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 3px,
    rgba(0,0,0,.09) 3px, rgba(0,0,0,.09) 4px
  );
  pointer-events: none; z-index: 1;
}

/* ── Navbar ─────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-h); z-index: 100;
  background: #03071af5;
  border-bottom: 1px solid var(--c-border);
  backdrop-filter: blur(12px);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem; gap: 1rem;
}
.nav-brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; }
.nav-brand-hex { width: 28px; height: 28px; flex-shrink: 0; }
.nav-brand-name {
  font-family: var(--font-mono); font-size: .82rem; letter-spacing: .12em;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.nav-badge-pill {
  font-family: var(--font-mono); font-size: .58rem;
  background: #7b2fff33; border: 1px solid #7b2fff66;
  color: var(--c-purple); padding: .15rem .5rem;
  border-radius: 2px; letter-spacing: .1em;
}
.nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-clock { font-family: var(--font-mono); font-size: .7rem; color: var(--c-cyan); letter-spacing: .1em; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  background: none; border: 1px solid var(--c-border); border-radius: 3px;
  color: var(--c-muted); font-family: var(--font-mono); font-size: .68rem;
  letter-spacing: .1em; padding: .38rem .85rem; cursor: pointer;
  transition: border-color .2s, color .2s, box-shadow .2s;
  white-space: nowrap; user-select: none; display: inline-block;
}
.btn:hover:not(:disabled) { border-color: var(--c-blue); color: var(--c-text); }
.btn:focus-visible { outline: 1px solid var(--c-cyan); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--primary { border-color: var(--c-blue); color: var(--c-cyan); }
.btn--primary:hover:not(:disabled) { border-color: var(--c-cyan); box-shadow: 0 0 10px #00c8ff20; }
.btn--danger  { border-color: #ff3c6e55; color: var(--c-error); }
.btn--danger:hover:not(:disabled)  { border-color: var(--c-error); box-shadow: 0 0 10px #ff3c6e20; }
.btn--success { border-color: #00ffb055; color: var(--c-green); }
.btn--success:hover:not(:disabled) { border-color: var(--c-green); box-shadow: 0 0 10px #00ffb020; }
.btn--sm { padding: .24rem .6rem; font-size: .62rem; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
/* Settings: отбивка между группой кнопок темы и заголовком «Режим» (CSP режет inline style) */
#theme-options { margin-bottom: 1.4rem; }

/* ── Form labels ─────────────────────────────────── */
.fl {
  font-family: var(--font-mono); font-size: .64rem; color: var(--c-cyan);
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: .45rem; display: block;
}

/* ── Form inputs ─────────────────────────────────── */
.fi, .fs, .fta {
  width: 100%; background: #030918; border: 1px solid var(--c-border);
  border-radius: 3px; padding: .65rem .9rem; color: var(--c-text);
  font-family: var(--font-mono); font-size: .82rem; outline: none;
  transition: border-color .2s; line-height: 1.4;
}
.fi:focus, .fs:focus, .fta:focus {
  border-color: var(--c-cyan); box-shadow: 0 0 0 1px #00c8ff15;
}
.fi:-webkit-autofill, .fs:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #030918 inset !important;
  -webkit-text-fill-color: var(--c-text) !important;
}
.fs { cursor: pointer; }
.fs option { background: #070d24; }
.fta { resize: vertical; min-height: 90px; line-height: 1.55; }

/* ── Form rows ───────────────────────────────────── */
.form-row   { display: grid; gap: 1.2rem; margin-bottom: 1.2rem; }
.form-row--2 { grid-template-columns: 1fr 1fr; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block; font-family: var(--font-mono); font-size: .6rem;
  padding: .14rem .5rem; border-radius: 2px; letter-spacing: .06em; white-space: nowrap;
}
.badge--pass   { background: #00ffb01a; border: 1px solid #00ffb044; color: var(--c-green); }
.badge--fail   { background: #ff3c6e1a; border: 1px solid #ff3c6e44; color: var(--c-error); }
.badge--on     { background: #00ffb01a; border: 1px solid #00ffb044; color: var(--c-green); }
.badge--off    { background: #4a608022; border: 1px solid #4a608055; color: var(--c-muted); }
.badge--pend   { background: #ffaa0022; border: 1px solid #ffaa0055; color: var(--c-warn); }
.badge--admin  { background: #7b2fff22; border: 1px solid #7b2fff55; color: var(--c-purple); }
.badge--active  { background: #00c8ff1a; border: 1px solid #00c8ff44; color: var(--c-cyan); }
.badge--teacher { background: #ff7a0022; border: 1px solid #ff7a0055; color: #ff9d3a; }
.badge--student { background: #00c8ff1a; border: 1px solid #00c8ff44; color: var(--c-cyan); }

/* ── Alerts ──────────────────────────────────────── */
.alert {
  padding: .75rem 1.1rem; border-radius: 3px; font-family: var(--font-mono);
  font-size: .72rem; letter-spacing: .04em; margin-bottom: 1.1rem;
  display: none; line-height: 1.5;
}
.alert--show { display: block; }
.alert--ok  { background: #00ffb010; border: 1px solid #00ffb044; color: var(--c-green); }
.alert--err { background: #ff3c6e10; border: 1px solid #ff3c6e44; color: var(--c-error); }

/* ── Loading overlay ─────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: #03071a; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: .82rem; color: var(--c-cyan);
  letter-spacing: .1em; flex-direction: column; gap: 1rem;
}
.spinner {
  width: 32px; height: 32px; border: 2px solid #00c8ff20;
  border-top-color: var(--c-cyan); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: #000000cc; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay--open { opacity: 1; pointer-events: all; }
.modal {
  background: #04091f; border: 1px solid var(--c-border); border-radius: 5px;
  width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto;
  transform: translateY(12px); transition: transform .2s;
  scrollbar-width: thin; scrollbar-color: var(--c-muted2) transparent;
  box-shadow: 0 0 40px #00c8ff14;
}
.modal--wide { max-width: min(98vw, 1800px); }
.modal--wide .modal__body { padding: .75rem 1rem; }
.modal--wide td, .modal--wide th { padding: .32rem .65rem; font-size: .8rem; }
.modal-overlay--open .modal { transform: translateY(0); }
.modal::-webkit-scrollbar { width: 3px; }
.modal::-webkit-scrollbar-thumb { background: var(--c-muted2); border-radius: 2px; }
.modal__hdr {
  padding: 1.1rem 1.4rem 1rem; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  position: sticky; top: 0; background: #04091f; z-index: 1;
}
.modal__title {
  font-family: var(--font-mono); font-size: .9rem;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  letter-spacing: .08em;
}
.modal__body { padding: 1.4rem; }
.modal__foot {
  padding: 1rem 1.4rem 1.4rem; border-top: 1px solid var(--c-border);
  display: flex; gap: .6rem; justify-content: flex-end;
}

/* ── Tables ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: 4px; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th {
  font-family: var(--font-mono); font-size: .62rem; color: var(--c-muted);
  letter-spacing: .1em; text-transform: uppercase; padding: .7rem 1rem;
  background: #030a1a; border-bottom: 1px solid var(--c-border);
  text-align: left; white-space: nowrap;
}
td {
  padding: .68rem 1rem; border-bottom: 1px solid #1a3a6022;
  vertical-align: middle; color: var(--c-text); white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #0a1530; }
td.wrap { white-space: normal; max-width: 280px; }
.mono { font-family: var(--font-mono); font-size: .76rem; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: 4px; padding: 1.4rem 1.6rem; margin-bottom: 1.4rem;
}
.card__title {
  font-family: var(--font-mono); font-size: .7rem; color: var(--c-cyan);
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: 1.1rem;
  display: flex; align-items: center; gap: .7rem;
}
.card__title::after { content: ''; flex: 1; height: 1px; background: var(--c-border); }

/* ── Status / live dots ──────────────────────────── */
.sdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .4em; vertical-align: middle; }
.sdot--on  { background: var(--c-green); box-shadow: 0 0 5px var(--c-green); }
.sdot--off { background: var(--c-muted); }
.ldot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }
.ldot--alive { background: #ff3c6e; box-shadow: 0 0 5px #ff3c6e; }
.ldot--dead  { background: #2a4060; }

/* ── Attempt table rows ──────────────────────────── */
.ans-row--correct td { background: #001a0e33; }
.ans-row--wrong   td { background: #1a000a33; }

@media (max-width: 480px) {
  .nav { padding: 0 .75rem; }
  .nav-clock { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Markdown-rendered content ───────────────────── */
.md-body { line-height: 1.75; color: var(--c-text); font-size: .9rem; }
.md-body > :first-child { margin-top: 0 !important; }
.md-body .md-blank { height: .9em; }
.md-body .md-h  { font-family: var(--font-mono); letter-spacing: .06em; margin: 1.4em 0 .5em; line-height: 1.3; color: var(--c-cyan); }
.md-body .md-h1 { font-size: 1.9rem; }
.md-body .md-h2 { font-size: 1.5rem; }
.md-body .md-h3 { font-size: 1.2rem; }
.md-body .md-h4 { font-size: 1rem;   }
.md-body .md-h5 { font-size: .88rem; }
.md-body .md-h6 { font-size: .82rem; }
.md-body .md-p  { margin: .6em 0; }
.md-body .md-pre {
  background: #020814; border: 1px solid var(--c-border); border-radius: 4px;
  padding: 1rem 1.1rem; overflow-x: auto; margin: 1em 0;
  font-family: var(--font-mono); font-size: .78rem; line-height: 1.55;
}
.md-body .md-code {
  font-family: var(--font-mono); font-size: .82em;
  background: #020814; border: 1px solid var(--c-border);
  border-radius: 2px; padding: .1em .4em; color: var(--c-cyan);
}
.md-body .md-pre .md-code { background: none; border: none; padding: 0; color: var(--c-text); }
.md-body .md-ul,.md-body .md-ol { margin: .6em 0 .6em 1.6em; }
.md-body .md-ul li,.md-body .md-ol li { margin: .3em 0; }
.md-body .md-blockquote {
  border-left: 3px solid var(--c-blue); margin: 1em 0;
  padding: .4em 1em; background: #030b1a; border-radius: 0 3px 3px 0;
}
.md-body .md-blockquote .md-p { margin: .2em 0; color: var(--c-muted); }
.md-body .md-blockquote--pipe {
  border-left-color: var(--c-cyan);
  background: linear-gradient(90deg, #00c8ff08 0%, transparent 100%);
  padding-left: 1.1em;
}
.md-body .md-blockquote--pipe .md-p { color: #c8dff0; }
.md-body .md-img { max-width: 100%; border-radius: 4px; display: block; margin: .8em 0; }
.md-body .md-a { color: var(--c-cyan); text-decoration: underline; text-underline-offset: 3px; }
.md-body .md-a:hover { color: var(--c-blue); }
.md-body .md-hr { border: none; border-top: 1px solid var(--c-border); margin: 1.5em 0; }

/* Markdown editor split pane */
.md-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2.5rem !important; }
@media (max-width: 700px) { .md-editor { grid-template-columns: 1fr; } }
.md-editor__pane { display: flex; flex-direction: column; gap: .4rem; }
.md-editor__label { font-family: var(--font-mono); font-size: .6rem; color: var(--c-muted); letter-spacing: .1em; }
.md-editor__preview {
  background: #04091f; border: 1px solid var(--c-border); border-radius: 3px;
  padding: .65rem .9rem; min-height: 180px; overflow-y: auto; box-sizing: border-box;
}
.md-img-btn { display: flex; align-items: center; gap: .5rem; margin-top: .3rem; }
.art-nav { display: flex; align-items: center; gap: .5rem; width: 100%; flex-wrap: wrap; }
.art-nav__count { flex: 1; text-align: center; font-family: var(--font-mono); font-size: .65rem; color: var(--c-muted); letter-spacing: .06em; }
