:root {
  --bg: #f1eee6;
  --surface: #fbfaf5;
  --text: #192236;
  --muted: #687084;
  --line: #cad0d6;
  --primary: #3d5fa8;
  --primary-soft: #e2e7f0;
  --green: #617c8c;
  --green-soft: #e2e9ec;
  --amber: #d1a23f;
  --red: #c1545f;
  --red-soft: #fdf0f1;
  --shadow: 0 8px 22px rgba(23, 32, 51, 0.055);
  --radius: 10px;
  --sidebar-width: 245px;
  --sidebar-collapsed-width: 82px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: Lato, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.brand-mark svg, .nav-item svg, .sp-progress-glyph, .sp-branch-glyph { stroke-linecap: square; stroke-linejoin: bevel; stroke-width: 1.65; }
.empty-state-icon :is(.sp-progress-glyph, .sp-branch-glyph) { width: 24px; height: 24px; }
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 28px 20px;
  overflow-x: hidden;
  border-right: 1px solid #e6e0d6;
  background: rgba(245, 243, 237, 0.98);
  transition:
    width 220ms ease,
    padding 220ms ease;
}
.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  width: 8px;
  cursor: ew-resize;
  touch-action: none;
}
.sidebar-resize-handle::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2px;
  background: var(--primary);
  content: "";
  opacity: 0;
  transition: opacity 140ms ease;
}
.sidebar-resize-handle:hover::after,
.sidebar-resize-handle:focus-visible::after,
body.sidebar-resizing .sidebar-resize-handle::after {
  opacity: 0.45;
}
.sidebar-resize-handle:focus-visible {
  outline: 0;
}
body.sidebar-resizing,
body.sidebar-resizing * {
  cursor: ew-resize !important;
  user-select: none !important;
}
body.sidebar-resizing .sidebar,
body.sidebar-resizing .main-content {
  transition: none !important;
}
.brand {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: Unbounded, Verdana, sans-serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.6px;
  text-align: left;
  text-decoration: none;
}
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid #1d2b4f; border-radius: 2px 9px 9px 9px; background: #1d2b4f; color: #e4b655; box-shadow: none; }
.brand-mark svg { width: 23px; height: 23px; }
.sidebar-direction-icon { stroke-width: 1.7; }
.sidebar-direction-collapsed { display: none; }
body.sidebar-collapsed .sidebar-direction-expanded { display: none; }
body.sidebar-collapsed .sidebar-direction-collapsed { display: inline; }
.side-nav { display: grid; gap: 7px; margin-top: 42px; }
.nav-item { display: flex; align-items: center; gap: 13px; padding: 11px 13px; border-radius: 7px; color: #687287; font-size: 14px; font-weight: 600; text-decoration: none; transition: 160ms ease; }
.nav-item:hover { background: #eee3d3; color: var(--primary); transform: translateX(2px); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}
.settings-category.sidebar-contact {
  width: 100%;
  min-height: 53px;
  padding: 14px 16px;
  margin-top: auto;
  flex: 0 0 auto;
  font-size: 16px;
}
.sidebar-tip { display: flex; gap: 10px; margin-top: auto; padding: 16px; border: 1px solid #d8ebe7; border-radius: 16px; background: linear-gradient(145deg, #f7fbfa, #f1f7f3); }
.tip-icon { color: var(--primary); font-size: 18px; }
.sidebar-tip strong { font-size: 13px; }
.sidebar-tip p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.main-content {
  width: calc(100% - var(--sidebar-width));
  max-width: 1480px;
  margin-left: var(--sidebar-width);
  padding: 38px 48px 64px;
  transition:
    width 220ms ease,
    margin-left 220ms ease;
}
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 12px; font-weight: 650; letter-spacing: 0; text-transform: none; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(290px, 0.75fr); gap: 22px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.composer-panel { padding: 30px; }
.panel-heading { display: flex; gap: 14px; margin-bottom: 27px; }
.heading-icon { display: grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center; border-radius: 13px; }
.heading-icon.purple { background: var(--primary-soft); color: var(--primary); }
.heading-icon.green { background: var(--green-soft); color: var(--green); }
.heading-icon svg { width: 23px; height: 23px; }
.panel h2 { margin: 0; font-family: Unbounded, Verdana, sans-serif; font-size: 19px; font-weight: 500; letter-spacing: -0.55px; }
.panel-description { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
@media (min-width: 761px) {
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    padding: 26px 14px;
  }

  body.sidebar-collapsed .brand {
    justify-content: center;
    padding: 0;
  }

  body.sidebar-collapsed .brand > span:last-child {
    display: none;
  }

  body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 13px;
    font-size: 0;
  }

  body.sidebar-collapsed .nav-item:hover {
    transform: none;
  }

  body.sidebar-collapsed .nav-item svg {
    width: 21px;
    height: 21px;
  }

  body.sidebar-collapsed .sidebar-contact {
    justify-content: center;
    padding: 13px;
  }

  body.sidebar-collapsed .sidebar-contact span {
    display: none;
  }

  body.sidebar-collapsed .sidebar-tip,
  body.sidebar-collapsed .sidebar-chat-history {
    display: none;
  }

  body.sidebar-collapsed .main-content {
    width: calc(100% - var(--sidebar-collapsed-width));
    margin-left: var(--sidebar-collapsed-width);
  }
}
.form-group { display: grid; gap: 9px; margin-top: 20px; }
.form-group label { color: #3d4158; font-size: 12px; font-weight: 700; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.field-hint { color: #a0a3b3; font-size: 10px; }
input, textarea, select { width: 100%; border: 1px solid #ddd6c8; outline: 0; background: #fffefc; color: var(--text); transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
input { height: 48px; padding: 0 15px; border-radius: 12px; }
select { height: 48px; padding: 0 40px 0 15px; border-radius: 12px; cursor: pointer; }
textarea { min-height: 220px; padding: 15px; border-radius: 14px; line-height: 1.6; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a7a9b8; }
input:hover, textarea:hover, select:hover { border-color: #c7c0b4; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); background: #ffffff; box-shadow: 0 0 0 3px rgba(61, 95, 168, 0.14); }
.primary-button { display: flex; width: 100%; min-height: 50px; align-items: center; justify-content: center; gap: 10px; margin-top: 22px; padding: 12px 18px; border: 1px solid #1d2b4f; border-radius: 3px 8px 8px 8px; background: #1d2b4f; color: white; box-shadow: 4px 4px 0 #d1a23f; cursor: pointer; font-size: 13px; font-weight: 700; transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease; }
.primary-button:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 #d1a23f; filter: none; }
.primary-button:active { transform: translateY(0); }
.primary-button:disabled { cursor: wait; opacity: 0.7; transform: none; }
.primary-button svg { width: 18px; height: 18px; }
.button-arrow { margin-left: auto; }

.library-panel { overflow: hidden; }
.library-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 25px 24px 19px; border-bottom: 1px solid var(--line); }
.live-badge { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 20px; background: var(--green-soft); color: #267e61; font-size: 9px; font-weight: 750; text-transform: uppercase; }
.live-badge span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.study-sets-list { display: grid; gap: 10px; max-height: 560px; padding: 14px; overflow-y: auto; }
.study-set-card { position: relative; padding: 15px 42px 15px 15px; border: 1px solid transparent; border-radius: 13px; background: #fbfbf8; cursor: pointer; transition: 160ms ease; }
.study-set-card::after { content: "›"; position: absolute; top: 50%; right: 16px; color: #b0b2c0; font-size: 22px; transform: translateY(-52%); transition: 160ms ease; }
.study-set-card:hover { border-color: #d8e8e4; background: #f4f9f7; transform: translateY(-1px); }
.study-set-card:hover::after { right: 13px; color: var(--primary); }
.study-set-card h3 { margin: 0 0 7px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.study-set-card p { margin: 0; color: var(--muted); font-size: 10px; }
.empty-state { padding: 38px 20px; color: var(--muted); text-align: center; }
.empty-state-icon { display: grid; width: 44px; height: 44px; margin: 0 auto 12px; place-items: center; border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-size: 18px; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--text); font-size: 13px; }
.empty-state p { margin: 0; font-size: 11px; line-height: 1.5; }
.skeleton-card { display: grid; gap: 10px; padding: 17px 15px; border-radius: 13px; background: #fbfbf8; }
.skeleton-card span { height: 9px; border-radius: 8px; background: linear-gradient(90deg, #ece8e0 25%, #f7f3eb 50%, #ece8e0 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-card span:last-child { width: 48%; height: 7px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.quiz-output { margin-top: 22px; }
.quiz-output:empty { display: none; }
.quiz-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.quiz-header h2 { margin: 0; font-size: 22px; }
.quiz-count { padding: 7px 10px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 750; }
.question-list { display: grid; gap: 14px; }
.question-card { padding: 24px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 8px 28px rgba(32, 35, 68, 0.045); }
.question-number { margin: 0 0 8px; color: var(--primary); font-size: 10px; font-weight: 760; letter-spacing: 1px; text-transform: uppercase; }
.question-text { margin: 0 0 18px; font-size: 15px; font-weight: 650; line-height: 1.55; }
.choices { display: grid; gap: 9px; }
.choice-option { display: flex; align-items: center; gap: 11px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fdfcf8; cursor: pointer; font-size: 12px; line-height: 1.4; transition: 150ms ease; }
.choice-option:hover { border-color: #cadfdc; background: #f5faf9; }
.choice-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: #2e4c86; box-shadow: 0 0 0 2px rgba(61, 95, 168, 0.09); }
.choice-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.submit-button { width: auto; min-width: 170px; margin: 18px 0 0 auto; }
.loading-state { display: flex; align-items: center; gap: 12px; padding: 20px; border: 1px solid #d9ebe7; border-radius: 15px; background: var(--primary-soft); color: #10625b; font-size: 13px; font-weight: 650; }
.spinner { width: 19px; height: 19px; border: 2px solid rgba(61, 95, 168, 0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-message { padding: 13px 15px; border: 1px solid #ffd7da; border-radius: 12px; background: var(--red-soft); color: #b53f4a; font-size: 12px; }
.score-card { padding: 25px; border: 1px solid #d8f0e7; border-radius: 17px; background: linear-gradient(145deg, #f4fcf8, #ebf9f3); text-align: center; }
.score-card p { margin: 0 0 6px; color: var(--green); font-size: 10px; font-weight: 760; letter-spacing: 1px; text-transform: uppercase; }
.score-card h2 { margin: 0; font-size: 28px; }
.result-list { display: grid; gap: 12px; margin-top: 14px; }
.result-card { padding: 20px; border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 14px; background: var(--surface); }
.result-card.correct { border-left-color: var(--green); }
.result-card h4 { margin: 0 0 12px; font-size: 13px; }
.result-card p { margin: 6px 0; color: #5e6278; font-size: 11px; line-height: 1.5; }
.result-status { display: inline-flex; margin-top: 7px; padding: 5px 8px; border-radius: 8px; background: var(--red-soft); color: var(--red); font-weight: 750; }
.correct .result-status { background: var(--green-soft); color: var(--green); }

@media (min-width: 761px) and (max-width: 980px) {
  .main-content {
    padding: 32px 28px 56px;
  }
}

@media (max-width: 760px) {
  .sidebar-resize-handle {
    display: none;
  }
  .sidebar {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 1200;
  width: min(82vw, 285px);
  height: 100dvh;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 24px 18px;
  border-right: 0;
  border-left: 1px solid #e6e0d6;
  border-bottom: 0;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: -24px 0 70px rgba(20, 22, 40, 0.18);
  transform: translateX(105%);
  transition: transform 220ms ease;
  overflow-y: auto;
}
  .sidebar.is-mobile-open {
  transform: translateX(0);
}

.brand {
  justify-content: flex-start;
  padding-right: 46px;
}

.brand > span:last-child {
  display: inline;
}

.side-nav {
  display: grid;
  gap: 7px;
  margin-top: 34px;
}

.nav-item {
  justify-content: flex-start;
  gap: 13px;
  padding: 12px 14px;
  font-size: 14px;
}

.nav-item svg {
  width: 19px;
  height: 19px;
}
  .main-content { width: 100%; margin: 0; padding: 25px 18px 48px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .library-panel { order: -1; }
  .study-sets-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 230px; }
.sidebar .brand {
  padding-right: 52px;
}
}

@media (max-width: 520px) {
  .composer-panel { padding: 22px 18px; }
  .study-sets-list { grid-template-columns: 1fr; }
  .field-hint { display: none; }
  .question-card { padding: 19px 16px; }
  .submit-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

.mobile-sidebar-toggle {
  display: none;
}

.mobile-sidebar-backdrop {
  display: none;
}

