:root {
  --bg-main: #f4f3ef;
  --bg-panel: rgba(255, 255, 255, 0.9);
  --bg-panel-strong: #ffffff;
  --ink-main: #1d2730;
  --ink-muted: #56636d;
  --line: rgba(26, 56, 63, 0.16);
  --accent: #1a7f76;
  --accent-strong: #13665f;
  --accent-soft: rgba(26, 127, 118, 0.12);
  --warn: #9a5b17;
  --good: #1f7d41;
  --shadow: 0 14px 34px rgba(18, 41, 45, 0.12);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans", "Segoe UI", sans-serif;
  color: var(--ink-main);
  background:
    radial-gradient(circle at 12% 8%, #ebdcc7 0%, transparent 40%),
    radial-gradient(circle at 85% 0%, #cedfdc 0%, transparent 36%),
    radial-gradient(circle at 80% 88%, #d8e0ea 0%, transparent 38%),
    var(--bg-main);
  line-height: 1.45;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(50px);
  z-index: -1;
  opacity: 0.35;
}

.bg-orb-a {
  width: 340px;
  height: 340px;
  background: #e4bf95;
  top: -120px;
  right: -90px;
}

.bg-orb-b {
  width: 290px;
  height: 290px;
  background: #7cb8ae;
  left: -120px;
  bottom: -80px;
}

.page {
  width: min(1400px, 96vw);
  margin: 1.2rem auto 2rem;
}

.page.page-width-reduced {
  width: min(1400px, 96vw);
}

.page.page-width-full {
  width: calc(100vw - 1rem);
  max-width: none;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.2rem 1.3rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(255, 254, 249, 0.84));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Noto Serif", "Times New Roman", serif;
  letter-spacing: 0.01em;
}

h1 {
  margin-top: 0.35rem;
  font-size: clamp(1.35rem, 2.8vw, 2.05rem);
}

.hero-copy {
  margin: 0.45rem 0 0;
  color: var(--ink-muted);
  max-width: 64ch;
}

.hero-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 290px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  align-self: stretch;
}

.sidebar-inner {
  position: sticky;
  top: 0.75rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  z-index: 12;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.sidebar-summary {
  margin: 0.45rem 0 0.8rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.section-nav {
  display: grid;
  gap: 0.35rem;
}

.section-link {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-main);
  text-align: left;
  font: inherit;
  padding: 0.42rem 0.56rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: 0.2s ease;
}

.section-link:hover {
  background: var(--accent-soft);
}

.section-link.active {
  background: rgba(26, 127, 118, 0.16);
  border-color: rgba(26, 127, 118, 0.36);
  font-weight: 700;
}

.section-link:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.section-count {
  float: right;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.main {
  min-width: 0;
}

.controls,
.stats,
.view,
.quiz-card,
.quiz-header,
.quiz-queue-wrap {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.controls {
  padding: 0.9rem;
}

.search-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input[type="search"],
input[type="password"],
input[type="text"],
textarea,
select {
  width: 100%;
  border: 1px solid rgba(21, 72, 78, 0.24);
  border-radius: 10px;
  padding: 0.58rem 0.68rem;
  font: inherit;
  color: var(--ink-main);
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(26, 127, 118, 0.34);
  outline-offset: 1px;
}

.control-row {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: center;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--ink-main);
}

.switch input {
  accent-color: var(--accent);
}

.control-actions {
  margin-top: 0.75rem;
}

.stats {
  margin-top: 0.8rem;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stat-pill {
  padding: 0.33rem 0.58rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.87rem;
}

.view {
  margin-top: 0.8rem;
  padding: 0.9rem;
}

.hidden {
  display: none !important;
}

.section-block + .section-block {
  margin-top: 1rem;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem;
  padding-bottom: 0.4rem;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
}

.section-title small {
  color: var(--ink-muted);
  font-size: 0.87rem;
}

.question-card {
  background: var(--bg-panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.85rem;
}

.question-card + .question-card {
  margin-top: 0.72rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.card-label {
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.badge {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.16rem 0.5rem;
  font-size: 0.79rem;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: #fff;
}

.badge.good {
  border-color: rgba(31, 125, 65, 0.42);
  background: rgba(31, 125, 65, 0.1);
  color: #1f6a39;
}

.badge.hard {
  border-color: rgba(154, 91, 23, 0.35);
  background: rgba(154, 91, 23, 0.11);
  color: #8a4f14;
}

.question-body,
.answer-body,
.quiz-question,
.quiz-answer,
.ai-response {
  font-size: 0.95rem;
}

.question-body p,
.answer-body p,
.quiz-question p,
.quiz-answer p {
  margin: 0 0 0.42rem;
}

.question-body ul,
.answer-body ul,
.question-body ol,
.answer-body ol,
.quiz-question ul,
.quiz-answer ul,
.quiz-question ol,
.quiz-answer ol {
  margin: 0.3rem 0 0.55rem 1.1rem;
  padding: 0;
}

.question-body img,
.answer-body img,
.quiz-question img,
.quiz-answer img {
  display: block;
  max-width: min(560px, 100%);
  width: auto;
  height: auto;
  margin: 0.35rem 0;
  cursor: zoom-in;
  border: none;
  outline: none;
  background: transparent;
  box-shadow: none;
}

.math,
.math * {
  font-style: normal !important;
  font-family: "STIX Two Text", "Noto Serif", serif !important;
}

.math-tex.inline {
  display: inline-block;
}

.math-tex.display {
  display: block;
  overflow-x: auto;
  padding: 0.15rem 0;
}

.math.display {
  display: block;
  overflow-x: auto;
  padding: 0.35rem 0.45rem;
  border-radius: 7px;
  background: rgba(26, 127, 118, 0.06);
  margin: 0.35rem 0;
}

.card-actions {
  margin-top: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.answer-wrap {
  margin-top: 0.62rem;
  border-top: 1px solid var(--line);
  padding-top: 0.62rem;
}

.answer-wrap.hidden-answer .answer-body {
  filter: blur(7px);
  user-select: none;
  pointer-events: none;
}

.answer-wrap.hidden-answer .answer-hint {
  display: block;
}

.answer-hint {
  display: none;
  color: var(--ink-muted);
  font-size: 0.87rem;
  margin-bottom: 0.35rem;
}

.rating-controls {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.rating-help {
  position: relative;
}

.rating-help summary {
  list-style: none;
  cursor: pointer;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--ink-muted);
  background: #fff;
}

.rating-help summary::-webkit-details-marker {
  display: none;
}

.rating-help-card {
  position: absolute;
  z-index: 12;
  width: min(320px, 72vw);
  top: 1.75rem;
  left: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 0.55rem;
  font-size: 0.86rem;
}

.rating-btn {
  padding: 0.3rem 0.55rem;
}

.rating-btn.active {
  outline: 2px solid rgba(26, 127, 118, 0.3);
}

.ai-panel {
  margin-top: 0.7rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.58rem;
}

.ai-panel summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 600;
  margin-bottom: 0.45rem;
}

.ai-row {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.45rem;
  flex-wrap: wrap;
}

.ai-row textarea {
  min-height: 76px;
  resize: vertical;
}

.ai-warning,
.ai-response {
  margin-top: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.55rem;
  white-space: pre-wrap;
}

.ai-warning {
  border-color: rgba(154, 91, 23, 0.3);
  background: rgba(154, 91, 23, 0.08);
}

.ai-thread {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ai-msg {
  border-radius: 12px;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: #fff;
  max-width: min(80%, 680px);
  align-self: flex-start;
}

.ai-msg.user {
  background: rgba(26, 127, 118, 0.11);
  border-color: rgba(26, 127, 118, 0.35);
  align-self: flex-end;
}

.ai-msg.assistant {
  background: #fff;
  align-self: flex-start;
}

.ai-msg p,
.ai-msg h1,
.ai-msg h2,
.ai-msg h3 {
  margin: 0;
}

.ai-msg p + p,
.ai-msg p + ul,
.ai-msg p + ol,
.ai-msg ul + p,
.ai-msg ol + p,
.ai-msg h1 + p,
.ai-msg h2 + p,
.ai-msg h3 + p {
  margin-top: 0.45rem;
}

.ai-msg ul,
.ai-msg ol {
  margin: 0.3rem 0 0.4rem 1.1rem;
  padding: 0;
}

.ai-msg pre {
  margin: 0.4rem 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 57, 63, 0.05);
  padding: 0.45rem 0.55rem;
  overflow-x: auto;
}

.ai-msg pre code {
  background: transparent;
  padding: 0;
}

.ai-msg code {
  padding: 0.08rem 0.24rem;
}

.ai-msg a {
  color: #0f5c55;
  text-decoration: underline;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  color: var(--ink-muted);
}

.quiz-header {
  padding: 0.75rem 0.9rem;
}

.quiz-header p {
  margin: 0.35rem 0 0;
  color: var(--ink-muted);
}

.quiz-layout {
  margin-top: 0.72rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0.8rem;
  align-items: start;
}

.quiz-layout.no-queue {
  grid-template-columns: minmax(0, 1fr);
}

.quiz-layout.queue-collapsed {
  grid-template-columns: minmax(0, 1fr) 140px;
}

.quiz-main-col {
  min-width: 0;
}

.quiz-queue-wrap {
  padding: 0.65rem 0.8rem;
  min-width: 0;
  position: relative;
}

.quiz-queue-wrap.collapsed {
  padding: 0.65rem 0.6rem;
}

.quiz-queue-wrap.collapsed .queue-head {
  justify-content: center;
}

.quiz-queue-wrap.collapsed .queue-head strong {
  display: none;
}

.queue-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.queue-toggle-btn {
  width: 1.95rem;
  height: 1.95rem;
  flex: 0 0 1.95rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-main);
  border-radius: 9px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.queue-toggle-btn:hover {
  background: #f6faf9;
  border-color: rgba(26, 127, 118, 0.42);
}

.queue-toggle-btn svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.queue-toggle-btn.collapsed svg {
  transform: rotate(-90deg);
}

.queue-event {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.quiz-queue-frame {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}

.quiz-queue {
  display: grid;
  gap: 0.35rem;
  --queue-row-height: 28px;
  --queue-row-step: 34px;
  max-height: 70vh;
  overflow: auto;
  padding-bottom: 0.1rem;
}

.queue-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3.3rem;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.82) 52%,
    rgba(255, 255, 255, 1) 100%
  );
}

.queue-row {
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: #fff;
  color: var(--ink-main);
  font-size: 0.83rem;
  line-height: 1.3;
  padding: 0.3rem 0.55rem;
  box-shadow: 0 2px 6px rgba(20, 42, 46, 0.08);
  transition: transform 0.25s ease, background-color 0.25s ease;
}

.queue-row.queue-gap {
  --queue-gap-extra: 10px;
  border-style: dashed;
  border-color: rgba(26, 127, 118, 0.35);
  background: rgba(26, 127, 118, 0.08);
  box-shadow: none;
  display: block;
  min-height: 0;
  height: calc(var(--queue-row-height, 28px) + var(--queue-gap-extra));
  padding: 0;
  animation: queueGapSettle 0.26s ease 1.12s forwards;
}

.queue-row.current {
  background: rgba(26, 127, 118, 0.17);
  border-color: rgba(26, 127, 118, 0.45);
  color: #0f5c55;
  font-weight: 700;
}

.queue-row.shift-seq {
  animation: queueShiftSequence 0.38s ease 0.34s both;
}

.queue-row.shift-next {
  animation: queueShiftSequence 0.42s ease 0.25s both;
}

.queue-more {
  margin-top: 0.28rem;
  text-align: right;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.queue-ghost-out {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  min-height: 2rem;
  border-radius: 10px;
  border: 1px solid rgba(26, 127, 118, 0.42);
  background: rgba(26, 127, 118, 0.16);
  color: #0f5c55;
  font-size: 0.83rem;
  line-height: 1.3;
  padding: 0.3rem 0.55rem;
  display: flex;
  align-items: center;
  z-index: 140;
  pointer-events: none;
  animation: queueOutRight 0.32s ease forwards;
}

.queue-ghost-in {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  min-height: 2rem;
  border-radius: 10px;
  border: 1px solid rgba(26, 127, 118, 0.42);
  background: rgba(26, 127, 118, 0.16);
  color: #0f5c55;
  font-size: 0.83rem;
  line-height: 1.3;
  padding: 0.3rem 0.55rem;
  display: flex;
  align-items: center;
  z-index: 150;
  pointer-events: none;
  opacity: 0;
  animation: queueInDownLeft 0.82s cubic-bezier(0.2, 0.82, 0.2, 1) 0.7s forwards;
}

@keyframes queueOutRight {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(118%);
    opacity: 0;
  }
}

@keyframes queueShiftSequence {
  0% {
    transform: translateY(var(--queue-row-step, 34px));
    opacity: 0.98;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes queueInDownLeft {
  0% {
    transform: translateX(118%) translateY(0);
    opacity: 0;
  }
  22% {
    opacity: 1;
  }
  68% {
    transform: translateX(118%) translateY(var(--target-y, 0px));
    opacity: 1;
  }
  100% {
    transform: translateX(0) translateY(var(--target-y, 0px));
    opacity: 1;
  }
}

@keyframes queueGapSettle {
  0% {
    height: calc(var(--queue-row-height, 28px) + var(--queue-gap-extra));
  }
  100% {
    height: var(--queue-row-height, 28px);
  }
}

.quiz-card {
  margin-top: 0.75rem;
  padding: 0.95rem;
}

.quiz-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.quiz-section-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #244c51;
  margin: 0.1rem 0 0.45rem;
}

.quiz-answer {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.quiz-actions {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quiz-rating-area {
  margin-top: 0.7rem;
}

.quiz-summary {
  display: grid;
  gap: 0.68rem;
}

.quiz-summary h3 {
  margin: 0;
}

.quiz-summary-note {
  margin: 0;
  color: var(--ink-muted);
}

.quiz-summary-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.quiz-summary-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.42rem 0.52rem;
}

.quiz-summary-stat span {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.quiz-summary-stat strong {
  display: block;
  margin-top: 0.12rem;
  font-size: 1.08rem;
}

.quiz-summary-meta {
  margin: 0;
  font-size: 0.9rem;
  color: #26464b;
}

.btn {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0.46rem 0.72rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s ease;
}

.btn:hover {
  background: var(--accent-strong);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-main);
}

.btn-secondary:hover {
  background: #f6faf9;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-main);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: rgba(8, 57, 63, 0.06);
}

.btn-small {
  font-size: 0.86rem;
  padding: 0.34rem 0.56rem;
}

.btn-again {
  background: #b34b2d;
}

.btn-again:hover {
  background: #983f24;
}

.btn-hard {
  background: var(--warn);
}

.btn-hard:hover {
  background: #7f4912;
}

.btn-good {
  background: var(--good);
}

.btn-good:hover {
  background: #165f32;
}

.btn-easy {
  background: #1e9268;
}

.btn-easy:hover {
  background: #187454;
}

.btn-danger {
  background: #b34b2d;
}

.btn-danger:hover {
  background: #983f24;
}

.settings-dialog {
  border: none;
  padding: 0;
  width: min(700px, 94vw);
  border-radius: var(--radius-lg);
}

.settings-dialog::backdrop {
  background: rgba(8, 21, 24, 0.45);
  backdrop-filter: blur(2px);
}

.settings-panel {
  margin: 0;
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.settings-panel header {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
}

.icon-close-btn {
  width: 2rem;
  height: 2rem;
  flex: 0 0 2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-main);
  display: inline-grid;
  place-items: center;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.icon-close-btn:hover {
  background: #f6faf9;
}

.icon-close-btn svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.field-label-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  color: #2e5d62;
}

.field-label-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-note {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.settings-panel hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.25rem 0;
}

.manual-sections {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.55rem;
  background: rgba(26, 127, 118, 0.05);
}

.manual-sections-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.manual-sections-note {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.manual-sections-actions {
  display: flex;
  gap: 0.35rem;
}

.manual-sections-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.manual-sections-list {
  margin-top: 0.42rem;
  max-height: 190px;
  overflow: auto;
  display: grid;
  gap: 0.35rem;
}

.manual-section-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.9rem;
  padding: 0.2rem 0.15rem;
  border-radius: 8px;
  transition: background-color 0.16s ease;
}

.manual-section-item:hover {
  background: rgba(26, 127, 118, 0.1);
}

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

.settings-footer {
  display: flex;
  justify-content: flex-end;
}

code {
  background: rgba(14, 74, 66, 0.08);
  border-radius: 4px;
  padding: 0.07rem 0.24rem;
}

.image-dialog {
  border: none;
  background: transparent;
  padding: 0;
  width: min(98vw, 1800px);
  max-width: 98vw;
}

.image-dialog::backdrop {
  background: rgba(6, 10, 12, 0.86);
}

#imageDialogImg {
  display: block;
  width: auto;
  max-width: 96vw;
  max-height: 92vh;
  margin: 0 auto;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.image-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border-radius: 999px;
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.3rem;
  cursor: pointer;
}

mjx-container,
mjx-container * {
  font-style: normal !important;
  font-family: "STIX Two Text", "Noto Serif", serif !important;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar-inner {
    position: sticky;
    top: 0.5rem;
    max-height: min(52vh, 460px);
  }

  .quiz-layout,
  .quiz-layout.queue-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .page,
  .page.page-width-reduced,
  .page.page-width-full {
    width: 95vw;
  }

  .hero {
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-msg {
    max-width: 90%;
  }
}
