:root {
  --sapi-bg: #eef2f6;
  --sapi-panel: #ffffff;
  --sapi-border: #d8e0e8;
  --sapi-text: #17324d;
  --sapi-muted: #6b7280;
  --sapi-user: #1455cc;
  --sapi-user-hover: #17324d;
  --sapi-bot: #eef1f4;
}

.sapi-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  color: var(--sapi-text);
  box-sizing: border-box;
  font-family: "Noto Serif", Georgia, serif;
}

.sapi-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.sapi-topbar__identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sapi-topbar__teacher {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 700;
}

.sapi-topbar__teacher-meta {
  color: var(--sapi-muted);
  font-size: 13px;
  line-height: 1.2;
}

.sapi-topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.sapi-topnav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--sapi-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.sapi-topnav__item {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: var(--sapi-text);
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}

.sapi-topnav__item.is-active {
  background: #dfeaf5;
  font-weight: 700;
}

.sapi-topnav__icon {
  width: 25px;
  height: 25px;
  display: block;
  flex: 0 0 25px;
  margin: 0 !important;
  padding: 0 !important;
  vertical-align: middle;
}

.sapi-topbar__help {
  border: 0;
  border-radius: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
  min-height: auto;
}

.sapi-topbar__help:hover {
  opacity: 0.82;
}

.sapi-topbar__help-icon {
  width: 25px;
  height: 25px;
  display: block;
  margin: 0 !important;
  padding: 0 !important;
  vertical-align: middle;
}

.sapi-mobile-materiales {
  display: none;
  border: 1px solid var(--sapi-border);
  border-radius: 999px;
  padding: 8px 12px;
  background: #dfeaf5;
  color: var(--sapi-text);
  font: inherit;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.sapi-mobile-materiales:hover {
  background: #cedfed;
}

.sapi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sapi-icon svg {
  width: 1em;
  height: 1em;
}


.sapi-layout {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 14px;
  height: min(78vh, 860px);
  min-height: 620px;
  align-items: stretch;
  transition: grid-template-columns 0.24s ease;
}

.sapi-layout.is-threads-open {
  grid-template-columns: 280px minmax(0, 1fr);
}

.sapi-shell[data-sapi-view="saved"] .sapi-leftnav {
  display: none;
}

.sapi-shell[data-sapi-view="saved"] .sapi-layout,
.sapi-shell[data-sapi-view="saved"] .sapi-layout.is-threads-open {
  grid-template-columns: minmax(0, 1fr);
}

.sapi-leftnav {
  position: relative;
  min-height: 0;
}

.sapi-threads-rail,
.sapi-threads-panel {
  position: absolute;
  inset: 0;
}

.sapi-threads-panel {
  background: var(--sapi-panel);
  border: 1px solid var(--sapi-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(14, 30, 37, 0.08);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.sapi-threads-rail {
  background: var(--sapi-panel);
  border: 1px solid var(--sapi-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(14, 30, 37, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 16px 0;
  min-height: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

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

.sapi-threads__header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sapi-threads__new {
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: #dfeaf5;
  color: var(--sapi-text);
  cursor: pointer;
  font: inherit;
  align-self: center;
}

.sapi-threads__new:hover {
  background: #cedfed;
}

.sapi-thread-groups {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sapi-threads-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 2px;
  color: var(--sapi-muted);
  font-size: 14px;
}

.sapi-threads-loading__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a5b8cc;
  animation: sapiThreadsPulse 1.2s ease-in-out infinite;
}

.sapi-threads-loading__dot:nth-child(2) {
  animation-delay: 0.15s;
}

.sapi-threads-loading__dot:nth-child(3) {
  animation-delay: 0.3s;
}

.sapi-threads-loading__text {
  margin-left: 4px;
}

@keyframes sapiThreadsPulse {
  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.45;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.sapi-threads__collapse,
.sapi-threads-rail__btn {
  width: 36px;
  height: 36px;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  background: var(--sapi-user);
  color: #fff;
}

.sapi-threads__collapse .sapi-icon--arrow,
.sapi-threads-rail__btn .sapi-icon--arrow,
.sapi-library-sidebar__toggle .sapi-icon--arrow {
  width: 18px;
  height: 18px;
}

.sapi-threads__collapse {
  border-radius: 12px;
  background: #dfeaf5;
  color: var(--sapi-text);
}

.sapi-threads__collapse:hover {
  background: #cedfed;
}

.sapi-threads-rail__btn--secondary {
  background: #dfeaf5;
  color: var(--sapi-text);
}

.sapi-threads-rail__btn--secondary:hover {
  background: #cedfed;
}

.sapi-threads-rail__divider {
  width: 28px;
  height: 1px;
  background: var(--sapi-border);
}

.sapi-layout:not(.is-threads-open) .sapi-threads-panel {
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
}

.sapi-layout.is-threads-open .sapi-threads-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.sapi-layout.is-threads-open .sapi-threads-rail {
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
}

.sapi-thread-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sapi-thread-group__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sapi-muted);
}

.sapi-thread-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--sapi-border);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfd;
  color: var(--sapi-text);
  cursor: pointer;
  font: inherit;
}

.sapi-thread-item:hover,
.sapi-thread-item.is-active {
  border-color: #bfd1e3;
  background: #f4f8fb;
}

.sapi-thread-item__title {
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sapi-thread-item__meta {
  font-size: 13px;
  color: var(--sapi-muted);
}

.sapi-main {
  min-width: 0;
  min-height: 0;
}

.sapi-workview {
  display: none;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.sapi-workview.is-active {
  display: block;
}

.sapi-workview--saved {
  height: 100%;
}

.sapi-library-workspace {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
}

.sapi-library-workspace.is-sidebar-collapsed {
  grid-template-columns: 74px minmax(0, 1fr);
}

.sapi-library-workspace.is-editor-open {
  grid-template-columns: 260px minmax(0, 1fr);
}

.sapi-library-workspace.is-sidebar-collapsed.is-editor-open {
  grid-template-columns: 74px minmax(0, 1fr);
}

.sapi-library-workspace.is-editor-open .sapi-library-main {
  display: none;
}

.sapi-library-sidebar,
.sapi-library,
.sapi-library-editor {
  min-height: 0;
  padding: 18px;
  background: var(--sapi-panel);
  border: 1px solid var(--sapi-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(14, 30, 37, 0.08);
}

.sapi-library-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  transition: width 0.2s ease, padding 0.2s ease;
}

.sapi-library-sidebar.is-collapsed {
  width: 74px;
  justify-items: center;
  padding-left: 12px;
  padding-right: 12px;
}

.sapi-library-sidebar.is-collapsed .sapi-library__eyebrow,
.sapi-library-sidebar.is-collapsed .sapi-library-sidebar__title,
.sapi-library-sidebar.is-collapsed .sapi-library-stat__label,
.sapi-library-sidebar.is-collapsed .sapi-library-stat__value {
  display: none;
}

.sapi-library-sidebar__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sapi-library-sidebar__title {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.1;
}

.sapi-library-sidebar__toggle {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 12px;
  background: #dfeaf5;
  color: var(--sapi-text);
  cursor: pointer;
  font: inherit;
}

.sapi-library-sidebar.is-collapsed .sapi-library-sidebar__toggle {
  background: var(--sapi-user);
  color: #fff;
}

.sapi-library-sidebar__stats {
  display: grid;
  gap: 12px;
  align-content: start;
}

.sapi-library-stat {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--sapi-border);
  border-radius: 14px;
  background: #fbfcfd;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.sapi-library-sidebar.is-collapsed .sapi-library-stat {
  width: 100%;
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 10px 6px;
}

.sapi-library-stat__icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dfeaf5;
  color: var(--sapi-text);
  font-weight: 700;
}

.sapi-library-stat__icon-image {
  width: 24px;
  height: 24px;
  display: block;
  margin: 0 !important;
  padding: 0 !important;
  vertical-align: middle;
}

.sapi-library-stat:hover {
  border-color: #bfd1e3;
  background: #f4f8fb;
}

.sapi-library-stat.is-active {
  border-color: #bfd1e3;
  background: #eef4fa;
}

.sapi-library-stat.is-active .sapi-library-stat__icon {
  background: #d8e8fb;
  color: var(--sapi-user);
}

.sapi-library-sidebar.is-collapsed .sapi-library-stat__icon {
  background: #d8e8fb;
  color: var(--sapi-user);
}

.sapi-library-stat__label {
  font-size: 13px;
  color: var(--sapi-muted);
}

.sapi-library-stat__value {
  margin-top: 2px;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}

.sapi-library-main {
  min-width: 0;
}

.sapi-library {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
}

.sapi-library-editor {
  height: 100%;
  overflow: auto;
}

.sapi-library-editor .sapi-classview {
  height: 100%;
}

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

.sapi-library__eyebrow {
  color: var(--sapi-muted);
  font-size: 13px;
}

.sapi-library__title {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.1;
}

.sapi-library__count {
  color: var(--sapi-muted);
  font-size: 13px;
  white-space: nowrap;
}

.sapi-library__search input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--sapi-border);
  border-radius: 12px;
  font: inherit;
  color: var(--sapi-text);
  background: #fff;
}

.sapi-library__table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 72px;
  gap: 12px;
  padding: 0 16px 6px;
  color: var(--sapi-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sapi-library__list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sapi-library-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 72px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--sapi-border);
  border-radius: 14px;
  background: #fbfcfd;
  color: var(--sapi-text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.sapi-library-row:hover {
  border-color: #bfd1e3;
  background: #f4f8fb;
}

.sapi-library-row__main {
  min-width: 0;
}

.sapi-library-row__title {
  font-weight: 700;
  min-width: 0;
  font-size: 15px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sapi-library-row__mode,
.sapi-library-row__date {
  color: var(--sapi-muted);
  font-size: 13px;
}

.sapi-library-row__mode {
  margin-top: 4px;
}

.sapi-library-row__action {
  justify-self: end;
  color: var(--sapi-user);
  font-weight: 700;
  font-size: 13px;
}

.sapi-library-row.is-active {
  border-color: #bfd1e3;
  background: #eef4fa;
}

.sapi-library-editor__empty {
  color: var(--sapi-muted);
  font-size: 15px;
  padding: 10px 4px;
}

.is-hidden {
  display: none !important;
}

.sapi-saved-item__main {
  min-width: 0;
}

.sapi-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: 18px;
}

.sapi-stage__pane {
  position: absolute;
  inset: 0;
  min-height: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.sapi-stage__pane--chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  transform: translateX(0);
  opacity: 1;
}

.sapi-stage__pane--class {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.sapi-stage.is-class-open .sapi-stage__pane--chat {
  transform: translateX(-10%);
  opacity: 0;
  pointer-events: none;
}

.sapi-stage.is-class-open .sapi-stage__pane--class {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.sapi-sidepanel__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.sapi-sidepanel__teacher {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 600;
}

.sapi-sidepanel__eyebrow {
  color: var(--sapi-muted);
  font-size: 14px;
}

.sapi-sidepanel__meta {
  color: var(--sapi-muted);
  font-size: 14px;
}

.sapi-saved-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.sapi-saved-item {
  display: block;
  border: 1px solid var(--sapi-border);
  border-radius: 12px;
  padding: 12px;
  text-decoration: none;
  color: var(--sapi-text);
  background: #fbfcfd;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font: inherit;
}

.sapi-saved-item:hover {
  border-color: #bfd1e3;
  background: #f4f8fb;
}

.sapi-saved-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 15px;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sapi-saved-date {
  font-size: 13px;
  color: var(--sapi-muted);
}

.sapi-chat__messages {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: var(--sapi-panel);
  border: 1px solid var(--sapi-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(14, 30, 37, 0.08);
}

.sapi-classview {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 22px;
  background: var(--sapi-panel);
  border: 1px solid var(--sapi-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(14, 30, 37, 0.08);
}

.sapi-classview__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sapi-classview__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sapi-classview__back,
.sapi-classview__action {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: #dfeaf5;
  color: var(--sapi-text);
  cursor: pointer;
  font: inherit;
}

.sapi-classview__back:hover,
.sapi-classview__action:hover {
  background: #cedfed;
}

.sapi-classview__action--danger {
  background: #fee2e2;
  color: #8b1e1e;
}

.sapi-classview__action--danger:hover {
  background: #fecaca;
}

.sapi-classview__action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sapi-classview__meta,
.sapi-classview__question {
  color: var(--sapi-muted);
  font-size: 14px;
}

.sapi-classview__title {
  width: 100%;
  margin: 10px 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sapi-text);
  font: inherit;
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
}

.sapi-classview__title:focus {
  outline: none;
}

.sapi-classview__content {
  min-height: 340px;
  margin-top: 18px;
  color: var(--sapi-text);
  font: inherit;
  font-size: 17px;
  line-height: 1.8;
  white-space: normal;
}

.sapi-classview__content p,
.sapi-classview__content div {
  margin: 0 0 12px;
}

.sapi-classview__content strong {
  font-weight: 700;
}

.sapi-classview__body {
  width: 100%;
  min-height: 340px;
  margin-top: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sapi-text);
  font: inherit;
  font-size: 17px;
  line-height: 1.8;
  resize: vertical;
}

.sapi-classview__body:focus {
  outline: none;
}

.sapi-classview__body[readonly],
.sapi-classview__title[readonly] {
  cursor: default;
}

.sapi-classview.is-editing .sapi-classview__title,
.sapi-classview.is-editing .sapi-classview__body {
  background: #fff;
  border: 1px solid var(--sapi-border);
  border-radius: 14px;
  padding: 14px 16px;
}

.sapi-classview__sources {
  margin-top: 20px;
}

.sapi-chat__empty {
  color: var(--sapi-muted);
}

.sapi-chat__message {
  margin-bottom: 15px;
}

.sapi-artifact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--sapi-border);
  border-radius: 16px;
  background: #fbfcfd;
}

.sapi-artifact-card__copy {
  min-width: 0;
}

.sapi-artifact-card__subtitle {
  font-size: 13px;
  color: var(--sapi-muted);
}

.sapi-artifact-card__title {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 700;
}

.sapi-artifact-card__open {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  background: #dfeaf5;
  color: var(--sapi-text);
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}

.sapi-artifact-card__open:hover {
  background: #cedfed;
}

.sapi-chat__bubble {
  display: inline-block;
  width: fit-content;
  max-width: min(100%, 680px);
  padding: 8px 10px;
  border-radius: 12px;
  line-height: 1.55;
  white-space: normal;
  vertical-align: top;
}

.sapi-chat__bubble > div {
  margin: 0;
}

.sapi-chat__message--user {
  text-align: right;
}

.sapi-chat__message--user .sapi-chat__bubble {
  background: var(--sapi-user);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

.sapi-chat__message--assistant .sapi-chat__bubble,
.sapi-chat__message--info .sapi-chat__bubble,
.sapi-chat__message--system .sapi-chat__bubble {
  background: var(--sapi-bot);
  color: var(--sapi-text);
  border-radius: 14px 14px 14px 4px;
}

.sapi-chat__message--system .sapi-chat__bubble {
  background: #fee2e2;
}

.sapi-chat__bubble--thinking {
  min-width: 300px;
}

.sapi-chat__thinking {
  display: grid;
  gap: 10px;
}

.sapi-chat__thinking-label {
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #6b7280;
}

.sapi-chat__thinking-status {
  font-weight: 700;
  color: var(--sapi-text);
}

.sapi-chat__thinking-lines {
  display: grid;
  gap: 8px;
}

.sapi-chat__thinking-lines span {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(203, 213, 225, 0.55) 0%, rgba(226, 232, 240, 0.95) 50%, rgba(203, 213, 225, 0.55) 100%);
  background-size: 200% 100%;
  animation: sapiShimmer 1.4s linear infinite;
}

.sapi-chat__thinking-lines span:nth-child(1) {
  width: 92%;
}

.sapi-chat__thinking-lines span:nth-child(2) {
  width: 84%;
}

.sapi-chat__thinking-lines span:nth-child(3) {
  width: 68%;
}

@keyframes sapiShimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.sapi-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--sapi-border);
  border-radius: 16px;
  background: var(--sapi-panel);
  box-shadow: 0 10px 24px rgba(14, 30, 37, 0.08);
}

.sapi-chat__form textarea {
  flex: 1;
  min-height: 56px;
  max-height: 180px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--sapi-border);
  border-radius: 12px;
  font: inherit;
  line-height: 1.6;
  background: #fff;
}

.sapi-chat__form button {
  border: 0;
  border-radius: 12px;
  padding: 10px 20px;
  background: var(--sapi-user);
  color: #fff;
  cursor: pointer;
  min-height: 48px;
}

.sapi-chat__form button:hover {
  background: var(--sapi-user-hover);
}

.sapi-message-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #cfd8e3;
  flex-wrap: wrap;
}

.sapi-message-action {
  border: 1px solid #c4d5e6;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  background: #dfeaf5;
  color: var(--sapi-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sapi-message-action:hover {
  background: #cedfed;
}

.sapi-message-action--secondary {
  background: #eef2f6;
  color: var(--sapi-text);
  border-color: #d0d9e3;
}

.sapi-message-action--secondary:hover {
  background: #dfe7ef;
}

.sapi-message-action .sapi-icon--button {
  width: 16px;
  height: 16px;
}

.sapi-fuentes {
  margin-top: 15px;
  margin-bottom: 50px;
  padding-bottom: 15px;
  font-size: 13px;
  color: #666;
}

.sapi-fuentes-linea {
  border-top: 1px solid #ccc;
  margin: 12px 0;
}

.sapi-fuentes-titulo,
.sapi-fuente-categoria {
  font-weight: 700;
}

.sapi-fuente-categoria {
  margin-top: 10px;
}

.sapi-fuente-item {
  margin-left: 10px;
}

.sapi-fuente-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sapi-fuente-link:hover {
  opacity: 0.85;
}

.sapi-footer-note {
  margin-top: 8px;
  color: var(--sapi-muted);
  font-size: 12px;
}

@media (max-width: 720px) {
  body.sapi-page footer {
    display: none !important;
  }

  .sapi-footer-note {
    display: none;
  }

  .sapi-shell {
    padding: 0;
    border-radius: 0;
  }

  .sapi-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .sapi-topbar__identity {
    width: 100%;
  }

  .sapi-topbar__actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "drawer help"
      "nav nav";
    align-items: center;
    row-gap: 10px;
    column-gap: 8px;
    margin-left: 0;
  }

  .sapi-mobile-materiales {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    white-space: nowrap;
    grid-area: drawer;
    justify-self: start;
  }

  .sapi-topnav {
    width: 100%;
    grid-area: nav;
    max-width: 100%;
    overflow: visible;
    justify-self: start;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .sapi-topnav__item {
    justify-content: center;
    width: 100%;
  }

  .sapi-topbar__help {
    grid-area: help;
    justify-self: end;
  }

  .sapi-library-workspace {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .sapi-library-workspace.is-editor-open,
  .sapi-library-workspace.is-sidebar-collapsed,
  .sapi-library-workspace.is-sidebar-collapsed.is-editor-open {
    grid-template-columns: 1fr;
  }

  .sapi-library-sidebar,
  .sapi-library,
  .sapi-library-editor {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .sapi-library-editor {
    width: 100%;
    min-width: 0;
  }

  .sapi-library-sidebar {
    width: auto;
  }

  .sapi-library-sidebar.is-collapsed {
    width: auto;
    padding-left: 18px;
    padding-right: 18px;
  }

  .sapi-library-sidebar.is-collapsed .sapi-library__eyebrow,
  .sapi-library-sidebar.is-collapsed .sapi-library-sidebar__title,
  .sapi-library-sidebar.is-collapsed .sapi-library-stat__label,
  .sapi-library-sidebar.is-collapsed .sapi-library-stat__value {
    display: initial;
  }

  .sapi-shell.is-mobile-drawer-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(20, 34, 53, 0.24);
    z-index: 110;
  }

  .sapi-shell[data-sapi-view="chat"] .sapi-threads-panel {
    position: fixed;
    top: 72px;
    left: 0;
    bottom: 0;
    width: min(86vw, 360px);
    border-radius: 0 16px 16px 0;
    border-left: 0;
    box-shadow: 0 18px 40px rgba(14, 30, 37, 0.2);
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
    z-index: 120;
    background: var(--sapi-panel);
  }

  .sapi-shell.is-mobile-drawer-open[data-sapi-view="chat"] .sapi-threads-panel {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .sapi-shell[data-sapi-view="saved"] .sapi-library-sidebar {
    position: fixed;
    top: 72px;
    left: 0;
    bottom: 0;
    width: min(86vw, 360px);
    border-radius: 0 16px 16px 0;
    border-left: 0;
    box-shadow: 0 18px 40px rgba(14, 30, 37, 0.2);
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
    z-index: 120;
    background: var(--sapi-panel);
    overflow: auto;
  }

  .sapi-shell.is-mobile-drawer-open[data-sapi-view="saved"] .sapi-library-sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .sapi-library__table-head {
    display: none;
  }

  .sapi-library-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .sapi-library-row__action {
    justify-self: start;
  }

  .sapi-topbar {
    padding: 16px 16px 0;
    margin-bottom: 0;
  }

  .sapi-topbar__title {
    font-size: 24px;
  }

  .sapi-layout {
    grid-template-columns: 1fr;
    gap: 0;
    height: auto;
    min-height: 0;
  }

  .sapi-main,
  .sapi-workview,
  .sapi-workview.is-active,
  .sapi-stage {
    height: auto;
    min-height: calc(100vh - 170px);
  }

  .sapi-stage {
    overflow: visible;
  }

  .sapi-stage__pane {
    position: static;
    inset: auto;
    transition: none;
  }

  .sapi-stage__pane--chat {
    min-height: calc(100dvh - 170px);
    height: calc(100dvh - 170px);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  .sapi-stage__pane--class {
    display: none;
    transform: none;
    opacity: 1;
  }

  .sapi-stage.is-class-open .sapi-stage__pane--chat {
    display: none;
    transform: none;
    opacity: 1;
    pointer-events: none;
  }

  .sapi-stage.is-class-open .sapi-stage__pane--class {
    display: block;
    pointer-events: auto;
  }

  .sapi-leftnav,
  .sapi-threads-rail {
    position: static;
    inset: auto;
  }

  .sapi-threads-rail {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .sapi-threads-rail {
    display: none;
  }

  .sapi-stage {
    border-radius: 0;
  }

  .sapi-chat__messages {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    box-shadow: none;
    min-height: 0;
    height: 100%;
    max-height: none;
    padding-bottom: 176px;
  }

  .sapi-classview {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .sapi-library-editor .sapi-classview {
    padding: 18px 16px 140px;
  }

  .sapi-chat__form {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    box-shadow: 0 -10px 24px rgba(14, 30, 37, 0.08);
    margin-top: 0;
    width: 100%;
  }

  .sapi-chat__form textarea {
    min-height: 96px;
  }

  .sapi-classview__toolbar {
    align-items: stretch;
    gap: 10px;
  }

  .sapi-classview__back {
    width: fit-content;
    max-width: 100%;
  }

  .sapi-classview__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }

  .sapi-classview__action {
    width: 100%;
    justify-content: center;
  }
}
