:root {
  --bg: #0c0c0d;
  --bg-card: #111113;
  --bg-hover: #1f1f23;
  --bg-input: #0f0f11;
  --border: #27272a;
  --border-soft: #1f1f22;
  --text: #f4f4f5;
  --text-muted: #9b9ba3;
  --text-dim: #71717a;
  --primary: #d6d6de;
  --primary-hover: #ffffff;
  --accent: #ffffff;
  --success: #f4f4f5;
  --error: #a1a1aa;
  --warning: #d4d4d8;
  --teacher: #e4e4e7;
  --student: #e4e4e7;
  --radius: 10px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  /* Code theme — cold slate */
  --code-bg: #12151a;
  --code-border: #2a3038;
  --code-text: #d8dee6;
  --code-inline-bg: #1a1f27;
  --code-inline-border: #323843;
  --code-keyword: #7eb6ff;
  --code-string: #9dcfb0;
  --code-number: #e0b278;
  --code-function: #8ec7e8;
  --code-comment: #6b7380;
  --code-builtin: #c9b4a0;
  --code-meta: #9aa3b2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

* {
  scrollbar-color: #3f3f46 transparent;
  scrollbar-width: thin;
}

*:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.72);
  outline-offset: 2px;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.055), transparent 34rem),
    linear-gradient(180deg, #101013 0%, var(--bg) 18rem);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

::selection {
  background: rgba(255, 255, 255, 0.18);
}

.hidden { display: none !important; }

pre,
textarea,
input {
  caret-color: var(--accent);
}

/* Login */
#login-screen,
#register-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.08) 0%, transparent 42%),
    var(--bg);
}

.login-card {
  background: rgba(17, 17, 19, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.logo { text-align: center; margin-bottom: 2rem; }
.logo h1 { font-size: 1.75rem; font-weight: 700; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}
.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  transition: background 0.16s, border-color 0.16s, box-shadow 0.16s;
}
.form-group input:focus {
  outline: none;
  background: #111113;
  border-color: #3f3f46;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s, opacity 0.16s;
}
.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none !important;
  filter: grayscale(0.35);
  pointer-events: none;
}
.btn-primary { background: #f4f4f5; color: #09090b; }
.btn-primary:hover:not(:disabled) { background: #ffffff; }
.btn-full { width: 100%; padding: 0.85rem; font-size: 1rem; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); border-color: #3f3f46; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: #52525b; color: #fff; }
.btn-success { background: #ededf0; color: #09090b; }
.btn-success:hover:not(:disabled) { background: #fff; }
.btn-success:disabled {
  background: #3f3f46;
  color: #a1a1aa;
  opacity: 1;
  filter: none;
}

.error-msg {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid #3f3f46;
  color: var(--error);
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: rgba(17, 17, 19, 0.88);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
}
.header-left { display: flex; align-items: center; gap: 0.5rem; }
.brand { font-weight: 700; font-size: 1.1rem; }

.nav {
  display: flex;
  gap: 0.25rem;
  background: #0f0f11;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.2rem;
}
.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn.active {
  background: #242428;
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.header-right { display: flex; align-items: center; gap: 0.75rem; }
.user-badge {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-weight: 600;
}
.user-badge.teacher,
.user-badge.student {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

.user-badge.teacher {
  cursor: pointer;
}

.user-badge.teacher:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Layout */
#main-screen { min-height: 100vh; display: flex; flex-direction: column; }
.main-content { flex: 1; display: flex; overflow: hidden; height: calc(100vh - 57px); position: relative; }
.view {
  display: flex;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.sidebar {
  width: 280px;
  min-width: 280px;
  background: rgba(17, 17, 19, 0.74);
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}
.sidebar h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.item-list { list-style: none; }
.item-list li {
  padding: 0.62rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  border: 1px solid transparent;
}
.item-list li:hover { background: rgba(255, 255, 255, 0.045); }
.item-list li.active {
  background: #242428;
  border-color: #333338;
  color: var(--text);
  font-weight: 500;
}

.content-panel {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.25rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  height: 100%;
  color: var(--text-muted);
}

/* Theory content */
.theory-article {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.theory-article > :first-child { margin-top: 0; }
.theory-article > :last-child { margin-bottom: 0; }
.theory-article h1 {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 1rem;
  color: var(--text);
}
.theory-article h2 {
  font-size: 1.35rem;
  font-weight: 650;
  line-height: 1.3;
  margin: 1.75rem 0 0.85rem;
  color: var(--text);
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-soft);
}
.theory-article h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.4rem 0 0.55rem;
  color: var(--text);
}
.theory-article p { margin: 0 0 0.9rem; color: var(--text-muted); }
.theory-article ul,
.theory-article ol {
  margin: 0.75rem 0 0.95rem 1.35rem;
  color: var(--text-muted);
}
.theory-article li { margin-bottom: 0.4rem; }
.theory-article li > ul,
.theory-article li > ol { margin-top: 0.35rem; }
.theory-article blockquote {
  margin: 1rem 0;
  padding: 0.65rem 1rem;
  border-left: 3px solid #3f3f46;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
}
.theory-article blockquote p:last-child { margin-bottom: 0; }
.theory-article a {
  color: #e4e4e7;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.theory-article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}
.theory-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}
.theory-article th,
.theory-article td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
}
.theory-article th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.theory-article td { color: var(--text-muted); }
.theory-article img {
  max-width: 100%;
  border-radius: 8px;
  margin: 0.75rem 0;
}
.theory-article :not(pre) > code,
.theory-article > code {
  display: inline;
  background: var(--code-inline-bg);
  border: 1px solid var(--code-inline-border);
  padding: 0.12rem 0.4rem;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.86em;
  font-weight: 500;
  color: var(--code-text);
}
.theory-article pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  margin: 1rem 0 1.2rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.theory-article pre code {
  display: block;
  background: none !important;
  border: none !important;
  padding: 0 !important;
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.7;
  white-space: pre;
}

/* Task panel */
.task-header { margin-bottom: 1.5rem; }
.task-header h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.task-description {
  margin-top: 0.75rem;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0;
}
.task-description > .theory-article {
  margin-bottom: 1rem;
}
.task-description > .theory-article > :first-child { margin-top: 0; }
.task-description > .theory-article > :last-child { margin-bottom: 0; }

.code-section { margin-top: 1.5rem; }
.code-section label,
.stdin-section label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.code-editor {
  width: 100%;
  min-height: 220px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.7;
  resize: vertical;
  tab-size: 4;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}
.code-editor:focus {
  outline: none;
  border-color: #3d4654;
  box-shadow: 0 0 0 3px rgba(126, 182, 255, 0.12);
}

.sandbox-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.stdin-section { margin-top: 1rem; }
.stdin-editor {
  width: 100%;
  min-height: 74px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}
.stdin-editor:focus {
  outline: none;
  border-color: #3f3f46;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.task-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  align-items: center;
}

.submission-result {
  margin-top: 1.5rem;
  border-radius: var(--radius);
  padding: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
.submission-result.passed {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid #3f3f46;
  color: var(--text);
}
.submission-result.failed {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid #333338;
  color: var(--text);
}
.submission-result-summary {
  margin: 0;
  font-weight: 600;
}
.submission-result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.submission-result-toolbar .submission-result-summary {
  margin: 0;
}
.submission-output-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0.5rem 0 0;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.submission-output-toggle:hover {
  color: var(--text);
  border-color: #3f3f46;
  background: var(--bg-hover);
}
.submission-test-value-full,
.submission-test-value-preview {
  display: none;
}
.submission-result-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.submission-test-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 0.75rem 0.85rem;
}
.submission-test-row.passed {
  border-color: #c0c0c0;
  box-shadow: 0 0 0 1px rgba(192, 192, 192, 0.35);
}
.submission-test-body {
  flex: 1 1 auto;
  min-width: 0;
}
.submission-test-mark {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
}
.submission-test-mark.ok { color: #e4e4e7; }
.submission-test-mark.bad { color: #a1a1aa; }
.submission-test-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem 0.55rem;
}
@media (max-width: 720px) {
  .submission-test-grid {
    grid-template-columns: 1fr;
  }
}
.submission-test-label {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
}
.submission-test-value,
.submission-result-plain {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  min-height: 1.35em;
}
.submission-test-error {
  margin-top: 0.55rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.submissions-history {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.submissions-history h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.submissions-history-toggle {
  margin-top: 0.75rem;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.history-status {
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.history-status.passed {
  background: #f4f4f5;
  color: #09090b;
}
.history-status.failed {
  background: #18181b;
  color: var(--text-muted);
  border: 1px solid #3f3f46;
}
.history-date { color: var(--text-muted); margin-left: auto; }

.empty-history {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.75rem 0;
}

.history-author {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.teacher-note {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.muted {
  color: var(--text-muted);
}

.submission-card {
  border-bottom: 1px solid var(--border);
}

.submission-card-summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  list-style: none;
  padding: 0.72rem 0;
  transition: background 0.15s;
}

.submission-card-summary::-webkit-details-marker {
  display: none;
}

.submission-card-summary:hover .expand-hint {
  color: var(--text);
}

.summary-left {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  min-width: 0;
}

.submission-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.expand-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.submission-card[open] .expand-hint {
  color: var(--text);
}

.submission-details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.25rem 0 1rem;
  align-items: stretch;
}

.submission-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.submission-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  min-height: 1.25rem;
  flex: 0 0 auto;
}

.submission-details-grid h3 {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  margin: 0;
  text-transform: uppercase;
}

.submission-details-grid .submission-result-summary {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.submission-code,
.submission-output {
  flex: 1 1 auto;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 1rem;
  white-space: pre-wrap;
  margin: 0;
  box-sizing: border-box;
}

.submission-col .submission-result-list {
  flex: 1 1 auto;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
}

.submission-col .submission-test-row {
  flex: 0 0 auto;
}

@media (max-width: 768px) {
  .sidebar { width: 220px; min-width: 220px; }
  .content-panel { padding: 1.25rem; }
  .nav-btn { padding: 0.4rem 0.6rem; font-size: 0.8rem; }
  .submission-card-summary,
  .submission-details-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
  .submission-card-meta {
    justify-content: flex-start;
  }
}

.register-footer {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.register-footer a {
  color: var(--text);
  text-decoration: none;
}

.register-footer a:hover {
  text-decoration: underline;
}

.submissions-panel,
.profile-panel {
  max-width: 960px;
}

#stats-view {
  width: 100%;
}

.stats-panel {
  width: 100%;
  max-width: none;
  padding: 1.5rem 2rem 2rem;
}

.stats-page {
  width: 100%;
  max-width: none;
}

.submissions-page h1,
.stats-page h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.stats-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(12rem, 18rem));
  gap: 0.75rem;
  margin: 1.25rem 0 1.75rem;
}

.stats-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stats-filter select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}

.stats-students {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr));
  gap: 1.25rem;
  width: 100%;
}

.stats-student-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 17, 19, 0.72);
  padding: 1rem 1.1rem 1.15rem;
}

.stats-student-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.stats-student-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.stats-student-score {
  min-width: 9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.stats-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.stats-count {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
}

.stats-meter {
  display: inline-block;
  width: 5.5rem;
  height: 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  vertical-align: middle;
}

.stats-meter.wide {
  width: 9rem;
}

.stats-meter-fill {
  display: block;
  height: 100%;
  background: rgba(244, 244, 245, 0.78);
}

.stats-lesson,
.stats-topic {
  border-top: 1px solid var(--border-soft);
}

.stats-lesson-summary,
.stats-topic-summary {
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  align-items: center;
  cursor: pointer;
  padding: 0.75rem 0.15rem;
}

.stats-lesson-summary::-webkit-details-marker,
.stats-topic-summary::-webkit-details-marker {
  display: none;
}

.stats-lesson-title,
.stats-topic-title {
  font-weight: 500;
}

.stats-kind {
  display: inline-block;
  margin-right: 0.45rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.stats-topics {
  padding: 0 0 0.35rem 0.75rem;
}

.stats-task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 0 0.85rem 0.15rem;
}

.stats-task-row {
  display: block;
  padding: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.stats-task-row.is-empty {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
}

.stats-task-details {
  width: 100%;
}

.stats-task-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  cursor: pointer;
  padding: 0.45rem 0.55rem;
}

.stats-task-summary::-webkit-details-marker {
  display: none;
}

.stats-task-summary .expand-hint {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.stats-task-details[open] .expand-hint {
  color: var(--text-muted);
}

.stats-task-submissions {
  padding: 0.35rem 0.55rem 0.7rem;
}

.stats-submissions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stats-submissions-list .submission-card {
  margin: 0;
}

.stats-task-meta {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-shrink: 0;
}

.stats-pill {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stats-task-row.status-passed .stats-pill {
  color: var(--text);
}

.stats-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.stats-profile-block {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-soft);
}

.stats-profile-block h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.stats-jump-note {
  margin-top: 1rem;
}

.stats-lessons.compact .stats-lesson-summary,
.stats-lessons.compact .stats-topic-summary {
  padding: 0.55rem 0.1rem;
}

@media (max-width: 800px) {
  .stats-filters {
    grid-template-columns: 1fr;
  }

  .stats-student-header {
    flex-direction: column;
  }

  .stats-student-score {
    align-items: stretch;
    width: 100%;
  }

  .stats-lesson-summary,
  .stats-topic-summary {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .stats-lesson-summary .stats-meter,
  .stats-topic-summary .stats-meter {
    display: none;
  }
}

.profile-section {
  margin-bottom: 2rem;
}

.profile-section h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.profile-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.profile-desc {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.profile-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.invite-row {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.invite-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.students-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.students-list li {
  border-bottom: 1px solid var(--border-soft);
}

.students-list li:last-child {
  border-bottom: none;
}

.student-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.student-item:hover,
.student-item.active {
  background: var(--bg-hover);
}

.student-item:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.72);
  outline-offset: -1px;
}

.student-submissions-panel {
  margin-top: 1.5rem;
}

.history-task {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.profile-students-section {
  margin-bottom: 0;
}

.student-name {
  font-weight: 500;
}

.student-login {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sidebar-header h2 {
  margin-bottom: 0;
}

.materials-lesson-nav {
  gap: 0.35rem;
}

.materials-lesson-nav h2 {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.3;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.lesson-nav-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.lesson-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: #52525b;
}

.lesson-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.item-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.visibility-badge {
  display: none;
}

.is-closed {
  opacity: 0.45;
}

.is-closed:hover,
.is-closed.active,
.nav-topic-block.is-closed > .nav-topic-item:hover,
.nav-topic-block.is-closed > .nav-topic-item.active {
  opacity: 0.72;
}

.plan-lesson-card.is-closed,
.topic-card.is-closed,
.manage-item.is-closed {
  opacity: 0.45;
}

.plan-lesson-card.is-closed:hover,
.topic-card.is-closed:hover,
.manage-item.is-closed:hover {
  opacity: 0.7;
}

/* Nested closed topic header only — tasks keep their own dimming */
.nav-topic-block.is-closed > .nav-nested-tasks,
.nav-topic-block.is-closed > .nav-teacher-action {
  opacity: 1;
}

.topic-theory-body.is-closed {
  opacity: 0.45;
}

.course-tabs {
  display: flex;
  gap: 0.25rem;
  background: #0f0f11;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.2rem;
  width: fit-content;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.course-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.course-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.course-tab.active {
  background: #242428;
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.course-preview-hint {
  margin-bottom: 1rem;
}

.student-preview {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.015);
}

.student-preview-banner {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.student-preview-layout {
  display: flex;
  min-height: 420px;
  max-height: 70vh;
}

.student-preview-sidebar {
  width: 260px;
  min-width: 220px;
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
  background: rgba(17, 17, 19, 0.55);
}

.student-preview-sidebar h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.student-preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
}

.student-preview-content .code-editor {
  min-height: 160px;
  opacity: 0.92;
}

@media (max-width: 900px) {
  .student-preview-layout {
    flex-direction: column;
    max-height: none;
  }

  .student-preview-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 220px;
  }
}


.course-manage {
  max-width: 980px;
}

.course-manage h1 {
  font-size: 1.6rem;
  margin-bottom: 0.35rem;
}

.course-student-line {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.visibility-student-select {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
  max-width: 360px;
  font-size: 0.9rem;
  font-weight: 600;
}

.visibility-student-select select {
  font-weight: 500;
}

.course-block {
  margin-bottom: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-soft);
}

.course-block h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.manage-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.manage-item-title {
  font-weight: 500;
}

.manage-item-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.course-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.015);
}

.course-form textarea,
.course-form select,
.course-form input[type="text"],
.course-form input[type="number"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
}

.course-form textarea {
  min-height: 110px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.course-form .form-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 0.75rem;
}

.course-form .checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.course-form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.course-create-card {
  max-width: 520px;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-danger-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #52525b;
  color: var(--text);
}

.content-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

body.modal-open {
  overflow: hidden;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-root.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: #121214;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: #121214;
  z-index: 2;
}

.modal-header h2 {
  font-size: 1.1rem;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.modal-body {
  padding: 1.25rem;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-form input,
.modal-form textarea,
.modal-form select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
}

.modal-form input[type="checkbox"],
.modal-form input[type="radio"] {
  width: auto;
  padding: 0;
  margin: 0;
  accent-color: #e4e4e7;
  flex-shrink: 0;
}

.modal-form textarea {
  font-family: var(--mono);
  font-size: 0.85rem;
  resize: vertical;
}

.modal-form .checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
}

.course-students-fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem 1rem;
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
}

.course-students-fieldset legend {
  padding: 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.student-pick-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.65rem;
  max-height: 240px;
  overflow: auto;
}

.student-pick-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.student-pick-item:hover {
  border-color: #3f3f46;
  background: var(--bg-hover);
}

.student-pick-item:has(input:checked) {
  border-color: #52525b;
  background: rgba(255, 255, 255, 0.05);
}

.student-pick-item input {
  width: auto !important;
  flex-shrink: 0;
}

.student-pick-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.student-pick-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.student-pick-user {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.field-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.45rem 0 0;
}

.task-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.modal.modal-wide {
  width: min(960px, 100%);
}

/* Full-page theory markdown editor */
.theory-editor-panel {
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
  background: #0e0e10;
  height: 100%;
}

.theory-editor-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.theory-editor-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: #121214;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
}

.theory-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.theory-icon-btn svg {
  width: 18px;
  height: 18px;
}

.theory-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: #3f3f46;
}

.theory-icon-btn-primary {
  background: #e4e4e7;
  border-color: #e4e4e7;
  color: #111113;
}

.theory-icon-btn-primary:hover {
  background: #fff;
  border-color: #fff;
  color: #111113;
}

.theory-editor-title-input {
  flex: 1;
  min-width: 0;
  height: 2.35rem;
  padding: 0 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
}

.theory-mode-tabs {
  display: flex;
  gap: 0.15rem;
  background: #0f0f11;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 0.15rem;
  flex-shrink: 0;
}

.theory-mode-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.theory-mode-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.theory-mode-tab.active {
  background: #242428;
  color: var(--text);
}

.theory-editor-pane,
.theory-ai-pane {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.theory-ai-pane {
  gap: 0.65rem;
  padding: 0.35rem 0.15rem 0.15rem;
}

.theory-ai-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.theory-ai-prompt {
  flex: 1 1 0;
  min-height: 12rem;
  width: 100%;
  resize: none;
  padding: 0.85rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
}

.theory-ai-prompt:focus {
  outline: none;
  border-color: #3f3f46;
}

.theory-ai-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.task-ai-type-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.task-ai-type-row .theory-ai-label {
  margin: 0;
}

.theory-ask-form .theory-ask-selection {
  margin: 0;
  max-height: 8rem;
  overflow: auto;
  padding: 0.75rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.theory-ask-form textarea {
  min-height: 7rem;
}

.theory-editor-visibility {
  color: var(--text-dim);
  position: relative;
  z-index: 40;
}

.theory-editor-visibility.is-on {
  color: #111113;
  background: #e4e4e7;
  border-color: #e4e4e7;
}

.theory-editor-visibility:not(.is-on) {
  color: var(--text-muted);
  background: transparent;
}

.theory-editor-visibility:disabled {
  opacity: 0.55;
  cursor: wait;
}

.theory-editor-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.65rem 0.65rem;
  overflow: hidden;
}

#theory-editor-error {
  margin: 0 0.65rem 0.55rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .theory-editor-bar {
    flex-wrap: wrap;
  }
  .theory-editor-title-input {
    order: 1;
    flex: 1 1 calc(100% - 4.5rem);
  }
  .theory-mode-tabs {
    order: 2;
  }
  .theory-editor-visibility {
    order: 3;
  }
}

.theory-editor-body .EasyMDEContainer {
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #121214;
}

.theory-editor-body .EasyMDEContainer .editor-toolbar {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  flex: 0 0 auto;
  padding: 0.2rem 0.35rem;
  position: sticky;
  top: 0;
  z-index: 8;
  background: #161618;
}

.theory-editor-body .EasyMDEContainer .editor-toolbar button {
  width: 26px !important;
  height: 26px !important;
}

.theory-editor-body .EasyMDEContainer .editor-statusbar {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  flex: 0 0 auto;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
}

.theory-editor-body .EasyMDEContainer .CodeMirror {
  flex: 1 1 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none;
  border: none;
  border-radius: 0;
  font-size: 0.82rem;
  overflow: hidden;
}

.theory-editor-body .EasyMDEContainer .CodeMirror-scroll {
  min-height: 0 !important;
  max-height: 100%;
}

.theory-editor-body .EasyMDEContainer .CodeMirror-sizer,
.theory-editor-body .EasyMDEContainer .CodeMirror-lines {
  min-height: 0 !important;
}

/* Full preview mode also scrolls under fixed toolbar */
.theory-editor-body .EasyMDEContainer .editor-preview {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 0;
  background: #101012;
}

/* Side-by-side: toolbar sticky, panes scroll independently */
.theory-editor-body .EasyMDEContainer.sided--no-fullscreen {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
}

.theory-editor-body .EasyMDEContainer.sided--no-fullscreen .editor-toolbar {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 8;
}

.theory-editor-body .EasyMDEContainer.sided--no-fullscreen .editor-statusbar {
  grid-column: 1 / -1;
  grid-row: 3;
  width: 100%;
}

.theory-editor-body .EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided {
  grid-column: 1;
  grid-row: 2;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100%;
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  border: none !important;
  border-right: 1px solid var(--border) !important;
  overflow: hidden;
}

.theory-editor-body .EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side {
  grid-column: 2;
  grid-row: 2;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  display: block !important;
  overflow: auto;
  padding: 0.85rem 1rem;
  background: #101012;
  border: none;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .theory-editor-body .EasyMDEContainer.sided--no-fullscreen {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr) auto;
  }
  .theory-editor-body .EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided {
    grid-column: 1;
    grid-row: 2;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .theory-editor-body .EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side {
    grid-column: 1;
    grid-row: 3;
  }
  .theory-editor-body .EasyMDEContainer.sided--no-fullscreen .editor-statusbar {
    grid-row: 4;
  }
}

.markdown-editor-field {
  gap: 0.5rem;
}

.markdown-editor-field .EasyMDEContainer {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* EasyMDE — dark theme to match app */
.EasyMDEContainer .editor-toolbar {
  background: #161618;
  border-color: var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 1;
}

.EasyMDEContainer .editor-toolbar button {
  color: var(--text-muted) !important;
  border: 0 !important;
  border-radius: 6px !important;
}

.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
  background: var(--bg-hover) !important;
  color: var(--text) !important;
}

.EasyMDEContainer .editor-toolbar i.separator {
  border-left-color: var(--border);
  border-right-color: transparent;
}

.EasyMDEContainer .CodeMirror {
  background: var(--bg-input);
  color: var(--text);
  border-color: var(--border);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.55;
  min-height: 320px;
}

.EasyMDEContainer .CodeMirror-scroll {
  min-height: inherit;
}

.EasyMDEContainer .CodeMirror-cursor {
  border-left-color: var(--accent);
}

.EasyMDEContainer .CodeMirror-selected {
  background: rgba(255, 255, 255, 0.12) !important;
}

.EasyMDEContainer .CodeMirror-line::selection,
.EasyMDEContainer .CodeMirror-line > span::selection,
.EasyMDEContainer .CodeMirror-line > span > span::selection {
  background: rgba(255, 255, 255, 0.16);
}

.EasyMDEContainer .cm-s-easymde .cm-header {
  color: #f4f4f5;
}

.EasyMDEContainer .cm-s-easymde .cm-comment,
.EasyMDEContainer .cm-s-easymde .cm-quote {
  color: #a1a1aa;
}

.EasyMDEContainer .cm-s-easymde .cm-link,
.EasyMDEContainer .cm-s-easymde .cm-url,
.EasyMDEContainer .cm-s-easymde .cm-string {
  color: #d4d4d8;
}

.EasyMDEContainer .cm-s-easymde .cm-keyword,
.EasyMDEContainer .cm-s-easymde .cm-tag {
  color: #e4e4e7;
}

.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: #101012;
  color: var(--text);
  border-color: var(--border);
  font-family: var(--font);
}

.EasyMDEContainer .editor-preview {
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.15rem 1.35rem;
  overflow: auto;
}

.EasyMDEContainer .editor-preview pre,
.EasyMDEContainer .editor-preview-side pre,
.editor-preview.theory-article pre {
  background: var(--code-bg) !important;
  border: 1px solid var(--code-border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  margin: 1rem 0 1.2rem;
  color: var(--code-text);
}

.EasyMDEContainer .editor-preview pre code,
.EasyMDEContainer .editor-preview-side pre code,
.editor-preview.theory-article pre code {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  color: inherit;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre;
}

.EasyMDEContainer .editor-preview :not(pre) > code,
.EasyMDEContainer .editor-preview-side :not(pre) > code,
.editor-preview.theory-article :not(pre) > code {
  background: var(--code-inline-bg) !important;
  border: 1px solid var(--code-inline-border);
  padding: 0.12rem 0.4rem;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.86em;
  font-weight: 500;
  color: var(--code-text);
}

.EasyMDEContainer .editor-preview table td,
.EasyMDEContainer .editor-preview table th,
.EasyMDEContainer .editor-preview-side table td,
.EasyMDEContainer .editor-preview-side table th {
  border-color: var(--border);
}

.theory-article .hljs,
.EasyMDEContainer .editor-preview .hljs,
.EasyMDEContainer .editor-preview-side .hljs {
  background: transparent;
  color: var(--code-text);
  padding: 0;
}
.theory-article .hljs-keyword,
.theory-article .hljs-selector-tag,
.theory-article .hljs-type,
.EasyMDEContainer .hljs-keyword,
.EasyMDEContainer .hljs-selector-tag,
.EasyMDEContainer .hljs-type { color: var(--code-keyword); }
.theory-article .hljs-string,
.theory-article .hljs-attr,
.theory-article .hljs-template-tag,
.EasyMDEContainer .hljs-string,
.EasyMDEContainer .hljs-attr,
.EasyMDEContainer .hljs-template-tag { color: var(--code-string); }
.theory-article .hljs-number,
.theory-article .hljs-literal,
.EasyMDEContainer .hljs-number,
.EasyMDEContainer .hljs-literal { color: var(--code-number); }
.theory-article .hljs-built_in,
.theory-article .hljs-title,
.theory-article .hljs-title.function_,
.EasyMDEContainer .hljs-built_in,
.EasyMDEContainer .hljs-title,
.EasyMDEContainer .hljs-title.function_ { color: var(--code-function); }
.theory-article .hljs-comment,
.theory-article .hljs-quote,
.EasyMDEContainer .hljs-comment,
.EasyMDEContainer .hljs-quote { color: var(--code-comment); font-style: italic; }
.theory-article .hljs-params,
.theory-article .hljs-variable,
.EasyMDEContainer .hljs-params,
.EasyMDEContainer .hljs-variable { color: var(--code-text); }
.theory-article .hljs-meta,
.theory-article .hljs-name,
.EasyMDEContainer .hljs-meta,
.EasyMDEContainer .hljs-name { color: var(--code-meta); }
.theory-article .hljs-subst,
.EasyMDEContainer .hljs-subst { color: var(--code-builtin); }

.EasyMDEContainer .editor-statusbar {
  color: var(--text-dim);
  border-color: var(--border);
  background: #161618;
  border-radius: 0 0 var(--radius) var(--radius);
}

.EasyMDEContainer.sided--no-fullscreen .CodeMirror {
  border-right: 1px solid var(--border);
}

.EasyMDEContainer .editor-toolbar.fullscreen,
.EasyMDEContainer .CodeMirror-fullscreen,
.EasyMDEContainer .editor-statusbar.fullscreen {
  z-index: 1100;
  background: #121214;
}

.EasyMDEContainer .editor-preview-side {
  z-index: 1;
}

.EasyMDEContainer .editor-preview-side.editor-preview-active-side {
  z-index: 1;
}

.bank-picker {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bank-picker-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 0.85rem;
  min-height: 280px;
}

@media (max-width: 720px) {
  .bank-picker-layout {
    grid-template-columns: 1fr;
  }
}

.bank-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}

.bank-item:hover {
  background: #16161a;
  border-color: #3f3f46;
}

.bank-item.is-selected {
  border-color: #a1a1aa;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.bank-item.is-placed {
  opacity: 0.72;
}

.bank-item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.bank-preview-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  padding: 1rem;
  overflow: auto;
  max-height: min(48vh, 440px);
}

.bank-preview-panel .empty-state {
  padding: 2rem 1rem;
}

.bank-preview-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.bank-preview-meta {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.bank-preview-desc {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.bank-preview-code {
  margin: 0;
  padding: 0.75rem 0.9rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--code-text);
  white-space: pre-wrap;
  overflow: auto;
  max-height: 180px;
}

.bank-preview-tests {
  margin-top: 0.85rem;
}

.bank-preview-tests .tests-human {
  margin-top: 0.5rem;
}

.reference-solution {
  margin: 1.25rem 0 0.5rem;
}

.reference-solution-code {
  max-height: 320px;
}

.task-condition-examples {
  margin-top: 1.25rem;
}

.task-condition-examples-title {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.task-examples-table {
  width: max-content;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 0.85rem;
}

.task-examples-table th,
.task-examples-table td {
  padding: 0.4rem 0.65rem;
  vertical-align: top;
  text-align: left;
  border: 1px solid var(--border);
}

.task-examples-table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-input);
  white-space: nowrap;
}

.task-examples-table td {
  min-width: 4rem;
  max-width: 18rem;
}

.task-examples-cell {
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: transparent;
  border: none;
}

.task-tests-panel {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.task-tests-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  list-style: none;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.task-tests-summary::-webkit-details-marker {
  display: none;
}

.task-tests-summary:hover .expand-hint {
  color: var(--text);
}

.task-tests-panel[open] .expand-hint {
  color: var(--text);
}

.task-tests-body {
  margin-top: 0.65rem;
}

.tests-human {
  margin: 1.5rem 0 1.25rem;
}

.tests-human-title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.tests-human-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  overflow: hidden;
}

.tests-human-list {
  display: flex;
  flex-direction: column;
}

.test-case-row {
  padding: 0.85rem 1rem;
}

.test-case-row + .test-case-row {
  border-top: 1px solid var(--border-soft);
}

.test-case-num {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}

.test-case-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1rem;
  align-items: start;
}

@media (max-width: 640px) {
  .test-case-grid {
    grid-template-columns: 1fr;
  }
}

.test-case-label {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.test-case-value {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  min-height: 1.35em;
}

.tests-editor {
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.tests-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.tests-editor-title {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}

.tests-editor-add {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.tests-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
}

.tests-editor-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0;
}

.test-editor-row {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #121214;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.test-editor-row-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.test-editor-row-head strong {
  min-width: 3.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.test-editor-row-actions {
  display: flex;
  gap: 0.2rem;
  margin-left: auto;
}

.test-type-toggle {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.15rem;
  background: #0f0f11;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}

.test-type-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
}

.test-type-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.test-type-btn.active {
  background: #242428;
  color: var(--text);
}

.test-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 0.65rem;
}

.test-editor-io-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.test-editor-fn,
.test-editor-stdout {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.test-editor-io-grid > .test-editor-fn,
.test-editor-io-grid > .test-editor-stdout,
.test-editor-io-grid > label {
  min-width: 0;
}

.test-editor-row label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.test-editor-row input,
.test-editor-row textarea,
.test-editor-row select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.85rem;
  line-height: 1.45;
}

.test-editor-row input:focus,
.test-editor-row textarea:focus {
  outline: none;
  border-color: #3f3f46;
}

.test-editor-io-grid textarea {
  min-height: 2.5rem;
  resize: vertical;
}

@media (max-width: 640px) {
  .test-editor-grid,
  .test-editor-io-grid {
    grid-template-columns: 1fr;
  }
}

/* Full-page task editor */
.task-editor-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 0.65rem 0.85rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: #101012;
  flex-shrink: 0;
  align-items: end;
}

.task-editor-meta label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 0;
}

.task-editor-meta input,
.task-editor-meta select {
  height: 2.2rem;
  padding: 0 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
}

.task-editor-meta .field-hint {
  grid-column: 1 / -1;
  margin: 0;
}

.task-editor-meta-bank {
  grid-template-columns: minmax(0, 1fr);
}

.task-tags-picker {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.task-tags-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.task-tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.task-tags-selected {
  display: contents;
}

.task-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2rem;
  padding: 0 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1a1a1e;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
}

.task-tag-chip:hover {
  border-color: #3f3f46;
  background: var(--bg-hover);
}

.task-tag-chip span {
  opacity: 0.65;
  font-size: 0.95rem;
  line-height: 1;
}

.task-tags-combobox {
  position: relative;
  flex: 0 1 11rem;
  min-width: 8.5rem;
  max-width: 16rem;
}

.task-tags-combobox input {
  width: 100%;
  height: 2rem;
  padding: 0 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
}

.task-tags-combobox input::placeholder {
  color: var(--text-muted);
}

.task-tags-combobox input:focus {
  outline: none;
  border-color: #3f3f46;
}

.task-tags-dropdown {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 12rem;
  overflow: auto;
  padding: 0.25rem;
  background: #161618;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.task-tags-dropdown-empty {
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.task-tags-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 0.45rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
}

.task-tags-option:hover,
.task-tags-option.is-active {
  background: var(--bg-hover);
}

.task-tags-option-create {
  color: var(--text-muted);
  border-top: 1px solid var(--border-soft);
  margin-top: 0.15rem;
  border-radius: 0 0 7px 7px;
}

.task-editor-order {
  width: 5.5rem;
}

.task-editor-body .task-editor-pane {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.task-editor-scroll {
  overflow: auto;
  padding: 0.15rem 0.1rem 0.35rem;
  gap: 0.85rem;
}

.task-editor-field-label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.task-editor-code {
  width: 100%;
  min-height: 12rem;
  padding: 0.85rem 1rem;
  background: var(--code-bg, #0c0c0e);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--code-text, var(--text));
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.875rem;
  line-height: 1.65;
  resize: vertical;
  tab-size: 4;
}

.task-editor-code:focus {
  outline: none;
  border-color: #3f3f46;
}

#task-editor-error {
  margin: 0 0.65rem 0.55rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.task-editor-body .EasyMDEContainer {
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #121214;
}

.task-editor-body .EasyMDEContainer .editor-toolbar {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  flex: 0 0 auto;
  padding: 0.2rem 0.35rem;
  position: sticky;
  top: 0;
  z-index: 8;
  background: #161618;
}

.task-editor-body .EasyMDEContainer .editor-toolbar button {
  width: 26px !important;
  height: 26px !important;
}

.task-editor-body .EasyMDEContainer .editor-statusbar {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  flex: 0 0 auto;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
}

.task-editor-body .EasyMDEContainer .CodeMirror {
  flex: 1 1 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none;
  border: none;
  border-radius: 0;
  font-size: 0.82rem;
  overflow: hidden;
}

.task-editor-body .EasyMDEContainer .CodeMirror-scroll {
  min-height: 0 !important;
  max-height: 100%;
}

.task-editor-body .EasyMDEContainer .editor-preview {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 0;
  background: #101012;
}

.task-editor-body .EasyMDEContainer.sided--no-fullscreen {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
}

.task-editor-body .EasyMDEContainer.sided--no-fullscreen .editor-toolbar {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
}

.task-editor-body .EasyMDEContainer.sided--no-fullscreen .editor-statusbar {
  grid-column: 1 / -1;
  grid-row: 3;
  width: 100%;
}

.task-editor-body .EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided {
  grid-column: 1;
  grid-row: 2;
  width: auto !important;
  height: auto !important;
  min-height: 0;
  position: relative !important;
  left: auto !important;
}

.task-editor-body .EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side {
  grid-column: 2;
  grid-row: 2;
  width: auto !important;
  height: auto !important;
  min-height: 0;
  position: relative !important;
  left: auto !important;
  display: block;
}

@media (max-width: 900px) {
  .task-editor-meta {
    grid-template-columns: 1fr 1fr;
  }
  .task-editor-order {
    width: auto;
  }
}

@media (max-width: 640px) {
  .task-editor-meta {
    grid-template-columns: 1fr;
  }
}

.bank-sidebar-filters {
  padding: 0.65rem 0.75rem 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  border-bottom: 1px solid var(--border-soft);
}

.bank-sidebar-filters .bank-search-label {
  margin: 0;
}

.bank-sidebar-filters .tag-filter-list {
  max-height: 5.5rem;
  overflow: auto;
}

#bank-list {
  flex: 1;
  overflow: auto;
}

#bank-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.bank-filters {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.bank-search-label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.bank-search-wrap {
  position: relative;
}

.bank-search-wrap::before {
  content: '';
  position: absolute;
  left: 0.85rem;
  top: 50%;
  width: 0.85rem;
  height: 0.85rem;
  transform: translateY(-50%);
  border: 1.5px solid var(--text-dim);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.9;
}

.bank-search-wrap::after {
  content: '';
  position: absolute;
  left: 1.55rem;
  top: calc(50% + 0.28rem);
  width: 0.4rem;
  height: 1.5px;
  background: var(--text-dim);
  transform: rotate(45deg);
  pointer-events: none;
  opacity: 0.9;
}

.bank-search-wrap input {
  width: 100%;
  padding: 0.7rem 0.9rem 0.7rem 2.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.bank-search-wrap input::placeholder {
  color: var(--text-dim);
}

.bank-search-wrap input:focus {
  outline: none;
  border-color: #52525b;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.bank-tag-filters {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tag-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-filter-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tag-filter-chip:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: #3f3f46;
}

.tag-filter-chip.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: #a1a1aa;
  color: var(--text);
}

.bank-results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.bank-results {
  max-height: min(48vh, 440px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-right: 0.15rem;
  margin: 0 -0.15rem;
  padding-left: 0.15rem;
}

.bank-item-main {
  min-width: 0;
  flex: 1;
}

.bank-item-main h4 {
  margin: 0 0 0.3rem;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.bank-item-desc {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.bank-item .btn {
  flex-shrink: 0;
}

.bank-item .btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.bank-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
}

.nav-lesson-label,
.nav-work-label,
.nav-topic-label {
  pointer-events: none;
  cursor: default;
  border: none !important;
  background: transparent !important;
  font-weight: 600 !important;
}

.nav-lesson-label {
  margin-top: 0.85rem;
  padding: 0.35rem 0.75rem !important;
  font-size: 0.8rem !important;
  color: var(--text) !important;
}

.nav-lesson-label:first-child {
  margin-top: 0;
}

.nav-work-label {
  margin-top: 0.35rem;
  padding: 0.25rem 0.75rem 0.25rem 0.9rem !important;
  font-size: 0.72rem !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted) !important;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.nav-work-label .nav-inline-btn {
  pointer-events: auto;
  min-width: 1.6rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.85rem;
  line-height: 1.2;
}

.nav-teacher-action {
  pointer-events: auto !important;
  cursor: default !important;
  border: none !important;
  background: transparent !important;
  padding: 0.2rem 0.75rem 0.4rem 1.1rem !important;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.nav-teacher-action.nested {
  /* Align with task rows (handle + title), not with topic edge */
  padding-left: 2.75rem !important;
}

.nav-teacher-action:hover {
  background: transparent !important;
}

.teacher-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.65rem 0 1.1rem;
}

.plan-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.plan-page-header h1 {
  margin-bottom: 0.35rem;
}

.teacher-context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.45rem 0 0.15rem;
}

.teacher-context-select {
  appearance: none;
  -webkit-appearance: none;
  max-width: 200px;
  min-width: 140px;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background:
    linear-gradient(45deg, transparent 50%, var(--text-dim) 50%) calc(100% - 14px) calc(50% - 2px) / 5px 5px no-repeat,
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%) calc(100% - 9px) calc(50% - 2px) / 5px 5px no-repeat,
    var(--bg-card);
  color: var(--text);
  cursor: pointer;
}

.teacher-context-select:hover {
  border-color: #3f3f46;
  background-color: var(--bg-hover);
}

.teacher-context-select:focus {
  outline: none;
  border-color: #52525b;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.student-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.student-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.student-chip:hover {
  color: var(--text);
  border-color: #3f3f46;
  background: rgba(255, 255, 255, 0.03);
}

.student-chip.is-active {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.materials-teacher-context {
  padding: 0.45rem 0.85rem 0.65rem;
  border-bottom: 1px solid var(--border-soft);
}

.materials-teacher-context:empty {
  display: none;
}

.materials-teacher-context .teacher-context-bar {
  margin: 0;
}

.plan-course-select {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.plan-course-select select {
  max-width: 320px;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated, #18181b);
  color: var(--text);
}

.plan-lesson-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .plan-page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .plan-lesson-actions {
    justify-content: stretch;
  }

  .plan-lesson-actions .btn {
    flex: 1;
  }
}

.nav-topic-label {
  margin-top: 0.15rem;
  padding: 0.2rem 0.75rem 0.2rem 1.1rem !important;
  font-size: 0.75rem !important;
  color: var(--text-dim) !important;
  font-weight: 500 !important;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.35rem;
  color: var(--text-dim);
  cursor: grab;
  user-select: none;
  touch-action: none;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
  vertical-align: middle;
}

.drag-handle:active,
body.sortable-dragging .drag-handle {
  cursor: grabbing;
}

body.sortable-dragging {
  cursor: grabbing;
  user-select: none;
}

body.sortable-dragging * {
  cursor: grabbing !important;
}

.plan-lessons.is-sorting > *:not(.dragging),
#materials-list.is-sorting > *:not(.dragging),
.nav-nested-tasks.is-sorting > *:not(.dragging) {
  opacity: 0.35;
  transition: opacity 0.12s ease;
}

.plan-lesson-card.dragging,
.nav-topic-block.dragging,
.nav-task-item.dragging,
.sortable-ghost {
  opacity: 1;
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 0 0 1px #3f3f46;
}

.plan-lesson-card.drag-over-before,
.nav-topic-block.drag-over-before,
.nav-task-item.drag-over-before {
  box-shadow: inset 0 2px 0 #a1a1aa;
}

.plan-lesson-card.drag-over-after,
.nav-topic-block.drag-over-after,
.nav-task-item.drag-over-after {
  box-shadow: inset 0 -2px 0 #a1a1aa;
}

.nav-topic-block {
  list-style: none;
  margin: 0;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  cursor: default !important;
}

.nav-topic-block:hover {
  background: transparent !important;
}

.nav-topic-block > .nav-topic-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.25rem 0.4rem;
  padding: 0.55rem 0.75rem 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}

.nav-topic-block > .nav-topic-item:hover {
  background: rgba(255, 255, 255, 0.045);
}

.nav-topic-block > .nav-topic-item.active {
  background: rgba(255, 255, 255, 0.07);
  border-color: #333338;
  border-left: 2px solid #f4f4f5;
}

.nav-homework-tasks {
  list-style: none;
  margin: 0;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  cursor: default !important;
}

.nav-homework-tasks > .nav-teacher-action {
  padding-left: 2.75rem !important;
}

.task-drop-zone.drop-target {
  min-height: 2rem;
  outline: 1px dashed #52525b;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.homework-task-list {
  min-height: 0.5rem;
}

.nav-topic-item {
  padding-left: 1.1rem !important;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  border-left: 2px solid transparent;
}

.nav-task-item {
  padding-left: 2.75rem !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.25rem 0.4rem;
  border-left: 2px solid transparent;
  opacity: 0.92;
}

.nav-item-title {
  line-height: 1.45;
  min-width: 0;
}

.nav-topic-item.active {
  border-left-color: #f4f4f5;
  background: rgba(255, 255, 255, 0.08) !important;
}

.nav-task-item.active {
  border-left-color: #a1a1aa;
  background: rgba(255, 255, 255, 0.05) !important;
}

.student-topic-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.task-group-label {
  pointer-events: none;
  cursor: default;
  margin-top: 0.75rem;
  margin-bottom: 0.2rem;
  padding: 0.35rem 0.75rem !important;
  font-size: 0.72rem !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim) !important;
  font-weight: 600 !important;
  border: none !important;
  background: transparent !important;
}

.task-group-label:hover {
  background: transparent !important;
}

.task-item {
  padding-left: 1rem !important;
}

.task-section-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.section-tasks-hint {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.topic-theory-body {
  margin-bottom: 0.5rem;
}

.topic-tasks-block {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
}

.topic-tasks-heading {
  font-size: 1.15rem;
  margin-bottom: 0.85rem;
}

.topic-task-title {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
}

.plan-page {
  max-width: 720px;
}

.plan-page h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.plan-lessons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.plan-lesson-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.plan-lesson-card.active {
  border-color: #3f3f46;
  background: rgba(255, 255, 255, 0.04);
}

.plan-lesson-main h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 1.1rem;
  margin: 0 0 0.35rem;
}

.plan-lesson-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .plan-lesson-card {
    flex-direction: column;
    align-items: stretch;
  }
}

.lesson-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.02);
}

.lesson-card.active {
  border-color: #3f3f46;
  background: rgba(255, 255, 255, 0.035);
}

.lesson-select {
  background: transparent;
  border: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.lesson-select h3 {
  font-size: 1.05rem;
}

.lesson-workspace {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

.topic-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.02);
}


.topic-card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.topic-card-header h3 {
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
}

.topic-tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.topic-tasks-header h2 {
  margin: 0;
}

.topic-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.85rem 0 0.5rem;
}

.topic-tasks-header .topic-subtitle {
  margin: 0;
}


.topic-theory-preview {
  margin-bottom: 0.5rem;
}

.topic-theory-preview summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.topic-theory-text {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  max-height: 180px;
  overflow: auto;
}

.manage-item.nested {
  background: rgba(255, 255, 255, 0.015);
}

@media (max-width: 768px) {
  .invite-row {
    flex-direction: column;
  }

  .course-form .form-row {
    grid-template-columns: 1fr;
  }

  .manage-item,
  .topic-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
