[hidden] {
  display: none !important;
}

/* Global shadow reset */
* {
  box-shadow: 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.75rem 1.35rem 1.6rem;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100vh;
  overflow: hidden;
}

.brand {
  font-weight: 700;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: "Montserrat", sans-serif;
  padding: 0.1rem 0.25rem;
}

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

.brand-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.45rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
}

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

.brand-status-text {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.logo-mark {
  width: 28px;
  height: 28px;
  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;
  margin-bottom: 5.5rem;
}

.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: 6px;
}

.stack-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

.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;
  background: transparent;
}

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

.chat-course-tag {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.stack-item:hover:not(.active) {
  color: var(--text);
  background: transparent;
}

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

.chats-list .stack-item {
  background: transparent !important;
}

.chat-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.5rem;
  cursor: pointer;
  transition: color 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 {
  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: 15000;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}

[data-theme="dark"] .chat-action-menu,
body.theme-dark .chat-action-menu {
  background: var(--panel);
  border-color: var(--border);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.55);
}

.chat-action-menu.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  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;
}

[data-theme="dark"] .chat-action-item,
body.theme-dark .chat-action-item {
  color: #e7ecf4;
}

.chat-action-item:hover {
  background: rgba(138, 43, 226, 0.12);
  color: var(--accent);
}

[data-theme="dark"] .chat-action-item:hover,
body.theme-dark .chat-action-item:hover {
  background: rgba(138, 43, 226, 0.12);
  color: var(--accent);
}

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

[data-theme="dark"] .chat-action-item i,
body.theme-dark .chat-action-item i {
  color: #c5ccdd;
}

[data-theme="dark"] .chat-action-item:hover i,
body.theme-dark .chat-action-item:hover i,
.chat-action-item:hover i {
  color: var(--accent);
}

[data-theme="dark"] .chat-action-item:hover i,
body.theme-dark .chat-action-item:hover i {
  color: var(--accent);
}

.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 {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  font-size: 1.2rem;
  line-height: 1;
}

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

body.theme-light .share-close-btn:hover {
  background: transparent;
}

.share-body {
  padding: 1.5rem;
}

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

.share-note {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.share-eye {
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
}

.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.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(123, 85, 227, 0.32);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.18s ease;
  font-size: 0.9rem;
}

.share-copy-btn i {
  color: currentColor;
  transition: transform 0.18s ease, opacity 0.18s ease;
  font-size: 0.85rem;
}

.share-copy-btn::after {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  opacity: 0;
  transform: scale(0.6);
  transition: transform 0.18s ease, opacity 0.18s ease;
  color: var(--accent);
}

.share-copy-btn.copied {
  transform: translateY(-50%) scale(1.02);
}

.share-copy-btn.copied i {
  opacity: 0;
  transform: scale(0.4);
}

.share-copy-btn.copied::after {
  opacity: 1;
  transform: scale(1);
}

.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-top: 1.25rem;
  padding-bottom: 1.5rem;
  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;
}

.chat-title-pill {
  display: none;
  align-self: center;
  padding: 0.35rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--text);
  box-shadow: none;
}

.chat-title-pill.hidden {
  display: none;
}

.workspace-tools {
  position: fixed;
  top: 14px;
  right: 1.1rem;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-only {
  display: none;
}

@media (max-width: 720px) {
  .workspace-header {
    position: sticky;
    justify-content: space-between;
    align-items: center;
  }

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

  .workspace-header .title-group {
    position: static;
    flex: 1;
    transform: none;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .workspace-tools {
    gap: 0.5rem;
  }

  .mobile-only {
    display: inline-flex;
  }

  .chat-title-pill {
    display: inline-flex;
    margin-top: 0.2rem; /* barely disconnected from header */
    margin-bottom: 0.6rem; /* slightly more padding under pill */
  }

  .chat-menu-btn {
    opacity: 1;
    pointer-events: auto;
    display: flex;
  }

  .settings-field-row {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }

  .settings-field-row > div:first-child {
    flex: 1;
    min-width: 0;
  }

  .settings-toggle {
    margin-left: auto;
  }
}

.icon-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text) !important;
  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) !important;
}

.icon-button i {
  color: inherit !important;
}

#materials-close.icon-button:hover {
  border-color: var(--border);
  color: var(--text) !important;
  background: rgba(255, 255, 255, 0.04);
}

/* Smooth transitions for citations toggle */
#teacher-citations-row {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1), transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

#teacher-citations-row:not([style*="display: none"]) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

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

/* Light mode passcode overlay background */
body.theme-light .passcode-overlay {
  background: var(--panel);
}

@media (prefers-color-scheme: light) {
  body.theme-system .passcode-overlay {
    background: var(--panel);
  }
}

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

.passcode-overlay.dismissing {
  opacity: 0;
  transform: translate(0, 68px);
  visibility: hidden;
  pointer-events: none;
}

.passcode-dimmer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 4;
}

.passcode-dimmer.active {
  opacity: 1;
  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;
  color: #ffffff !important;
}

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

/* Fix passcode overlay text for light mode */
body.theme-light .passcode-overlay span {
  color: #0f0f0f !important;
}

body.theme-light .passcode-overlay span:hover {
  color: var(--accent) !important;
}

/* System mode with light preference - fix passcode text */
@media (prefers-color-scheme: light) {
  body.theme-system .passcode-overlay span {
    color: #0f0f0f !important;
  }

  body.theme-system .passcode-overlay span:hover {
    color: var(--accent) !important;
  }
}

.passcode-fullscreen {
  position: fixed;
  top: 7rem;
  left: 50%;
  transform: translate(-50%, -16px);
  background: rgba(26, 26, 26, 0.95);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.75rem 3.25rem 2rem;
  min-width: min(560px, 92vw);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  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.9rem, 6vw, 5.2rem);
  letter-spacing: 0.42em;
  font-weight: 700;
}

.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);
}

.top-banner {
  position: fixed;
  top: -56px;
  left: 50%;
  transform: translate(-50%, -12px);
  padding: 0.75rem 1.3rem;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
  z-index: 140;
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.4, 1), opacity 180ms ease;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.top-banner.show {
  opacity: 1;
  transform: translate(-50%, 12px);
}

.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;
}

.chat-title.is-editable {
  border-bottom-color: #cfd3d8;
}

.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: center;
  gap: 1rem;
}

.passcode-inputs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 58px);
  grid-auto-rows: 82px;
  column-gap: 0.45rem;
  row-gap: 0.45rem;
  justify-content: center;
  align-items: center;
  width: auto;
  padding: 0 1rem;
}

.passcode-inputs input {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 18px;
  color: var(--text);
  font-weight: 600;
  text-align: center;
  font-size: 2rem;
  font-family: "Montserrat", sans-serif;
  letter-spacing: 0.05em;
  padding: 0.35rem;
  height: 82px;
  width: 58px;
  transition: border-color 160ms ease, transform 160ms ease;
}

/* Light mode borders for passcode inputs */
body.theme-light .passcode-inputs input {
  border: 2px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.92);
}

body.theme-dark .passcode-inputs input {
  border: 2px solid rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.08);
}

@media (prefers-color-scheme: light) {
  body.theme-system .passcode-inputs input {
    border: 2px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.92);
  }
}

.passcode-inputs input:focus {
  outline: none;
  border-color: var(--accent);
  transform: translateY(-3px);
}

body.theme-light .passcode-inputs input:focus {
  border-color: var(--accent);
}

@media (prefers-color-scheme: light) {
  body.theme-system .passcode-inputs input:focus {
    border-color: var(--accent);
  }
}

.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;
  padding-top: 42vh;
  text-align: center;
  align-self: center;
  justify-content: flex-start;
  box-shadow: none;
  gap: 1.25rem;
}

.passcode-label {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 2.5rem;
  font-family: "Montserrat", sans-serif;
  letter-spacing: -0.01em;
}

#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, 0.75);
}

.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: var(--scrollbar-thumb);
  border-radius: 999px;
}

.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%;
    margin-bottom: 1.5rem;
  }
}

.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.interrupted .meta {
  color: var(--muted);
}

.interrupt-note {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-weight: 600;
}

.interrupt-note i {
  color: var(--accent);
  font-size: 0.9rem;
}

.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;
}

.transforming-inline-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.transforming-inline-label i {
  font-size: 0.85rem;
  color: var(--accent);
}

/* Meta icon theme handling */
.meta-icon {
  display: block;
  flex-shrink: 0;
  opacity: 0.9;
  transition: opacity 0.2s ease;
  object-fit: contain;
}

.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%;
}

.chat-row-attachments.align-end {
  align-items: flex-end;
}

.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 1rem !important;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: left;
  line-height: 1.5;
  display: block;
}

.chat-skeleton {
  display: flex !important;
  flex-direction: column;
  gap: 0.65rem !important;
  margin-top: 0.5rem;
}

/* Ensure skeleton lines stay consistent when reasoning content is present */
.chat-skeleton:has(.reasoning-thought) {
  margin-top: 0 !important;
  gap: 0.65rem !important;
}

.chat-skeleton .skeleton-line {
  flex-shrink: 0;
  min-height: 8px;
  margin: 0 !important;
  padding: 0;
}

.chat-row .chat-skeleton {
  gap: 0.65rem !important;
}

.chat-row.assistant .chat-skeleton {
  gap: 0.65rem !important;
}

.chat-row.loading .chat-skeleton {
  gap: 0.65rem !important;
}

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

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

@media (prefers-color-scheme: light) {
  body.theme-system .skeleton-line {
    background: linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.06),
      rgba(0, 0, 0, 0.12),
      rgba(0, 0, 0, 0.06)
    );
  }
}

.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%;
}

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

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

.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),
              opacity 160ms ease,
              transform 160ms ease,
              border-color 160ms ease;
  opacity: 0.92;
}

.insight-vote-pill.active {
  background: var(--chip-bg);
  border-color: var(--accent);
  opacity: 1;
  transform: translateY(-1px);
}

.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;
  opacity: 0;
  transform: translateY(12px);
  animation: citationSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.insight-inline-card:nth-child(1) {
  animation-delay: 0.05s;
}

.insight-inline-card:nth-child(2) {
  animation-delay: 0.1s;
}

.insight-inline-card:nth-child(3) {
  animation-delay: 0.15s;
}

.insight-inline-card:nth-child(4) {
  animation-delay: 0.2s;
}

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

.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.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 0.85;
}

.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.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.insight-inline-answer.expanded {
  max-height: 1000px;
  opacity: 1;
}

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

.insight-inline-answer span {
  display: block;
  white-space: nowrap;
  transition: white-space 0.35s 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);
}

/* Fix "Thinking…" visibility in light mode */
body.theme-light .chat-row.loading .meta {
  color: #2a2a3c;
  font-weight: 500;
}

@media (prefers-color-scheme: light) {
  body.theme-system .chat-row.loading .meta {
    color: #2a2a3c;
    font-weight: 500;
  }
}

/* Fix reasoning thought visibility in light mode */
body.theme-light .reasoning-thought {
  color: #5a5a6e;
}

@media (prefers-color-scheme: light) {
  body.theme-system .reasoning-thought {
    color: #5a5a6e;
  }
}

.chat-feedback {
  display: flex;
  gap: 0.6rem;
  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;
  border-left: none;
}

.chat-feedback .transformation-btn {
  margin-left: 0.5rem;
}

.chat-feedback .transformation-btn + .transformation-btn {
  margin-left: 0.5rem;
}

.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, color 140ms ease;
  flex-shrink: 0;
}

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

.composer-icon-btn:hover {
  color: var(--accent);
}

.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;
  transition: opacity 140ms ease, transform 140ms ease;
}

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

.composer-send-btn.is-busy,
.composer-send-btn:disabled {
  cursor: pointer;
  opacity: 0.9;
}

.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;
}

@media (max-width: 720px) {
  .composer-hint {
    display: none;
  }
}

.math-input-overlay {
  position: absolute;
  left: 3.5rem;
  right: 4.5rem;
  bottom: 0.9rem;
  top: 0.9rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: "Montserrat", sans-serif;
  color: var(--text);
  overflow-y: auto;
  z-index: 5;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.4;
  min-height: 60px;
}

.math-input-overlay:empty:before {
  content: attr(data-placeholder);
  color: var(--muted);
  opacity: 0.7;
}

.composer textarea.has-math {
  opacity: 0;
  pointer-events: none;
}

.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;
}

@media (max-width: 720px) {
  .composer-disclaimer {
    text-align: center;
    margin-top: 0.75rem;
  }
}

.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 cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 220ms;
}

#share-chat-modal {
  z-index: 20000;
}

.modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 220ms cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 0s;
}

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

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

.alert-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.35rem;
}

.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.35;
  font-family: "Montserrat", sans-serif;
}

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

.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, color 140ms ease;
}

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

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

.alert-button.primary:hover {
  background: rgba(138, 43, 226, 0.08);
}

.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.in-progress {
  border-color: transparent;
  border-top-color: transparent;
  animation: none;
}

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

.chase-loader {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-block;
}

.chase-loader span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: chase 1.2s infinite ease-in-out both;
}

.chase-loader span:nth-child(1) { top: 0; left: 50%; margin-left: -4px; animation-delay: -1.1s; }
.chase-loader span:nth-child(2) { top: 8px; left: 8px; animation-delay: -1.0s; }
.chase-loader span:nth-child(3) { top: 50%; margin-top: -4px; left: 0; animation-delay: -0.9s; }
.chase-loader span:nth-child(4) { bottom: 8px; left: 8px; animation-delay: -0.8s; }
.chase-loader span:nth-child(5) { bottom: 0; left: 50%; margin-left: -4px; animation-delay: -0.7s; }
.chase-loader span:nth-child(6) { bottom: 8px; right: 8px; animation-delay: -0.6s; }
.chase-loader span:nth-child(7) { top: 50%; margin-top: -4px; right: 0; animation-delay: -0.5s; }
.chase-loader span:nth-child(8) { top: 8px; right: 8px; animation-delay: -0.4s; }

@keyframes chase {
  0%, 100% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1); opacity: 1; }
}

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

.materials-loader {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.materials-loader.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.materials-loader.done .dot-spinner {
  opacity: 0;
  transform: scale(0.85);
}

.materials-loader.done .loader-check {
  opacity: 1;
  transform: scale(1);
}

.three-body {
  --uib-size: 18px;
  --uib-speed: 0.8s;
  --uib-color: var(--accent);
  position: relative;
  display: inline-block;
  height: var(--uib-size);
  width: var(--uib-size);
  animation: spin78236 calc(var(--uib-speed) * 2.5) infinite linear;
}

.three-body__dot {
  position: absolute;
  height: 100%;
  width: 30%;
}

.three-body__dot:after {
  content: '';
  position: absolute;
  height: 0%;
  width: 100%;
  padding-bottom: 100%;
  background-color: var(--uib-color);
  border-radius: 50%;
}

.three-body__dot:nth-child(1) {
  bottom: 5%;
  left: 0;
  transform: rotate(60deg);
  transform-origin: 50% 85%;
}

.three-body__dot:nth-child(1)::after {
  bottom: 0;
  left: 0;
  animation: wobble1 var(--uib-speed) infinite ease-in-out;
  animation-delay: calc(var(--uib-speed) * -0.3);
}

.three-body__dot:nth-child(2) {
  bottom: 5%;
  right: 0;
  transform: rotate(-60deg);
  transform-origin: 50% 85%;
}

.three-body__dot:nth-child(2)::after {
  bottom: 0;
  left: 0;
  animation: wobble1 var(--uib-speed) infinite calc(var(--uib-speed) * -0.15) ease-in-out;
}

.three-body__dot:nth-child(3) {
  bottom: -5%;
  left: 0;
  transform: translateX(116.666%);
}

.three-body__dot:nth-child(3)::after {
  top: 0;
  left: 0;
  animation: wobble2 var(--uib-speed) infinite ease-in-out;
}

@keyframes spin78236 {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes wobble1 {
  0%, 100% {
    transform: translateY(0%) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-66%) scale(0.65);
    opacity: 0.8;
  }
}

@keyframes wobble2 {
  0%, 100% {
    transform: translateY(0%) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(66%) scale(0.65);
    opacity: 0.8;
  }
}

.loader-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #0b0b0f;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 160ms ease, transform 160ms ease;
}

.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 220ms cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 220ms;
}

.settings-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 220ms cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 0s;
}

.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: none;
  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 {
  margin-bottom: 1.25rem;
}

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


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

.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;
  flex-shrink: 0;
}

.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;
  flex-shrink: 0;
}

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

.settings-field-row > div:first-child {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 120px);
}

.settings-field-row .settings-toggle {
  flex-shrink: 0;
  align-self: center;
}

/* Keep toggles vertically aligned even when text wraps (align-start rows) */
.settings-field-row.align-start {
  align-items: center;
}

.settings-field-row .settings-toggle {
  margin-top: 0;
}

.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)));
}

@media (max-width: 960px) {
  .theme-toggle {
    margin-left: auto;
    margin-right: auto;
  }
}

.shortcuts-section {
  margin-top: 2rem;
  padding-top: 0.35rem;
  margin-bottom: 1rem;
}

.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;
  gap: 0.4rem;
}

.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-textarea-block {
  margin-top: 1.4rem;
}

.settings-textarea-block .input-label {
  margin-top: 0;
  margin-bottom: 0.6rem;
}

.settings-textarea-block textarea {
  min-height: 140px;
  line-height: 1.5;
}

.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;
  transition: border-color 160ms ease, background 160ms ease;
}

.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 220ms cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 220ms 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;
  transition: color 140ms ease, background 140ms ease;
}

.dropdown-menu button:hover {
  background: rgba(138, 43, 226, 0.12);
  color: var(--accent);
}

.dropdown-toggle i {
  transition: transform 160ms ease, color 160ms ease;
}

.settings-dropdown[data-open="true"] .dropdown-toggle i {
  transform: rotate(180deg);
}

.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: auto;
  min-height: 520px;
  max-height: 90vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: none;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.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;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.memory-sort button:hover,
.memory-clear:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
}

.memory-sort-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.5rem;
  min-width: 160px;
  width: auto;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 10;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transition: opacity 220ms cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1),
              visibility 0s linear 220ms;
  pointer-events: none;
  visibility: hidden;
}

.memory-sort-menu button {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
  font-size: 0.9rem;
  white-space: nowrap;
  width: 100%;
  transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.memory-sort-menu button:hover {
  background: rgba(138, 43, 226, 0.12);
  color: var(--accent);
}

.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 {
  min-width: 140px;
}

#chats-sort-menu button:first-child::after {
  display: none;
}

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

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

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

.sidebar .search-wrapper {
  margin-left: 0.9rem;
  margin-right: 0.9rem;
}

.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(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: "Montserrat", sans-serif;
  outline: none;
  will-change: border-color, box-shadow, background;
  transition: border-color 0.2s cubic-bezier(0.2, 0.8, 0.4, 1),
              box-shadow 0.2s cubic-bezier(0.2, 0.8, 0.4, 1),
              background 0.18s ease;
}

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

.search-input:focus {
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 2px rgba(181, 129, 227, 0.18);
}

.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;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.memory-confirm-actions button:last-child {
  background: transparent;
  border-color: #e25b5b;
  color: #b02323;
}

.memory-confirm-actions button:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
}

.memory-confirm-actions button:last-child:hover {
  background: rgba(226, 91, 91, 0.08);
  border-color: #e25b5b;
  color: #9b1f1f;
}

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: var(--scrollbar-thumb);
}

@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: row;
    align-items: center;
  }
}

@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 cubic-bezier(0.4, 0, 0.2, 1),
              opacity 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.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: 1;
  transform: none;
}

.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: var(--accent);
}

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

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

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

.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 i {
  color: currentColor;
}

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

[data-feedback="2"] .version-btn,
[data-feedback="2"] .version-btn i,
[data-feedback="2"] .version-btn:hover:not(:disabled),
[data-feedback="2"] .version-btn:hover:not(:disabled) i {
  color: var(--muted) !important;
}

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

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

/* Top Menu Dropdown */
.top-menu-dropdown {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 0.75rem 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  z-index: 100;
  transform: translateY(-100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.top-menu-dropdown.active {
  transform: translateY(0);
}

.top-menu-content {
  padding: 1rem 0;
}

.top-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--fg);
  background: transparent;
  border: none;
  text-decoration: none;
  transition: background 150ms ease;
  cursor: pointer;
}

.top-menu-item:hover {
  background: var(--hover);
}

.top-menu-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  color: var(--muted);
}

.top-menu-divider {
  margin: 0.5rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

#top-menu-btn {
  display: none;
}

.top-menu-dropdown {
  display: none !important;
}

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

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

@media (max-width: 960px) {
  /* Show mobile menu button */
  .mobile-menu-btn {
    display: flex !important;
  }

  /* Hide top menu dropdown on mobile */
  #top-menu-btn {
    display: none !important;
  }

  .top-menu-dropdown {
    display: none !important;
  }

  .mobile-header-left {
    position: fixed;
    top: 10px;
    left: 1rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: 32px;
  }

  .mobile-logo {
    width: 26px;
    height: 26px;
    display: block;
    flex-shrink: 0;
  }

  .mobile-brand {
    font-weight: 600;
    font-size: 1.2rem;
    font-family: "Montserrat", sans-serif;
    line-height: 32px;
    display: flex;
    align-items: center;
    height: 32px;
  }

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

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

  /* Mobile sidebar overlay - dropdown from top */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 70vh;
    padding: 0.2rem 1rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 130;
    transform: translateY(-100%);
    transition: transform 220ms cubic-bezier(0.25, 0.1, 0.25, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

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

  /* Make sidebar content scrollable on mobile */
  .sidebar-scroll {
    margin-top: 0;
    overflow: visible;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    max-height: calc(70vh - 80px);
    gap: 0.5rem;
    padding-bottom: 0.9rem;
  }

  /* Ensure sections are visible */
  .sidebar-section {
    flex-shrink: 0;
  }

  /* Make lists scrollable within sections */
  .stack-list {
    max-height: none;
    overflow-y: visible;
    padding-bottom: 0.25rem;
  }

  .sidebar-section:last-child {
    margin-bottom: 1rem;
  }

  /* Hide chat title pill on mobile to avoid duplicate heading */
  .chat-title-pill {
    display: none;
  }

  .sidebar-section:first-child {
    position: sticky;
    top: 26px;
    z-index: 120;
    background: var(--sidebar-bg);
    padding-top: 0.05rem;
    padding-bottom: 0.05rem;
  }

  .sidebar-section:last-child {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }

  /* Keep sidebar section headings visible on mobile */
  .sidebar-section:nth-of-type(2) {
    margin-top: 0.75rem;
  }

  .sidebar-section .section-heading {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    opacity: 1;
    visibility: visible;
    padding: 0 0.15rem;
    color: var(--text);
    margin-bottom: 0.35rem;
  }

  /* Force Chats header visibility on mobile */
  .sidebar-section:nth-of-type(2) .section-heading {
    display: flex !important;
    gap: 0.22rem;
    padding-top: 0.3rem;
    padding-bottom: 0.08rem;
    margin-top: 0.7rem;
    margin-bottom: 0.02rem;
    opacity: 1 !important;
    visibility: visible !important;
  }
  .sidebar-section .section-heading span {
    font-weight: 700;
    display: inline-flex;
    align-items: center;
  }

  .sidebar-section:last-child .section-heading {
    position: sticky;
    top: 34px;
    z-index: 119;
    background: var(--sidebar-bg);
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }

  .sidebar-section:last-child .stack-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.3rem;
    margin-right: -0.1rem;
  }

  /* Hide close button on mobile */
  .mobile-menu-close,
  #mobile-menu-close {
    display: none !important;
  }

  /* Ensure sidebar header is visible on mobile */
  .sidebar-header {
    flex-shrink: 0;
    padding: 0 0 0.2rem 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }

  /* Position brand with fixed positioning to match user-chip exactly */
  .sidebar-header .brand {
    position: relative;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: auto;
  }

  .sidebar-header .logo-mark {
    width: 26px;
    height: 26px;
    display: block;
    flex-shrink: 0;
  }

  .sidebar-header .brand span {
    font-weight: 600;
    font-size: 1.2rem;
    font-family: "Montserrat", sans-serif;
    line-height: 32px;
    height: 32px;
    display: flex;
    align-items: center;
  }

  /* Align mobile header elements */
  .workspace-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 12px 1.15rem;
    min-height: 58px;
  }

  /* Simplified user chip on mobile - fixed position aligned with header */
  .user-chip {
    position: fixed;
    top: 12px;
    right: 1.1rem;
    bottom: auto;
    left: auto;
    border: none;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 100;
    cursor: pointer;
    margin: 0;
  }

  .user-chip .label {
    display: none;
  }

  .user-chip .avatar {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Position hamburger menu and other tools fixed aligned with header */
  .workspace-tools {
    position: fixed;
    top: 10px;
    right: 1rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  /* Ensure all workspace tool icons match avatar size for perfect alignment */
  .workspace-tools .icon-button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Make all icon buttons 32px on mobile to match header */
  .icon-button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Mobile backdrop */
  .mobile-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 125;
    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;
  }

/* Force 4x2 layout only on <=960px */
@media (max-width: 960px) {
  .passcode-inputs {
    grid-template-columns: repeat(8, 48px);
    grid-auto-rows: 60px;
    column-gap: 0.4rem;
    row-gap: 0.4rem;
    padding: 0 0.4rem;
  }
  .passcode-inputs input {
    height: 60px;
    width: 48px;
    font-size: 1.6rem;
    border-radius: 14px;
  }
}

/* Compact passcode sizing on small phones */
@media (max-width: 640px) {
  .passcode-inputs {
    grid-template-columns: repeat(8, 42px);
    grid-auto-rows: 54px;
    column-gap: 0.35rem;
    row-gap: 0.35rem;
    padding: 0 0.35rem;
  }
  .passcode-inputs input {
    height: 54px;
    width: 42px;
    font-size: 1.4rem;
    border-radius: 12px;
    padding: 0.2rem;
  }
}

@media (max-width: 400px) {
  .passcode-inputs {
    grid-template-columns: repeat(8, 38px);
    grid-auto-rows: 50px;
    column-gap: 0.3rem;
    row-gap: 0.3rem;
  }
  .passcode-inputs input {
    height: 50px;
    width: 38px;
    font-size: 1.2rem;
    border-radius: 11px;
  }
}

  .passcode-label {
    font-size: 1.3rem;
  }

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

.course-wizard-panel .passcode-label {
  text-align: center;
  margin: 0;
}

.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 var(--border);
  padding: 0.6rem 0.6rem 0.6rem 1.1rem;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
}

/* Teacher light mode - sleeker and lighter course input */
body.theme-light .wizard-input {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(20px);
}

body.theme-light .wizard-input input {
  color: #1a1a1a;
}

body.theme-light .wizard-input input::placeholder {
  color: rgba(0, 0, 0, 0.45);
}

.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: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

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

.wizard-input button:hover {
  background: var(--panel);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 2px rgba(181, 129, 227, 0.12);
}

.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;
}

/* Light theme tweaks for wizard control */
body.theme-light .wizard-input button {
  background: #f8f3e9;
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--muted);
}

body.theme-light .wizard-input button:hover {
  background: #f8f3e9;
  border-color: var(--accent);
  color: var(--accent);
}

@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;
  padding-bottom: 0.25rem;
  border-bottom: none;
}

.chats-tab {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 0;
  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),
              transform 160ms ease;
  font-family: "Montserrat", sans-serif;
  position: relative;
}

.chats-tab.active {
  color: var(--accent);
  transform: translateY(1px);
}

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

.chats-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0.6);
  transition: opacity 160ms ease, transform 160ms ease;
}

.chats-tab.active::after {
  opacity: 1;
  transform: scaleX(1);
}

.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: calc(90vh - 280px);
  overflow-y: auto;
  padding-right: 0.5rem;
  padding-bottom: 1rem;
  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: 6px;
}

.chats-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

.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(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: color 0.16s ease, border-color 0.16s ease;
}

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

.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: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
  box-shadow: var(--shadow);
  z-index: 12000;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

[data-theme="dark"] .chat-manager-menu-options,
body.theme-dark .chat-manager-menu-options {
  background: #0f1115;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.45);
}

.chat-manager-menu.open .chat-manager-menu-options {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.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;
}

[data-theme="dark"] .chat-manager-menu-options button,
body.theme-dark .chat-manager-menu-options button {
  color: #e7ecf4;
}

.chat-manager-menu-options button:hover {
  background: rgba(138, 43, 226, 0.12);
  color: var(--accent);
}

[data-theme="dark"] .chat-manager-menu-options button:hover,
body.theme-dark .chat-manager-menu-options button:hover {
  background: rgba(138, 43, 226, 0.12);
  color: var(--accent);
}

.chat-manager-menu-options button:hover i {
  color: var(--accent);
}

.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: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, box-shadow 150ms ease, color 150ms ease, border-color 150ms ease;
}

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

body.theme-light .share-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.share-close i {
  color: inherit !important;
}

.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.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(123, 85, 227, 0.32);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.18s ease;
}

.share-copy-btn:hover {
  background: rgba(123, 85, 227, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.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 180ms cubic-bezier(0.16, 1, 0.3, 1), opacity 140ms ease;
  font-size: 0.85rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.transformation-btn i {
  color: currentColor;
  transition: color 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* Ensure transform icons in chat footer honor hover accent */
.chat-feedback .transformation-btn:hover:not(:disabled),
.chat-feedback .transformation-btn:hover:not(:disabled) i {
  color: var(--accent);
}

.transform-icon:hover:not(:disabled),
.transform-icon:hover:not(:disabled) i {
  color: var(--accent);
}

.chat-row[data-feedback="2"] .transformation-btn,
.chat-row[data-feedback="2"] .transformation-btn i,
.chat-row[data-feedback="2"] .transform-icon,
.chat-row[data-feedback="2"] .transform-icon i {
  color: var(--muted) !important;
}

.chat-row[data-feedback="2"] .transformation-btn:hover:not(:disabled),
.chat-row[data-feedback="2"] .transformation-btn:hover:not(:disabled) i,
.chat-row[data-feedback="2"] .transform-icon:hover:not(:disabled),
.chat-row[data-feedback="2"] .transform-icon:hover:not(:disabled) i {
  color: var(--accent) !important;
}

.transformation-btn:disabled {
  opacity: 1;
  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,
.chat-action-menu,
.modal,
.dropdown-menu,
.alert-dialog,
.memory-dialog,
.settings-dialog,
.passcode-launcher {
  box-shadow: none !important;
}

.selection-menu {
  position: fixed;
  background: var(--panel-alt);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 0.5rem 0.6rem;
  box-shadow: none;
  z-index: 10000;
  display: flex;
  gap: 0.4rem;
  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.55rem;
  padding: 0.6rem 0.9rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: "Montserrat", sans-serif;
  cursor: pointer;
  white-space: nowrap;
}

.selection-menu-btn:hover {
  background: transparent;
}

.selection-menu-btn i {
  color: var(--accent);
  transition: transform 140ms ease, color 140ms ease;
}

.selection-menu-btn .selection-menu-label {
  font-weight: 600;
}

/* 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;
}
