[hidden] {
  display: none !important;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

.sidebar {
  width: 260px;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  padding: 1.5rem 1.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100vh;
  overflow: hidden;
}

.brand {
  font-weight: 600;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: "Montserrat", sans-serif;
}

.brand .highlight {
  color: var(--accent);
}

.logo-mark {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-scroll {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  overflow: visible;
  padding-right: 0.4rem;
  flex: 1;
  min-height: 0;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

.sidebar-section:last-child {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-family: "Montserrat", sans-serif;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  padding-right: 0.4rem;
  flex: 1;
  min-height: 0;
}

.stack-list::-webkit-scrollbar {
  width: 4px;
}

.stack-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

.stack-empty {
  padding: 1rem 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.stack-item {
  padding: 0.5rem 0.35rem;
  border-radius: 8px;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  cursor: pointer;
  transition: color 160ms ease;
  font-family: "Montserrat", sans-serif;
}

.stack-item span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.stack-item small {
  color: var(--muted);
  font-size: 0.75rem;
}

.stack-item.active {
  color: var(--accent);
}

.chat-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  width: 32px;
  height: 32px;
}

.stack-item:hover .chat-menu-btn {
  opacity: 1;
  pointer-events: auto;
}

.chat-menu-btn:hover {
  background: var(--border);
  color: var(--text);
}

.chat-action-menu {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  box-shadow: var(--shadow);
  z-index: 10000;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chat-action-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: background 0.15s ease;
  text-align: left;
  width: 100%;
  font-family: "Montserrat", sans-serif;
}

.chat-action-item:hover {
  background: var(--border);
}

.chat-action-item i {
  width: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.share-dialog {
  background: var(--panel);
  border-radius: 16px;
  padding: 0;
  max-width: 500px;
  width: 90vw;
  box-shadow: var(--shadow);
}

.share-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.share-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.share-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.15s ease;
  font-size: 1.1rem;
}

.share-close-btn:hover {
  background: var(--border);
  color: var(--text);
}

.share-body {
  padding: 1.5rem;
}

.share-body p {
  margin: 0 0 1rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.share-input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.share-url-input {
  flex: 1;
  padding: 0.85rem 3.5rem 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: "Montserrat", monospace;
  width: 100%;
}

.share-copy-btn {
  position: absolute;
  right: 0.5rem;
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s ease;
  font-size: 0.9rem;
}

.share-copy-btn:hover {
  opacity: 0.85;
}

.user-chip {
  position: absolute;
  bottom: 1.4rem;
  left: 1.2rem;
  right: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--chip-bg);
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
}

.user-chip .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.user-chip .label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  gap: 0.15rem;
}

.user-chip .label span {
  font-size: 0.9rem;
  color: var(--text);
  font-family: "Montserrat", sans-serif;
}

.user-chip .label small {
  color: var(--muted);
  margin-left: 0;
  font-family: "Montserrat", sans-serif;
  text-align: left;
}

.workspace {
  flex: 1;
  padding: 1.5rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  padding-bottom: 1rem;
  background: var(--bg);
  z-index: 2;
}

.workspace-header h1 {
  font-size: 1.4rem;
  font-family: "Montserrat", sans-serif;
}

.workspace-header small {
  color: var(--muted);
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

.workspace-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.passcode-overlay {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(22, 22, 22, 0.95);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  transform: translate(20px, 45px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  z-index: 5;
}

.passcode-overlay.active {
  opacity: 1;
  visibility: visible;
  transform: translate(0, 45px);
  pointer-events: auto;
}

.passcode-overlay span {
  font-family: "Montserrat", sans-serif;
  letter-spacing: 0.35em;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  transition: color 140ms ease;
}

.passcode-overlay span:hover {
  color: var(--accent);
}

.passcode-fullscreen {
  position: fixed;
  top: 8rem;
  left: 50%;
  transform: translate(-50%, -16px);
  background: rgba(12, 12, 12, 0.95);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.25rem 2.5rem 1.5rem;
  min-width: min(520px, 90vw);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 20;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 220ms ease, transform 220ms ease;
}

.passcode-fullscreen.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.passcode-fullscreen span {
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  letter-spacing: 0.4em;
  font-weight: 600;
}

.passcode-fullscreen button {
  position: absolute;
  top: 8px;
  right: 8px;
}

.copy-notification {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -120%);
  background: var(--accent);
  color: #ffffff;
  padding: 0.85rem 1.5rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  z-index: 30;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: "Montserrat", sans-serif;
}

.copy-notification.show {
  opacity: 1;
  transform: translate(-50%, 20px);
  pointer-events: auto;
}

.memory-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #0f0f0f;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 32;
  pointer-events: none;
  font-family: "Montserrat", sans-serif;
}

.memory-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.copy-notification button {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.copy-notification button:hover {
  opacity: 0.8;
}

.chat-title {
  cursor: text;
  transition: border-bottom 140ms ease;
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
}

.chat-title[contenteditable="true"] {
  border-bottom-color: transparent;
  outline: none;
}

.main-canvas {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow: hidden;
}

.starter-panel {
  flex: 1;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  font-size: 1.1rem;
  color: var(--muted);
  padding: 2rem;
  font-family: "Montserrat", sans-serif;
}

.passcode-launcher {
  border: none;
  box-shadow: none;
  background: transparent;
  min-height: 0;
  height: 100%;
  padding: 0 1rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 22vh;
  gap: 1rem;
}

.passcode-inputs {
  display: grid;
  grid-template-columns: repeat(8, clamp(50px, 5.5vw, 92px));
  gap: clamp(0.85rem, 1.2vw, 1.4rem);
  justify-content: center;
  align-items: center;
  width: min(720px, 100%);
}

.passcode-inputs input {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 22px;
  color: var(--text);
  font-weight: 600;
  text-align: center;
  font-size: clamp(2rem, 3.2vw, 2.6rem);
  font-family: "Montserrat", sans-serif;
  letter-spacing: 0.05em;
  padding: 0.35rem;
  height: clamp(72px, 11vh, 112px);
  width: clamp(50px, 5.8vw, 84px);
  transition: border-color 160ms ease, transform 160ms ease;
}

.passcode-inputs input:focus {
  outline: none;
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.passcode-inputs input::-webkit-autofill,
.passcode-inputs input::-webkit-autofill:hover,
.passcode-inputs input::-webkit-autofill:focus,
.passcode-inputs input::-webkit-autofill:active {
  -webkit-autofill: none !important;
  -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
}

.starter-panel button {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
}

#student-launcher {
  flex: 0;
  width: min(640px, 100%);
  min-height: auto;
  padding: 0;
  text-align: center;
  align-self: center;
  justify-content: flex-start;
  box-shadow: none;
}

#student-launcher > div {
  width: 100%;
}

#teacher-course-builder {
  flex: 0;
  align-items: flex-start;
  text-align: left;
  width: min(560px, 100%);
  padding: 2rem 2.5rem;
}

.course-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.course-form label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  opacity: 0;
  transform: translateY(14px);
  animation: fieldFade 280ms ease forwards;
}

.course-form label:nth-child(1) {
  animation-delay: 40ms;
}

.course-form label:nth-child(2) {
  animation-delay: 120ms;
}

.course-form label:nth-child(3) {
  animation-delay: 200ms;
}

.course-form span {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: "Montserrat", sans-serif;
}

.course-form input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: "Montserrat", sans-serif;
  transition: border-color 180ms ease, background 180ms ease;
}

.course-form input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.course-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--input-bg);
}

.course-form input::-webkit-autofill,
.course-form input::-webkit-autofill:hover,
.course-form input::-webkit-autofill:focus,
.course-form input::-webkit-autofill:active {
  -webkit-autofill: none !important;
  -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
}

.course-form .pill-btn {
  align-self: flex-start;
  border-radius: 999px;
  padding: 0.85rem 1.8rem;
  background: var(--accent);
  border: none;
  color: #0f0f0f;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
  animation: fieldFade 280ms ease forwards;
  animation-delay: 280ms;
  font-family: "Montserrat", sans-serif;
}

.course-form .pill-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.chat-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.empty-chat-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-chat-state i {
  font-size: 4rem;
  opacity: 0.5;
}

.empty-chat-state h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  font-family: "Montserrat", sans-serif;
}

.empty-chat-state p {
  font-size: 1rem;
  margin: 0;
  opacity: 0.7;
  font-family: "Montserrat", sans-serif;
}

.chat-feed:not(:empty) ~ .empty-chat-state,
.chat-shell:has(.chat-feed:not(:empty)) .empty-chat-state {
  display: none;
}

.attachment-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 0 0;
  min-height: 0;
}

.attachment {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment-image {
  max-width: 140px;
  max-height: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.attachment-pdf {
  width: 140px;
  height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 1rem;
  text-align: center;
}

.attachment-pdf i {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.attachment-pdf-name {
  font-size: 0.75rem;
  word-break: break-word;
  max-width: 100%;
}

.attachment-remove {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: rgba(0, 0, 0, 0.8);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  cursor: pointer;
  transition: background 140ms ease;
  font-size: 0.8rem;
}

.attachment-remove:hover {
  background: rgba(0, 0, 0, 1);
}

.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-feed::-webkit-scrollbar {
  width: 6px;
}

.chat-feed::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.chat-row {
  display: flex;
  flex-direction: column;
  max-width: min(55%, 520px);
  position: relative;
  width: 100%;
}

@media (max-width: 960px) {
  .chat-row {
    max-width: 100%;
  }
}

.chat-row.student {
  align-self: flex-end;
  text-align: right;
  padding-right: 0.75rem;
}

.chat-row.assistant {
  align-self: flex-start;
  text-align: left;
}

.chat-row .meta {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chat-row.student .meta {
  justify-content: flex-end;
}

.chat-row.assistant .meta {
  justify-content: flex-start;
}

.chat-row p {
  margin: 0;
  padding: 0.6rem 0;
  line-height: 1.3;
  color: var(--text);
  font-family: "Montserrat", sans-serif;
}

.chat-row.student.len-short p {
  font-size: 1.5rem;
}

.chat-row.student.len-medium p {
  font-size: 1.2rem;
}

.chat-row.student.len-long p {
  font-size: 0.95rem;
}

.chat-row p h1,
.chat-row p h2,
.chat-row p h3 {
  margin: 0.75rem 0 0.5rem 0;
  font-weight: 600;
  color: var(--text);
}

.chat-row p h1 {
  font-size: 1.4rem;
}

.chat-row p h2 {
  font-size: 1.2rem;
}

.chat-row p h3 {
  font-size: 1.05rem;
}

.chat-row p strong {
  font-weight: 600;
  color: var(--text);
}

.chat-row p em {
  font-style: italic;
}

.chat-row p code {
  background: var(--surface-muted);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 0.9em;
  border: 1px solid var(--border);
}

.chat-row p pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.chat-row p pre code {
  background: none;
  padding: 0;
}

.chat-row p ul,
.chat-row p ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.chat-row p li {
  margin: 0.25rem 0;
  line-height: 1.5;
}

.chat-row p hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.chat-row-attachments {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.75rem;
  width: 100%;
}

.followup-list {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.followup-item {
  color: var(--text);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: color 160ms ease, transform 160ms ease;
  width: 100%;
  justify-content: flex-start;
  background: none;
  border: none;
  padding: 0;
  font-family: "Montserrat", sans-serif;
}

.followup-item svg {
  width: 18px;
  height: 18px;
  stroke: var(--accent);
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.followup-item:hover {
  color: var(--accent);
  transform: translateX(2px);
}

.reasoning-thought {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: left;
}

.chat-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.22),
    rgba(255, 255, 255, 0.08)
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}

body.theme-light .skeleton-line {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.08),
    rgba(0, 0, 0, 0.22),
    rgba(0, 0, 0, 0.08)
  );
}

.skeleton-line.w-90 {
  width: 90%;
}

.skeleton-line.w-85 {
  width: 85%;
}

.skeleton-line.w-80 {
  width: 80%;
}

.skeleton-line.w-75 {
  width: 75%;
}

.skeleton-line.w-70 {
  width: 70%;
}

.skeleton-line.w-65 {
  width: 65%;
}

.skeleton-line.w-60 {
  width: 60%;
}

.delay-0 {
  animation-delay: 0s;
}

.delay-1 {
  animation-delay: 0.15s;
}

.delay-2 {
  animation-delay: 0.3s;
}

.insight-vote-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.2rem 0.85rem;
  margin-right: 0.5rem;
  background: var(--surface-muted);
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
  transition: background 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.insight-vote-pill.active {
  background: var(--chip-bg);
  border-color: var(--accent);
}

.insight-inline {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.insight-inline.open {
  display: flex;
}

.insight-inline-card {
  border-radius: 16px;
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.insight-inline-question {
  margin: 0;
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
}

.insight-inline-question.len-short {
  font-size: 1.1rem;
}

.insight-inline-question.len-medium {
  font-size: 1rem;
}

.insight-inline-question.len-long {
  font-size: 0.9rem;
}

.insight-inline-answer {
  display: flex;
  flex-direction: column;
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  position: relative;
  max-height: 1.5em;
  overflow: hidden;
  transition: max-height 0.3s ease, mask-image 0.3s ease;
}

.insight-inline-answer::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 60px;
  background: linear-gradient(to right, transparent, var(--panel));
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.insight-inline-answer.expanded {
  max-height: none;
}

.insight-inline-answer.expanded::after {
  opacity: 0;
}

.insight-inline-answer span {
  display: block;
  white-space: nowrap;
  transition: white-space 0.3s ease;
}

.insight-inline-answer.expanded span {
  white-space: normal;
}

.insight-view-btn {
  align-self: flex-start;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.chat-attachment {
  border-radius: 12px;
  overflow: hidden;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-attachment-image {
  max-width: 140px;
  max-height: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.chat-attachment-pdf {
  width: 120px;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 1rem;
  text-align: center;
}

.chat-attachment-pdf i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.chat-attachment-pdf-name {
  font-size: 0.75rem;
  word-break: break-word;
  max-width: 100%;
}

.chat-row.student p {
  font-size: clamp(1rem, calc(2.5rem - 0.08vw * var(--char-count, 0)), 2.2rem);
  font-weight: 500;
}

.chat-row.loading {
  align-self: flex-start;
}

.chat-row.loading .meta {
  color: rgba(255, 255, 255, 0.5);
}

.chat-feedback {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.chat-feedback button {
  position: relative;
  overflow: hidden;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 140ms ease, transform 140ms ease;
  font-size: 0.9rem;
  z-index: 1;
}

.chat-feedback button.active {
  color: var(--accent);
  transform: scale(1.05);
}

.chat-feedback .version-controls {
  margin-top: 0;
  margin-left: 0.6rem;
  padding-left: 0.6rem;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.composer {
  position: relative;
  margin-top: 0.5rem;
  display: flex;
  align-items: flex-end;
  gap: 0;
}

.composer textarea {
  flex: 1;
  min-height: 140px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem 3.5rem 1rem 3.5rem;
  resize: none;
  color: var(--text);
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.composer textarea::-webkit-autofill,
.composer textarea::-webkit-autofill:hover,
.composer textarea::-webkit-autofill:focus,
.composer textarea::-webkit-autofill:active {
  -webkit-autofill: none !important;
  -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.1);
}

body.theme-light .composer textarea:focus {
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.12);
}

.composer-icon-btn {
  position: absolute;
  border: none;
  background: transparent;
  color: var(--text);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 140ms ease;
  flex-shrink: 0;
}

.composer-icon-btn#student-add-btn,
.composer-icon-btn#educator-add-btn {
  left: 0.9rem;
  bottom: 0.9rem;
}


.composer-send-btn {
  position: absolute;
  right: 0.9rem;
  bottom: 0.9rem;
  border: none;
  background: var(--accent);
  color: #ffffff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.composer-send-btn i {
  color: currentColor;
}

.composer-hint {
  position: absolute;
  right: 4.5rem;
  bottom: 1.9rem;
  font-size: 0.72rem;
  color: var(--muted);
  pointer-events: none;
  user-select: none;
  opacity: 0.7;
}

.composer-disclaimer {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: rgba(237, 237, 237, 0.55);
  text-align: right;
  letter-spacing: 0.01em;
  font-family: "Montserrat", sans-serif;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 3, 3, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.alert-dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

.modal.active .alert-dialog {
  transform: scale(1);
  opacity: 1;
}

.alert-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert-header h2 {
  font-size: 1.3rem;
  color: var(--text);
  margin: 0;
  font-family: "Montserrat", sans-serif;
}

.alert-header p {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
  font-family: "Montserrat", sans-serif;
}

.alert-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.alert-button {
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: "Montserrat", sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.alert-button:hover {
  border-color: var(--accent);
}

.alert-button.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.alert-button.primary:hover {
  opacity: 0.9;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dropzone {
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 2.5rem;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropzone:hover,
.dropzone.active {
  border-color: var(--accent);
  background: var(--surface-muted);
}

.dropzone i {
  font-size: 2rem;
  color: var(--accent);
}

.materials-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.material-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text);
  font-family: "Montserrat", sans-serif;
}

.material-status {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.material-status.loading {
  border-color: var(--accent);
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

.material-status.done {
  border-color: var(--accent);
  color: var(--accent);
}

.material-status.error {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.material-row button {
  margin-left: auto;
}

/* Settings modal */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 10, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.settings-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.settings-dialog {
  display: flex;
  width: min(960px, 95vw);
  height: 620px;
  max-height: 85vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.settings-nav {
  width: 220px;
  background: var(--panel-alt);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-close {
  align-self: flex-start;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
  font-family: "Montserrat", sans-serif;
}

.settings-tab.active {
  background: var(--chip-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.settings-panels {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  max-height: 80vh;
}

.settings-panel {
  display: none;
  opacity: 0;
  transform: translateY(-8px);
}

.settings-panel.active {
  display: block;
  animation: panelFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes panelFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-panel-header h2 {
  font-size: 1.6rem;
  font-family: "Montserrat", sans-serif;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 1.2rem 0;
}

.settings-divider.subtle {
  opacity: 0.4;
  margin: 0.8rem 0;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: transparent;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 600;
}

.profile-meta strong {
  font-size: 1.1rem;
  color: var(--text);
  display: block;
  font-family: "Montserrat", sans-serif;
}

.profile-meta small {
  color: var(--muted);
  font-size: 0.9rem;
  font-family: "Montserrat", sans-serif;
}

.reauth-btn {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.settings-field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.settings-field-row:last-child {
  border-bottom: none;
}

.settings-field-row.align-start {
  align-items: flex-start;
}

.field-label {
  font-weight: 600;
  margin: 0;
  font-family: "Montserrat", sans-serif;
}

.field-hint {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-family: "Montserrat", sans-serif;
}

.theme-toggle {
  position: relative;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.3rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  --theme-index: 1;
}

.theme-toggle button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  font-family: "Montserrat", sans-serif;
  transition: color 180ms ease;
  width: 36px;
  height: 36px;
  position: relative;
}

.theme-toggle button span {
  display: none;
}

.theme-toggle button i {
  font-size: 1.1rem;
}

.theme-toggle button.active {
  color: #ffffff;
}

.theme-toggle-indicator {
  position: absolute;
  top: 0.3rem;
  left: 0.3rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: translateX(calc((var(--theme-index, 1) * 36px) + (var(--theme-index, 1) * 0.25rem)));
}

.shortcuts-section {
  margin-top: 1.5rem;
}

.settings-subheader h3 {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: "Montserrat", sans-serif;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  padding: 0.85rem 1.2rem;
  font-size: 0.95rem;
  color: var(--text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 140ms ease;
  font-family: "Montserrat", sans-serif;
  cursor: pointer;
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.shortcut-key {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color: var(--muted);
}

.settings-group {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: transparent;
}

.settings-group h3 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-family: "Montserrat", sans-serif;
}

.input-label {
  display: block;
  margin-bottom: 0.5rem;
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
  font-family: "Montserrat", sans-serif;
}

.settings-group .input-label:first-of-type {
  margin-top: 0;
}

.settings-group input,
.settings-group textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  resize: none;
  min-height: 48px;
  transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-group input:focus,
.settings-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.1);
}

body.theme-light .settings-group input:focus,
body.theme-light .settings-group textarea:focus {
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.12);
}

.settings-dropdown {
  position: relative;
  min-width: 180px;
}

.dropdown-toggle {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  padding: 0.65rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 190px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  z-index: 3;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  transition: opacity 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              visibility 0s linear 200ms;
  pointer-events: none;
  visibility: hidden;
}

.settings-dropdown[data-open="true"] .dropdown-menu,
.memory-sort-menu[data-open="true"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
  transition: opacity 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dropdown-menu button {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
}

.dropdown-menu button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.settings-memory-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-memory-header h3 {
  margin: 0;
}

.memory-meter {
  font-size: 0.85rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: "Montserrat", sans-serif;
}

.memory-manage-btn {
  margin-left: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
  transition: background 140ms ease;
}

.memory-manage-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.settings-toggle {
  position: relative;
  width: 56px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  cursor: pointer;
  transition: background 160ms ease;
}

.settings-toggle[aria-checked="true"] {
  background: var(--accent);
  border-color: transparent;
}

.settings-toggle .toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.5);
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
              background 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
              border-color 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.theme-light .settings-toggle .toggle-thumb {
  border-color: rgba(0, 0, 0, 0.35);
}

.settings-toggle[aria-checked="true"] .toggle-thumb {
  transform: translateX(26px);
  background: #ffffff;
  border-color: transparent;
}

.memory-overlay {
  z-index: 45;
}

.memory-dialog {
  width: min(520px, 90vw);
  height: 600px;
  max-height: 80vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.memory-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.memory-dismiss {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.memory-header h3 {
  margin: 0;
  font-size: 1.2rem;
  flex: 1;
  font-family: "Montserrat", sans-serif;
}

.memory-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.memory-sort {
  position: relative;
}

.memory-sort button,
.memory-clear {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.memory-sort-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.4rem;
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 3;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  transition: opacity 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              visibility 0s linear 200ms;
  pointer-events: none;
  visibility: hidden;
}

.memory-sort-menu button {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
  word-spacing: 0.3em;
  transition: background 0.15s ease;
}

.memory-sort-menu button:first-child {
  margin-bottom: 0.2rem;
  padding-bottom: 0.65rem;
  position: relative;
}

.memory-sort-menu button:first-child::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -0.4rem;
  right: -0.4rem;
  height: 1px;
  background: var(--border);
}

.memory-sort-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Chats sort menu specific styling */
#chats-sort-menu button:first-child::after {
  display: none;
}

#chats-sort-menu button:nth-child(2) {
  margin-bottom: 0.2rem;
  padding-bottom: 0.65rem;
  position: relative;
}

#chats-sort-menu button:nth-child(2)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -0.4rem;
  right: -0.4rem;
  height: 1px;
  background: var(--border);
}

/* Search Input Styling */
.search-wrapper {
  position: relative;
  margin: 1.25rem 1.5rem;
  animation: fadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
  transition: color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: "Montserrat", sans-serif;
  outline: none;
  transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.1);
}

body.theme-light .search-input:focus {
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.12);
}

.search-wrapper:focus-within .search-icon {
  color: var(--accent);
}

.memory-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 50vh;
  overflow-y: auto;
  animation: fadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.memory-list[hidden] {
  display: none;
}

.memory-card {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  font-family: "Montserrat", sans-serif;
}

.memory-card:last-child {
  border-bottom: none;
}

.memory-card time {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.memory-card p {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
}

.memory-context {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.memory-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 16px;
  font-family: "Montserrat", sans-serif;
  animation: fadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.memory-empty[hidden] {
  display: none;
}

.memory-confirm {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  background: var(--surface-muted);
}

.memory-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.memory-confirm-actions button {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
}

.memory-confirm-actions button:last-child {
  background: #ff6b6b;
  border-color: #ff6b6b;
  color: #0f0f0f;
}

body.theme-light .settings-overlay {
  background: rgba(15, 15, 23, 0.35);
}

body.theme-light .settings-field-row {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.theme-light .shortcut-row {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.theme-light .shortcut-row:hover {
  background: rgba(0, 0, 0, 0.04);
}

body.theme-light .settings-toggle {
  border-color: #d6d2eb;
}

body.theme-light .shortcut-row:last-child,
body.theme-light .settings-field-row:last-child {
  border-bottom: none;
}

body.theme-light .composer-disclaimer {
  color: rgba(27, 27, 31, 0.55);
}

/* System mode with light preference */
@media (prefers-color-scheme: light) {
  body.theme-system .shortcut-key {
    color: #5c5b70;
  }

  body.theme-system .settings-toggle .toggle-thumb {
    border-color: rgba(0, 0, 0, 0.35);
  }
}

body.theme-light .passcode-overlay {
  background: rgba(255, 255, 255, 0.95);
}

body.theme-light .passcode-fullscreen {
  background: rgba(255, 255, 255, 0.95);
}

body.theme-light .chat-row .meta {
  color: #4a4a5c;
}

body.theme-light .chat-row.loading .meta {
  color: #4a4a5c;
}

body.theme-light .memory-list::-webkit-scrollbar-thumb,
body.theme-light .chats-list::-webkit-scrollbar-thumb,
body.theme-light .stack-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

@media (max-width: 960px) {
  .settings-dialog {
    flex-direction: column;
  }

  .settings-nav {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .settings-tabs {
    flex-direction: row;
    flex: 1;
  }

  .settings-tab {
    flex: 1;
    text-align: center;
  }

  .settings-field-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

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

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

.modal.active .modal-content {
  transform: scale(1);
  opacity: 1;
}

.modal-content .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.5;
  font-family: "Montserrat", sans-serif;
}

.message-edit-controls {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.message-edit-controls.visible {
  opacity: 1;
  transform: translateY(0);
}

.chat-row p[contenteditable="true"] {
  outline: none;
  border: none;
  box-shadow: none;
}

.message-edit-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 1.1rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-edit-btn:hover {
  color: var(--accent);
}

.message-edit-btn.confirm {
  color: #4ade80;
}

.message-edit-btn.confirm:hover {
  color: #22c55e;
}

.message-edit-btn.cancel {
  color: #f87171;
}

.message-edit-btn.cancel:hover {
  color: #ef4444;
}

.version-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0;
  margin-left: 0.5rem;
}

.version-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 140ms ease, opacity 140ms ease;
  font-size: 0.85rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.version-btn:hover:not(:disabled) {
  color: var(--accent);
}

.version-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.version-label {
  font-size: 0.8rem;
  color: var(--muted);
  user-select: none;
}

/* Mobile Styles */
.mobile-menu-btn,
.mobile-menu-close,
.mobile-header-left {
  display: none;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 960px) {
  /* Show mobile header elements */
  .mobile-menu-btn {
    display: inline-flex;
  }

  .mobile-header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
  }

  .mobile-logo {
    width: 26px;
    height: 26px;
  }

  .mobile-brand {
    font-weight: 600;
    font-size: 1.2rem;
    font-family: "Montserrat", sans-serif;
  }

  /* Hide desktop title on mobile */
  .workspace-header .title-group {
    display: none;
  }

  /* Mobile sidebar overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    max-height: 100vh;
    border-right: 1px solid var(--border);
    border-bottom: none;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Show close button on mobile */
  .mobile-menu-close {
    display: inline-flex;
  }

  /* Simplified user chip on mobile - only show avatar */
  .user-chip .label {
    display: none;
  }

  /* Mobile backdrop */
  .mobile-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity 280ms ease;
  }

  .mobile-menu-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Workspace adjustments */
  .workspace {
    padding: 1rem;
    width: 100%;
  }

  .workspace-header {
    padding-bottom: 0.75rem;
  }

  /* Left-align follow-up questions on mobile */
  .followup-item {
    justify-content: flex-start;
    text-align: left;
  }

  /* Adjust chat rows for mobile */
  .chat-row {
    max-width: 100%;
  }
}
.course-wizard-panel {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0 1.5rem;
  padding-top: 12vh;
}

.course-wizard {
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wizard-track {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wizard-input {
  display: flex;
  align-items: center;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.wizard-input.is-transitioning {
  animation: wizardSwap 260ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes wizardSwap {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.wizard-input input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-family: "Montserrat", sans-serif;
  transition: color 200ms ease;
}

.wizard-input input:focus {
  outline: none;
}

.wizard-input input.wizard-error {
  animation: inputShake 0.28s ease;
}

.wizard-input button {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.wizard-input button svg {
  width: 22px;
  height: 22px;
  stroke: #0f0f0f;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wizard-input button.wizard-finish {
  width: auto;
  padding: 0 1.6rem;
  border-radius: 26px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.wizard-finish-label {
  color: #0f0f0f;
  font-family: "Montserrat", sans-serif;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.wizard-input button:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow);
}

@keyframes inputShake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(4px);
  }
  75% {
    transform: translateX(-2px);
  }
  100% {
    transform: translateX(0);
  }
}

/* Chats Manager Styles */
.chats-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.chats-tab {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              border-bottom-color 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: "Montserrat", sans-serif;
}

.chats-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.chats-tab:hover:not(.active) {
  color: var(--text);
}

.archived-disclaimer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 183, 77, 0.1);
  border: 1px solid rgba(255, 183, 77, 0.3);
  border-radius: 12px;
  color: #ffb74d;
  font-size: 0.85rem;
  font-family: "Montserrat", sans-serif;
  animation: fadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.archived-disclaimer i {
  font-size: 1rem;
  flex-shrink: 0;
}

.archived-disclaimer[hidden] {
  display: none;
}

.chats-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
  animation: fadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chats-list[hidden] {
  display: none;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chats-list::-webkit-scrollbar {
  width: 4px;
}

.chats-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

.chats-empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-family: "Montserrat", sans-serif;
  animation: fadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chats-empty[hidden] {
  display: none;
}

.chat-manager-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s ease;
}

.chat-manager-row:hover {
  background: var(--hover);
}

.chat-manager-title {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Montserrat", sans-serif;
}

.chat-manager-menu {
  position: relative;
}

.chat-manager-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chat-manager-menu-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.chat-manager-menu-options {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
  box-shadow: var(--shadow);
  z-index: 1000;
}

.chat-manager-menu.open .chat-manager-menu-options {
  display: flex;
}

.chat-manager-menu-options button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  white-space: nowrap;
  font-family: "Montserrat", sans-serif;
}

.chat-manager-menu-options button:hover {
  background: var(--hover);
}

.chat-manager-menu-options button i {
  width: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Share Modal Styles */
.share-dialog {
  width: min(480px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.share-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.share-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text);
  font-family: "Montserrat", sans-serif;
}

.share-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.share-close:hover {
  background: var(--hover);
}

.share-input-wrapper {
  position: relative;
  margin-bottom: 0.75rem;
}

.share-input-wrapper input {
  width: 100%;
  padding: 0.75rem 3rem 0.75rem 1rem;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: 'Montserrat', sans-serif;
  transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.share-input-wrapper input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.1);
}

body.theme-light .share-input-wrapper input:focus {
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.12);
}

.share-copy-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.share-copy-btn:hover {
  opacity: 0.9;
}

.share-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: "Montserrat", sans-serif;
}

/* Transformation Selector Styles */
.transformation-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.transformation-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 140ms ease, opacity 140ms ease;
  font-size: 0.85rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.transformation-btn:hover:not(:disabled) {
  color: var(--accent);
}

.transformation-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.transformation-label {
  font-size: 0.8rem;
  color: var(--muted);
  user-select: none;
}

.transformation-loading {
  color: var(--muted);
  font-size: 0.85rem;
}

.transformation-loading i {
  color: var(--accent);
  font-size: 0.8rem;
}

.referenced-chat-indicator {
  color: var(--accent);
  font-size: 0.85rem;
  font-style: italic;
}

.reply-attachments {
  margin-bottom: 0.5rem;
  margin-top: 0rem;
  opacity: 0.8;
}

/* Text Selection Menu */
.selection-menu {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.4rem;
  box-shadow: var(--shadow);
  z-index: 10000;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.selection-menu.visible {
  opacity: 1;
  pointer-events: auto;
}

.selection-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: "Montserrat", sans-serif;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.selection-menu-btn:hover {
  background: var(--border);
}

.selection-menu-btn img {
  width: 14px;
  height: 14px;
}

/* Context Chip */
.context-chip {
  position: relative;
  margin-bottom: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-family: "Montserrat", sans-serif;
}

.context-chip-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 0.1rem;
}

.context-chip-text {
  flex: 1;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

.context-chip-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  transition: color 0.15s ease;
}

.context-chip-close:hover {
  color: var(--text);
}

/* Message Context Indicator */
.message-context-indicator {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.85rem;
  font-family: "Montserrat", sans-serif;
}

.context-indicator-icon {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin-top: 0.1rem;
  opacity: 0.8;
}

.context-indicator-text {
  flex: 1;
  color: var(--text);
  opacity: 0.85;
  line-height: 1.4;
  word-break: break-word;
  font-size: 0.82rem;
}
