:root {
  --bg: #f7fbf6;
  --panel: #ffffff;
  --ink: #111816;
  --muted: #66736d;
  --line: #e2ece5;
  --brand: #ffc107;
  --brand-dark: #9a6f00;
  --mint: #fff8df;
  --lime: #ffe28a;
  --yellow: #ffe26d;
  --blue: #286e9f;
  --red: #d84e43;
  --shadow: 0 18px 45px rgba(128, 92, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 193, 7, 0.28), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(255, 225, 138, 0.38), transparent 32%),
    #f7fbf6;
}

.auth-card {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-logout {
  display: none;
}

.auth-brand {
  justify-content: center;
  margin-bottom: 26px;
  text-align: center;
}

.auth-brand h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--brand);
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
}

.brand-logo {
  width: 176px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  background: transparent;
}

.auth-brand .brand-logo {
  width: 210px;
  height: 58px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #eff7f1;
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(128, 92, 0, 0.08);
}

.auth-form,
.editor-form,
.panel-column {
  display: grid;
  gap: 14px;
}

.auth-form {
  gap: 16px;
}

.auth-invite-title {
  margin: 0;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.auth-form label {
  gap: 8px;
}

#loginForm label:first-of-type {
  padding-top: 11px;
}

.auth-form input {
  min-height: 48px;
}

.auth-form .button {
  width: 100%;
  min-height: 48px;
  margin-top: 2px;
}

label {
  display: grid;
  gap: 7px;
  color: #34414a;
  font-size: 14px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  font-weight: 400;
}

input[type="file"] {
  padding: 9px 12px;
  background: rgb(248, 250, 249);
}

#courseTitle,
#lessonTitle {
  font-weight: 800;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.rich-editor-field {
  display: grid;
  gap: 7px;
}

.field-label {
  color: #34414a;
  font-size: 14px;
  font-weight: 600;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: rgb(248, 250, 249);
}

.rich-toolbar button {
  width: 34px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.rich-toolbar select {
  flex: 0 0 auto;
  width: auto;
  height: 32px;
  min-width: 76px;
  max-width: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 0 28px 0 10px;
}

.rich-toolbar select[data-rich-font-size] {
  min-width: 76px;
}

.rich-toolbar select:focus {
  outline: 2px solid rgba(255, 193, 7, 0.35);
  outline-offset: 1px;
}

.rich-toolbar button:hover {
  border-color: #e4cb70;
  background: white;
}

.rich-toolbar button[data-word-import-button] {
  width: auto;
  min-width: 54px;
  padding: 0 10px;
}

.rich-editor {
  min-height: 210px;
  padding: 14px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  background: #fbfcfd;
  color: var(--ink);
  line-height: 1.6;
  outline: none;
}

.rich-editor:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.22);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #8b9691;
  pointer-events: none;
}

.rich-editor h2,
.rich-editor h3,
.rich-content h2,
.rich-content h3 {
  margin: 18px 0 8px;
}

.rich-editor p,
.rich-content p {
  margin: 0 0 12px;
}

.rich-editor blockquote,
.rich-content blockquote,
.kb-article-content blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: #fff8d7;
}

.rich-editor ul,
.rich-editor ol,
.rich-content ul,
.rich-content ol {
  padding-left: 24px;
}

.rich-editor img,
.rich-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px auto;
  border-radius: 8px;
}

.rich-editor img[data-align="left"],
.rich-content img[data-align="left"],
.image-editor-preview img[data-align="left"] {
  margin-left: 0;
  margin-right: auto;
}

.rich-editor img[data-align="center"],
.rich-content img[data-align="center"],
.image-editor-preview img[data-align="center"] {
  margin-left: auto;
  margin-right: auto;
}

.rich-editor img[data-align="right"],
.rich-content img[data-align="right"],
.image-editor-preview img[data-align="right"] {
  margin-left: auto;
  margin-right: 0;
}

.rich-editor img.selected {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}

.rich-editor [data-rich-video],
.rich-content [data-rich-video],
.kb-article-content [data-rich-video] {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  margin: 16px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111a17;
}

.rich-editor [data-rich-video][data-align="left"],
.rich-content [data-rich-video][data-align="left"],
.kb-article-content [data-rich-video][data-align="left"] {
  margin-left: 0;
  margin-right: auto;
}

.rich-editor [data-rich-video][data-align="center"],
.rich-content [data-rich-video][data-align="center"],
.kb-article-content [data-rich-video][data-align="center"] {
  margin-left: auto;
  margin-right: auto;
}

.rich-editor [data-rich-video][data-align="right"],
.rich-content [data-rich-video][data-align="right"],
.kb-article-content [data-rich-video][data-align="right"] {
  margin-left: auto;
  margin-right: 0;
}

.rich-editor [data-rich-video] {
  cursor: pointer;
}

.rich-editor [data-rich-video] iframe {
  pointer-events: none;
}

.rich-editor [data-rich-video] iframe,
.rich-content [data-rich-video] iframe,
.kb-article-content [data-rich-video] iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.image-size-controls {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) 52px auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #f4df98;
  border-radius: 12px;
  background: #fffdf4;
}

.image-size-controls span,
.image-size-controls output {
  font-size: 13px;
  font-weight: 700;
}

.image-size-controls input[type="range"] {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.image-size-controls .button {
  min-height: 34px;
  border-radius: 10px;
}

.rich-content {
  color: #3d4c55;
  line-height: 1.65;
}

.image-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 22, 0.56);
}

.image-editor-dialog {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: 0 24px 70px rgba(17, 24, 22, 0.22);
}

.image-editor-close {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.image-editor-preview {
  min-height: 260px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(45deg, #f1f5f2 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f2 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f2 75%),
    white;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.image-editor-preview img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.video-url-setting {
  display: grid;
  gap: 7px;
}

.video-editor-preview {
  display: grid;
  place-items: center;
}

.video-editor-preview iframe {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border: 0;
  border-radius: 8px;
  background: #111a17;
}

.video-editor-preview iframe[data-align="left"] {
  justify-self: start;
}

.video-editor-preview iframe[data-align="center"] {
  justify-self: center;
}

.video-editor-preview iframe[data-align="right"] {
  justify-self: end;
}

.video-editor-placeholder {
  color: var(--muted);
  text-align: center;
}

.video-editor-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #f2b8b5;
  border-radius: 10px;
  background: #fff3f2;
  color: #b42318;
  font-weight: 700;
}

.image-editor-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.range-setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  align-items: center;
  gap: 10px;
}

.range-setting input {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.range-setting output {
  font-weight: 800;
  text-align: right;
}

.image-align-setting {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f4f7f5;
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented-control button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(17, 24, 22, 0.08);
}

.image-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.structure-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 22, 0.56);
}

.structure-editor-dialog {
  width: min(520px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: 0 24px 70px rgba(17, 24, 22, 0.22);
}

.structure-editor-close {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.structure-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.structure-editor-actions .button {
  min-width: 120px;
}

.visually-hidden-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.group-icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  max-height: 238px;
  overflow: auto;
  padding: 4px;
}

.group-icon-option {
  min-height: 74px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: center;
}

.group-icon-option span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #171714;
  font-size: 22px;
  font-weight: 900;
}

.group-icon-option small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
}

.group-icon-option.active {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.structure-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.structure-delete-note {
  margin: -4px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(207, 75, 64, 0.22);
  border-radius: 10px;
  background: #fff7f5;
  color: var(--red);
  font-size: 13px;
  line-height: 1.4;
}

.structure-editor-footer .button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  box-shadow: none;
}

@media (max-width: 560px) {
  .structure-editor-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .structure-editor-footer > .button,
  .structure-editor-actions,
  .structure-editor-actions .button {
    width: 100%;
  }
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.22);
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0 14px;
  background: var(--brand);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.button.primary {
  background: var(--brand);
  color: var(--ink);
  box-shadow: 0 12px 24px rgba(255, 193, 7, 0.28);
}

.button:not(.ghost):not(.danger):not(.support-button):hover {
  background: #f4b900;
  box-shadow: 0 8px 18px rgba(255, 193, 7, 0.22);
}

.button.ghost {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.button.small {
  min-height: 34px;
}

.button.save-course-top {
  background: var(--brand);
  color: var(--ink);
  margin-left: 12px;
}

.button.is-saved,
.button.is-saved:hover {
  border-color: rgba(27, 125, 68, 0.28);
  background: #e3f6eb;
  color: #15683a;
  box-shadow: none;
}

#deleteCourseBtn {
  width: 42px;
  height: 34px;
  min-height: 34px;
  border-radius: 10px;
}

.button.danger {
  border-color: rgba(207, 75, 64, 0.35);
  background: #fff2f0;
  color: var(--red);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.danger {
  border-color: rgba(207, 75, 64, 0.35);
  background: #fff2f0;
  color: var(--red);
}

.auth-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.social-auth {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.social-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.social-button.telegram {
  border-color: #b8dcf2;
  background: #eef8ff;
}

.social-button.whatsapp {
  border-color: #bfe7cc;
  background: #effaf2;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.profile-box {
  padding: 16px;
  border: 1px solid #f4df98;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--mint), #ffffff);
}

.profile-box span {
  display: block;
  margin-bottom: 4px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.main-nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: #3c4a44;
  font-weight: 800;
  text-align: left;
  padding: 0 14px;
}

.nav-btn-label {
  min-width: 0;
}

.nav-review-badge,
.review-count-badge {
  flex: 0 0 auto;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--brand);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.nav-review-badge.hidden {
  display: none;
}

.nav-btn.active {
  background: var(--brand);
  color: var(--ink);
  box-shadow: 0 12px 24px rgba(255, 193, 7, 0.24);
}

.workspace {
  min-width: 0;
  padding: 32px;
}

.topbar {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar h2 {
  margin: 0;
  font-size: 36px;
  line-height: 1.08;
}

.screen-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.public-kb-logo {
  display: none;
  width: auto;
  height: 28px;
  flex: 0 0 auto;
  object-fit: contain;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user .profile-box {
  min-width: 190px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: right;
}

.topbar-user .profile-box:hover strong,
.topbar-user .profile-box:focus-visible strong {
  color: #2b2a27;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.topbar-user .profile-box strong {
  display: inline;
  font-size: 14px;
  line-height: 1.2;
}

.topbar-user .profile-box span {
  display: inline;
  margin: 0;
  color: var(--brand-dark);
  font-size: 14px;
  text-transform: none;
}

#screenEyebrow,
#profileRole {
  display: none !important;
}

.logout-small {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat,
.panel-column,
.reader,
.catalog {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat {
  padding: 20px;
  background: linear-gradient(180deg, #ffffff, #fbfefb);
}

.stat span {
  color: var(--muted);
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.admin-panel {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.appearance-settings {
  width: min(920px, 100%);
}

.settings-heading {
  margin-bottom: 22px;
}

.settings-heading h3 {
  margin-bottom: 6px;
  font-size: 24px;
}

.settings-heading p {
  margin: 0;
  color: var(--muted);
}

.theme-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.theme-choice {
  position: relative;
  min-width: 0;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.theme-choice:hover {
  border-color: #d7a600;
}

.theme-choice.active {
  border-color: var(--brand);
  box-shadow: 0 12px 28px rgba(128, 92, 0, 0.13);
}

.theme-preview {
  height: 220px;
  display: grid;
  grid-template-columns: 28% 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fbf6;
}

.theme-preview-sidebar {
  background: white;
}

.theme-preview-content {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-content: start;
  gap: 10px;
  padding: 24px 14px;
}

.theme-preview-content i {
  height: 48px;
  border: 1px solid #e2ece5;
  border-radius: 6px;
  background: white;
}

.theme-preview-content i:first-child {
  grid-column: 1 / -1;
  height: 24px;
  background: #ffc107;
}

.theme-preview-rosta {
  background: #f7f6f4;
}

.theme-preview-rosta .theme-preview-sidebar {
  background: #2d2d2a;
}

.theme-preview-rosta .theme-preview-content i {
  border: 0;
  background: #f7cf59;
}

.theme-preview-rosta .theme-preview-content i:first-child {
  background: #57534d;
}

.theme-choice-copy {
  display: grid;
  gap: 3px;
  padding: 14px 4px 3px;
}

.theme-choice-copy strong {
  font-size: 17px;
}

.theme-choice-copy small {
  color: var(--muted);
}

.theme-choice-check {
  position: absolute;
  right: 18px;
  bottom: 20px;
  width: 24px;
  height: 24px;
  display: none;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #171714;
  font-weight: 900;
}

.theme-choice.active .theme-choice-check {
  display: grid;
}

body[data-theme="2"] {
  --bg: #f7f6f4;
  --panel: #ffffff;
  --ink: #171714;
  --muted: #77736c;
  --line: #dedbd5;
  --brand: #ffc107;
  --brand-dark: #b17e00;
  --mint: #fff5cf;
  --lime: #f9d66c;
  --yellow: #f7cf59;
  --shadow: 0 12px 28px rgba(44, 42, 38, 0.08);
}

body[data-theme="2"] .app-shell {
  grid-template-columns: 250px minmax(0, 1fr);
}

body[data-theme="2"] .sidebar {
  border-right: 0;
  background: #2d2d2a;
  color: #ffffff;
}

body[data-theme="2"] .sidebar .brand h1 {
  color: #ffffff;
}

body[data-theme="2"] .sidebar .brand-logo {
  background: transparent;
}

body[data-theme="2"] .main-nav {
  gap: 3px;
}

body[data-theme="2"] .nav-btn {
  min-height: 44px;
  border: 0;
  border-radius: 4px;
  color: #f5f4f1;
  font-weight: 600;
}

body[data-theme="2"] .nav-btn:hover {
  background: #333330;
}

body[data-theme="2"] .nav-btn.active {
  padding-left: 18px;
  background: #252523;
  color: #ffffff;
  box-shadow: inset 4px 0 #ffc107;
}

body[data-theme="2"] .workspace {
  padding: 28px 32px;
  background: #f7f6f4;
}

body[data-theme="2"] .topbar {
  padding-bottom: 18px;
  border-bottom: 1px solid #e2dfda;
}

body[data-theme="2"] .topbar h2 {
  font-size: 32px;
  font-weight: 500;
}

body.public-knowledge-mode {
  background: #f7f6f4;
}

body.public-knowledge-mode .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.public-knowledge-mode .sidebar,
body.public-knowledge-mode .topbar-user,
body.public-knowledge-mode .admin-only,
body.public-knowledge-mode .course-author-tools {
  display: none !important;
}

body.public-knowledge-mode .workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 24px 48px;
  background: #f7f6f4;
}

body.public-knowledge-mode .topbar {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e2dfda;
}

body.public-knowledge-mode .public-kb-logo {
  display: block;
}

body.public-knowledge-mode .topbar h2 {
  font-size: 32px;
  font-weight: 500;
}

body[data-theme="2"] .button,
body[data-theme="2"] input,
body[data-theme="2"] textarea,
body[data-theme="2"] select {
  border-radius: 6px;
}

body[data-theme="2"] .button.primary,
body[data-theme="2"] .button:not(.ghost):not(.danger):not(.support-button),
body[data-theme="2"] .tab.active {
  background: #ffc107;
  color: #171714;
}

body[data-theme="2"] .stat {
  min-height: 108px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffc533, #f8d879);
  box-shadow: var(--shadow);
}

body[data-theme="2"] .stat span {
  color: #8b6c1f;
  font-weight: 500;
}

body[data-theme="2"] .stat strong {
  font-size: 34px;
  font-weight: 500;
}

body[data-theme="2"] .panel-column,
body[data-theme="2"] .reader,
body[data-theme="2"] .catalog,
body[data-theme="2"] .users-panel,
body[data-theme="2"] .course-tile,
body[data-theme="2"] .kb-group-card,
body[data-theme="2"] .kb-structure-panel,
body[data-theme="2"] .kb-article-browser,
body[data-theme="2"] .learner-overview,
body[data-theme="2"] .student-course-card {
  border-radius: 8px;
  box-shadow: var(--shadow);
}

body[data-theme="2"] .panel-head {
  margin: 0;
  padding: 16px 18px;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

body[data-theme="2"] .panel-column > .panel-head,
body[data-theme="2"] .kb-structure-panel > .panel-head,
body[data-theme="2"] .kb-article-browser > .panel-head {
  margin: -20px -20px 14px;
}

body[data-theme="2"] .lesson-zone > .panel-head {
  margin: -24px -18px 14px;
}

body[data-theme="2"] .panel-head h3 {
  color: var(--ink);
}

body[data-theme="2"] .panel-head p {
  color: var(--muted);
}

body[data-theme="2"] .panel-head .toggle-field,
body[data-theme="2"] .panel-head .toggle-field strong {
  color: var(--ink);
}

body[data-theme="2"] .panel-head .toggle-ui {
  background: #817d76;
}

body[data-theme="2"] .panel-head .toggle-field input:checked + .toggle-ui {
  background: var(--brand);
}

body[data-theme="2"] .course-editor-page > .panel-column > .panel-head {
  margin: -20px -20px 14px;
}

body[data-theme="2"] .structure-editor-dialog > .panel-head {
  margin: 0;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}

body[data-theme="2"] .structure-editor-dialog > .panel-head h3,
body[data-theme="2"] .structure-editor-dialog > .panel-head p,
body[data-theme="2"] .structure-editor-dialog > .panel-head .structure-editor-close {
  color: var(--ink);
}

body[data-theme="2"] .course-tile.active {
  border-color: #ffc107;
  box-shadow: inset 0 0 0 1px #ffc107, var(--shadow);
}

body[data-theme="2"] .kb-hero {
  background: linear-gradient(135deg, #ffc533, #f7da80);
}

body[data-theme="2"] .kb-mode-switch,
body[data-theme="2"] .auth-tabs {
  border-radius: 6px;
  background: #eae7e2;
}

body[data-theme="2"] .auth-screen {
  place-items: start center;
  padding: 112px 24px 40px;
  background: #f7f6f4;
}

body[data-theme="2"] .auth-card {
  width: min(420px, 100%);
  min-height: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  border-color: #dedbd5;
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(39, 38, 35, 0.12);
}

body[data-theme="2"] .auth-brand {
  grid-column: 1;
  grid-row: 1;
  min-height: 100px;
  margin: 0;
  padding: 18px 36px;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #e5e1da;
  background: #fff;
}

body[data-theme="2"] .auth-brand .brand-logo {
  width: min(230px, 82%);
  height: 42px;
}

body[data-theme="2"] .auth-tabs {
  grid-column: 1;
  grid-row: 2;
  margin: 36px 38px 24px;
  border: 0;
}

body[data-theme="2"] .auth-tabs .tab {
  border-radius: 4px;
}

body[data-theme="2"] .auth-tabs .tab.active {
  background: var(--brand);
  color: #171714;
  box-shadow: 0 8px 18px rgba(255, 193, 7, 0.18);
}

body[data-theme="2"] .auth-form {
  grid-column: 1;
  grid-row: 3;
  align-content: start;
  padding: 0 34px 34px;
}

body[data-theme="2"] .auth-form label {
  color: #343330;
}

body[data-theme="2"] .auth-form input {
  border-color: #d8d5cf;
  background: #fbfaf8;
}

body[data-theme="2"] .auth-form input:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(255, 193, 7, 0.2);
}

body[data-theme="2"] .auth-form .button {
  border: 0;
  box-shadow: 0 10px 22px rgba(255, 193, 7, 0.18);
}

#kbAdmin {
  grid-template-columns: 1fr;
}

#courseAdmin {
  grid-template-columns: 1fr;
}

.users-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.users-toolbar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 10px;
}

.users-toolbar h3 {
  margin: 0;
  font-size: 20px;
}

.users-toolbar p {
  margin: 0;
  color: var(--muted);
}

.users-filters {
  width: 100%;
  display: grid;
  grid-template-columns: 120px 160px minmax(220px, 1fr) 150px 160px;
  gap: 10px;
  align-items: end;
}

.users-create-button,
.users-invite-button {
  width: 100%;
  min-height: 42px;
  align-self: end;
  font-weight: 600;
}

.users-filters label {
  min-width: 0;
  gap: 6px;
}

.users-filters span {
  font-size: 12px;
  color: var(--muted);
}

.users-filters input,
.users-filters select {
  width: 100%;
}

.create-user-dialog {
  gap: 14px;
}

.create-user-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.generated-password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.generated-password-row input {
  font-family: Consolas, monospace;
  font-weight: 800;
  letter-spacing: 0;
}

.invite-link-dialog .generated-password-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.profile-editor-dialog {
  width: min(620px, 100%);
}

.profile-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.profile-editor-grid label {
  min-width: 0;
}

.profile-editor-grid label:first-child,
.profile-editor-grid label:nth-child(2) {
  grid-column: 1 / -1;
}

.profile-editor-grid input[readonly] {
  background: #f6f6f3;
  color: var(--muted);
  cursor: not-allowed;
}

.create-user-note {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.users-table-wrap {
  overflow-x: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.users-table th,
.users-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.users-table th {
  background: #f7faf7;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.users-table tbody tr:last-child td {
  border-bottom: 0;
}

.user-row {
  cursor: pointer;
}

.user-row:hover td {
  background: #fffdf4;
}

.user-progress-cell {
  display: grid;
  gap: 5px;
}

.user-progress-value {
  font-size: 18px;
}

.user-role-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2f0;
  color: #4f5d56;
  font-size: 12px;
  font-weight: 800;
}

.user-role-badge.role-admin {
  background: #fff0b8;
  color: #795800;
}

.user-role-badge.role-author {
  background: #e6f0f7;
  color: #285f82;
}

.user-role-badge.role-partner {
  background: #e9f8ee;
  color: #237640;
}

.analytics-status {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.analytics-status.completed {
  background: #e9f8ee;
  color: #237640;
}

.analytics-status.in_progress {
  background: #fff4c9;
  color: #765900;
}

.analytics-status.pending_review {
  background: #fff0d9;
  color: #9a5900;
}

.user-status-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.review-count-badge {
  min-width: 26px;
  height: 26px;
  box-shadow: 0 8px 16px rgba(255, 193, 7, 0.22);
}

.user-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-identity > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.user-identity strong,
.user-identity span,
.user-login {
  overflow-wrap: anywhere;
}

.user-identity span,
.user-date {
  color: var(--muted);
  font-size: 13px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--ink) !important;
  font-weight: 900;
}

.user-login {
  font-weight: 700;
}

.user-role-select {
  min-width: 160px;
  height: 40px;
  padding: 0 34px 0 12px;
  font-weight: 600;
}

.user-role-select:disabled {
  color: var(--ink);
  opacity: 0.72;
}

.user-delete-button {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #111;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.user-detail-panel {
  margin-top: 18px;
}

.user-detail-topline {
  justify-content: flex-end;
}

.user-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.user-profile-panel {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.user-profile-panel-head {
  list-style: none;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: white;
  color: var(--ink);
  cursor: pointer;
}

.user-profile-panel-head::-webkit-details-marker {
  display: none;
}

.user-profile-panel:not([open]) .user-profile-panel-head {
  border-bottom: 0;
}

.user-profile-chevron {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf4;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.user-profile-panel[open] .user-profile-chevron {
  font-size: 0;
}

.user-profile-panel[open] .user-profile-chevron::before {
  content: "-";
  font-size: 22px;
}

.user-profile-body {
  background: white;
}

.user-profile-panel:not([open]) .user-profile-body {
  display: none;
}

.user-profile-delete-row {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px 0;
}

.user-profile-panel-head h3,
.user-learning-heading h3 {
  margin: 0 0 5px;
  font-size: 20px;
}

.user-profile-panel-head p,
.user-learning-heading p {
  margin: 0;
  color: var(--muted);
}

.user-profile-delete {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(216, 78, 67, 0.35);
  border-radius: 6px;
  background: #fff2f0;
  color: var(--red);
  font-weight: 800;
}

.user-profile-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.user-profile-fact,
.user-profile-field {
  min-width: 0;
  min-height: 78px;
  align-content: start;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.user-profile-fact {
  display: grid;
}

.user-profile-fact span,
.user-profile-field {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.user-profile-fact strong {
  color: var(--ink);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.user-profile-field input,
.user-profile-field select {
  min-height: 40px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.user-profile-field input {
  width: 100%;
}

.user-profile-note {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 13px;
}

.user-learning-heading {
  margin-top: 24px;
}

.user-identity-large h3 {
  margin: 0 0 4px;
  font-size: 24px;
}

.user-analytics-stats {
  margin-top: 14px;
}

body[data-theme="2"] .user-profile-panel-head {
  border-bottom-color: var(--line);
  background: white;
  color: var(--ink);
}

body[data-theme="2"] .user-profile-panel-head h3 {
  color: var(--ink);
}

body[data-theme="2"] .user-profile-panel-head p {
  color: var(--muted);
}

.user-course-analytics {
  display: grid;
  gap: 12px;
}

.user-course-detail {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  overflow: hidden;
}

.user-course-detail summary {
  min-height: 78px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.user-course-detail summary::-webkit-details-marker {
  display: none;
}

.user-course-detail summary span {
  display: grid;
  gap: 5px;
}

.user-course-detail summary small {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
}

.user-course-detail summary small .analytics-status {
  font-size: 11px;
}

.user-course-detail summary b {
  font-size: 22px;
}

.user-course-progress {
  height: 7px;
  background: #f0e6be;
}

.user-course-progress i {
  display: block;
  height: 100%;
  background: var(--brand);
}

.user-lesson-analytics {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.user-lesson-result {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
}

.user-lesson-result > div:first-child {
  display: grid;
  gap: 4px;
}

.user-lesson-result span {
  color: var(--muted);
  font-size: 13px;
}

.manual-review {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-left: 3px solid #d5b84c;
  background: #fffdf4;
}

.manual-review p,
.manual-review small {
  margin: 0;
}

.manual-review-question {
  color: var(--ink);
  font-weight: 800;
}

.manual-review-question strong {
  color: var(--muted);
}

.manual-review > div {
  display: flex;
  gap: 8px;
}

.manual-review.accepted {
  border-color: #237640;
}

.manual-review.rejected {
  border-color: var(--red);
}

.learner-overview {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.learner-overview-head {
  display: block;
}

.learner-overview-head h3 {
  margin: 0;
  font-size: 24px;
}

.learner-metrics {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.learner-metrics div {
  padding: 14px;
  border-radius: 12px;
  background: #f7faf8;
}

body[data-theme="2"] .learner-metrics div {
  border-radius: 8px;
  background: linear-gradient(135deg, #ffc533, #f8d879);
  box-shadow: var(--shadow);
}

.learner-metrics span,
.learner-metrics strong {
  display: block;
}

.learner-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

body[data-theme="2"] .learner-metrics span {
  color: #6d5b25;
}

.learner-metrics strong {
  margin-top: 5px;
  font-size: 24px;
}

.user-delete-button:hover {
  color: #b42318;
}

.protected-user {
  color: var(--muted);
  font-size: 12px;
}

.users-loading,
.users-empty {
  padding: 28px 20px !important;
  color: var(--muted);
  text-align: center !important;
}

.users-error {
  color: #b42318;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.course-browser {
  width: 100%;
}

.course-editor-page {
  margin-top: 18px;
}

.editor-topline {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-course-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.button.small.editor-nav-action {
  background: var(--brand);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(255, 193, 7, 0.2);
}

.button.small.editor-nav-action:hover {
  background: #f4b900;
}

.panel-column {
  padding: 20px;
  box-shadow: none;
}

.panel-column.wide {
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h3 {
  margin: 0;
}

.split-list {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.course-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.course-tile {
  position: relative;
  min-height: 170px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fffdf4);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 12px 24px rgba(128, 92, 0, 0.06);
  overflow: hidden;
}

.course-add-tile {
  min-height: 170px;
  display: grid;
  place-items: center;
  border: 1px dashed #d9bd53;
  border-radius: 18px;
  background: #fffaf0;
  color: var(--brand-dark);
}

.course-add-tile span {
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
}

.course-tile.dragging {
  opacity: 0.55;
}

.course-tile.active {
  border-color: var(--brand);
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.18);
}

.course-tile.with-image {
  background:
    linear-gradient(90deg, rgba(255, 253, 244, 0.96), rgba(255, 253, 244, 0.7)),
    var(--course-image) center / cover;
}

.course-tile span {
  display: block;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.course-tile strong {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 22px;
  line-height: 1.18;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.course-tile em {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.toggle-field {
  position: relative;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: var(--ink);
  font-weight: 700;
}

.toggle-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  width: 46px;
  height: 26px;
  position: relative;
  border-radius: 999px;
  background: #dfe8e2;
  transition: background 0.2s ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 8px rgba(17, 24, 22, 0.22);
  transition: transform 0.2s ease;
}

.toggle-field input:checked + .toggle-ui {
  background: var(--brand);
}

.toggle-field input:checked + .toggle-ui::after {
  transform: translateX(20px);
}

.toggle-field strong {
  font-size: 14px;
}

.course-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.course-save-bottom {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.course-save-bottom .button {
  min-width: 150px;
}

.course-form-grid label:first-child,
.course-form-grid label:nth-child(2),
.course-audience-field,
.course-image-preview {
  grid-column: 1 / -1;
}

.course-audience-field {
  display: grid;
  gap: 8px;
}

.course-audience-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.course-audiences {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8faf9;
}

.course-audiences label {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 40px;
  cursor: pointer;
}

.course-audiences input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.course-audiences label span {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.course-audiences label span::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border: 2px solid #b9c7bf;
  border-radius: 50%;
  background: white;
}

.course-audiences input:checked + span {
  border-color: #f1c447;
  background: #fff4c9;
  color: var(--ink);
}

.course-audiences input:checked + span::before {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: inset 0 0 0 2px white;
}

.course-audiences input:focus-visible + span {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.course-image-preview {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid #f4df98;
  border-radius: 16px;
  background: #fffdf4;
}

.course-image-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7fbf6 center / cover no-repeat;
}

.course-image-preview strong,
.course-image-preview span {
  display: block;
}

.course-image-preview span {
  margin: 6px 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

.image-clear-btn {
  min-height: 34px;
  border-radius: 10px;
}

.lesson-editor-head {
  margin: 0 0 14px;
  padding-top: 0;
}

.lesson-zone {
  margin-top: 18px;
  padding: 24px 18px 18px;
  border: 1px solid #f4df98;
  border-radius: 18px;
  border-color: #f4df98;
  background: rgb(248, 250, 249);
}

.standalone-preview {
  min-height: 100vh;
  background: var(--bg);
}

.preview-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.preview-topbar h1 {
  margin: 0;
  font-size: 22px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#closePreviewBtn {
  width: 42px;
  height: 42px;
  font-size: 24px;
  line-height: 1;
}

.preview-page {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.preview-course-head {
  margin-bottom: 18px;
}

.preview-course-head h2 {
  margin-bottom: 10px;
  font-size: 42px;
}

.preview-course-head p:last-child {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.6;
}

.preview-ribbon {
  margin-bottom: 18px;
}

.preview-reader {
  max-width: 920px;
  margin: 0 auto;
}

.preview-empty {
  padding: 48px;
  border: 1px dashed #e1c96f;
  border-radius: 18px;
  background: #fffdf4;
  text-align: center;
}

.lesson-workspace {
  display: grid;
  gap: 16px;
}

.lesson-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.lesson-tile {
  position: relative;
  min-height: 150px;
  height: 150px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 22px rgba(128, 92, 0, 0.05);
  overflow: hidden;
}

.lesson-add-tile {
  min-height: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  border: 1px dashed #d9bd53;
  border-radius: 18px;
  background: #fffaf0;
  color: var(--brand-dark);
}

.lesson-add-tile span {
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
}

.lesson-tile.dragging {
  opacity: 0.55;
}

.lesson-tile.active {
  border-color: var(--brand);
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.16);
}

.lesson-tile span {
  display: block;
  margin-bottom: 0;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.lesson-tile strong {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.22;
  padding-right: 28px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.lesson-tile em {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.lesson-delete {
  width: 26px;
  height: 26px;
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.lesson-delete svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lesson-status-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px);
  gap: 12px;
}

.test-builder,
.test-module {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.test-builder.collapsed {
  padding: 0;
  border-color: #f4df98;
  background: #fffdf4;
}

.test-builder-toggle {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  border: 0;
  border-radius: 15px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
}

.test-builder-toggle strong {
  width: auto;
  height: auto;
  flex: 0 0 auto;
  display: block;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.test-builder:not(.collapsed) .test-builder-toggle {
  border-bottom: 1px solid var(--line);
  border-radius: 15px 15px 0 0;
}

.test-builder-body {
  display: grid;
  gap: 14px;
}

.test-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px 2px;
}

.test-builder-head h3,
.test-builder-head p {
  margin: 0;
}

.test-builder-head h3 {
  font-size: 20px;
}

.test-builder-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.test-form-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.test-question-field,
.choice-only {
  grid-column: 1 / -1;
}

.test-list {
  display: grid;
  gap: 10px;
}

.test-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.test-card.editing {
  border-color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.test-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.test-card strong {
  display: block;
  line-height: 1.35;
}

.test-card em {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-style: normal;
  line-height: 1.5;
}

.test-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.test-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.test-edit,
.test-delete {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.test-edit:hover {
  border-color: var(--brand);
  background: #fff8df;
}

.test-delete:hover {
  border-color: #efaaa3;
  background: #fff2f0;
  color: var(--red);
}

.test-empty-state {
  min-height: 110px;
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 20px;
  border: 1px dashed #d8c57b;
  border-radius: 8px;
  background: #fffdf4;
  text-align: center;
}

.test-empty-state span {
  color: var(--muted);
  font-size: 13px;
}

.test-editor {
  display: grid;
  gap: 16px;
  margin-top: 2px;
  padding: 18px;
  border: 1px solid #e4c65c;
  border-radius: 8px;
  background: #fffdf4;
}

.test-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.test-editor-head h4 {
  margin: 3px 0 0;
  font-size: 20px;
}

.test-editor-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.test-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.test-editor-actions .button {
  min-width: 160px;
}

.course-progress {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px solid #f4df98;
  border-radius: 16px;
  background: #fffdf4;
}

.course-progress strong {
  font-size: 16px;
}

.course-progress span {
  color: var(--muted);
  font-weight: 700;
}

.course-progress div {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0e6be;
}

.course-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.test-question {
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.test-question legend {
  padding: 0 8px;
  font-weight: 800;
}

.answer-option {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 10px;
  margin-top: 10px;
  font-weight: 500;
}

.answer-option input {
  width: auto;
}

.test-question small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.test-result {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 800;
}

.test-result span {
  font-weight: 600;
  line-height: 1.5;
}

.test-result.passed {
  background: #effaf2;
  color: #237640;
}

.test-result.failed {
  background: #fff2f0;
  color: var(--red);
}

.test-result.pending {
  background: #fff4d8;
  color: #865c00;
}

.completion-result {
  border: 1px solid rgba(35, 118, 64, 0.22);
}

.item-list {
  display: grid;
  gap: 8px;
}

.list-item,
.catalog-card,
.category-link {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  color: var(--ink);
  text-align: left;
}

.list-item {
  padding: 12px;
}

.list-item.active,
.catalog-card.active,
.category-link.active {
  border-color: var(--brand);
  background: var(--mint);
}

.list-item span,
.plain-item span,
.catalog-card span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.plain-item {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
  line-height: 1.35;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 12px;
}

.student-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

#courseStudentView {
  grid-template-columns: 1fr;
  min-width: 0;
}

#courseStudentView #courseCatalog {
  display: none;
}

.student-course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

#courseReader > h2:first-child {
  margin-top: -9px;
}

.course-reader-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.course-reader-head h2 {
  margin-bottom: 0;
}

.course-lessons-flow {
  display: grid;
  gap: 22px;
  margin-top: 24px;
}

.lesson-ribbon {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding: 10px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdf4;
}

.lesson-ribbon-item {
  position: relative;
  min-width: 190px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
  text-align: left;
}

.lesson-ribbon-item.active {
  border-color: var(--brand);
  background: white;
  box-shadow: none;
}

.lesson-ribbon-item.active::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 0;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--brand);
}

.lesson-ribbon-item.completed {
  border-color: rgba(35, 118, 64, 0.28);
}

.lesson-ribbon-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.lesson-ribbon-item.completed span::after {
  content: " - завершён";
  color: #237640;
}

.lesson-ribbon-item.locked {
  cursor: not-allowed;
  opacity: 0.52;
  background: #f2f3f1;
}

.lesson-ribbon-item.locked span::after {
  content: " - закрыт";
  color: var(--muted);
}

.lesson-ribbon-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.reader-lesson {
  min-width: 0;
  max-width: 100%;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.reader-lesson:first-child {
  padding-top: 0;
  border-top: 0;
}

.lesson-flow-number {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.reader-lesson h3 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.15;
}

.reader-lesson h4 {
  margin: 18px 0 8px;
  font-size: 18px;
}

.catalog,
.reader {
  padding: 22px;
}

.catalog {
  display: grid;
  gap: 10px;
  box-shadow: none;
}

.catalog-card,
.category-link {
  padding: 15px;
}

.catalog-group {
  display: grid;
  gap: 8px;
}

.catalog-group h3 {
  margin: 10px 0 2px;
  font-size: 15px;
}

.reader {
  padding: 34px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.reader h2 {
  margin-bottom: 12px;
  font-size: 42px;
  line-height: 1.12;
}

.reader h3 {
  margin: 24px 0 8px;
}

.lead,
.reader p,
.reader li {
  color: #3d4c55;
  line-height: 1.65;
}

.video-frame {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  margin: 22px 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #17211f;
  color: #c8d6d2;
}

.video-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.youtube-fallback {
  padding: 24px;
  background: #171717;
  text-align: center;
}

.youtube-fallback div {
  max-width: 420px;
  display: grid;
  gap: 12px;
}

.youtube-fallback strong {
  color: white;
  font-size: 20px;
}

.youtube-fallback span {
  color: #c8d6d2;
  line-height: 1.5;
}

.youtube-fallback a {
  display: inline-grid;
  place-items: center;
  justify-self: center;
  min-width: 180px;
  text-decoration: none;
}

.lesson-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 800;
}

.chip.active {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.article-card {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.article-card h3 {
  margin-top: 0;
}

.knowledge-app {
  display: grid;
  gap: 28px;
}

.kb-mode-switch {
  width: max-content;
  margin-bottom: 16px;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

#knowledgeView > .stats-grid,
#knowledgeView > .kb-mode-switch,
#knowledgeView > .kb-article-analytics,
#knowledgeView > .admin-panel {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

#knowledgeView > .kb-mode-switch {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
}

#knowledgeView .kb-home,
#knowledgeView .kb-section,
#knowledgeView .kb-lists,
#knowledgeView .kb-section-page-head,
#knowledgeView .kb-category-columns,
#knowledgeView .kb-article-layout,
#knowledgeView .kb-breadcrumbs {
  width: 100%;
  max-width: none;
}

#knowledgeView > .kb-mode-switch button {
  border: 1px solid var(--line);
  background: #f2f0eb;
}

#knowledgeView > .kb-mode-switch button.active {
  border-color: var(--brand);
  background: var(--brand);
}

.kb-mode-switch button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.kb-mode-switch button.active {
  background: var(--brand);
  color: var(--ink);
}

.kb-structure-panel,
.kb-article-browser {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.kb-structure-panel .panel-head p,
.kb-article-browser .panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.kb-structure-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.kb-structure-column {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
}

.kb-structure-column-head {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kb-structure-column-head h4 {
  margin: 0;
  font-size: 16px;
}

.kb-structure-column-head .button {
  padding: 0 14px;
}

.kb-structure-column .item-list {
  display: grid;
  gap: 10px;
}

.kb-structure-column .plain-item {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kb-structure-panel > .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.kb-tree-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.kb-tree-search {
  min-width: 240px;
  flex: 1 1 260px;
}

.kb-tree-search input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.kb-tree-search input:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.18);
}

body[data-theme="2"] .kb-structure-panel > .panel-head {
  border-bottom: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

body[data-theme="2"] .kb-structure-panel > .panel-head h3 {
  color: var(--ink);
}

body[data-theme="2"] .kb-structure-panel > .panel-head p {
  color: var(--muted);
}

.kb-tree-shell {
  margin-top: 18px;
}

.kb-tree {
  display: grid;
  gap: 12px;
}

.kb-tree-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: #fbfcfd;
}

.kb-tree-row {
  min-height: 64px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.kb-tree-group-row {
  grid-template-columns: 30px 38px minmax(0, 1fr) auto;
  padding: 10px 12px;
  background: white;
}

.kb-tree-toggle {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
}

.kb-tree-toggle span {
  display: block;
  transform: rotate(0deg);
  transition: transform 150ms ease;
}

.kb-tree-group.expanded > .kb-tree-group-row .kb-tree-toggle span,
.kb-tree-category.expanded > .kb-tree-category-row .kb-tree-toggle span {
  transform: rotate(90deg);
}

.kb-tree-section-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  color: #171714;
  font-style: normal;
  font-weight: 900;
}

.kb-tree-row-main {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.kb-tree-level {
  color: var(--brand-dark);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

.kb-tree-row-main strong {
  overflow-wrap: anywhere;
  font-size: 16px;
}

.kb-tree-row-main small {
  color: var(--muted);
  font-size: 12px;
}

.kb-tree-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-tree-add,
.kb-tree-inline-add {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #d8d5cf;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.kb-tree-add:hover,
.kb-tree-inline-add:hover {
  border-color: var(--brand);
  background: #fff8df;
}

.kb-tree-children {
  padding: 8px 12px 12px 48px;
  background: #fbfcfd;
}

.kb-tree-category {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 3px solid #a8a49c;
  border-radius: 7px;
  background: #f5f5f3;
}

.kb-tree-category + .kb-tree-category {
  margin-top: 8px;
}

.kb-tree-category-row {
  padding: 7px 8px 7px 10px;
  border-bottom: 1px solid var(--line);
  background: #f5f5f3;
}

.kb-tree-category .kb-tree-level {
  color: #6d6962;
}

.kb-tree-articles {
  display: grid;
  gap: 6px;
  padding: 8px 8px 10px 40px;
  background: white;
}

.kb-tree-article {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  text-align: left;
}

.kb-tree-article:hover {
  border-color: var(--brand);
  box-shadow: 0 6px 16px rgba(128, 92, 0, 0.08);
}

.kb-tree-article > span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.kb-tree-article strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.kb-tree-article small {
  color: var(--muted);
  font-size: 11px;
}

.kb-tree-article em {
  padding: 4px 7px;
  border-radius: 999px;
  background: #eef1ef;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.kb-tree-article em.published {
  background: #e7f4e9;
  color: #237640;
}

.kb-tree-document {
  position: relative;
  width: 15px;
  height: 18px;
  border: 1.5px solid #8a847b;
  border-radius: 2px;
}

.kb-tree-document::before,
.kb-tree-document::after {
  content: "";
  position: absolute;
  left: 3px;
  width: 7px;
  height: 1px;
  background: #8a847b;
}

.kb-tree-document::before {
  top: 6px;
}

.kb-tree-document::after {
  top: 10px;
}

.kb-tree-open {
  color: var(--brand-dark);
  font-size: 22px;
}

.kb-tree-inline-add {
  justify-self: start;
  margin: 9px 0 0 40px;
}

.kb-tree-empty {
  min-height: 160px;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 24px;
  border: 1px dashed #d8c57b;
  border-radius: 8px;
  background: #fffdf4;
  text-align: center;
}

.kb-tree-empty span {
  color: var(--muted);
}

.kb-admin-category strong {
  display: block;
}

.kb-item-edit {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 18px;
}

.kb-item-edit:hover {
  border-color: var(--brand);
  background: var(--mint);
}

.kb-article-browser {
  margin-top: 18px;
}

.kb-article-analytics {
  margin-top: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.kb-analytics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.kb-analytics-head h3 {
  margin: 0;
}

.kb-analytics-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.kb-analytics-toggle {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.kb-analytics-toggle:hover {
  color: var(--brand-dark);
}

.kb-article-analytics.collapsed {
  padding-block: 16px;
}

.kb-article-analytics.collapsed .kb-analytics-table-wrap {
  display: none;
}

.kb-analytics-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.kb-analytics-table {
  width: 100%;
  border-collapse: collapse;
}

.kb-analytics-table th,
.kb-analytics-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.kb-analytics-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.kb-analytics-table td:first-child {
  min-width: 260px;
}

.kb-analytics-table td strong,
.kb-analytics-table td span {
  display: block;
}

.kb-analytics-table td span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.kb-usefulness {
  min-width: 120px;
}

.kb-usefulness > span {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee9d8;
}

.kb-usefulness i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.kb-analytics-empty {
  padding: 28px !important;
  color: var(--muted);
  text-align: center !important;
}

.kb-article-browser .course-tile-grid {
  margin-top: 18px;
}

.kb-article-tile {
  min-height: 150px;
}

.kb-article-editor {
  width: 100%;
}

.kb-article-form {
  margin-top: 18px;
}

.kb-article-form .rich-editor {
  min-height: 340px;
}

.kb-article-editor #deleteArticleBtn {
  width: 42px;
  height: 34px;
  min-height: 34px;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
}

.kb-home {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.kb-home-panel {
  width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.kb-hero {
  padding: 28px 32px 30px;
  background: white;
}

body[data-theme="2"] .kb-home .kb-hero {
  background: white;
}

.kb-hero-inner {
  width: min(880px, 100%);
  margin: 0 auto;
  text-align: center;
}

.kb-hero h2 {
  margin: 0 0 20px;
  font-size: 36px;
  line-height: 1.1;
}

.kb-search {
  min-height: 58px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
  box-shadow: 0 10px 25px rgba(17, 24, 22, 0.06);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.kb-search:focus-within {
  border-color: #aaa69e;
  box-shadow: 0 0 0 3px rgba(87, 83, 77, 0.1);
}

.kb-search b {
  color: var(--brand-dark);
  font-size: 24px;
  line-height: 1;
  font-weight: 500;
}

.kb-search input {
  height: 56px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  font-weight: 500;
}

.kb-search input:focus {
  border-color: transparent;
  box-shadow: none;
}

.kb-search-main {
  grid-template-columns: minmax(0, 1fr) 30px 46px;
  gap: 6px;
  padding: 5px 6px 5px 16px;
}

.kb-search-main input {
  height: 46px;
}

.kb-search-clear {
  width: 30px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #52708b;
  font-size: 24px;
  line-height: 1;
}

.kb-search-clear:hover {
  color: var(--ink);
}

.kb-search-clear.invisible {
  visibility: hidden;
  pointer-events: none;
}

.kb-search-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: var(--ink);
}

.kb-search-icon {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
}

.kb-search-icon::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.kb-search-icon::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 7px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: center;
}

.kb-search-button:hover {
  filter: brightness(0.96);
}

.kb-search-button:focus-visible {
  outline: 3px solid rgba(40, 110, 159, 0.35);
  outline-offset: 2px;
}

.kb-section,
.kb-lists,
.kb-section-page-head,
.kb-category-columns,
.kb-article-layout,
.kb-breadcrumbs {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.kb-section {
  display: grid;
  gap: 16px;
}

.kb-home > .kb-section {
  padding: 24px 28px 28px;
}

.kb-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.kb-section-head h3 {
  margin: 3px 0 0;
  font-size: 24px;
}

.kb-section-kicker {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.kb-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.kb-group-card {
  min-height: 118px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fffdf4);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 12px 24px rgba(128, 92, 0, 0.06);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.kb-group-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(128, 92, 0, 0.09);
}

.kb-group-icon,
.kb-section-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #171714;
  font-size: 24px;
  font-style: normal;
  font-weight: 900;
}

.kb-group-copy {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.kb-group-copy strong {
  font-size: 18px;
  line-height: 1.25;
}

.kb-group-copy small {
  color: var(--muted);
  font-weight: 700;
}

.kb-card-arrow {
  color: var(--brand-dark);
  font-size: 22px;
}

.kb-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.kb-home > .kb-lists {
  padding: 24px 28px 28px;
}

.kb-compact-list {
  min-width: 0;
}

.kb-article-list {
  display: grid;
}

.kb-article-row {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.kb-article-row:hover strong {
  color: var(--brand-dark);
}

.kb-article-row > span {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.kb-article-row strong,
.kb-article-row small {
  overflow-wrap: anywhere;
}

.kb-article-row strong {
  font-size: 15px;
  line-height: 1.35;
}

.kb-article-row small {
  color: var(--muted);
  line-height: 1.35;
}

.kb-article-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.kb-article-row i {
  color: var(--brand-dark);
  font-size: 18px;
  font-style: normal;
}

.kb-text-button,
.kb-breadcrumbs button,
.kb-toc button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font-weight: 800;
}

.kb-empty {
  min-height: 110px;
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  border: 1px dashed #d9c36f;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.kb-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 9px;
  margin-bottom: 4px;
  border-color: #5c5a57;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.15;
}

.kb-breadcrumbs button {
  color: #2b2a27;
  font-size: inherit;
}

.kb-breadcrumbs strong {
  max-width: min(480px, 55vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-section-page-head {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) minmax(240px, 360px);
  align-items: center;
  gap: 18px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.kb-section-page-head .kb-section-icon {
  width: 64px;
  height: 64px;
  font-size: 30px;
}

.kb-section-page-head h2 {
  margin: 3px 0;
  font-size: 32px;
}

.kb-section-page-head p {
  margin: 0;
  color: var(--muted);
}

.kb-search-compact {
  min-height: 50px;
  grid-template-columns: minmax(0, 1fr) 30px 42px;
  gap: 6px;
  padding: 4px 5px 4px 14px;
  box-shadow: 0 10px 25px rgba(17, 24, 22, 0.06);
}

.kb-search-compact input {
  height: 42px;
  font-size: 15px;
}

.kb-search-compact .kb-search-clear {
  height: 42px;
}

.kb-search-compact .kb-search-button {
  width: 42px;
  height: 42px;
}

.kb-category-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 28px;
}

.kb-category-block {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.kb-category-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--brand);
}

.kb-category-head h3 {
  margin: 0;
  font-size: 19px;
}

.kb-category-head span {
  color: var(--muted);
  font-weight: 800;
}

.kb-article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  align-items: start;
  gap: 24px;
}

.kb-article {
  min-width: 0;
  padding: 20px 28px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.kb-article-head {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.kb-article-head h2 {
  margin: 7px 0 12px;
  font-size: 40px;
  line-height: 1.12;
}

.kb-article-head > p {
  margin: 0;
  color: #3d4c55;
  font-size: 18px;
  line-height: 1.6;
}

.kb-article-meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kb-article-content {
  padding: 14px 0 34px;
}

.kb-article-content h2,
.kb-article-content h3 {
  scroll-margin-top: 24px;
  letter-spacing: 0;
}

.kb-article-content h2 {
  margin: 34px 0 12px;
  font-size: 27px;
}

.kb-article-content h3 {
  margin: 26px 0 10px;
  font-size: 21px;
}

.kb-article-content p,
.kb-article-content li {
  color: #31413b;
  font-size: 16px;
  line-height: 1.75;
}

.kb-article-content ul,
.kb-article-content ol {
  padding-left: 24px;
}

.kb-toc {
  position: sticky;
  top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.kb-toc > strong {
  display: block;
  margin-bottom: 12px;
}

.kb-toc nav,
.kb-mobile-toc nav {
  display: grid;
  gap: 10px;
}

.kb-toc button,
.kb-mobile-toc button {
  color: var(--muted);
  text-align: left;
  line-height: 1.4;
}

.kb-toc button:hover,
.kb-mobile-toc button:hover {
  color: var(--brand-dark);
}

.kb-toc button.nested,
.kb-mobile-toc button.nested {
  padding-left: 14px;
  font-weight: 600;
}

.kb-mobile-toc {
  display: none;
}

.kb-feedback {
  display: grid;
  gap: 16px;
  margin-top: 8px;
  padding: 26px 0 0;
  border-top: 1px solid var(--line);
}

.kb-feedback h3 {
  margin: 4px 0 0;
  font-size: 21px;
}

.kb-feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.support-button {
  border: 1px solid #2d3935;
  background: white;
  color: var(--ink);
}

.kb-related {
  margin-top: 34px;
}

.kb-related h3 {
  margin-bottom: 4px;
}

.kb-admin-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-admin-group-title i {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: #171714;
  font-style: normal;
  font-weight: 900;
}

pre {
  white-space: pre-wrap;
  margin: 0;
  color: #3d4c55;
  font-family: inherit;
  line-height: 1.65;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  min-height: 170px;
  padding: 24px;
  border: 1px dashed #e1c96f;
  border-radius: 18px;
  background: #fffdf4;
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 1350px) {
  .users-panel {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .users-toolbar {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
  }

  .users-table-wrap {
    overflow: visible;
  }

  .users-table {
    min-width: 0;
    border-collapse: separate;
  }

  .users-table thead {
    display: none;
  }

  .users-table,
  .users-table tbody {
    display: grid;
    gap: 12px;
  }

  .users-table .user-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 0.7fr 1fr;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
  }

  .users-table .user-row:hover {
    background: #fffdf4;
  }

  .users-table .user-row td {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 7px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .users-table .user-row td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .users-table .user-row td:first-child {
    grid-column: 1;
    grid-row: 1;
  }

  .users-table .user-row td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }

  .users-table .user-row td:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
  }

  .users-table .user-row td:nth-child(4) {
    grid-column: 4;
    grid-row: 1;
  }

  .user-role-select {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .create-user-grid,
  .generated-password-row {
    grid-template-columns: 1fr;
  }

  .generated-password-row .button {
    width: 100%;
  }
}

@media (max-width: 1100px) {
  .admin-panel,
  #kbAdmin,
  .student-layout {
    grid-template-columns: 1fr;
  }

  .split-list {
    grid-template-columns: 1fr;
  }

  .kb-article-layout {
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 20px;
  }
}

@media (max-width: 760px) {
  body[data-theme="2"] .auth-screen {
    padding: 28px 14px;
  }

  body[data-theme="2"] .auth-card {
    min-height: 0;
    margin: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  body[data-theme="2"] .auth-brand {
    grid-column: 1;
    grid-row: 1;
    min-height: 86px;
    padding: 16px 20px;
    align-items: center;
    justify-content: center;
  }

  body[data-theme="2"] .auth-brand .brand-logo {
    width: min(195px, 78%);
    height: 36px;
  }

  body[data-theme="2"] .auth-tabs {
    grid-column: 1;
    grid-row: 2;
    margin: 22px 20px 18px;
  }

  body[data-theme="2"] .auth-form {
    grid-column: 1;
    grid-row: 3;
    padding: 0 20px 24px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  body[data-theme="2"] .app-shell {
    grid-template-columns: 1fr;
  }

  body[data-theme="2"] .sidebar {
    background: #2d2d2a;
  }

  .sidebar {
    min-height: auto;
    padding: 16px 18px;
    gap: 14px;
  }

  .sidebar .brand {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-logout {
    min-height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0 12px;
    border-color: rgba(255, 255, 255, 0.32);
    background: transparent;
    color: white;
    font-size: 13px;
  }

  .mobile-logout:hover {
    border-color: var(--brand);
    background: rgba(255, 193, 7, 0.14);
    color: white;
  }

  .mobile-logout:focus-visible {
    border-color: var(--brand);
    outline: 2px solid rgba(255, 193, 7, 0.4);
    outline-offset: 2px;
    background: rgba(255, 193, 7, 0.14);
  }

  .sidebar .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 22px;
  }

  .sidebar .brand-logo {
    width: 154px;
    height: 42px;
  }

  .sidebar .brand h1 {
    margin: 0;
    font-size: 24px;
  }

  .sidebar .eyebrow {
    margin-bottom: 2px;
    font-size: 10px;
  }

  .main-nav {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 6px;
  }

  .theme-choice-grid {
    grid-template-columns: 1fr;
  }

  .theme-preview {
    height: 180px;
  }

  .nav-btn {
    min-height: 42px;
    padding: 6px 8px;
    text-align: center;
    font-size: 13px;
  }

  .topbar {
    position: relative;
    min-height: auto;
    padding-right: 0;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-user {
    display: none;
  }

  .topbar-user .profile-box {
    display: none;
  }

  .topbar-user .logout-small {
    min-height: 30px;
    padding: 0 9px;
  }

  .topbar h2 {
    font-size: 30px;
  }

  .preview-topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px 18px;
  }

  .preview-actions {
    justify-content: space-between;
  }

  .preview-actions .button {
    flex: 1;
  }

  .workspace {
    padding: 18px 10px;
  }

  body[data-theme="2"] .workspace {
    padding: 18px 10px;
  }

  #courseStats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  #courseStats .stat {
    min-width: 0;
    padding: 14px 12px;
  }

  #courseStats .stat span {
    font-size: 12px;
  }

  #courseStats .stat strong {
    font-size: 28px;
  }

  .learner-overview {
    padding: 14px;
  }

  .learner-metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .learner-metrics div {
    padding: 12px;
  }

  .course-audiences {
    display: grid;
  }

  .users-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .users-filters {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .users-create-button,
  .users-invite-button {
    width: 100%;
    justify-self: stretch;
  }

  .users-search {
    grid-column: 1 / -1;
  }

  .users-table .user-row {
    grid-template-columns: 1fr 1fr;
    gap: 16px 12px;
    padding: 16px;
  }

  .users-table .user-row td:first-child,
  .users-table .user-row td:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .users-table .user-row td:nth-child(3),
  .users-table .user-row td:nth-child(4) {
    grid-column: auto;
    grid-row: auto;
  }

  .kb-article-analytics {
    padding: 16px;
  }

  .kb-analytics-table-wrap {
    overflow: visible;
  }

  .kb-analytics-table thead {
    display: none;
  }

  .kb-analytics-table,
  .kb-analytics-table tbody {
    display: block;
  }

  .kb-analytics-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf8;
  }

  .kb-analytics-table td {
    display: grid;
    gap: 3px;
    padding: 0;
    border: 0;
  }

  .kb-analytics-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .kb-analytics-table td:first-child,
  .kb-analytics-table td:last-child {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .kb-analytics-table .kb-analytics-empty {
    display: block;
    grid-column: 1 / -1;
  }

  .user-detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .user-profile-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .user-profile-delete {
    width: 100%;
  }

  .user-profile-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .user-analytics-stats {
    grid-template-columns: 1fr 1fr;
  }

  .user-course-detail summary {
    align-items: flex-start;
  }

  .manual-review > div {
    display: grid;
  }

  #courseAdmin .course-browser {
    padding: 16px;
  }

  #courseAdmin .course-tile-grid,
  .student-course-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #courseAdmin .course-tile,
  #courseAdmin .course-add-tile,
  .student-course-grid .course-tile {
    min-height: 145px;
    padding: 18px;
  }

  .course-editor-page {
    margin-top: 14px;
  }

  .course-editor-page > .editor-topline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .course-editor-page > .editor-topline .button {
    width: 100%;
    justify-content: center;
  }

  #courseEditor > .panel-column {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: none;
  }

  #courseEditor > .panel-column > .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  body[data-theme="2"] #courseEditor > .panel-column > .panel-head {
    margin: -16px -16px 14px;
  }

  body[data-theme="2"] #courseEditor .lesson-zone > .panel-head {
    margin: -18px -14px 14px;
  }

  #courseEditor .editor-actions {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 42px;
    gap: 8px;
  }

  #courseEditor .editor-actions .toggle-field {
    min-width: 0;
  }

  #courseEditor .save-course-top {
    width: 100%;
    margin-left: 0;
  }

  #courseEditor .lesson-zone {
    margin-top: 16px;
    padding: 18px 14px 14px;
  }

  #courseEditor .lesson-tile-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 78vw);
    gap: 10px;
    padding: 3px 3px 10px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
  }

  #courseEditor .lesson-tile,
  #courseEditor .lesson-add-tile {
    min-height: 142px;
    height: 142px;
    scroll-snap-align: start;
  }

  #courseEditor .editor-form {
    min-width: 0;
  }

  #courseEditor .rich-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  #courseEditor .rich-toolbar button {
    flex: 0 0 38px;
  }

  #courseEditor .rich-editor {
    min-height: 220px;
  }

  #kbArticleEditor .rich-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  #kbArticleEditor .rich-toolbar button {
    flex: 0 0 38px;
  }

  #kbArticleEditor .rich-toolbar select {
    flex: 0 0 86px;
  }

  #kbArticleEditor .rich-editor {
    min-height: 260px;
  }

  #courseEditor .course-save-bottom .button {
    width: 100%;
  }

  #courseStudentView .reader {
    min-width: 0;
    padding: 18px;
    overflow: hidden;
    border-radius: 16px;
  }

  .student-course-grid {
    margin-top: 14px;
  }

  .course-reader-head {
    align-items: stretch;
    flex-direction: column;
  }

  .course-reader-head .button {
    width: 100%;
  }

  #courseStudentView .reader h2 {
    font-size: 31px;
  }

  .course-progress {
    margin-bottom: 16px;
  }

  .lesson-ribbon {
    margin: 14px -4px 0;
    padding: 8px;
    scroll-snap-type: inline mandatory;
  }

  .lesson-ribbon-item {
    min-width: min(240px, 76vw);
    scroll-snap-align: start;
  }

  .reader-lesson {
    padding-top: 18px;
  }

  .reader-lesson h3 {
    font-size: 27px;
  }

  .reader-lesson .video-frame {
    margin: 18px 0;
  }

  .kb-hero {
    margin: 0;
    padding: 22px 14px 24px;
  }

  .kb-hero h2 {
    margin-bottom: 16px;
    font-size: 29px;
  }

  .kb-search {
    min-height: 52px;
  }

  .kb-search input {
    height: 50px;
    font-size: 15px;
  }

  .kb-search-main {
    grid-template-columns: minmax(0, 1fr) 28px 42px;
    padding: 4px 5px 4px 12px;
  }

  .kb-search-main input,
  .kb-search-button {
    height: 42px;
  }

  .kb-search-clear {
    width: 28px;
    height: 42px;
  }

  .kb-search-button {
    width: 42px;
  }

  .kb-group-grid,
  .kb-lists,
  .kb-category-columns,
  .kb-article-layout,
  .kb-structure-grid {
    grid-template-columns: 1fr;
  }

  .kb-category-columns {
    gap: 14px;
  }

  .kb-category-block {
    padding: 16px;
  }

  .kb-structure-panel > .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .kb-structure-panel > .panel-head .button {
    width: 100%;
  }

  .kb-tree-toolbar {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .kb-tree-search {
    min-width: 0;
    width: 100%;
    flex-basis: auto;
  }

  .kb-tree-group-row {
    grid-template-columns: 28px 36px minmax(0, 1fr);
  }

  .kb-tree-group-row .kb-tree-actions {
    grid-column: 2 / -1;
  }

  .kb-tree-children {
    padding: 0 8px 10px 20px;
  }

  .kb-tree-category-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .kb-tree-category-row .kb-tree-actions {
    grid-column: 2;
  }

  .kb-tree-actions {
    align-items: stretch;
  }

  .kb-tree-add {
    flex: 1;
  }

  .kb-tree-articles {
    padding-left: 18px;
  }

  .kb-tree-article {
    grid-template-columns: 20px minmax(0, 1fr) 16px;
  }

  .kb-tree-article em {
    grid-column: 2;
    justify-self: start;
  }

  .kb-tree-open {
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .kb-home {
    gap: 14px;
  }

  .kb-home > .kb-section,
  .kb-home > .kb-lists {
    padding: 18px 14px;
  }

  .kb-section-page-head {
    grid-template-columns: 54px minmax(0, 1fr);
    margin-top: 6px;
    padding: 16px 14px;
  }

  .kb-section-page-head .kb-section-icon {
    width: 54px;
    height: 54px;
  }

  .kb-section-page-head .kb-search {
    grid-column: 1 / -1;
  }

  .kb-section-page-head h2 {
    font-size: 26px;
  }

  .kb-article-head h2 {
    font-size: 31px;
  }

  .kb-article-head > p {
    font-size: 16px;
  }

  .kb-breadcrumbs {
    gap: 6px 8px;
    font-size: 14px;
  }

  .kb-breadcrumbs strong {
    max-width: 100%;
    overflow: visible;
    white-space: normal;
  }

  .kb-article {
    padding: 16px 18px 18px;
  }

  .kb-toc {
    display: none;
  }

  .kb-mobile-toc {
    margin-top: 18px;
    display: block;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
  }

  .kb-mobile-toc summary {
    cursor: pointer;
    font-weight: 900;
  }

  .kb-mobile-toc nav {
    margin-top: 12px;
  }

  .kb-feedback {
    padding: 22px 0 0;
  }

  .kb-feedback-actions {
    display: grid;
  }

  .kb-feedback-actions .button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .two-columns {
    grid-template-columns: 1fr;
  }

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

  .course-image-preview {
    grid-template-columns: 1fr;
  }

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

  .test-builder-head {
    align-items: stretch;
    flex-direction: column;
  }

  .test-builder-head .button {
    width: 100%;
  }

  .test-builder:not(.collapsed) {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .test-builder:not(.collapsed) .test-builder-toggle {
    padding-inline: 0;
    border-radius: 0;
  }

  .test-builder-body {
    gap: 12px;
  }

  .test-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .test-card span {
    margin-bottom: 4px;
  }

  .test-card em {
    margin-top: 7px;
    font-size: 14px;
    line-height: 1.4;
  }

  .test-card-actions {
    justify-content: flex-end;
  }

  .test-editor {
    padding: 14px;
  }

  .test-editor-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .test-editor-actions .button {
    width: 100%;
    min-width: 0;
  }

  .image-size-controls {
    grid-template-columns: 1fr 52px;
  }

  .image-size-controls span,
  .image-size-controls .button {
    grid-column: 1 / -1;
  }

  .image-editor-settings {
    grid-template-columns: 1fr;
  }

  .image-align-setting {
    grid-column: auto;
  }

  .image-editor-preview {
    min-height: 180px;
  }
}

/* Interface rhythm pass: tighter, consistent spacing across the cabinet. */
body[data-theme="2"] .workspace {
  padding: 24px;
}

body[data-theme="2"] .topbar {
  margin-bottom: 16px;
  padding-bottom: 14px;
  align-items: center;
}

body[data-theme="2"] .topbar h2 {
  font-size: 30px;
  line-height: 1.1;
}

.stats-grid {
  gap: 12px;
  margin-bottom: 14px;
}

body[data-theme="2"] .stat {
  min-height: 92px;
  padding: 16px 18px;
}

body[data-theme="2"] .stat strong {
  margin-top: 4px;
  font-size: 30px;
}

.panel-column,
.kb-structure-panel,
.kb-article-browser {
  padding: 16px;
}

body[data-theme="2"] .panel-head {
  padding: 14px 16px;
}

body[data-theme="2"] .panel-column > .panel-head,
body[data-theme="2"] .kb-structure-panel > .panel-head,
body[data-theme="2"] .kb-article-browser > .panel-head,
body[data-theme="2"] .course-editor-page > .panel-column > .panel-head {
  margin: -16px -16px 12px;
}

body[data-theme="2"] .lesson-zone > .panel-head {
  margin: -16px -16px 12px;
}

.course-editor-page {
  margin-top: 12px;
}

.editor-topline {
  margin-bottom: 10px;
  gap: 8px;
}

.course-tile-grid,
.student-course-grid,
.kb-group-grid {
  gap: 12px;
}

.course-tile,
.course-add-tile {
  min-height: 148px;
  padding: 16px;
}

.course-tile strong {
  margin-top: 8px;
  font-size: 20px;
}

.course-tile em {
  margin-top: 10px;
}

.course-form-grid,
.kb-structure-grid,
.admin-panel {
  gap: 12px;
}

.course-audiences {
  border-radius: 8px;
}

.course-image-preview {
  border-radius: 8px;
}

.course-save-bottom {
  padding-top: 0;
}

.lesson-zone {
  margin-top: 14px;
}

.lesson-ribbon {
  margin-top: 14px;
  padding: 8px;
  border-radius: 8px;
}

.lesson-ribbon-item {
  min-width: 208px;
  min-height: 82px;
  padding: 14px;
  border-radius: 8px;
}

.course-lessons-flow {
  gap: 18px;
  margin-top: 18px;
}

.reader,
.catalog {
  padding: 20px;
}

.reader {
  padding: 26px;
}

.reader h2 {
  font-size: 38px;
}

.reader-lesson {
  padding-top: 18px;
}

.reader-lesson h3 {
  font-size: 28px;
}

.course-progress {
  gap: 7px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
}

.users-toolbar {
  padding: 16px 18px;
  gap: 14px;
}

.users-table th,
.users-table td {
  padding: 12px;
}

.knowledge-app {
  gap: 18px;
}

.kb-mode-switch {
  margin-bottom: 12px;
}

.kb-structure-grid {
  margin-top: 14px;
}

.kb-structure-column {
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
}

.kb-tree-shell {
  margin-top: 14px;
}

.kb-tree {
  gap: 10px;
}

.kb-tree-group-row {
  padding: 9px 10px;
}

.kb-tree-children {
  padding: 6px 10px 10px 40px;
}

.kb-tree-category-row {
  padding: 8px 10px;
}

.kb-tree-articles {
  padding: 8px 8px 10px 32px;
}

.kb-tree-article {
  min-height: 52px;
}

.kb-article-analytics {
  margin-bottom: 14px;
  padding: 16px 18px;
}

.kb-home {
  gap: 14px;
}

.kb-hero {
  padding: 24px 26px;
}

.kb-hero h2 {
  margin-bottom: 16px;
  font-size: 32px;
}

.kb-home > .kb-section,
.kb-home > .kb-lists {
  padding: 20px 22px;
}

.kb-group-card {
  min-height: 104px;
  padding: 16px;
  border-radius: 8px;
}

.kb-lists {
  gap: 18px;
}

.kb-article {
  padding: 24px 28px;
}

.kb-article-head h2 {
  font-size: 38px;
}

.kb-feedback {
  margin-top: 26px;
  padding: 22px;
  border-radius: 8px;
}

.appearance-settings {
  width: min(860px, 100%);
}

.settings-heading {
  margin-bottom: 16px;
}

.theme-choice-grid {
  gap: 14px;
}

@media (max-width: 760px) {
  body[data-theme="2"] .workspace,
  .workspace {
    padding: 14px 8px;
  }

  body[data-theme="2"] .topbar,
  .topbar {
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .topbar h2,
  body[data-theme="2"] .topbar h2 {
    font-size: 28px;
  }

  body.public-knowledge-mode .workspace {
    padding: 20px 10px 34px;
  }

  body.public-knowledge-mode .topbar {
    margin-bottom: 14px;
  }

  body.public-knowledge-mode .topbar h2 {
    font-size: 30px;
  }

  body.public-knowledge-mode .screen-heading {
    gap: 10px;
  }

  body.public-knowledge-mode .public-kb-logo {
    width: auto;
    height: 25px;
  }

  .stats-grid {
    gap: 8px;
    margin-bottom: 12px;
  }

  body[data-theme="2"] .stat {
    min-height: 76px;
    padding: 12px;
  }

  .panel-column,
  .kb-structure-panel,
  .kb-article-browser,
  .users-panel,
  .learner-overview {
    padding: 14px;
  }

  body[data-theme="2"] .panel-column > .panel-head,
  body[data-theme="2"] .kb-structure-panel > .panel-head,
  body[data-theme="2"] .kb-article-browser > .panel-head,
  body[data-theme="2"] .course-editor-page > .panel-column > .panel-head,
  body[data-theme="2"] #courseEditor > .panel-column > .panel-head {
    margin: -14px -14px 12px;
  }

  .course-tile-grid,
  .student-course-grid {
    gap: 10px;
  }

  .course-tile,
  .course-add-tile,
  #courseAdmin .course-tile,
  #courseAdmin .course-add-tile,
  .student-course-grid .course-tile {
    min-height: 136px;
    padding: 14px;
  }

  .reader,
  #courseStudentView .reader,
  .kb-article {
    padding: 16px;
  }

  .reader h2,
  #courseStudentView .reader h2,
  .kb-article-head h2 {
    font-size: 31px;
  }

  .reader-lesson h3 {
    font-size: 26px;
  }

  .course-progress,
  .lesson-ribbon,
  .kb-home-panel,
  .kb-category-block,
  .kb-feedback {
    border-radius: 8px;
  }

  .kb-home > .kb-section,
  .kb-home > .kb-lists,
  .kb-hero {
    padding: 16px 12px;
  }

  .kb-hero h2 {
    font-size: 27px;
  }

  .kb-group-card {
    min-height: 92px;
    padding: 14px;
  }

  .kb-tree-children {
    padding-left: 14px;
  }

  .kb-tree-articles {
    padding-left: 14px;
  }

  .users-toolbar {
    padding: 14px;
  }

  .users-table .user-row {
    padding: 14px;
    gap: 12px;
  }
}

.lesson-flow-number {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0;
}

.lesson-flow-number + h3 {
  margin-top: 10px;
}

@media (max-width: 760px) {
  .lesson-flow-number {
    margin-bottom: 4px;
    font-size: 18px;
  }
}

.lesson-ribbon-item span {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
  letter-spacing: 0;
}

.lesson-ribbon-item strong {
  display: -webkit-box;
  max-height: calc(1.25em * 3);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  font-weight: 500;
}

.preview-ribbon .lesson-ribbon-item strong {
  font-weight: 500;
}

.lesson-ribbon-item.completed span::after,
.lesson-ribbon-item.locked span::after {
  font-weight: 600;
  letter-spacing: 0;
}

@media (max-width: 760px) {
  .lesson-ribbon-item span {
    font-size: 12px;
  }
}

.button,
.button.primary,
.button.small.editor-nav-action,
.social-button,
.auth-tabs .tab.active,
.kb-mode-switch button.active,
.kb-search-button,
.support-button,
.course-save-bottom .button,
.test-editor-actions .button,
.test-builder-head .button,
.image-size-controls .button,
.generated-password-row .button,
.preview-actions .button,
.kb-feedback-actions .button,
body[data-theme="2"] .auth-form .button,
body[data-theme="2"] .auth-tabs .tab.active,
body[data-theme="2"] .button.primary,
body[data-theme="2"] .button:not(.ghost):not(.danger):not(.support-button) {
  box-shadow: none !important;
}

.button,
.button.primary,
.button.ghost,
.button.danger,
.button.small.editor-nav-action,
.social-button,
.auth-tabs .tab,
.segmented-control button,
.kb-mode-switch button,
.kb-search-button,
.support-button,
.users-create-button,
.users-invite-button,
.course-save-bottom .button,
.test-editor-actions .button,
.test-builder-head .button,
.image-size-controls .button,
.generated-password-row .button,
.preview-actions .button,
.kb-feedback-actions .button,
.kb-text-button,
.kb-breadcrumbs button,
.kb-toc button,
.kb-mobile-toc button,
body[data-theme="2"] .auth-form .button,
body[data-theme="2"] .auth-tabs .tab,
body[data-theme="2"] .button.primary,
body[data-theme="2"] .button:not(.ghost):not(.danger):not(.support-button) {
  font-weight: 700 !important;
}
