* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0d0f14;
  --bg-soft: #141820;
  --surface: rgba(255, 255, 255, 0.052);
  --surface-strong: rgba(255, 255, 255, 0.092);
  --surface-solid: #171a21;
  --border: rgba(255, 255, 255, 0.105);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f7f7f8;
  --muted: #a6adb8;
  --faint: #737c89;
  --accent: #10a37f;
  --accent-2: #4285f4;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --sidebar-width: 248px;
  --sidebar-offset: var(--sidebar-width);
  --radius: 8px;
  --topbar-height: 64px;
  --composer-clearance: 210px;
  --composer-bottom: 18px;
}

html {
  height: 100%;
  overflow: hidden;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  height: 100%;
  margin: 0;
  padding-top: var(--topbar-height);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: none;
  touch-action: pan-x pan-y;
  background:
    linear-gradient(135deg, rgba(66, 133, 244, 0.1), transparent 34%),
    linear-gradient(225deg, rgba(16, 163, 127, 0.1), transparent 32%),
    linear-gradient(180deg, #0d0f14 0%, #11141a 48%, #0b0d11 100%);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  transition: background 0.25s ease, color 0.25s ease;
}

body.light {
  --bg: #f7f8fb;
  --bg-soft: #eef2f7;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #111827;
  --muted: #5f6b7a;
  --faint: #7b8794;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.1);
  background:
    linear-gradient(135deg, rgba(66, 133, 244, 0.1), transparent 34%),
    linear-gradient(225deg, rgba(16, 163, 127, 0.08), transparent 32%),
    linear-gradient(180deg, #fbfcff 0%, #f4f7fb 52%, #ffffff 100%);
}

.answer-text,
.chat-bubble,
textarea,
input {
  user-select: text;
  -webkit-user-select: text;
}

a,
button,
label {
  -webkit-touch-callout: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(66, 133, 244, 0.7);
  outline-offset: 2px;
}

button:active,
.sidebar-btn:active,
.upload-btn:active,
.solve-btn:active,
a.sidebar-btn:active {
  transform: scale(0.98);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.42);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
}

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.spin {
  animation: spin 1s linear infinite;
}

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

.top-bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1000;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: linear-gradient(180deg, rgba(13, 15, 20, 0.94), rgba(13, 15, 20, 0.58));
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.light .top-bar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.68));
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 720;
  text-decoration: none;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--border);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-btn,
.icon-close {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.theme-btn:hover,
.icon-close:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
}

.theme-btn svg,
.upload-btn svg,
.solve-btn svg,
.output-header svg,
.upload-status svg,
.sidebar-btn svg,
.modal-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sidebar {
  position: fixed;
  top: calc(var(--topbar-height) + 14px);
  bottom: 14px;
  left: 14px;
  z-index: 900;
  width: var(--sidebar-width);
  padding: 10px;
  display: flex;
  flex-direction: column;
  background: rgba(15, 18, 24, 0.82);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.22);
  transition: transform 0.24s ease, opacity 0.2s ease;
}

body.light .sidebar {
  background: rgba(255, 255, 255, 0.78);
}

.sidebar-nav {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-top,
.nav-bottom {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-bottom {
  margin-top: auto;
}

.sidebar-btn {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.sidebar-btn:hover,
.history-item:hover {
  color: var(--text);
  background: var(--surface-strong);
  border-color: var(--border);
}

.upgrade-btn {
  color: var(--text);
  background: linear-gradient(135deg, rgba(16, 163, 127, 0.18), rgba(66, 133, 244, 0.12));
  border-color: rgba(16, 163, 127, 0.22);
}

.sidebar-label {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-size: 14px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-history {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0;
  overflow-y: auto;
}

.history-label {
  padding: 0 10px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  min-height: 38px;
  padding: 8px 8px 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

.history-item-content {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-chat-btn,
.copy-btn,
.code-copy-btn,
.remove-image-btn {
  border: 0;
  cursor: pointer;
}

.delete-chat-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--faint);
  background: transparent;
  border-radius: 7px;
  opacity: 0;
  transition: opacity 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.history-item:hover .delete-chat-btn,
.delete-chat-btn:focus-visible {
  opacity: 1;
}

.delete-chat-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.sidebar.collapsed {
  transform: translateX(calc(-100% - 22px));
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 641px) {
  .sidebar.collapsed ~ .app {
    --sidebar-offset: 0px;
  }

  .sidebar.collapsed ~ footer {
    --sidebar-offset: 0px;
  }
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 850;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(4px);
}

.sidebar-backdrop.hidden,
.sidebar-backdrop:not(.visible) {
  display: none;
}

.app {
  width: calc(100% - var(--sidebar-offset));
  min-height: calc(100vh - var(--topbar-height) - 70px);
  margin-left: var(--sidebar-offset);
  margin-right: 0;
  padding: clamp(26px, 5vw, 54px) clamp(18px, 5vw, 74px) 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: margin 0.24s ease, width 0.24s ease;
}

.hero-panel {
  width: min(100%, 820px);
  margin-bottom: 18px;
  text-align: left;
  transition: opacity 0.24s ease, transform 0.24s ease, max-height 0.24s ease, margin 0.24s ease;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(16, 163, 127, 0.12);
}

.title {
  max-width: 820px;
  margin: 0 0 10px;
  color: var(--text);
  font-size: clamp(38px, 6vw, 68px);
  font-weight: 760;
  line-height: 1.05;
  letter-spacing: 0;
  transition: opacity 0.24s ease, transform 0.24s ease, max-height 0.24s ease, margin 0.24s ease;
}

.subtitle {
  max-width: 620px;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  transition: opacity 0.24s ease, transform 0.24s ease, max-height 0.24s ease, margin 0.24s ease;
}

.session-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.session-strip span {
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 680;
}

.session-strip svg {
  width: 14px;
  height: 14px;
}

.prompt-starters {
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  transition: opacity 0.24s ease, transform 0.24s ease, max-height 0.24s ease, margin 0.24s ease;
}

.starter-chip {
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.starter-chip svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.starter-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.starter-chip:hover {
  color: var(--text);
  background: var(--surface-strong);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

body.light .starter-chip {
  background: rgba(255, 255, 255, 0.68);
}

.input-card {
  width: min(100%, 820px);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.055)),
    rgba(13, 16, 22, 0.8);
  border-color: var(--border-strong);
  isolation: isolate;
}

body.light .input-card {
  background: rgba(255, 255, 255, 0.96);
}

.composer-head {
  min-height: 28px;
  padding: 0 6px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--faint);
  font-size: 12px;
  font-weight: 720;
}

.composer-head span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.composer-head svg {
  width: 14px;
  height: 14px;
}

.composer-state {
  color: var(--accent);
}

.image-preview-container {
  position: relative;
  width: 112px;
  height: 112px;
  overflow: hidden;
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.image-preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-image-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.56);
  border-radius: 7px;
}

.remove-image-btn:hover {
  background: var(--danger);
}

.remove-image-btn svg {
  width: 15px;
  height: 15px;
}

textarea {
  width: 100%;
  min-height: 96px;
  max-height: 380px;
  padding: 14px 16px 6px;
  resize: none;
  outline: none;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.55;
  transition: min-height 0.2s ease;
}

textarea::placeholder {
  color: var(--faint);
}

.input-card:focus-within {
  border-color: rgba(66, 133, 244, 0.45);
  box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.08), var(--shadow);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 1px 1px;
}

.upload-btn,
.solve-btn,
.modal-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.upload-btn {
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
}

.upload-btn:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.solve-btn {
  padding: 0 16px;
  color: #fff;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

body:not(.light) .solve-btn {
  background: #f4f4f5;
  color: #111827;
}

.solve-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

.solve-btn:disabled,
.modal-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
}

.upload-status {
  min-height: 18px;
  color: var(--success);
  font-size: 13px;
  text-align: right;
}

.output-card {
  width: min(100%, 900px);
  margin-top: 22px;
  padding: 0;
  overflow: visible;
  text-align: left;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body:not(.post-first) .output-card {
  display: none;
}

.output-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 2px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#outputContent {
  min-height: 80px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.65;
}

#outputContent:empty::before {
  content: "Answers will appear here.";
  color: var(--faint);
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  transition: mask-image 0.18s ease, -webkit-mask-image 0.18s ease;
}

.chat-bubble {
  position: relative;
  width: fit-content;
  max-width: min(100%, 780px);
  border-radius: var(--radius);
  line-height: 1.65;
  transition: opacity 0.38s cubic-bezier(0.2, 0, 0, 1), transform 0.38s cubic-bezier(0.2, 0, 0, 1);
}

.chat-bubble.is-reveal-ready {
  opacity: 0.001;
  transform: translateY(12px);
}

.chat-bubble.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.follow-up-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  transition: opacity 0.32s cubic-bezier(0.2, 0, 0, 1), transform 0.32s cubic-bezier(0.2, 0, 0, 1);
}

.follow-up-actions.is-reveal-ready {
  opacity: 0.001;
  transform: translateY(8px);
}

.follow-up-actions.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.follow-up-chip {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.follow-up-chip:hover {
  color: var(--text);
  background: var(--surface-strong);
  border-color: var(--border-strong);
}

.chat-bubble.user {
  align-self: flex-end;
  max-width: min(82%, 640px);
  padding: 12px 15px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(66, 133, 244, 0.14), rgba(16, 163, 127, 0.09));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.12);
}

.chat-bubble.ai {
  align-self: stretch;
  width: 100%;
  padding: 8px 46px 22px 42px;
  color: var(--text);
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.chat-bubble.ai:last-child {
  border-bottom: 0;
}

.bubble-header {
  position: absolute;
  left: 0;
  top: 8px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: linear-gradient(135deg, rgba(66, 133, 244, 0.28), rgba(16, 163, 127, 0.22));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
}

.ai-icon {
  width: 16px;
  height: 16px;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 0;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  background: transparent;
  border-radius: 7px;
  opacity: 0;
  transition: opacity 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.chat-bubble.ai:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.user-prompt,
.answer-text {
  overflow-wrap: anywhere;
}

.answer-text {
  max-width: 760px;
  transition: opacity 0.16s ease, transform 0.16s ease;
  will-change: opacity, transform;
}

.chat-bubble.ai.is-streaming .answer-text.is-soft-revealing {
  opacity: 0.74;
  transform: translateY(2px);
}

.chat-bubble.ai.is-streaming .answer-text {
  animation: answerSettle 0.22s ease;
}

@keyframes answerSettle {
  from {
    opacity: 0.78;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.is-chat-scrolling .chat-history {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 74px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 74px), transparent 100%);
}

#outputContent p {
  margin: 0 0 14px;
}

#outputContent h1,
#outputContent h2,
#outputContent h3 {
  margin: 22px 0 10px;
  color: var(--text);
  font-weight: 680;
  line-height: 1.25;
}

#outputContent h1 {
  font-size: 24px;
}

#outputContent h2 {
  font-size: 21px;
}

#outputContent h3,
.explanation h3,
.steps h3,
.final-answer h3 {
  font-size: 18px;
}

#outputContent ul,
#outputContent ol {
  margin: 12px 0 16px;
  padding-left: 24px;
}

#outputContent li {
  margin-bottom: 7px;
}

#outputContent blockquote {
  margin: 14px 0;
  padding: 2px 0 2px 16px;
  color: var(--muted);
  border-left: 3px solid var(--border-strong);
}

#outputContent a {
  color: var(--accent-2);
}

#outputContent pre {
  position: relative;
  margin: 14px 0;
  padding: 42px 14px 14px;
  overflow-x: auto;
  color: #e5e7eb;
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#outputContent code,
.inline-math,
code.inline-math {
  padding: 2px 5px;
  color: var(--text);
  background: var(--surface-strong);
  border-radius: 6px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace;
  font-size: 0.92em;
}

#outputContent pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  border-radius: 0;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  opacity: 0;
  transition: opacity 0.16s ease, background 0.16s ease;
}

#outputContent pre:hover .code-copy-btn,
.code-copy-btn:focus-visible {
  opacity: 1;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.final-answer {
  margin-top: 18px;
  padding: 14px 16px;
  background: rgba(16, 163, 127, 0.1);
  border: 1px solid rgba(16, 163, 127, 0.22);
  border-radius: var(--radius);
  font-weight: 650;
}

.steps,
.explanation {
  margin-bottom: 20px;
}

#outputContent img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 15px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.image-download-container {
  display: flex;
  justify-content: center;
  margin-top: 15px;
  padding-bottom: 20px;
}

.skeleton {
  width: 100%;
  max-width: 512px;
  min-height: 300px;
  aspect-ratio: 1 / 1;
  margin: 20px auto;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-strong) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: shimmer 1.5s infinite;
}

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

.loading-pulse {
  display: inline-block;
  color: var(--accent);
  font-weight: 650;
  animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.custom-notification {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 9999;
  max-width: calc(100vw - 28px);
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 550;
  pointer-events: none;
  transform: translateX(-50%);
  animation: notifyIn 0.22s ease forwards;
}

.custom-notification.fade-out {
  animation: notifyOut 0.2s ease forwards;
}

@keyframes notifyIn {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes notifyOut {
  to {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(12px);
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-content {
  width: min(100%, 420px);
  max-height: calc(100vh - 44px);
  padding: 26px;
  overflow-y: auto;
  text-align: center;
  background: var(--surface-solid);
  border-color: var(--border-strong);
  animation: modalIn 0.2s ease forwards;
}

.wide-modal {
  width: min(100%, 900px);
  text-align: left;
}

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

.modal-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: rgba(16, 163, 127, 0.12);
  border: 1px solid rgba(16, 163, 127, 0.18);
  border-radius: var(--radius);
}

.modal-icon.warning {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.2);
}

.modal-content h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.25;
}

.modal-content p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.modal-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.modal-topline p {
  margin-bottom: 0;
}

.modal-actions,
.quiz-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-btn {
  min-width: 116px;
  padding: 0 16px;
  border: 1px solid transparent;
}

.modal-btn.secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.modal-btn.secondary:hover {
  background: var(--surface-strong);
}

.modal-btn.primary,
.modal-btn.danger {
  color: #fff;
  background: var(--danger);
}

.primary-gradient {
  color: #fff;
  background: #111827;
  border-color: rgba(255, 255, 255, 0.18);
}

body:not(.light) .primary-gradient {
  color: #111827;
  background: #f4f4f5;
}

.plan-details {
  margin-bottom: 22px;
  padding: 18px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.plan-price {
  margin-bottom: 14px;
  color: var(--text);
  font-size: 30px;
  font-weight: 750;
}

.plan-price span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.plan-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.plan-features svg {
  color: var(--accent);
}

.analytics-content,
.quiz-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric-card,
.analytics-row,
.quiz-summary > div,
.quiz-question,
.quiz-option,
.quiz-explanation,
.quiz-summary,
.quiz-note,
.empty-state,
.quiz-loading,
.quiz-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.metric-card {
  min-height: 96px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card span,
.analytics-row span,
.quiz-summary-label,
.quiz-result span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.analytics-lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.analytics-lists h4 {
  margin: 0 0 10px;
  color: var(--text);
}

.analytics-row-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analytics-row {
  min-height: 44px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quiz-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px auto;
  gap: 10px;
  margin-bottom: 18px;
}

.quiz-topic-input,
.quiz-count {
  min-height: 44px;
  padding: 0 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.quiz-topic-input::placeholder {
  color: var(--faint);
}

.quiz-count option {
  color: #111827;
}

.quiz-summary {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quiz-summary > div {
  min-height: 72px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.quiz-summary strong {
  color: var(--text);
  font-size: 15px;
}

.quiz-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quiz-question {
  margin: 0;
  padding: 16px;
}

.quiz-question-head {
  width: 100%;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
}

.quiz-number,
.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--accent);
  background: rgba(16, 163, 127, 0.1);
  border: 1px solid rgba(16, 163, 127, 0.18);
}

.quiz-number {
  min-width: 40px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
}

.question-text {
  padding-top: 3px;
  color: var(--text);
  font-weight: 650;
  line-height: 1.45;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quiz-option {
  min-height: 54px;
  padding: 11px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.quiz-option:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
}

.quiz-option input {
  margin-top: 5px;
  accent-color: var(--accent);
}

.option-letter {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.option-text {
  line-height: 1.45;
}

.quiz-option.correct {
  border-color: rgba(34, 197, 94, 0.62);
  background: rgba(34, 197, 94, 0.12);
}

.quiz-option.wrong {
  border-color: rgba(239, 68, 68, 0.62);
  background: rgba(239, 68, 68, 0.12);
}

.quiz-question.unanswered {
  border-color: rgba(245, 158, 11, 0.42);
}

.quiz-explanation {
  margin-top: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.quiz-result {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
}

.quiz-result strong {
  color: var(--text);
  font-size: 26px;
}

.quiz-result em {
  color: var(--accent);
  font-style: normal;
  font-weight: 750;
}

footer {
  width: calc(100% - var(--sidebar-offset));
  margin-left: var(--sidebar-offset);
  margin-right: 0;
  padding: 20px;
  color: var(--faint);
  text-align: center;
  font-size: 13px;
}

body.post-first .app {
  justify-content: flex-start;
  min-height: calc(100vh - var(--topbar-height));
  padding-top: 22px;
  padding-bottom: var(--composer-clearance);
}

body.post-first .title,
body.post-first .subtitle,
body.post-first .hero-panel,
body.post-first .prompt-starters {
  max-height: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-8px);
}

body.post-first .output-card {
  order: 1;
  margin-top: 0;
}

body.post-first .input-card {
  position: fixed;
  left: calc(var(--sidebar-offset) + ((100vw - var(--sidebar-offset)) / 2));
  bottom: var(--composer-bottom);
  z-index: 820;
  width: min(calc(100vw - var(--sidebar-offset) - 44px), 780px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 6px 7px 6px 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.115), rgba(255, 255, 255, 0.075)),
    rgba(17, 19, 24, 0.82);
  border-color: var(--border-strong);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

body.post-first .input-card textarea {
  grid-column: 1;
  min-height: 34px;
  max-height: 118px;
  padding: 8px 6px 4px;
  line-height: 1.45;
}

body.post-first .composer-head {
  display: none;
}

body.post-first .input-card .actions {
  grid-column: 2;
  align-self: end;
  padding: 0;
  margin: 0;
}

body.post-first .image-preview-container,
body.post-first .upload-status {
  grid-column: 1 / -1;
}

body.post-first .upload-btn,
body.post-first .solve-btn {
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
}

body.light.post-first .input-card {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 22px 58px rgba(15, 23, 42, 0.16);
}

body.post-first footer {
  display: none;
}

.auth-page {
  width: min(100%, 500px);
  min-height: calc(100vh - 140px);
  margin: 0 auto;
  padding: 40px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 34px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-header {
  margin-bottom: 28px;
  text-align: center;
}

.auth-header h1 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 2rem;
}

.auth-header p,
.auth-switch {
  margin: 0;
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-input {
  min-height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.auth-input::placeholder {
  color: var(--faint);
}

.auth-action-btn {
  min-height: 48px;
  color: #fff;
  background: #111827;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
}

body:not(.light) .auth-action-btn {
  color: #111827;
  background: #f4f4f5;
}

.auth-divider {
  position: relative;
  margin: 22px 0;
  color: var(--faint);
  text-align: center;
  font-size: 13px;
}

.auth-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  position: relative;
  padding: 0 12px;
  background: var(--surface-solid);
}

.auth-link-btn,
.auth-switch button {
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  font-weight: 650;
  cursor: pointer;
}

.auth-error {
  color: var(--danger);
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 224px;
  }

  .app {
    padding-left: 28px;
    padding-right: 28px;
  }
}

@media (max-width: 760px) {
  .analytics-grid,
  .analytics-lists,
  .quiz-builder,
  .quiz-summary,
  .quiz-options {
    grid-template-columns: 1fr;
  }

  .wide-modal {
    padding: 22px;
  }

  .quiz-actions,
  .modal-actions {
    flex-direction: column;
  }

  .modal-btn {
    width: 100%;
  }

  .quiz-result {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --sidebar-offset: 0px;
    --topbar-height: 62px;
    --composer-clearance: 178px;
    --composer-bottom: 12px;
  }

  body {
    padding-top: var(--topbar-height);
  }

  .top-bar {
    padding: 0 14px;
  }

  .logo span {
    font-size: 15px;
  }

  .sidebar {
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    width: min(86vw, 300px);
    padding: 14px;
    border-radius: 0;
    transform: translateX(-105%);
    opacity: 0;
    pointer-events: none;
  }

  .sidebar.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .app {
    width: 100%;
    min-height: calc(100vh - var(--topbar-height) - 58px);
    margin: 0;
    padding: 28px 12px 14px;
  }

  .hero-panel {
    width: 100%;
    margin-bottom: 14px;
  }

  .hero-kicker {
    margin-bottom: 10px;
  }

  .title {
    font-size: 36px;
  }

  .subtitle {
    margin-bottom: 16px;
    font-size: 15px;
  }

  .session-strip {
    margin-bottom: 14px;
  }

  .prompt-starters {
    width: 100%;
    margin: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .starter-chip {
    min-width: max-content;
    scroll-snap-align: start;
  }

  .input-card {
    width: 100%;
    padding: 8px;
  }

  .composer-head {
    padding: 0 4px;
  }

  textarea {
    min-height: 82px;
    padding: 12px 10px 5px;
    font-size: 16px;
  }

  .actions {
    gap: 7px;
  }

  .upload-btn span,
  .solve-btn span {
    display: none;
  }

  .upload-btn,
  .solve-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
  }

  .output-card {
    width: 100%;
    margin-top: 16px;
  }

  .output-header {
    padding-left: 2px;
  }

  .chat-history {
    gap: 18px;
  }

  .chat-bubble.user {
    max-width: 90%;
  }

  .chat-bubble.ai {
    padding: 2px 38px 2px 36px;
  }

  .copy-btn,
  .delete-chat-btn,
  .code-copy-btn {
    opacity: 1;
  }

  body.post-first .app {
    padding-bottom: var(--composer-clearance);
  }

  body.post-first .input-card {
    left: 50%;
    bottom: var(--composer-bottom);
    width: calc(100% - 18px);
  }

  body.post-first .input-card textarea {
    min-height: 34px;
    max-height: 92px;
  }

  footer {
    width: 100%;
    margin-left: 0;
    padding: 18px 14px;
  }

  .modal-overlay {
    padding: 12px;
  }

  .modal-content {
    padding: 22px;
  }

  .auth-page {
    padding: 24px 14px;
  }

  .auth-container {
    padding: 28px 22px;
  }
}

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

  .chat-bubble.is-reveal-ready,
  .chat-bubble.is-visible,
  .follow-up-actions.is-reveal-ready,
  .follow-up-actions.is-visible,
  .chat-bubble.ai.is-streaming .answer-text.is-soft-revealing {
    opacity: 1 !important;
    transform: none !important;
  }

  body.is-chat-scrolling .chat-history {
    -webkit-mask-image: none;
    mask-image: none;
  }
}
