/* Layout and components extracted from the inline styles of the original Django templates. */

a { color: inherit; }

.muted { color: var(--text-muted); }
.text-small { font-size: 0.85rem; }
.hidden { display: none !important; }

/* ---------- Responsive Utility Classes ---------- */
.show-mobile-only { display: none !important; }
.show-tablet-only { display: none !important; }
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .show-mobile-only { display: block !important; }
  span.show-mobile-only, strong.show-mobile-only, a.show-mobile-only { display: inline !important; }
  div.show-mobile-only { display: block !important; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .show-tablet-only { display: block !important; }
}

@media (max-width: 1024px) {
  .hide-tablet { display: none !important; }
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
}

.site-header__side { display: flex; gap: 1.2rem; align-items: center; flex: 1; }
.site-header__side--end { justify-content: flex-end; }
.site-header__center { display: flex; justify-content: center; flex: 1; }
.site-brand { text-decoration: none; color: var(--text-main); font-weight: bold; font-size: 1.2rem; }

.header-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  position: relative;
}
.header-link:hover { color: var(--text-main); }
.header-divider { width: 1px; height: 20px; background-color: var(--border-color); }

.notification-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background-color: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 10px;
  line-height: 1.4;
}

/* Theme switcher */
.theme-switcher {
  display: flex;
  align-items: center;
  background-color: var(--bg-body);
  padding: 2px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}
.theme-switcher__btn {
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 14px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.theme-switcher__btn.is-active {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Dropdown menus (user menu, workspace switcher) */
.dropdown { position: relative; }
.dropdown__panel {
  position: absolute;
  z-index: 1000;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  padding: 0.5rem 0;
}
.dropdown__panel--right { right: 0; top: 120%; width: 220px; }
.dropdown__panel--full { top: calc(100% + 6px); left: 0; width: 100%; min-width: 230px; padding: 0.5rem; }
.dropdown__header { padding: 0.6rem 1rem; border-bottom: 1px solid var(--border-color); margin-bottom: 0.4rem; }
.dropdown__separator { border-top: 1px solid var(--border-color); margin: 0.4rem 0; }

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  color: var(--text-main);
  text-decoration: none;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  border-radius: 6px;
}
.menu-item:hover { background-color: var(--bg-surface-hover); }
.menu-item--danger { color: var(--error-color); }
.menu-item--compact { padding: 0.45rem 0.6rem; font-size: 0.85rem; }
.menu-item--current { background-color: var(--bg-surface-hover); font-weight: 600; color: var(--accent-color); justify-content: space-between; }

.user-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  color: var(--text-main);
  font-family: inherit;
}
.user-trigger:hover { background-color: var(--bg-surface-hover); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--accent-color-alpha);
  color: var(--accent-color);
  font-weight: bold;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar--square { border-radius: 6px; }
.avatar--small { width: 22px; height: 22px; border-radius: 4px; font-size: 0.75rem; }
.avatar--large { width: 42px; height: 42px; border-radius: 8px; font-size: 1.1rem; }
.avatar--solid { background-color: var(--accent-color); color: var(--bg-body); }
.avatar--neutral { background-color: var(--border-color); color: var(--text-main); }

.site-footer {
  padding: 1.5rem 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface);
}

.site-footer__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-footer__links {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
}

.site-footer__links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-footer__links a:hover {
  color: var(--accent-color);
  text-decoration: underline;
}

@media (max-width: 640px) {
  .site-footer__inner {
    flex-direction: column;
    text-align: center;
    justify-content: center;
  }
}

/* ---------- Workspace shell ---------- */
.workspace-shell { display: flex; min-height: calc(100vh - 81px); }
.workspace-sidebar {
  width: 260px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 1rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.workspace-switcher {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-main);
  text-align: left;
  font-family: inherit;
  transition: border-color 0.2s;
}
.workspace-switcher:hover { border-color: var(--accent-color); }
.workspace-switcher__name { font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-options { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.2rem; }

.sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; margin-top: 1.5rem; }
.sidebar-nav__link {
  display: block;
  padding: 0.6rem 1rem;
  color: var(--text-main);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
}
.sidebar-nav__link:hover, .sidebar-nav__link.is-active { background-color: var(--bg-surface-hover); }
.sidebar-nav__link.is-disabled { color: var(--text-muted); cursor: default; }
.sidebar-nav__separator { border-top: 1px solid var(--border-color); margin: 0.5rem 0; }
.workspace-section-picker { display: none; }

.workspace-main {
  flex: 1;
  padding: 2.5rem;
  overflow-y: auto;
  background-color: var(--bg-body);
  display: flex;
  justify-content: center;
}
.workspace-main__inner { width: 100%; max-width: 1200px; }

/* ---------- Page building blocks ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }
.page--narrow { max-width: 600px; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.page-header h1 { font-size: 2rem; font-weight: bold; }
.page-header .subtitle { margin: 0.5rem 0 0; }
.section-title { font-size: 1.25rem; font-weight: bold; margin-bottom: 1.5rem; }

.centered-page { display: flex; justify-content: center; align-items: center; min-height: 70vh; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 440px; padding: 2.5rem; }
.auth-card h2 { font-size: 1.75rem; font-weight: bold; text-align: center; margin-bottom: 0.5rem; }
.auth-card .subtitle { text-align: center; font-size: 0.95rem; margin-bottom: 2rem; }
.auth-divider { border-top: 1px solid var(--border-color); margin: 2rem 0 1.5rem; text-align: center; }
.auth-divider span {
  background-color: var(--bg-surface);
  padding: 0 0.75rem;
  position: relative;
  top: -0.7rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.status-card { width: 100%; max-width: 500px; padding: 3rem 2rem; text-align: center; }
.status-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--accent-color-alpha);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.btn-block { width: 100%; }
.actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); }
.actions--plain { border-top: none; padding-top: 0; }
.button-row { display: flex; gap: 0.5rem; align-items: center; }
.button-row--end { justify-content: flex-end; }
.inline-form { display: inline-flex; margin: 0; }

.field-error { color: var(--error-color); display: block; margin-top: 0.25rem; font-size: 0.85rem; font-weight: 500; }
.field-hint { color: var(--text-muted); font-size: 0.8rem; display: block; margin-top: 0.2rem; }

.alert { padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; font-size: 0.9rem; line-height: 1.5; }
.alert--error { background-color: rgba(239, 68, 68, 0.1); border-left: 4px solid var(--error-color); color: var(--error-color); }
.alert--warning { background-color: rgba(245, 158, 11, 0.1); border: 1px solid #f59e0b; color: #b45309; }
.alert--info { background-color: var(--bg-surface); border: 1px solid var(--border-color); color: var(--text-muted); }
.alert--danger-solid { background-color: var(--error-color); color: white; }
.alert--warning-solid { background-color: #f59e0b; color: white; }

.empty-state { padding: 3rem 1.5rem; text-align: center; color: var(--text-muted); }
.empty-state h3 { font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--text-main); }

.list-plain { list-style: none; }
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}
.list-row:hover { background-color: var(--bg-surface-hover); }
.list-row--highlight { background-color: var(--accent-color-alpha); }
.list-row__main { display: flex; align-items: center; gap: 1rem; }
.list-row__title { font-weight: bold; font-size: 1.05rem; }

.card--flush { padding: 0; }
.card--dashed { padding: 1.25rem; border: 1px dashed var(--border-color); box-shadow: none; background-color: var(--bg-surface-hover); margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.grid-members { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; align-items: start; }

/* ---------- Stat Cards / KPIs ---------- */
.sat-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
  width: 100%;
}

@media (max-width: 1100px) {
  .sat-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

.stat-card-link {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
}

.stat-card {
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  color: inherit;
  height: 100%;
  width: 100%;
  margin-bottom: 0 !important;
  padding: 1.5rem 1rem !important;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -2px rgba(0, 0, 0, 0.08);
}

.stat-card__label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  min-height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.stat-card__value {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--accent-color);
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.modal-card { width: 100%; max-width: 500px; margin: 1rem; position: relative; animation: modal-pop 0.2s ease-out; }
.modal-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-card__header h3 { font-size: 1.25rem; font-weight: bold; }
.modal-card__title--danger { color: var(--error-color); }
.modal-close { background: transparent; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); line-height: 1; }

/* <dialog> used by data-turbo-confirm (see app/javascript/confirm_dialog.js) */
.confirm-dialog { margin: auto; color: var(--text-main); }
.confirm-dialog[open] { animation: modal-pop 0.2s ease-out; }
.confirm-dialog::backdrop { background-color: rgba(0, 0, 0, 0.4); backdrop-filter: blur(2px); }

@keyframes modal-pop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Category tree ---------- */
.category-tree-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  padding-left: calc(1.5rem + var(--tree-level, 0) * 2rem);
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s;
  list-style: none;
  cursor: default;
}
.category-tree-row::-webkit-details-marker { display: none; }
details > .category-tree-row { cursor: pointer; }
.category-tree-row:hover { box-shadow: inset 4px 0 0 0 var(--accent-color); background-color: var(--bg-surface-hover); }
.category-tree-row--level-2 { background-color: rgba(0, 0, 0, 0.02); }
.category-tree-row--level-3 { background-color: rgba(0, 0, 0, 0.04); }
.category-tree-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
details[open] > .category-tree-row .category-tree-toggle { transform: rotate(90deg); }
.category-tree-count { background-color: var(--border-color); color: var(--text-main); font-size: 0.7rem; padding: 0.15rem 0.4rem; }

/* ---------- Question form ---------- */
.option-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.25rem; }
.option-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}
.option-row__correct {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 90px;
}
.option-row input[type="checkbox"], .radio-choice input, .checkbox-card input { width: 1.15rem; height: 1.15rem; cursor: pointer; accent-color: var(--accent-color); }
.option-row input[type="checkbox"] { accent-color: var(--success-color); }
.option-row .input-element { flex: 1; padding: 0.6rem 0.85rem; }
.form-section { border-top: 1px solid var(--border-color); padding-top: 1.5rem; margin-bottom: 2rem; }
.form-section__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.form-section__header h3 { font-size: 1.1rem; font-weight: bold; }
.radio-choice { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.checkbox-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  background-color: var(--bg-surface-hover);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

/* Segmented control (question filter AND / OR) */
.segmented-control {
  display: inline-flex;
  background-color: var(--bg-surface-hover);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  user-select: none;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.segmented-control::-webkit-scrollbar { display: none; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control label {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.segmented-control input:checked + label {
  background-color: var(--accent-color);
  color: var(--bg-body);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Pyramid selector */
.pyramid-levels { display: flex; flex-direction: column; gap: 1rem; }
.pyramid-level-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.pyramid-level-row__title { font-size: 0.85rem; font-weight: bold; color: var(--text-muted); min-width: 60px; }
.pyramid-level-row .custom-select-container { flex: 1; min-width: 200px; }

/* Turbo progress bar follows the theme accent */
.turbo-progress-bar { background-color: var(--accent-color); }

/* ---------- Responsive Layout Breakpoints (Tablets and Mobile) ---------- */
@media (max-width: 900px) {
  .workspace-shell {
    flex-direction: column;
    min-height: auto;
  }

  .workspace-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    position: static;
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }

  .workspace-switcher {
    padding: 0.4rem 0.65rem;
  }

  .workspace-switcher__name {
    font-size: 0.88rem;
  }

  .sidebar-nav {
    display: none !important;
  }

  .workspace-section-picker {
    display: block !important;
    width: 100%;
    margin-top: 0.4rem;
  }

  .support-banner {
    padding: 0.5rem 1rem;
  }

  .support-banner__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .support-banner__info {
    min-width: 0;
    font-size: 0.8rem;
  }

  .support-banner__actions {
    justify-content: flex-end;
  }

  .segmented-control label {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  .workspace-main {
    padding: 1.25rem 0.85rem;
    width: 100%;
  }

  .workspace-main__inner {
    width: 100%;
    max-width: 100%;
  }

  .grid-members, .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  .site-header__side {
    gap: 0.6rem;
  }

  .site-brand {
    font-size: 1.05rem;
  }

  .page {
    padding: 1.25rem 0.85rem;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }

  .page-header h1 {
    font-size: 1.6rem;
  }

  .page-header .button-row {
    width: 100%;
    flex-wrap: wrap;
  }

  .table-clean th,
  .table-clean td {
    padding: 0.75rem 0.65rem;
    font-size: 0.85rem;
  }

  .button-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .card {
    padding: 1.2rem 1rem;
  }

  .card--flush {
    padding: 0;
  }

  .auth-card {
    padding: 1.5rem 1rem;
  }

  .modal-card {
    margin: 0.75rem;
    width: calc(100% - 1.5rem);
    padding: 1.25rem 1rem;
  }

  .sat-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .stat-card {
    padding: 0.75rem 0.5rem;
  }

  .stat-card__value {
    font-size: 1.4rem;
  }

  .option-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .option-row__correct {
    order: 1;
  }

  .option-row .btn-danger {
    order: 2;
    margin-left: auto;
  }

  .option-row .input-element {
    order: 3;
    width: 100%;
    flex: 1 1 100%;
  }

  .category-tree-row {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    padding-left: calc(0.5rem + var(--tree-level, 0) * 0.75rem);
  }

  .pyramid-level-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .pyramid-level-row__title {
    min-width: 0;
  }

  .pyramid-level-row .custom-select-container {
    min-width: 0;
    width: 100%;
  }

  .list-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem 0.85rem;
  }

  .list-row .button-row {
    justify-content: flex-end;
    width: 100%;
  }

  .list-row > .btn-secondary,
  .list-row > form > .btn-secondary,
  .list-row > form > .btn-primary {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .sat-stats-grid {
    grid-template-columns: 1fr !important;
  }

  .custom-select-trigger {
    font-size: 0.85rem;
    padding: 0.5rem 0.65rem;
  }
}

/* Toast icon colours per flash type */
.toast-icon { flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success-color); }
.toast-error .toast-icon { color: var(--error-color); }
.toast-warning .toast-icon { color: #eab308; }
.toast-info .toast-icon { color: #3b82f6; }

/* Tabs navigation */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease-in-out;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  flex-shrink: 0;
}
}

.tab-btn:hover {
  color: var(--text-main);
  border-bottom-color: var(--border-color);
}

.tab-btn.is-active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
  font-weight: 600;
}

/* Print Toolbar and Document layout */
.print-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.print-sheet {
  max-width: 840px;
  margin: 1.5rem auto 3rem;
  padding: 2.5rem;
  background: #ffffff;
  color: #111827;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.print-sheet__header {
  border-bottom: 2px solid #111827;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.print-sheet__student-box {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.print-field-line {
  border-bottom: 1px dotted #6b7280;
  display: inline-block;
  min-width: 140px;
  height: 1.2rem;
}

.print-sheet__question {
  margin-bottom: 1.5rem;
  page-break-inside: avoid;
}

.print-sheet__option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.print-bubble {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid #374151;
  border-radius: 50%;
  margin-top: 3px;
  flex-shrink: 0;
}

.print-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.print-matrix-cell {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

/* ---------- Custom Multi-Select ---------- */
.custom-multiselect-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  font-size: 0.88rem;
  transition: background-color 0.15s;
}

.custom-multiselect-option:hover,
.custom-multiselect-option:focus {
  background-color: var(--bg-surface-hover);
  outline: none;
}

.custom-multiselect-option.option-selected {
  background-color: var(--accent-color-alpha);
  color: var(--accent-color);
}

.custom-multiselect-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  transition: all 0.15s;
  background-color: var(--bg-surface);
}

.custom-multiselect-option.option-selected .custom-multiselect-checkbox {
  border-color: var(--accent-color);
  background-color: var(--accent-color);
  color: #ffffff;
}

/* Print mode for exams */
@media print {
  @page {
    size: A4;
    margin: 15mm;
  }

  .site-header-container,
  .site-header,
  .support-banner,
  .workspace-sidebar,
  .site-footer,
  .page-header .button-row,
  .no-print,
  .print-toolbar,
  .toast-container {
    display: none !important;
  }

  body, .workspace-shell, .workspace-main, .main-content {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .print-sheet {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .card {
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }

  .exam-question-item,
  .print-sheet__question {
    page-break-inside: avoid;
    margin-bottom: 1.5rem !important;
  }
}

/* ---------- Category Popover / Tooltip ---------- */
.category-tooltip-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.category-more-badge {
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  flex-shrink: 0;
  line-height: 1.2;
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.category-more-badge:hover,
.category-more-badge[aria-expanded="true"] {
  background-color: var(--border-color);
  border-color: var(--text-muted);
}

.category-popover-panel {
  position: fixed;
  z-index: 9999;
  min-width: 220px;
  max-width: 320px;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 0.75rem 0.85rem;
  font-size: 0.8rem;
  pointer-events: auto;
  animation: popoverFadeIn 0.12s ease-out;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-color);
}

.category-popover-title {
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.category-popover-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.category-popover-item {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-main);
  line-height: 1.35;
}

.category-popover-bullet {
  color: var(--accent-color);
  font-weight: bold;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ---------- Sticky Header Container ---------- */
.site-header-container {
  position: sticky;
  top: 0;
  z-index: 200;
  width: 100%;
}

/* ---------- Support Mode Top Banner (Refined Warning Alert) ---------- */
.support-banner {
  background-color: #fef9c3;
  border-bottom: 1px solid #facc15;
  padding: 0.45rem 1.5rem;
  font-size: 0.84rem;
  color: #854d0e;
}

:root[data-theme="dark"] .support-banner {
  background-color: rgba(234, 179, 8, 0.12);
  border-bottom: 1px solid rgba(234, 179, 8, 0.3);
  color: #fef08a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .support-banner {
    background-color: rgba(234, 179, 8, 0.12);
    border-bottom: 1px solid rgba(234, 179, 8, 0.3);
    color: #fef08a;
  }
}

.support-banner__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.support-banner__info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 260px;
  line-height: 1.35;
}

.support-banner__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ca8a04;
  flex-shrink: 0;
}

:root[data-theme="dark"] .support-banner__icon {
  color: #facc15;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .support-banner__icon {
    color: #facc15;
  }
}

.support-banner__actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.support-banner__btn {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 9999px;
  text-decoration: none;
  color: inherit;
  border: 1px solid currentColor;
  opacity: 0.85;
  transition: all 0.15s ease;
}

.support-banner__btn:hover {
  opacity: 1;
  background-color: rgba(133, 77, 14, 0.1);
}

:root[data-theme="dark"] .support-banner__btn:hover {
  background-color: rgba(254, 240, 138, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .support-banner__btn:hover {
    background-color: rgba(254, 240, 138, 0.15);
  }
}

/* ---------- Toggle Switch Component ---------- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  margin: 0;
}

.toggle-switch__slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  border: 1px solid #94a3b8;
  transition: all 0.25s ease;
  border-radius: 26px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

:root[data-theme="dark"] .toggle-switch__slider {
  background-color: #334155;
  border-color: #64748b;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .toggle-switch__slider {
    background-color: #334155;
    border-color: #64748b;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
  }
}

.toggle-switch__slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

/* Checked state: High-contrast emerald green (#10b981) indicating clearly ON/Active */
.toggle-switch input:checked + .toggle-switch__slider {
  background-color: #10b981;
  border-color: #059669;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.toggle-switch input:checked + .toggle-switch__slider::before {
  transform: translateX(22px);
  background-color: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:focus-visible + .toggle-switch__slider {
  outline: 2px solid #10b981;
  outline-offset: 2px;
}


/* ---------- Listings: filter form (shared/_category_filter) and tables ---------- */
.filter-card { padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.filter-form__search { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.filter-form__search > .input-element { flex: 1; min-width: 250px; }
.filter-form__difficulties { min-width: 220px; }
.filter-form__categories { border-top: 1px solid var(--border-color); margin-top: 1rem; padding-top: 1rem; }
.filter-form__header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.filter-form__criteria { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; max-width: 100%; }
.filter-form__criteria .segmented-control { max-width: 100%; }
.filter-form--compact .filter-form__search > .input-element { padding: 0.45rem 0.65rem; font-size: 0.85rem; }
.filter-form--compact .filter-form__categories { margin-top: 0.75rem; padding-top: 0.75rem; }
.filter-form--compact .filter-form__header { margin-bottom: 0.5rem; }
.filter-form--compact .segmented-control label { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.form-label--tiny { font-size: 0.75rem; }

.table-scroll { overflow-x: auto; }
.table-clean--rows tbody tr { cursor: pointer; }
.table-clean--rows td { vertical-align: middle; padding: 1.25rem 1.5rem; }
.table-clean__title { font-weight: 600; font-size: 0.98rem; margin-bottom: 0.25rem; }
.table-clean__statement { font-weight: 500; font-size: 0.98rem; line-height: 1.55; margin-bottom: 0.65rem; }
.table-clean__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem; font-size: 0.8rem; }
.table-clean__title + .table-clean__meta, .text-small + .table-clean__meta { margin-top: 0.4rem; }
.table-clean .table-clean__chevron { width: 44px; padding-right: 1.5rem; text-align: right; color: var(--text-muted); }
.badge--plain { text-transform: none; letter-spacing: normal; }
.badge--count { font-weight: 700; font-size: 0.85rem; }
.separator-dot { margin: 0 0.15rem; color: var(--border-color); }
.text-center { text-align: center; }
.link-plain { text-decoration: none; }
.badge-list { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.empty-state__lead { font-size: 1rem; margin-bottom: 0.5rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; }
.btn-compact { height: 28px; padding: 0 0.55rem; gap: 0.3rem; font-size: 0.8rem; }
.btn-square { width: 28px; height: 28px; padding: 0; }

/* ---------- Form blocks (titled sections inside a card) ---------- */
.form-block { margin-bottom: 2rem; }
.form-block__title { font-size: 1.15rem; font-weight: 700; margin-bottom: 1.25rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.form-block__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}
.form-block__header .form-block__title { margin: 0 0 0.2rem; padding: 0; border: none; }
.card__title { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.5rem; }
.card__hint { margin-bottom: 1rem; }
.checkbox-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.checkbox-row label { display: flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; cursor: pointer; }
.segmented-control--block { width: 100%; margin-top: 0.25rem; }
.segmented-control--block label { flex: 1; text-align: center; }

.button-row--wrap { flex-wrap: wrap; }
.button-row--spaced { gap: 1rem; }
.checkbox-card__title { display: block; font-weight: 600; font-size: 0.9rem; }
.checkbox-card small { font-size: 0.8rem; }

/* ---------- Small layout helpers ---------- */
.cluster { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { font-size: 0.7rem; }
.button-row--center { justify-content: center; }
.btn-wide { min-width: 140px; }
.page--medium { max-width: 800px; }
.card--limited { max-width: 900px; }
.form-label-row { display: flex; justify-content: space-between; align-items: center; }
.form-label-row a { font-size: 0.8rem; }
.checkbox-card--static { justify-content: space-between; cursor: default; }
.confirm-dialog [data-confirm-message] { margin-bottom: 1.5rem; line-height: 1.5; }

.auth-card--wide { max-width: 480px; }
.auth-card__footer { text-align: center; font-size: 0.9rem; font-weight: 500; }
.status-card h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.status-card .alert { text-align: left; }
.status-card__emoji { font-size: 3rem; margin-bottom: 1rem; }

.list-section { margin-bottom: 2.5rem; }
.list-heading { display: flex; align-items: center; gap: 0.4rem; font-size: 1rem; margin-bottom: 0.8rem; }
.avatar--success { color: var(--success-color); }
.avatar--support { color: var(--primary-color); }
.empty-state > svg { margin-bottom: 1rem; }

.user-trigger__name { font-weight: 500; font-size: 0.9rem; }
.dropdown__header strong, .dropdown__header span { display: block; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
.dropdown__header span { font-size: 0.78rem; }
.dropdown__search { padding: 0.25rem 0.25rem 0.5rem; }
.dropdown__search .input-element { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.workspace-switcher .caret { font-size: 0.75rem; margin-left: 0.4rem; }
.workspace-switcher--static { cursor: default; }
.sidebar-nav__link--split { display: flex; justify-content: space-between; align-items: center; }
.toast-item__body { display: flex; align-items: center; gap: 0.75rem; flex: 1; font-size: 0.9rem; font-weight: 500; line-height: 1.4; }
.toast-item .modal-close { font-size: 1.2rem; }

.category-tree-row__main { display: flex; align-items: center; gap: 0.75rem; flex: 1; }
.category-tree-row--level-1 .category-tree-row__name { font-weight: 600; }

/* Landing page */
.landing { max-width: 1000px; margin: 0 auto; padding: 4rem 1.5rem; text-align: center; }
.landing__hero { margin-bottom: 3rem; }
.landing__badge { display: inline-block; max-width: 100%; white-space: normal; background-color: var(--accent-color-alpha); color: var(--accent-color); padding: 0.4rem 1rem; font-size: 0.85rem; margin-bottom: 1.5rem; }
.landing__title { font-size: clamp(2rem, 5vw + 1rem, 3.25rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1.15; margin-bottom: 1.25rem; }
.landing__lead { font-size: 1.25rem; max-width: 680px; margin: 0 auto 2.5rem; }
.landing__features { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; margin-top: 5rem; text-align: left; }
.feature-card .avatar { width: 44px; height: 44px; margin-bottom: 1rem; }
.feature-card h3 { font-size: 1.2rem; font-weight: bold; margin-bottom: 0.5rem; }
.feature-card p { font-size: 0.95rem; line-height: 1.5; }

/* Spacing overrides for one-off gaps between blocks. Keep them last so they win over component margins. */
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mt-xl { margin-top: 2rem; }
.mb-none { margin-bottom: 0; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mb-xl { margin-bottom: 2rem; }
