/* ---------- optional licensed font (see /fonts/README.txt) ---------- */
@font-face {
  font-family: "Copernicus";
  src: url("fonts/Copernicus-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Copernicus";
  src: url("fonts/Copernicus-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Copernicus";
  src: url("fonts/Copernicus-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens (light) ---------- */
:root, [data-theme="light"] {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e7e5df;
  --text: #292824;
  --text-muted: #75736c;
  --text-faint: #a8a59c;

  --accent: #5b7fde;
  --accent-soft: #eef1fb;
  --accent-text: #3f5cc4;

  --user-bubble-bg: #eef1fb;
  --ai-bubble-bg: #f4f3ef;
  --danger: #c85a4e;
  --danger-bg: #fdf0ef;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-sm: 0 1px 2px rgba(30, 28, 20, 0.05);
  --shadow-md: 0 6px 20px rgba(30, 28, 20, 0.06);
  --shadow-lg: 0 12px 40px rgba(30, 28, 20, 0.10);

  --font-body: "Copernicus", "Literata", Georgia, "Times New Roman", serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------- tokens (dark) ---------- */
[data-theme="dark"] {
  --bg: #1a1a1e;
  --surface: #232328;
  --surface-raised: #2c2c32;
  --border: #3a3a42;
  --text: #e8e6e1;
  --text-muted: #9e9c96;
  --text-faint: #6b6963;

  --accent: #7b9cf0;
  --accent-soft: #2a3050;
  --accent-text: #9db5f5;

  --user-bubble-bg: #2a3050;
  --ai-bubble-bg: #2c2c32;
  --danger: #e87c70;
  --danger-bg: #3a2020;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

::selection { background: var(--accent-soft); color: var(--accent-text); }

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* ---------- page system ---------- */
.page {
  display: none;
  width: 100%;
  min-height: 100vh;
  height: 100vh;
}
.page[hidden] { display: none !important; }
.page.active {
  display: flex;
  width: 100%;
}

.page-chat {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}
.page-chat.active {
  display: flex;
  width: 100%;
}

.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  padding: 30px;
}

.page-scroll {
  align-items: flex-start;
  overflow-y: auto;
  padding-top: 60px;
  padding-bottom: 60px;
}

/* ---------- connect page ---------- */
.connect-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 44px 36px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.connect-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 14px;
}

.connect-card h1 {
  font-weight: 700;
  font-size: 26px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.connect-card h2 {
  font-weight: 600;
  font-size: 20px;
  margin: 0 0 4px;
}

.connect-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.connect-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 22px;
}

.connect-tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.connect-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.connect-tab:hover:not(.active) { color: var(--text); }

.connect-tab-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}
.connect-tab-body[hidden] { display: none; }

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.field-inline input[type="checkbox"] {
  accent-color: var(--accent);
}

.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row .btn-primary,
.btn-row .btn-secondary { flex: 1; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--surface-raised); }

.btn-danger {
  background: var(--danger) !important;
}
.btn-danger:hover { filter: brightness(1.08); }

/* ---------- shell (chat page) ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  width: 100%;
  height: 100vh;
  flex: 1;
  transition: grid-template-columns 0.22s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 64px 1fr;
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 18px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  height: 28px;
  width: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text {
  flex: 1;
  min-width: 0;
  transition: opacity 0.15s ease, max-width 0.22s ease;
}

.brand h1 {
  font-weight: 600;
  font-size: 19px;
  margin: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.sidebar-collapse-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-collapse-btn:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-soft); }
.sidebar-collapse-btn svg { transition: transform 0.22s ease; }

/* Collapsed sidebar: stack logo above expand button */
.sidebar-collapsed .sidebar {
  padding: 18px 8px 16px;
  align-items: center;
}

.sidebar-collapsed .brand {
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  width: 100%;
}

.sidebar-collapsed .brand-text {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  position: absolute;
  visibility: hidden;
  pointer-events: none;
}

.sidebar-collapsed .sidebar-content {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

/* Collapsed sidebar bottom navigation with proper 40px square hover pills */
.sidebar-collapsed .sidebar-nav {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border-top: none;
  padding-top: 12px;
  width: 100%;
}

.sidebar-collapsed .sidebar-nav-label {
  display: none;
}

.sidebar-collapsed .sidebar-nav-btn {
  width: 42px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex: none;
  margin: 0 auto;
}
.sidebar-collapsed .sidebar-nav-btn svg {
  width: 20px;
  height: 20px;
  margin: 0;
  flex-shrink: 0;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Sidebar bottom nav (expanded) */
.sidebar-nav {
  display: flex;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: auto;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex: 1;
}
.sidebar-nav-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.sidebar-nav-btn svg { flex-shrink: 0; }
.sidebar-nav-label { white-space: nowrap; }

.sidebar-nav-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  padding: 13px 15px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
}

.panel-toggle:hover { color: var(--text); }
.chevron { transition: transform 0.2s ease; color: var(--text-faint); }
.panel-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

.panel-body {
  padding: 4px 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-body[hidden] { display: none; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.field input, .field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
}

.field input:focus, .field select:focus,
#course-select:focus {
  border-color: var(--accent);
}

.btn-primary {
  margin-top: 4px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-faint);
  min-height: 16px;
}
.hint.error { color: var(--danger); }
.hint.ok { color: var(--accent-text); }

#course-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
}

/* tabs = index-card style selector */
.tab-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tab {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
}
.tab:hover { color: var(--text); border-color: var(--text-faint); }
.tab.active {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 40vh;
  overflow-y: auto;
}
.item-list[hidden] { display: none; }

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
  color: var(--text-muted);
  cursor: pointer;
}
.item-row:hover { background: var(--bg); color: var(--text); }
.item-row.active { background: var(--accent-soft); color: var(--accent-text); }
.item-row .meta { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

.back-row {
  font-size: 12px;
  color: var(--text-faint);
  background: none;
  border: none;
  text-align: left;
  padding: 7px 11px;
  cursor: pointer;
}
.back-row:hover { color: var(--accent-text); }

/* ---------- main (content + chat) ---------- */
.main {
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}
@media (max-width: 860px) { .main { height: auto; } }

.content-preview {
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.content-preview[hidden] { display: none; }

.preview-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  padding: 18px 30px;
  cursor: pointer;
  text-align: left;
}

.preview-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.preview-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#preview-title {
  font-weight: 600;
  font-size: 19px;
  margin: 3px 0 0;
  color: var(--text);
}

.preview-canvas-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-faint);
  transition: color 0.15s;
  padding: 4px;
}
.preview-canvas-link:hover { color: var(--accent-text); }
.preview-canvas-link[hidden] { display: none; }

.preview-body {
  padding: 0 30px 22px;
  max-height: 240px;
  overflow-y: auto;
}
.preview-body.collapsed { display: none; }

.preview-extra {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: pre-wrap;
  margin: 0 0 8px;
}

.media-warning {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  margin: 0 0 10px;
}
.media-warning[hidden] { display: none; }

#preview-text {
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- chat area ---------- */
.chat {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-log {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.empty-state {
  margin: auto;
  max-width: 420px;
  text-align: center;
  color: var(--text-faint);
}
.empty-mark {
  width: 52px;
  height: 52px;
  object-fit: contain;
  opacity: 0.32;
}
.empty-state h2 {
  color: var(--text-muted);
  font-weight: 600;
  margin: 8px 0 8px;
}
.empty-state p { font-size: 13.5px; line-height: 1.65; }

.msg-block {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.msg-block.user { align-self: flex-end; align-items: flex-end; }
.msg-block.assistant { align-self: flex-start; align-items: flex-start; }

.msg-sender {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  margin: 0 4px 5px;
}

.msg {
  padding: 13px 15px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.6;
}
.msg.user {
  background: var(--user-bubble-bg);
  color: var(--accent-text);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.msg.assistant {
  background: var(--ai-bubble-bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg.system-note {
  align-self: center;
  color: var(--text-faint);
  font-size: 11.5px;
  background: none;
  padding: 4px 0;
}
.msg.pending { color: var(--text-faint); }

/* ============================================================ */
/* ---------- 4 CUSTOM TYPING ANIMATIONS ----------             */
/* ============================================================ */

/* 1. Wave Dots (Iconscout 4347818 style) */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: wave-dots-bounce 1.3s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }
@keyframes wave-dots-bounce {
  0%, 80%, 100% {
    transform: translateY(0) scale(0.7);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-8px) scale(1.15);
    opacity: 1;
  }
}

/* 2. Orbit Rings (Iconscout 3469029 style) */
.typing-orbit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 22px;
  height: 22px;
  padding: 2px;
}
.typing-orbit .orbit-outer {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  animation: orbit-spin 1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}
.typing-orbit .orbit-inner {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-bottom-color: var(--accent-text);
  border-left-color: var(--accent-text);
  animation: orbit-spin-reverse 0.8s linear infinite;
}
@keyframes orbit-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes orbit-spin-reverse {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

/* 3. Grid Cubes (Iconscout 3469036 style) */
.typing-cubes {
  display: inline-grid;
  grid-template-columns: repeat(2, 6px);
  gap: 3px;
  padding: 4px;
}
.typing-cubes span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 2px;
  animation: cube-flip 1.4s infinite ease-in-out;
}
.typing-cubes span:nth-child(1) { animation-delay: 0.1s; }
.typing-cubes span:nth-child(2) { animation-delay: 0.25s; }
.typing-cubes span:nth-child(4) { animation-delay: 0.4s; }
.typing-cubes span:nth-child(3) { animation-delay: 0.55s; }
@keyframes cube-flip {
  0%, 70%, 100% {
    transform: scale3D(1, 1, 1);
    opacity: 0.4;
  }
  35% {
    transform: scale3D(0, 0, 1);
    opacity: 0.1;
  }
}

/* 4. Liquid Pulse (Iconscout 9601675 style) */
.typing-pulse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 22px;
  height: 22px;
}
.typing-pulse span {
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.6;
  animation: pulse-liquid 1.6s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.typing-pulse span:nth-child(2) {
  animation-delay: -0.5s;
}
.typing-pulse span:nth-child(3) {
  animation-delay: -1s;
}
@keyframes pulse-liquid {
  0% {
    transform: scale(0.15);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

/* blinking cursor */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: cursor-blink 0.9s step-start infinite;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

/* small spinner for the connect button */
.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: -2px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* new message fade/slide in */
.msg-block { animation: msg-in 0.2s ease; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* markdown content inside assistant replies */
.msg.assistant > *:first-child { margin-top: 0; }
.msg.assistant > *:last-child { margin-bottom: 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 {
  font-weight: 600;
  line-height: 1.3;
  margin: 14px 0 6px;
}
.msg.assistant h1 { font-size: 18px; }
.msg.assistant h2 { font-size: 16.5px; }
.msg.assistant h3 { font-size: 15px; }
.msg.assistant p { margin: 8px 0; }
.msg.assistant ul, .msg.assistant ol { margin: 8px 0; padding-left: 22px; }
.msg.assistant li { margin: 3px 0; }
.msg.assistant strong { font-weight: 700; }
.msg.assistant em { font-style: italic; }
.msg.assistant a { color: var(--accent-text); }
.msg.assistant code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 5px;
}
[data-theme="dark"] .msg.assistant code {
  background: rgba(255, 255, 255, 0.08);
}
.msg.assistant pre {
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
  position: relative;
}
[data-theme="dark"] .msg.assistant pre {
  background: rgba(255, 255, 255, 0.05);
}
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant blockquote {
  border-left: 3px solid var(--border);
  margin: 8px 0;
  padding: 2px 0 2px 12px;
  color: var(--text-muted);
}
.msg.assistant hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* download button on code blocks */
.code-download-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg.assistant pre:hover .code-download-btn { opacity: 1; }
.code-download-btn:hover { color: var(--accent-text); border-color: var(--accent); }

/* prompt chips */
.prompt-chips {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 30px 14px;
}
.prompt-chips[hidden] { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip svg { flex-shrink: 0; color: var(--text-faint); transition: color 0.15s ease; }
.chip:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-soft);
}
.chip:hover svg { color: var(--accent-text); }

/* ---------- chat input ---------- */
.chat-input-row {
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 30px 26px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}
.chat-input-wrap:focus-within { border-color: var(--accent); }

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
}
.attachment-chips[hidden] { display: none; }

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
}
.attachment-chip-remove {
  background: none;
  border: none;
  color: var(--accent-text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.6;
}
.attachment-chip-remove:hover { opacity: 1; }

#chat-input {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  padding: 13px 15px;
  font-size: 14.5px;
  color: var(--text);
  outline: none;
  max-height: 160px;
  /* Hide scrollbar but keep scrolling */
  scrollbar-width: none; /* Firefox */
}
#chat-input::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}
#chat-input:disabled { opacity: 0.5; }

.attach-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.attach-btn:hover { background: var(--accent-soft); color: var(--accent-text); }
.attach-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- flashcards ---------- */
.flashcard-deck {
  width: 100%;
  margin: 12px 0;
}

.flashcard-container {
  perspective: 1000px;
  width: 100%;
  min-height: 160px;
  cursor: pointer;
  margin-bottom: 10px;
}

.flashcard {
  width: 100%;
  min-height: 160px;
  position: relative;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-front, .flashcard-back {
  position: absolute;
  top: 0; left: 0; right: 0;
  min-height: 160px;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  padding: 24px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
}
.flashcard-front {
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 2px solid var(--accent);
}
.flashcard-back {
  background: var(--surface-raised);
  color: var(--text);
  border: 2px solid var(--border);
  transform: rotateY(180deg);
}

.flashcard-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.flashcard-nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.flashcard-nav-btn:hover { background: var(--accent-soft); color: var(--accent-text); }
.flashcard-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.flashcard-counter {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 500;
}
.flashcard-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 6px;
}

/* ---------- settings page ---------- */
.settings-card {
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.settings-header {
  margin-bottom: 28px;
}
.settings-header h1 {
  font-weight: 700;
  font-size: 24px;
  margin: 8px 0 0;
}

.back-link {
  background: none;
  border: none;
  color: var(--accent-text);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.back-link:hover { text-decoration: underline; }

.settings-section {
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.settings-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 14px;
  line-height: 1.5;
}

.settings-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: var(--font-body);
  min-height: 80px;
}
.settings-textarea:focus { border-color: var(--accent); }

.theme-toggle-row {
  display: flex;
  gap: 8px;
}
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.theme-btn:hover { border-color: var(--accent); }
.theme-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.animation-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.animation-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 10px;
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: 12px;
  color: var(--text-muted);
}
.animation-option:hover { border-color: var(--accent); }
.animation-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.animation-preview {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 600px) {
  .animation-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- docs page ---------- */
.docs-card {
  width: 100%;
  max-width: 700px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.docs-content {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
}
.docs-content h2 {
  font-weight: 600;
  font-size: 18px;
  margin: 28px 0 10px;
}
.docs-content h2:first-child { margin-top: 0; }
.docs-content p { margin: 8px 0; }
.docs-content ul, .docs-content ol { padding-left: 22px; margin: 8px 0; }
.docs-content li { margin: 4px 0; }
.docs-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
}
[data-theme="dark"] .docs-content code {
  background: rgba(255, 255, 255, 0.08);
}
.docs-content a { color: var(--accent-text); }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
