:root {
  color-scheme: light;
  --bg: #f8f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f1f7;
  --surface-hover: #e9e9f2;
  --text: #20202a;
  --muted: #6d6d7c;
  --subtle: #8a8a99;
  --line: #e3e3ec;
  --accent: #079447;
  --accent-strong: #05783a;
  --accent-soft: #e5f6ec;
  --accent-text: #075f32;
  --positive: #217a52;
  --danger: #b43a4c;
  --focus: #f26a21;
  --sidebar: 260px;
  --topbar: 64px;
  --content: 860px;
  --app-height: 100dvh;
  --composer-height: 112px;
  --ease: 200ms ease;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111315;
  --surface: #1f2023;
  --surface-soft: #222326;
  --surface-hover: #2b2c30;
  --text: #f2f1f7;
  --muted: #b1afbc;
  --subtle: #92909e;
  --line: #393842;
  --accent: #42ce7d;
  --accent-strong: #69df99;
  --accent-soft: #173d29;
  --accent-text: #9aefbd;
  --positive: #78d6a6;
  --danger: #ff8998;
  --focus: #ff8a4c;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button:not(:disabled), select, a { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.app-shell { display: flex; width: 100%; height: var(--app-height); }
.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex: 0 0 var(--sidebar);
  flex-direction: column;
  width: var(--sidebar);
  padding: 14px 12px 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% -5%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 27%),
    color-mix(in srgb, var(--surface-soft) 94%, var(--surface));
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 32px rgba(18, 24, 21, .035);
  transition: width var(--ease), flex-basis var(--ease), transform var(--ease);
}
.sidebar-top { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; min-height: 48px; gap: 8px; padding: 0 2px; }
.brand { display: flex; min-width: 0; align-items: center; gap: 11px; color: var(--text); font-weight: 800; text-decoration: none; letter-spacing: -.01em; }
.brand-logo { width: 42px; height: 40px; flex: 0 0 42px; padding: 2px; border: 1px solid color-mix(in srgb, var(--line) 72%, transparent); border-radius: 9px; background: #fff; object-fit: contain; box-shadow: 0 2px 9px rgba(18, 25, 21, .1); }
.brand-mark {
  display: inline-grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px 17px 11px 17px;
  background: linear-gradient(145deg, var(--accent), #f26a21);
  color: white;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}
.brand-name { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .collapse-button { width: 36px; height: 36px; flex-basis: 36px; border-radius: 12px; color: var(--muted); }
.icon-button, .composer-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  transition: background-color var(--ease), color var(--ease), transform var(--ease);
}
.icon-button:hover, .composer-button:hover { background: var(--surface-hover); }
.icon-button:active, .composer-button:active { transform: scale(.96); }
svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.new-chat-button, .sidebar-action {
  display: flex;
  min-height: 48px;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), transform var(--ease), box-shadow var(--ease);
}
.new-chat-button {
  position: relative;
  min-height: 50px;
  margin: 20px 0 22px;
  overflow: hidden;
  border: 0;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--text);
  box-shadow: none;
  font-weight: 750;
}
.new-chat-button::after { display: none; }
.new-chat-button:hover { background: var(--surface-hover); box-shadow: none; transform: none; }
.sidebar-action:hover { background: var(--surface-hover); transform: translateX(2px); }
.new-chat-button svg, .sidebar-action svg { flex: 0 0 21px; }
.history-section { display: flex; min-width: 0; min-height: 0; flex: 1; flex-direction: column; overflow: hidden; }
.sidebar-label { display: flex; align-items: center; gap: 10px; margin: 0 10px 9px; color: var(--subtle); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-label::after { height: 1px; flex: 1; background: var(--line); content: ""; }
.history-list { display: grid; width: 100%; min-width: 0; gap: 5px; padding: 2px 2px 12px; overflow-x: hidden; overflow-y: auto; scrollbar-color: color-mix(in srgb, var(--muted) 36%, transparent) transparent; scrollbar-width: thin; }
.history-list::-webkit-scrollbar { width: 5px; }
.history-list::-webkit-scrollbar-thumb { border-radius: 99px; background: color-mix(in srgb, var(--muted) 35%, transparent); }
.history-item {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 56px;
  align-items: center;
  padding: 5px 38px 5px 11px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
.history-item::before { position: absolute; top: 12px; bottom: 12px; left: 0; width: 3px; border-radius: 0 6px 6px 0; background: var(--accent); content: ""; opacity: 0; transform: scaleY(.35); transition: opacity var(--ease), transform var(--ease); }
.history-item:hover { border-color: color-mix(in srgb, var(--line) 80%, transparent); background: color-mix(in srgb, var(--surface) 66%, transparent); color: var(--text); transform: translateX(1px); }
.history-item.active { border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); background: linear-gradient(100deg, var(--accent-soft), color-mix(in srgb, var(--surface) 72%, transparent)); color: var(--text); }
.history-item.active::before { opacity: 1; transform: scaleY(1); }
.history-item-title { display: grid; width: 100%; min-width: 0; min-height: 44px; align-content: center; gap: 2px; padding: 0; overflow: hidden; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; }
.history-title-text { display: block; overflow: hidden; font-size: 13px; font-weight: 650; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { display: block; overflow: hidden; color: var(--subtle); font-size: 10.5px; font-weight: 500; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.history-delete {
  position: absolute;
  right: 5px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  opacity: 0;
  pointer-events: none;
  transform: scale(.86);
  transition: opacity var(--ease), transform var(--ease), background-color var(--ease), color var(--ease);
}
.history-item:hover .history-delete, .history-item:focus-within .history-delete { opacity: 1; pointer-events: auto; transform: scale(1); }
.history-delete:hover { color: var(--danger); background: var(--surface); }
.history-empty { margin: 10px 3px; padding: 18px 14px; border: 1px dashed var(--line); border-radius: 14px; color: var(--subtle); font-size: 13px; text-align: center; }
.sidebar-bottom { display: grid; gap: 4px; margin: 0 -2px; padding: 12px 2px 0; border-top: 1px solid var(--line); }
.sidebar-action[hidden] { display: none; }
.privacy-note { margin: 5px 13px 0; color: var(--subtle); font-size: 10.5px; white-space: nowrap; }
.privacy-note span { color: var(--positive); }

.app-shell.sidebar-collapsed .sidebar { width: 72px; flex-basis: 72px; }
.app-shell.sidebar-collapsed .brand-name,
.app-shell.sidebar-collapsed .new-chat-button span,
.app-shell.sidebar-collapsed .sidebar-action span,
.app-shell.sidebar-collapsed .history-section,
.app-shell.sidebar-collapsed .privacy-note { display: none; }
.app-shell.sidebar-collapsed .sidebar-top { flex-direction: column; }
.app-shell.sidebar-collapsed .collapse-button svg { transform: rotate(180deg); }
.app-shell.sidebar-collapsed .new-chat-button,
.app-shell.sidebar-collapsed .sidebar-action { justify-content: center; padding: 0; }

.workspace { position: relative; min-width: 0; flex: 1; background: var(--bg); transition: margin-right var(--ease); }
.topbar {
  position: absolute;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  height: var(--topbar);
  align-items: center;
  justify-content: flex-end;
  padding: 8px 22px;
  pointer-events: none;
}
.topbar button, .topbar .context-pill { pointer-events: auto; }
.topbar-actions { display: flex; align-items: center; gap: 5px; }
.context-pill { display: none !important; padding: 5px 12px; border: 0; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 13px; }
.account-button { min-height: 36px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 750; }
.mobile-menu, .mobile-brand { display: none; }
.sun-icon { display: none; }
html[data-theme="dark"] .moon-icon { display: none; }
html[data-theme="dark"] .sun-icon { display: block; }

.conversation {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(var(--topbar) + 28px) max(24px, calc((100% - var(--content)) / 2)) 232px;
  scroll-padding-bottom: 232px;
  -webkit-overflow-scrolling: touch;
}
.welcome { width: min(680px, calc(100% - 36px)); margin: clamp(118px, 20vh, 205px) auto 0; text-align: center; }
.welcome-logo-wrap { display: grid; width: 76px; height: 70px; margin: 0 auto 17px; padding: 5px; place-items: center; border: 1px solid color-mix(in srgb, var(--line) 78%, transparent); border-radius: 14px; background: #fff; box-shadow: 0 5px 18px rgba(15, 33, 23, .1); }
.welcome-logo { display: block; width: 100%; height: 100%; border-radius: 7px; object-fit: contain; }
.welcome-hello { margin: 0 0 4px; color: var(--muted); font-size: 15px; font-weight: 500; }
.welcome h1 { margin: 0; color: color-mix(in srgb, var(--text) 86%, var(--muted)); font-size: clamp(30px, 3vw, 42px); font-weight: 400; line-height: 1.2; letter-spacing: -.035em; }
.message-list { display: none; width: 100%; max-width: var(--content); margin: 0 auto; }
.workspace.has-messages .welcome { display: none; }
.workspace.has-messages .message-list { display: block; }
.message { margin: 0 0 34px; animation: arrive 200ms ease both; }
.scroll-latest { display: none; }
.user-message { display: flex; justify-content: flex-end; }
.user-bubble { max-width: min(78%, 590px); padding: 12px 18px; border-radius: 22px 22px 6px 22px; background: var(--accent-soft); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-message { width: 100%; }
.assistant-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; color: var(--accent-text); font-size: 14px; font-weight: 700; }
.assistant-head .brand-logo { width: 30px; height: 29px; flex-basis: 30px; padding: 1px; border: 0; border-radius: 7px; box-shadow: none; }
.assistant-head .brand-mark { width: 28px; height: 28px; flex-basis: 28px; border-radius: 9px 13px 8px 13px; font-size: 13px; }
.answer-content { min-height: 24px; color: var(--text); line-height: 1.7; overflow-wrap: anywhere; }
.answer-content > :first-child { margin-top: 0; }
.answer-content > :last-child { margin-bottom: 0; }
.answer-content h1, .answer-content h2, .answer-content h3 { margin: 1.35em 0 .55em; line-height: 1.3; letter-spacing: -.015em; }
.answer-content h1 { font-size: 1.45rem; }
.answer-content h2 { padding-bottom: 7px; border-bottom: 1px solid var(--line); font-size: 1.25rem; }
.answer-content h3 { position: relative; padding-left: 11px; font-size: 1.08rem; }
.answer-content h3::before { position: absolute; top: .16em; bottom: .12em; left: 0; width: 3px; border-radius: 99px; background: linear-gradient(var(--accent), #f26a21); content: ""; }
.answer-content p { margin: .55em 0; }
.answer-content ul, .answer-content ol { padding-left: 1.4em; }
.answer-content pre { overflow-x: auto; padding: 16px; border-radius: 16px; background: var(--surface-soft); font: 14px/1.55 ui-monospace, Consolas, monospace; }
.answer-content code { padding: .12em .35em; border-radius: 6px; background: var(--surface-soft); font: .9em ui-monospace, Consolas, monospace; }
.answer-content pre code { padding: 0; background: transparent; }
.answer-content a { color: var(--accent-text); text-underline-offset: 3px; }
.answer-content blockquote {
  margin: 16px 0;
  padding: 11px 15px;
  border-left: 4px solid var(--accent);
  border-radius: 0 13px 13px 0;
  background: var(--accent-soft);
  color: var(--text);
}
.answer-content blockquote p { margin: 0; }
.answer-content hr { height: 1px; margin: 22px 0; border: 0; background: var(--line); }
.answer-table-wrap { width: 100%; margin: 17px 0 22px; overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px rgba(20, 30, 24, .055); scrollbar-width: thin; }
.answer-content table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.45; }
.answer-content th, .answer-content td { min-width: 110px; padding: 12px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.answer-content th:last-child, .answer-content td:last-child { border-right: 0; }
.answer-content th { background: linear-gradient(135deg, var(--accent-soft), var(--surface-soft)); color: var(--accent-text); font-size: 12px; font-weight: 800; letter-spacing: .015em; white-space: nowrap; }
.answer-content tbody tr:last-child td { border-bottom: 0; }
.answer-content tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-soft) 50%, transparent); }
.answer-content tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.answer-content td:first-child { color: var(--text); font-weight: 700; }
.answer-data-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.answer-data-row span { padding: 5px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.cursor { display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: -.15em; background: var(--accent); animation: blink .8s steps(2) infinite; }
.thinking-state {
  display: flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  font-size: 15px;
  font-weight: 600;
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease;
}
.thinking-state.is-leaving { opacity: 0; transform: translateY(-2px); }
.thinking-icon { width: 20px; height: 20px; flex: 0 0 20px; color: var(--accent); animation: thinking-spin 3s linear infinite, thinking-pulse 1.6s ease-in-out infinite; }
.thinking-icon path { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.thinking-label { background: linear-gradient(90deg, #9ca3af 0%, #1f2937 50%, #9ca3af 100%); background-size: 200% 100%; background-clip: text; color: transparent; -webkit-background-clip: text; animation: thinking-shimmer 2s linear infinite; transition: opacity 200ms ease; }
.thinking-label.is-changing { opacity: 0; }
html[data-theme="dark"] .thinking-label { background-image: linear-gradient(90deg, #6b7280 0%, #e5e7eb 50%, #6b7280 100%); }
.answer-actions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 14px; }
.answer-actions button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.answer-actions button:hover, .answer-actions button[aria-pressed="true"] { background: var(--surface-soft); color: var(--accent-text); }
.answer-actions svg { width: 18px; height: 18px; }
.answer-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.answer-suggestions button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--accent-text); }
.answer-suggestions button:hover { border-color: var(--accent); background: var(--accent-soft); }
.source-links { display: grid; gap: 8px; margin: 18px 0; }
.source-links h3 { margin: 0 0 2px; }
.source-links a { color: var(--accent-text); overflow-wrap: anywhere; }

.video-lessons { margin: 22px 0; }
.video-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.video-section-heading h3 { margin: 0; font-size: 17px; }
.video-section-heading span { color: var(--muted); font-size: 12px; }
.video-loading { min-height: 122px; }
.video-loading-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.video-loading-row span { min-height: 76px; border-radius: 14px; background: linear-gradient(100deg, var(--surface-soft) 20%, var(--surface-hover) 45%, var(--surface-soft) 70%); background-size: 220% 100%; animation: video-loading 1.4s linear infinite; }
.video-unavailable { margin: 0; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); font-size: 13px; }
.video-search-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.video-search-links a, .video-search-single { display: flex; min-height: 58px; align-items: center; justify-content: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--accent-text); font-size: 13px; font-weight: 750; line-height: 1.35; text-align: center; text-decoration: none; }
.video-search-links a:hover, .video-search-single:hover { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 640px) { .video-search-links { grid-template-columns: 1fr; } }
.video-player { position: relative; width: 100%; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 20px; background: #111; box-shadow: 0 12px 32px rgba(18,17,28,.12); }
.video-player iframe { width: 100%; height: 100%; border: 0; }
.video-preview { position: relative; width: 100%; height: 100%; padding: 0; overflow: hidden; border: 0; background: #111; color: white; cursor: pointer; }
.video-preview::after { position: absolute; inset: 45% 0 0; content: ""; background: linear-gradient(transparent, rgba(0,0,0,.78)); pointer-events: none; }
.video-preview img { width: 100%; height: 100%; object-fit: cover; }
.video-play, .video-card-play { position: absolute; display: grid; place-items: center; border-radius: 999px; background: #e62117; color: white; box-shadow: 0 5px 18px rgba(0,0,0,.28); }
.video-play { z-index: 2; top: 50%; left: 50%; width: 68px; height: 48px; padding-left: 4px; transform: translate(-50%, -50%); font-size: 21px; }
.video-preview-label { position: absolute; z-index: 2; right: 18px; bottom: 15px; left: 18px; overflow: hidden; font-size: 15px; font-weight: 750; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.video-grid { display: grid; gap: 10px; margin: 12px 0 0; }
.video-card {
  display: grid;
  grid-template-columns: 144px 1fr;
  width: 100%;
  min-height: 100px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--ease), transform var(--ease);
}
.video-card:hover, .video-card.selected { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--surface-soft); transform: translateY(-1px); }
.video-thumb { position: relative; min-height: 100px; background: var(--surface-soft); overflow: hidden; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-card-play { top: 50%; left: 50%; width: 38px; height: 28px; padding-left: 2px; transform: translate(-50%, -50%); font-size: 11px; }
.video-duration { position: absolute; right: 7px; bottom: 7px; padding: 1px 6px; border-radius: 6px; background: rgba(18,18,22,.84); color: white; font-size: 11px; }
.video-info { padding: 10px 13px; }
.video-badge { display: inline-block; margin-bottom: 3px; color: var(--accent-text); font-size: 11px; font-weight: 700; }
.video-title { display: -webkit-box; margin: 0; overflow: hidden; font-weight: 700; line-height: 1.3; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.video-meta, .video-reason { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }

.composer-area {
  position: absolute;
  z-index: 15;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 24px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent 0, var(--bg) 28px, var(--bg) 100%);
}
.workspace:not(.has-messages) .composer-area { top: clamp(350px, 53vh, 540px); bottom: auto; background: transparent; }
.composer {
  position: relative;
  display: flex;
  width: min(100%, 620px);
  min-height: 62px;
  align-items: center;
  gap: 5px;
  padding: 7px 9px 7px 11px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--surface-soft);
  box-shadow: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.composer:focus-within { border-color: var(--accent); box-shadow: none; }
.attachment-menu { position:absolute; z-index:12; bottom:calc(100% + 9px); left:0; display:grid; min-width:190px; padding:7px; border:1px solid var(--line); border-radius:15px; background:var(--surface); box-shadow:0 16px 40px rgba(18,17,28,.18); }
.attachment-menu[hidden] { display:none; }
.attachment-menu button { min-height:40px; padding:8px 11px; border:0; border-radius:10px; background:transparent; color:var(--text); text-align:left; }
.attachment-menu button:hover { background:var(--surface-hover); }
.pending-image { display:flex; width:min(100%,620px); align-items:center; gap:10px; margin-top:8px; padding:7px 9px; border:1px solid var(--line); border-radius:14px; background:var(--surface); color:var(--muted); font-size:12px; }
.pending-image[hidden] { display:none; }
.pending-image img { width:42px; height:42px; border-radius:9px; object-fit:cover; }
.pending-image span { min-width:0; flex:1; }
.pending-image button { width:34px; height:34px; border:0; border-radius:10px; background:transparent; color:var(--muted); font-size:20px; }
.message-image { display:block; width:min(260px,100%); max-height:260px; margin:0 0 10px; border-radius:15px; object-fit:cover; }
.composer textarea { display: block; min-width: 0; max-height: 120px; flex: 1; padding: 10px 5px; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.5; }
.composer textarea::placeholder { color: var(--subtle); }
.composer-controls { display: flex; flex: 0 0 auto; align-items: center; gap: 2px; }
.composer-button { width: 40px; height: 40px; flex-basis: 40px; border-radius: 13px; color: var(--muted); }
.input-hint { display: none; }
.send-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  transition: background-color var(--ease), transform var(--ease);
}
.send-button:not(:disabled):hover { background: var(--accent-strong); }
.send-button:not(:disabled):active { transform: scale(.95); }
.stop-icon { display: none; width: 11px; height: 11px; border-radius: 2px; background: currentColor; }
.composer-area.is-generating .send-icon { display: none; }
.composer-area.is-generating .stop-icon { display: block; }
.composer-area.is-generating .send-button { border-radius: 50%; background: var(--text); }
.tool-indicator { width: min(100%, var(--content)); margin: 0 0 7px; color: var(--accent-text); font-size: 13px; }
.tool-indicator:not([hidden]) { display: flex; align-items: center; gap: 5px; }
.tool-indicator button { width: 30px; height: 30px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 19px; }
.suggestion-row { display: flex; width: min(100%, 600px); flex-direction: column; gap: 1px; margin-top: 19px; overflow: hidden; }
.suggestion-row::-webkit-scrollbar { display: none; }
.suggestion-row button {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}
.suggestion-row button svg { width: 18px; height: 18px; flex: 0 0 18px; }
.suggestion-row button:hover { background: var(--surface-soft); color: var(--text); }
.disclaimer { margin: 12px 0 0; color: var(--subtle); font-size: 10px; text-align: center; }
.workspace.has-messages .suggestion-row { display: none; }

.flashcard-deck { width:min(100%,620px); margin:22px 0 8px; }
.flashcard-heading { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; color:var(--text); font-size:14px; }
.flashcard-counter { color:var(--muted); font-size:12px; }
.flashcard { display:grid; width:100%; min-height:220px; padding:28px; place-items:center; border:1px solid var(--line); border-radius:22px; background:linear-gradient(145deg,var(--surface-soft),var(--surface)); color:var(--text); box-shadow:0 16px 38px rgba(16,48,31,.1); text-align:center; cursor:pointer; transition:transform .22s ease,border-color .22s ease,background .22s ease; }
.flashcard:hover { border-color:color-mix(in srgb,var(--accent) 55%,var(--line)); transform:translateY(-2px); }
.flashcard.is-flipped { background:linear-gradient(145deg,color-mix(in srgb,var(--accent) 11%,var(--surface)),var(--surface)); }
.flashcard-face { max-width:520px; font-size:clamp(18px,3vw,24px); font-weight:720; line-height:1.45; }
.flashcard small { align-self:end; color:var(--muted); font-size:12px; font-weight:550; }
.flashcard-controls { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:10px; }
.flashcard-controls button { min-height:42px; padding:8px 12px; border:1px solid var(--line); border-radius:999px; background:var(--surface-soft); color:var(--muted); font-size:13px; }
.flashcard-controls button:hover { border-color:var(--accent); color:var(--accent-text); }

.document-panel {
  display: none !important;
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  bottom: 0;
  width: clamp(420px, 36vw, 520px);
  padding: 22px 24px 28px;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(18, 24, 21, .08);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform var(--ease), visibility var(--ease);
}
.document-panel.open { transform: translateX(0); visibility: visible; }
@media (min-width: 1101px) {
  .app-shell.document-open .workspace { margin-right: clamp(420px, 36vw, 520px); }
}
.panel-header, .dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.eyebrow { color: var(--accent-text); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.panel-header h2, .dialog-header h2 { margin: 2px 0 0; font-size: 22px; line-height: 1.25; }
.document-actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 22px 0; }
.document-actions button, .primary-button, .danger-button {
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 13px;
  background: var(--surface-soft);
  font-weight: 650;
}
.document-actions button:hover { background: var(--surface-hover); }
.document-content { min-height: calc(100vh - 160px); padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); white-space: pre-wrap; line-height: 1.75; outline: none; }
.document-content[contenteditable="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.document-panel.resource-view #editDocument { display: none; }
.document-panel.resource-view .document-content { min-height: 0; padding: 0; border: 0; background: transparent; white-space: normal; }
.resource-document-intro { margin-bottom: 18px; }
.resource-count { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.resource-document-intro h3 { margin: 10px 0 5px; font-size: 24px; line-height: 1.25; letter-spacing: -.025em; }
.resource-document-intro p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.resource-document-grid { display: grid; gap: 12px; }
.resource-document-card { padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 8px 24px rgba(18, 24, 21, .055); transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
.resource-document-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 12px 30px rgba(18, 24, 21, .09); transform: translateY(-1px); }
.resource-card-top, .resource-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.resource-number { color: var(--subtle); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.resource-badge { padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 10px; font-weight: 800; }
.resource-card-title { display: block; margin: 11px 0 7px; color: var(--text); font-size: 16px; font-weight: 780; line-height: 1.35; text-decoration: none; }
.resource-card-title:hover { color: var(--accent-text); }
.resource-document-card > p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.resource-card-footer { padding-top: 11px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 11px; }
.resource-card-footer a { color: var(--accent-text); font-size: 12px; font-weight: 800; text-decoration: none; }
.resource-card-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
.resource-document-note { margin: 15px 0 0; padding: 12px 13px; border-left: 3px solid var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 12px; line-height: 1.5; }

.settings-dialog { width: min(620px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: hidden; border: 0; border-radius: 24px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(18,17,28,.22); }
.settings-dialog::backdrop { background: rgba(20, 19, 29, .44); backdrop-filter: blur(3px); }
.media-dialog { width:min(700px,calc(100% - 24px)); max-height:calc(100dvh - 24px); padding:0; overflow:hidden; border:0; border-radius:22px; background:var(--surface); color:var(--text); box-shadow:0 24px 80px rgba(18,17,28,.25); }
.media-dialog::backdrop { background:rgba(20,19,29,.58); backdrop-filter:blur(3px); }
.media-dialog-shell { max-height:calc(100dvh - 24px); padding:22px; overflow-y:auto; overscroll-behavior:contain; }
.media-dialog-shell > p { color:var(--muted); font-size:13px; }
.crop-stage { overflow:hidden; border-radius:16px; background:#090b0a; }
.crop-stage canvas { display:block; width:100%; height:auto; aspect-ratio:4/3; object-fit:contain; }
.crop-controls { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-top:16px; }
.crop-controls label { display:grid; gap:6px; color:var(--muted); font-size:12px; }
.crop-controls input { width:100%; accent-color:var(--accent); }
.media-actions { display:flex; justify-content:flex-end; gap:9px; margin-top:18px; }
.media-actions button { min-height:44px; padding:8px 15px; border:1px solid var(--line); border-radius:12px; background:var(--surface-soft); color:var(--text); }
.media-actions .primary-button { border:0; background:var(--accent); color:white; }
.settings-dialog form { max-height: calc(100dvh - 32px); padding: 24px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.dialog-intro { margin: 15px 0 20px; color: var(--muted); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 13px; outline: 0; background: var(--bg); color: var(--text); }
.form-grid textarea { resize: vertical; line-height: 1.5; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.dialog-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.primary-button { background: var(--accent); color: white; }
.danger-button { color: var(--danger); }

.admin-dialog { width: min(790px, calc(100% - 32px)); max-height: calc(100dvh - 32px); }
.admin-dialog form { max-height: calc(100dvh - 32px); overflow-y: auto; }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 20px; }
.admin-stats div { display: grid; gap: 1px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.admin-stats strong { color: var(--accent-text); font-size: 20px; }
.admin-stats span { color: var(--muted); font-size: 12px; }
.admin-form-grid .full-field { grid-column: 1 / -1; }
.admin-footer { align-items: center; }
.admin-footer > span { color: var(--muted); font-size: 12px; }

.account-dialog { width: min(680px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: hidden; }
.account-dialog-shell { min-height: 0; }
.account-auth-visual { display: none; }
.account-dialog-body { max-height: calc(100dvh - 32px); padding: 24px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.account-dialog-content { width: 100%; }
.auth-intro { margin: 8px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.auth-form { display: grid; gap: 15px; }
.auth-form[hidden] { display: none; }
.google-auth-panel { margin-top: 24px; }
.google-auth-copy { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; text-align: center; }
.google-signin-button { display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: center; gap: 12px; padding: 10px 18px; border: 1px solid #cfd7d1; border-radius: 999px; background: #fff; color: #26322b; font-size: 15px; font-weight: 750; text-decoration: none; transition: background-color var(--ease), border-color var(--ease), transform var(--ease); }
.google-signin-button:hover { border-color: #9caaa1; background: #f7faf8; }
.google-signin-button:active { transform: scale(.985); }
.google-signin-button[aria-busy="true"] { opacity: .65; pointer-events: none; }
.google-signin-button svg { width: 21px; height: 21px; flex: 0 0 21px; }
.auth-form > label, .auth-form .form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: color-mix(in srgb, var(--text) 78%, var(--muted)); }
.field-label small { color: var(--subtle); font-size: 11px; font-weight: 500; }
.auth-form input, .auth-form select { width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 13px; outline: 0; background: var(--bg); color: var(--text); }
.auth-form input::placeholder { color: color-mix(in srgb, var(--subtle) 78%, transparent); }
.auth-form input[readonly] { background: var(--surface-soft); color: var(--text); cursor: default; }
.auth-form button:disabled { cursor: wait; opacity: .65; }
.auth-form input:focus, .auth-form select:focus { outline: 0; }
.auth-form input:focus-visible, .auth-form select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.floating-field { position: relative; display: block !important; }
.floating-field input::placeholder { color: transparent; }
.floating-field > input, .floating-field .password-field > input { height: 56px; padding: 20px 15px 7px; }
.floating-label { position: absolute; top: 50%; left: 15px; z-index: 1; color: #667169; font-size: 15px; font-weight: 500; pointer-events: none; transform: translateY(-50%); transform-origin: left top; transition: top var(--ease), transform var(--ease), font-size var(--ease), color var(--ease); }
.floating-field input:focus + .floating-label,
.floating-field input:not(:placeholder-shown) + .floating-label { top: 9px; color: #4f5e55; font-size: 11px; transform: none; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 50px; }
.password-toggle { position: absolute; top: 50%; right: 5px; display: grid; width: 40px; height: 40px; padding: 0; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); transform: translateY(-50%); }
.password-toggle:hover { background: var(--surface-hover); color: var(--text); }
.password-toggle svg { width: 19px; height: 19px; }
.signup-password { grid-column: 1 / -1; }
.forgot-password { width: fit-content; margin: 0 auto; padding: 3px 6px; border: 0; background: transparent; color: var(--accent-text); font-size: 14px; font-weight: 700; }
.forgot-password:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: #849087; font-size: 13px; }
.auth-divider::before, .auth-divider::after { height: 1px; flex: 1; background: #dfe5e0; content: ""; }
.create-account-button { width: 100%; min-height: 50px; border: 1.5px solid #079447; border-radius: 999px; background: transparent; color: #087844; font-size: 15px; font-weight: 780; }
.create-account-button:hover { background: #eef9f2; }
.back-to-login { justify-self: center; padding: 6px; border: 0; background: transparent; color: #087844; font-size: 14px; font-weight: 700; }
.auth-message { min-height: 0; margin: 0; color: var(--muted); font-size: 13px; }
.auth-message:not(:empty) { padding: 10px 12px; border-radius: 10px; background: var(--surface-soft); color: var(--text); }
.auth-privacy { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 7px 0 0; color: var(--subtle); font-size: 13px; text-align: center; }
.auth-privacy svg { width: 15px; height: 15px; flex: 0 0 15px; }
.auth-footer { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12.5px; }
.auth-footer a, .auth-footer button { padding: 2px; border: 0; background: transparent; color: var(--muted); text-decoration: none; }
.auth-footer a:hover, .auth-footer button:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.auth-powered-by { margin: 18px 0 0; color: var(--subtle); font-size: 11px; letter-spacing: .025em; text-align: center; }
.auth-powered-by strong { color: var(--muted); font-weight: 750; }
.account-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.account-summary div { display: grid; gap: 3px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); overflow-wrap: anywhere; }
.account-summary span { color: var(--muted); font-size: 12px; }
.account-summary strong { font-size: 14px; }
.billing-card { margin-top: 16px; padding: 18px; border-radius: 17px; background: var(--surface-soft); }
.billing-card h3 { margin: 5px 0 12px; font-size: 18px; }
.billing-card p { margin: 8px 0; color: var(--muted); font-size: 13px; }
.billing-card progress { width: 100%; height: 10px; accent-color: var(--accent); }
.billing-card .billing-help { margin-top: 14px; }
.account-dialog .dialog-footer { flex-wrap: wrap; }
.account-dialog .dialog-footer button { min-height: 42px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--text); }
.account-dialog .dialog-footer .danger-button { color: var(--danger); }
.account-dialog .dialog-footer .primary-button { border-color: var(--accent); background: var(--accent); color: #fff; }

.library-dialog { width: min(720px, calc(100% - 32px)); max-height: calc(100dvh - 32px); }
.library-shell { max-height: calc(100dvh - 32px); padding: 24px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.book-upload-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.book-upload-form input[type="file"], .book-upload-form input[type="text"], .book-upload-form select { width: 100%; min-height: 46px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); color: var(--text); }
.book-upload-form input[type="file"] { padding: 10px; }
.book-upload-form input[type="file"]::file-selector-button { margin-right: 10px; padding: 7px 10px; border: 0; border-radius: 8px; background: var(--surface-hover); color: var(--text); font-weight: 650; }
.share-book-row { display: flex; min-height: 46px; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.share-book-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.book-upload-form .primary-button { min-height: 46px; border-radius: 11px; }
.library-list { display: grid; gap: 10px; margin-top: 18px; }
.library-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.library-item > div { display: grid; min-width: 0; gap: 4px; }
.library-item strong { overflow-wrap: anywhere; }
.library-item span { color: var(--muted); font-size: 12px; }
.library-item button { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--danger); }
.library-empty { padding: 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }
.official-books { margin-top: 22px; }
.official-books h3 { font-size: 15px; }
.official-books > div { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.official-books a { display: grid; gap: 3px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); text-decoration: none; }
.official-books a:hover { border-color: var(--accent); background: var(--surface-soft); }
.official-books span { color: var(--muted); font-size: 12px; }
.book-citations { margin: 18px 0 4px; padding: 14px 16px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: var(--surface-soft); }
.book-citations h4 { margin: 0 0 8px; font-size: 13px; }
.book-citations ul { margin: 0; padding-left: 18px; }
.book-citations li { margin: 5px 0; color: var(--muted); font-size: 12px; }
body.auth-required .composer { opacity: .58; }
body.auth-required .account-dialog {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}
body.auth-required .account-dialog::backdrop { background: var(--surface); backdrop-filter: none; }
body.auth-required .account-dialog-shell { display: grid; width: 100%; min-height: 100dvh; grid-template-columns: 1fr 1fr; }
body.auth-required .account-auth-visual { position: relative; display: flex; min-width: 0; min-height: 100dvh; padding: clamp(28px, 4vw, 54px); flex-direction: column; overflow: hidden; background: #f3f7f3; }
.account-auth-brand { display: flex; align-items: center; gap: 12px; width: fit-content; color: #143328; font-size: 16px; font-weight: 800; }
.account-auth-brand img { width: 50px; height: 48px; padding: 2px; border-radius: 9px; background: white; object-fit: contain; }
.account-auth-copy { margin-top: clamp(42px, 7vh, 76px); color: #17382d; }
.account-auth-copy h2 { margin: 0; font-size: clamp(38px, 4vw, 58px); font-weight: 740; line-height: 1.02; letter-spacing: -.05em; }
.mobile-headline-space { display: none; }
.account-auth-copy h2 strong { color: #087844; font-weight: inherit; }
.account-auth-copy p { max-width: 570px; margin: 16px 0 0; color: #51665a; font-size: 16px; line-height: 1.55; }
.account-auth-photo { position: relative; min-height: 270px; max-height: 410px; margin-top: clamp(28px, 5vh, 48px); flex: 1; }
.account-auth-image { width: 100%; height: 100%; border-radius: 28px; object-fit: cover; object-position: center 44%; box-shadow: 0 24px 65px rgba(23, 61, 43, .17); }
.learning-chip { position: absolute; z-index: 2; display: flex; min-height: 42px; align-items: center; padding: 0 16px; border: 1px solid rgba(255,255,255,.72); border-radius: 999px; background: rgba(255,255,255,.92); color: #17382d; box-shadow: 0 12px 30px rgba(21,54,39,.16); font-size: 13px; font-weight: 760; backdrop-filter: blur(10px); }
.learning-chip::before { width: 8px; height: 8px; margin-right: 9px; border-radius: 50%; background: #079447; content: ""; }
.learning-chip-one { top: 22px; left: -14px; }
.learning-chip-two { right: -12px; bottom: 24px; }
body.auth-required .account-dialog-body { display: flex; width: 100%; min-width: 0; min-height: 100dvh; align-items: stretch; justify-content: stretch; padding: 0; overflow-y: auto; background: #fff; color: #17221c; }
body.auth-required .account-dialog-content { display: flex; width: 100%; max-width: none; min-height: 100dvh; margin: 0; padding: clamp(48px, 6vw, 96px); flex-direction: column; justify-content: center; border: 0; border-radius: 0; background: #fff; box-shadow: none; }
body.auth-required #closeAccount { display: none; }
body.auth-required .eyebrow { color: #087844; }
body.auth-required .account-dialog .dialog-header h2 { margin-top: 8px; font-size: clamp(30px, 2.5vw, 34px); line-height: 1.08; letter-spacing: -.04em; }
body.auth-required .auth-intro { color: #5c6a61; font-size: 15px; }
body.auth-required .auth-form { gap: 14px; margin-top: 28px; }
body.auth-required .field-label { color: #26342b; font-size: 14px; }
body.auth-required .field-label small { color: #69766e; }
body.auth-required .auth-form input,
body.auth-required .auth-form select { min-height: 52px; border-color: #cfd9d1; border-radius: 13px; background: #fbfcfb; color: #18231c; font-size: 16px; }
body.auth-required .auth-form input[readonly] { background: #eef2ef; }
body.auth-required .password-toggle { color: #59675e; }
body.auth-required .forgot-password { color: #087844; }
body.auth-required .auth-form > .primary-button { width: 100%; min-height: 52px; margin-top: 2px; border-radius: 999px; background: #079447; box-shadow: 0 8px 18px rgba(7,148,71,.18); font-size: 16px; font-weight: 780; transition: background-color var(--ease), box-shadow var(--ease), transform var(--ease); }
body.auth-required .auth-form > .primary-button:hover { background: #067d3d; box-shadow: 0 10px 24px rgba(7,148,71,.24); transform: translateY(-1px); }
body.auth-required .auth-form > .primary-button:active { transform: translateY(0) scale(.99); }
body.auth-required .login-submit { display: flex; align-items: center; justify-content: center; gap: 9px; }
body.auth-required .login-submit.is-loading::after { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.5); border-top-color: white; border-radius: 50%; content: ""; animation: auth-spin .7s linear infinite; }
body.auth-required .auth-form button:focus { outline: 0; }
body.auth-required .auth-form button:focus-visible,
body.auth-required .auth-footer a:focus-visible,
body.auth-required .auth-footer button:focus-visible { outline: 3px solid rgba(7,148,71,.35); outline-offset: 3px; }
body.auth-required .auth-message { color: #435148; }
body.auth-required .auth-message:not(:empty) { background: #edf3ef; }
body.auth-required .auth-privacy { color: #5f6d64; }
body.auth-required .auth-footer { border-color: #e1e7e2; }
body.auth-required .auth-footer a, body.auth-required .auth-footer button { color: #5d6a62; }
body.auth-required .auth-message { margin-bottom: 0; }

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

@media (min-width: 768px) and (max-width: 1100px) {
  body.auth-required .account-dialog-content { padding: 38px 32px; }
  body.auth-required .auth-form .form-grid { grid-template-columns: 1fr; }
  body.auth-required .signup-password { grid-column: auto; }
}

@media (max-width: 767px) {
  body.auth-required { overflow: hidden; }
  body.auth-required .account-dialog { width: 100vw; height: 100dvh; max-height: none; overflow: hidden; background: #edf5ef; }
  body.auth-required .account-dialog-shell { height: 100dvh; min-height: 0; grid-template: 72px minmax(0, 1fr) / 1fr; overflow: hidden; }
  body.auth-required .account-auth-visual { min-height: 0; align-items: center; justify-content: center; padding: 8px 16px 4px; overflow: hidden; background: radial-gradient(circle at 50% -70%, rgba(7,148,71,.22), transparent 70%), #edf5ef; }
  .account-auth-brand { margin: 0 auto; gap: 10px; color: #123b2c; font-size: 15px; letter-spacing: -.015em; }
  .account-auth-brand img { width: 45px; height: 45px; padding: 3px; border: 1px solid rgba(7,148,71,.15); border-radius: 11px; box-shadow: 0 7px 20px rgba(20,58,39,.12); }
  .account-auth-copy, .account-auth-photo, .learning-chip { display: none; }
  body.auth-required .account-dialog-body { min-height: 0; align-items: stretch; padding: 0 12px 12px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; background: linear-gradient(180deg, #edf5ef 0%, #f7faf8 100%); }
  body.auth-required .account-dialog-content { width: 100%; max-width: none; min-height: 0; height: 100%; padding: 22px 20px 18px; justify-content: center; border: 1px solid rgba(20,70,45,.1); border-radius: 28px; background: rgba(255,255,255,.96); box-shadow: 0 18px 50px rgba(23,61,43,.11); }
  body.auth-required .eyebrow { display: none; }
  body.auth-required .account-dialog .dialog-header { justify-content: center; }
  body.auth-required .account-dialog .dialog-header h2 { margin: 0; color: #15372b; font-size: 27px; font-weight: 760; line-height: 1.1; letter-spacing: -.04em; text-align: center; }
  body.auth-required .auth-intro { margin-top: 5px; font-size: 13px; line-height: 1.35; text-align: center; }
  body.auth-required .auth-form { gap: 11px; margin-top: 22px; }
  body.auth-required .auth-form input,
  body.auth-required .auth-form select { min-height: 46px; font-size: 14px; }
  body.auth-required .floating-field > input,
  body.auth-required .floating-field .password-field > input { height: 48px; padding: 18px 14px 6px; font-size: 15px; }
  body.auth-required .floating-label { left: 14px; font-size: 14px; }
  body.auth-required .google-signin-button { min-height: 54px; border-color: #d5ddd7; box-shadow: 0 8px 22px rgba(23,61,43,.08); font-size: 15px; }
  body.auth-required .google-signin-button:active { box-shadow: 0 3px 10px rgba(23,61,43,.08); }
  body.auth-required .auth-form > .primary-button { min-height: 46px; font-size: 15px; }
  body.auth-required .create-account-button { min-height: 44px; font-size: 14px; }
  body.auth-required .forgot-password, body.auth-required .back-to-login { font-size: 13px; }
  body.auth-required .auth-divider { font-size: 12px; }
  body.auth-required .auth-privacy { display: flex; max-width: 290px; margin: 14px auto 0; color: #6b776f; font-size: 11.5px; line-height: 1.4; }
  body.auth-required .auth-footer { display: flex; gap: 14px; margin-top: 16px; padding-top: 13px; font-size: 11.5px; }
  body.auth-required .auth-powered-by { margin-top: 14px; color: #8b958e; font-size: 10.5px; }
  body.auth-required .auth-powered-by strong { color: #4d6658; }
  body.auth-required #signupForm { gap: 10px; margin-top: 12px; }
  body.auth-required #signupForm .form-grid { grid-template-columns: 1fr 1fr; gap: 8px 10px; }
  body.auth-required #signupForm .form-grid label { gap: 3px; font-size: 12px; }
  body.auth-required #signupForm .field-label { font-size: 12px; }
  body.auth-required #signupForm .field-label small { font-size: 9px; }
  body.auth-required #signupForm input,
  body.auth-required #signupForm select { min-height: 42px; padding: 6px 9px; border-radius: 10px; font-size: 13px; }
  body.auth-required #signupForm .signup-password { grid-column: 1 / -1; }
  body.auth-required #signupForm .primary-button { min-height: 44px; }
}

@media (max-width: 767px) and (max-height: 650px) {
  body.auth-required .account-dialog-shell { grid-template-rows: 62px minmax(0, 1fr); }
  body.auth-required .account-auth-visual { padding-block: 5px 2px; }
  .account-auth-brand img { width: 38px; height: 37px; }
  body.auth-required .account-dialog-body { padding: 0 9px 9px; }
  body.auth-required .account-dialog-content { padding: 14px 16px 12px; border-radius: 22px; }
  body.auth-required .account-dialog .dialog-header h2 { font-size: 23px; }
  body.auth-required .auth-intro { font-size: 12px; }
  body.auth-required .auth-form { margin-top: 13px; }
  body.auth-required .auth-privacy { margin-top: 9px; }
  body.auth-required .auth-footer { margin-top: 10px; padding-top: 9px; }
  body.auth-required .auth-powered-by { margin-top: 8px; }
}

.toast {
  position: fixed;
  z-index: 100;
  bottom: 22px;
  left: 50%;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity var(--ease), transform var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.pwa-install-button[hidden], .pwa-install-help[hidden], .network-status[hidden] { display: none !important; }
.pwa-install-button { border: 0; color: inherit; }
.topbar .pwa-install-button {
  color: var(--accent-text);
  background: var(--accent-soft);
  animation: install-nudge 520ms cubic-bezier(.2,.8,.2,1) both;
}
.pwa-install-auth {
  position: absolute;
  z-index: 4;
  top: 34px;
  right: 34px;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: #075f32;
  box-shadow: 0 8px 24px rgba(20, 58, 39, .13);
  font-size: 13px;
  font-weight: 780;
  backdrop-filter: blur(12px);
  animation: install-nudge 520ms cubic-bezier(.2,.8,.2,1) both;
}
.pwa-install-auth svg { width: 18px; height: 18px; }
.pwa-install-auth:active { transform: scale(.96); }
.pwa-install-help {
  position: absolute;
  z-index: 5;
  top: 86px;
  right: 34px;
  max-width: 280px;
  margin: 0;
  padding: 10px 13px;
  border: 1px solid rgba(7,148,71,.18);
  border-radius: 13px;
  background: rgba(255,255,255,.96);
  color: #31483b;
  box-shadow: 0 14px 32px rgba(20,58,39,.14);
  font-size: 12px;
  line-height: 1.45;
  animation: arrive 180ms ease both;
}
.network-status {
  position: fixed;
  z-index: 90;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--muted);
  box-shadow: 0 8px 26px rgba(18,24,21,.12);
  font-size: 12px;
  font-weight: 650;
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
  animation: status-enter 180ms ease both;
}
.network-status span { width: 8px; height: 8px; border-radius: 50%; background: #df8d2d; }
.drawer-backdrop { display: none; }

/* Open WebUI-inspired shell, adapted to the school chat workflow. */
.sidebar {
  padding: 8px 8px 10px;
  background: color-mix(in srgb, var(--surface-soft) 68%, var(--bg));
  border-right-color: color-mix(in srgb, var(--line) 55%, transparent);
  box-shadow: none;
}
.sidebar-top { min-height: 38px; padding: 0 4px; }
.brand { gap: 9px; font-weight: 600; }
.brand-logo { width: 30px; height: 30px; flex-basis: 30px; padding: 2px; border-radius: 8px; background: #fff; object-fit: contain; box-shadow: none; }
.brand-name { font-size: 14px; }
.sidebar .collapse-button { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; }
.sidebar .collapse-button svg { width: 17px; height: 17px; }
.new-chat-button, .sidebar-action {
  min-height: 36px;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}
.new-chat-button { margin: 12px 0 1px; background: transparent; }
.new-chat-button:hover, .sidebar-action:hover { background: var(--surface-hover); transform: none; }
.new-chat-button svg, .sidebar-action svg { width: 17px; height: 17px; flex-basis: 17px; stroke-width: 1.7; }
.search-chats-button { margin-bottom: 9px; }
.history-search-panel {
  position: relative;
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  margin: 2px 2px 10px;
  padding: 0 7px 0 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.history-search-panel[hidden] { display: none; }
.history-search-panel > svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--muted); }
.history-search-panel input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.history-search-panel button { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 18px; }
.history-search-panel button:hover { background: var(--surface-hover); }
.sidebar-label { margin: 4px 10px 5px; font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.sidebar-label::after { display: none; }
.history-list { gap: 1px; padding: 0 0 10px; }
.history-group-label { margin: 12px 10px 4px; color: var(--subtle); font-size: 11px; font-weight: 600; }
.history-group-label:first-child { margin-top: 3px; }
.history-item { min-height: 34px; padding: 2px 35px 2px 10px; border: 0; border-radius: 10px; }
.history-item::before { display: none; }
.history-item:hover, .history-item.active { border: 0; background: var(--surface-hover); transform: none; }
.history-item-title { min-height: 30px; gap: 0; }
.history-title-text { font-size: 13px; font-weight: 450; line-height: 1.4; }
.history-meta { display: none; }
.history-delete { right: 3px; width: 28px; height: 28px; border-radius: 8px; }
.sidebar-bottom { margin: 0; padding: 7px 0 0; border-top-color: color-mix(in srgb, var(--line) 55%, transparent); }
.sidebar-profile { display: flex; align-items: center; gap: 2px; }
.sidebar-account { display: flex; min-width: 0; min-height: 44px; flex: 1; align-items: center; gap: 9px; padding: 5px 7px; border: 0; border-radius: 11px; background: transparent; color: var(--text); text-align: left; }
.sidebar-account:hover, .sidebar-settings:hover { background: var(--surface-hover); }
.sidebar-avatar { display: grid; width: 29px; height: 29px; flex: 0 0 29px; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; font-weight: 750; }
.sidebar-account-copy { display: grid; min-width: 0; flex: 1; }
.sidebar-account-copy strong, .sidebar-account-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account-copy strong { font-size: 12.5px; font-weight: 600; }
.sidebar-account-copy small { color: var(--subtle); font-size: 10px; }
.sidebar-settings { width: 34px; height: 34px; flex-basis: 34px; border-radius: 9px; color: var(--muted); }
.sidebar-settings svg { width: 17px; height: 17px; }
.topbar { padding: 7px 16px; }
@media (min-width: 801px) { .topbar .account-button { display: none; } }
.workspace { background: var(--bg); }
.welcome { display: flex; width: min(720px, calc(100% - 36px)); margin-top: clamp(130px, 24vh, 245px); flex-direction: column; align-items: center; justify-content: center; gap: 11px; }
.welcome-brand-lockup { display: flex; align-items: center; justify-content: center; gap: 17px; }
.welcome-logo-wrap { position: relative; display: grid; width: 68px; height: 68px; margin: 0; padding: 5px; place-items: center; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line)); border-radius: 15px; background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .12), 0 0 0 4px color-mix(in srgb, var(--accent) 7%, transparent); }
.welcome-logo-wrap::after { position: absolute; right: -4px; bottom: -4px; width: 13px; height: 13px; border: 3px solid var(--bg); border-radius: 50%; background: var(--accent); content: ""; }
.welcome-logo { display: block; width: 100%; height: 100%; border-radius: 9px; object-fit: contain; }
.welcome-title-group { display: grid; gap: 1px; text-align: left; }
.welcome-school-name { color: var(--accent-text); font-size: 11px; font-weight: 800; letter-spacing: .13em; line-height: 1.2; text-transform: uppercase; }
.welcome-hello { display: none; }
.welcome h1 { margin: 0; font-size: clamp(34px, 3vw, 44px); font-weight: 700; letter-spacing: -.045em; line-height: 1.08; }
.welcome-tagline { margin: 0; color: var(--muted); font-size: 14px; font-weight: 450; letter-spacing: .01em; }
.workspace:not(.has-messages) .composer-area { top: clamp(365px, calc(24vh + 220px), 520px); }
.composer { width: min(100%, 720px); min-height: 72px; align-items: flex-end; padding: 12px 10px 8px 14px; border-radius: 24px; background: color-mix(in srgb, var(--surface-soft) 76%, var(--surface)); box-shadow: 0 10px 32px rgba(18, 18, 22, .08); }
.composer textarea { min-height: 44px; padding: 8px 5px; }
.pending-image { width: min(100%, 720px); }
.suggestion-row { width: min(100%, 610px); margin-top: 24px; }
.suggestion-row::before { margin: 0 11px 5px; color: var(--subtle); font-size: 11px; font-weight: 650; content: "✦  Suggested"; }
.suggestion-row button { min-height: 46px; align-items: flex-start; padding: 7px 11px; font-size: 14px; }
.suggestion-row button span { font-weight: 560; }
.disclaimer { margin-top: 18px; }
.assistant-head { color: var(--text); font-weight: 600; }
.answer-content { font-size: 15px; line-height: 1.72; }
.answer-content h2 { border-bottom: 0; }
.answer-content h3 { padding-left: 0; }
.answer-content h3::before { display: none; }
.user-bubble { border-radius: 18px; background: var(--surface-soft); }
.answer-actions button { min-height: 36px; }

.app-shell.sidebar-collapsed .sidebar-profile { justify-content: center; }
.app-shell.sidebar-collapsed .sidebar-account-copy,
.app-shell.sidebar-collapsed .sidebar-settings,
.app-shell.sidebar-collapsed .search-chats-button span { display: none; }
.app-shell.sidebar-collapsed .sidebar-account { flex: 0 0 42px; justify-content: center; padding: 5px; }
.app-shell.sidebar-collapsed .search-chats-button { justify-content: center; padding: 0; }
.app-shell.sidebar-collapsed .history-search-panel { display: none; }

html[data-theme="dark"] .sidebar { background: #0e0e0e; }
html[data-theme="dark"] .workspace { background: #171717; }
html[data-theme="dark"] .composer { background: #212121; border-color: #343434; box-shadow: 0 12px 34px rgba(0,0,0,.24); }

@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
@keyframes app-enter { from { opacity: 0; transform: translateY(-7px); } }
@keyframes composer-enter { from { opacity: 0; } }
@keyframes install-nudge { from { opacity: 0; } to { opacity: 1; } }
@keyframes status-enter { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes video-loading { to { background-position: -220% 0; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes thinking-spin { to { transform: rotate(360deg); } }
@keyframes thinking-pulse { 0%, 100% { opacity: .55; scale: .85; } 50% { opacity: 1; scale: 1.08; } }
@keyframes thinking-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 800px) {
  :root { --topbar: 58px; }
  body { overflow: hidden; }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 320px) !important;
    transform: translateX(-102%);
    flex-basis: auto !important;
    padding-top: max(14px, env(safe-area-inset-top));
  }
  .app-shell.drawer-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-collapsed .brand-name,
  .app-shell.sidebar-collapsed .new-chat-button span,
  .app-shell.sidebar-collapsed .sidebar-action span,
  .app-shell.sidebar-collapsed .history-section,
  .app-shell.sidebar-collapsed .privacy-note { display: initial; }
  .app-shell.sidebar-collapsed .sidebar-top { flex-direction: row; }
  .app-shell.sidebar-collapsed .new-chat-button,
  .app-shell.sidebar-collapsed .sidebar-action { justify-content: flex-start; padding: 0 14px; }
  .app-shell.sidebar-collapsed .sidebar-account-copy,
  .app-shell.sidebar-collapsed .sidebar-settings { display: grid; }
  .app-shell.sidebar-collapsed .sidebar-profile { justify-content: initial; }
  .app-shell.sidebar-collapsed .sidebar-account { flex: 1; justify-content: flex-start; padding: 5px 7px; }
  .app-shell.sidebar-collapsed .search-chats-button span { display: inline; }
  .collapse-button { display: none; }
  .drawer-backdrop { position: fixed; z-index: 29; inset: 0; border: 0; background: rgba(20,19,29,.4); }
  .app-shell.drawer-open .drawer-backdrop { display: block; }
  .topbar { justify-content: space-between; padding: max(6px, env(safe-area-inset-top)) 10px 4px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); }
  body.app-ready .topbar { animation: app-enter 260ms ease both; }
  body.app-ready .composer-area { animation: composer-enter 300ms 40ms cubic-bezier(.2,.8,.2,1) both; }
  body.app-ready .suggestion-row button { animation: arrive 260ms ease both; }
  body.app-ready .suggestion-row button:nth-child(2) { animation-delay: 45ms; }
  body.app-ready .suggestion-row button:nth-child(3) { animation-delay: 90ms; }
  .mobile-menu { display: inline-grid; }
  .mobile-brand, .assistant-head { display: none; }
  .context-pill { display: none; }
  .conversation {
    padding: calc(var(--topbar) + 16px) 16px calc(var(--composer-height) + 24px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-padding: calc(var(--topbar) + 14px) 0 calc(var(--composer-height) + 24px);
    scrollbar-width: none;
    touch-action: pan-y;
  }
  .conversation::-webkit-scrollbar { display: none; }
  .message-list { padding-bottom: 2px; }
  .message { margin-bottom: 30px; scroll-margin-top: calc(var(--topbar) + 14px); }
  .user-bubble { max-width: 90%; padding: 11px 15px; border-radius: 20px 20px 5px 20px; font-size: 15px; line-height: 1.5; }
  .answer-content { font-size: 15.5px; line-height: 1.72; }
  .answer-content h1 { font-size: 1.34rem; }
  .answer-content h2 { font-size: 1.18rem; }
  .answer-content h3 { font-size: 1.04rem; }
  .welcome { margin-top: clamp(72px, 14vh, 120px); }
  .welcome-brand-lockup { gap: 13px; }
  .welcome-logo-wrap { width: 61px; height: 61px; margin: 0; padding: 4px; }
  .welcome h1 { font-size: clamp(29px, 8vw, 36px); }
  .welcome-school-name { font-size: 9px; }
  .welcome-tagline { font-size: 13px; }
  .message { margin-bottom: 28px; }
  .user-bubble { max-width: 88%; }
  .composer-area {
    position: absolute;
    padding: 18px 10px max(8px, env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, transparent, var(--bg) 18px, var(--bg) 100%);
  }
  .composer-area:focus-within { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .workspace:not(.has-messages) .composer-area { top: auto; bottom: 0; }
  .composer { min-height: 56px; align-items: flex-end; padding: 6px 7px 6px 11px; border-radius: 24px; box-shadow: 0 8px 28px rgba(18, 24, 21, .08); }
  .composer textarea { max-height: 96px; padding: 9px 4px; font-size: 16px; line-height: 1.42; scrollbar-width: thin; }
  .composer.is-expanded {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 2px 5px;
    padding: 8px 7px 7px;
    border-radius: 22px;
  }
  .composer.is-expanded textarea {
    grid-column: 1 / -1;
    width: 100%;
    padding: 3px 7px 2px;
  }
  .composer.is-expanded .attach-button { grid-column: 1; }
  .composer.is-expanded .composer-controls { grid-column: 3; justify-self: end; }
  .composer.has-text:not(.is-expanded) #cameraButton { display: none; }
  .scroll-latest:not([hidden]) {
    position: absolute;
    z-index: 18;
    right: 50%;
    bottom: calc(var(--composer-height) + 8px);
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    color: var(--muted);
    box-shadow: 0 8px 24px rgba(12, 18, 15, .16);
    backdrop-filter: blur(12px);
    transform: translateX(50%);
    animation: arrive 160ms ease both;
  }
  .scroll-latest svg { width: 19px; height: 19px; }
  .scroll-latest:active { transform: translateX(50%) scale(.94); }
  .workspace:not(.has-messages) .scroll-latest { display: none; }
  .input-hint, .disclaimer { display: none; }
  .suggestion-row { width: calc(100% + 24px); margin-top: 8px; padding: 0 12px; justify-content: flex-start; }
  .suggestion-row button { min-height: 44px; }
  .tool-indicator { width: 100%; }
  .video-card { grid-template-columns: 112px 1fr; }
  .video-loading-row { gap: 7px; }
  .video-loading-row span { min-height: 62px; }
  .media-dialog-shell { padding:16px; }
  .crop-controls { grid-template-columns:1fr; gap:8px; }
  .media-actions { display:grid; grid-template-columns:1fr 1fr; }
  .media-actions .primary-button { grid-column:1 / -1; grid-row:1; }
  .flashcard { min-height:190px; padding:22px 18px; }
  .flashcard-controls { grid-template-columns:1fr 1fr; }
  .flashcard-controls button:nth-child(2) { grid-column:1 / -1; grid-row:1; }
  .video-thumb { min-height: 94px; }
  .video-reason { display: none; }
  .video-player { border-radius: 14px; }
  .video-play { width: 58px; height: 42px; }
  .video-section-heading span { display: none; }
  .answer-actions button { width: 44px; padding: 0; justify-content: center; }
  .answer-actions button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .document-panel { width: 100%; padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); border: 0; }
  .settings-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); }
  .settings-dialog form { max-height: calc(100dvh - 20px); padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr; }
  .admin-form-grid .full-field { grid-column: auto; }
  .admin-footer { align-items: stretch; flex-direction: column; }
  body:not(.auth-required) .account-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); }
  body:not(.auth-required) .account-dialog-body { max-height: calc(100dvh - 20px); padding: 16px; }
  .account-summary { grid-template-columns: 1fr; }
  .library-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); }
  .library-shell { max-height: calc(100dvh - 20px); padding: 16px; }
  .book-upload-form, .official-books > div { grid-template-columns: 1fr; }
  .account-dialog .dialog-footer { display: grid; grid-template-columns: 1fr 1fr; }
  .account-dialog .dialog-footer button { width: 100%; }
  .pwa-install-auth { top: 12px; right: 12px; width: 44px; height: 44px; min-height: 44px; justify-content: center; padding: 0; }
  .pwa-install-auth span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pwa-install-help { top: 62px; right: 12px; left: 12px; max-width: none; text-align: center; }
  .network-status { top: max(8px, env(safe-area-inset-top)); max-width: calc(100% - 24px); white-space: nowrap; }
  button, a { touch-action: manipulation; }
  .suggestion-row button:active, .answer-actions button:active, .history-item:active { transform: scale(.98); }
}

@media (min-width: 801px) and (max-height: 720px) {
  .welcome { margin-top: clamp(76px, 14vh, 108px); }
  .welcome-logo-wrap { width: 58px; height: 58px; margin: 0; padding: 4px; }
  .welcome h1 { font-size: clamp(28px, 3vw, 36px); }
  .workspace:not(.has-messages) .composer-area { top: 76vh; }
  .suggestion-row { margin-top: 10px; }
  .suggestion-row button { min-height: 36px; padding-block: 5px; }
  .disclaimer { margin-top: 6px; }
}

@media (max-width: 420px) {
  .composer-button { width: 38px; height: 38px; flex-basis: 38px; }
  .dialog-footer { flex-direction: column-reverse; }
  .dialog-footer button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .thinking-state, .thinking-label { transition: none !important; }
  .thinking-icon, .thinking-label { animation: none !important; }
  .thinking-label { background: none; color: var(--muted); -webkit-text-fill-color: currentColor; }
}

@media print {
  body { overflow: visible; background: white; color: black; }
  .sidebar, .topbar, .composer-area, .answer-actions, .drawer-backdrop { display: none !important; }
  .workspace { display: block; }
  .conversation { height: auto; overflow: visible; padding: 0; }
  .document-panel.open { position: static; display: block; width: 100%; padding: 0; border: 0; transform: none; }
  .document-panel.open .panel-header button, .document-panel.open .document-actions { display: none; }
  .document-content { min-height: 0; padding: 0; background: white; color: black; }
}
