:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --surface-2: #f4f5f2;
  --rail: #f3f4f0;
  --ink: #1d2321;
  --ink-2: #3f4845;
  --muted: #6b7470;
  --faint: #959c98;
  --line: #e5e7e2;
  --line-strong: #d4d8d1;
  --accent: #FA463C;
  --accent-ink: #C42A1F;
  --accent-soft: #FEECE9;
  --accent-fill: #D63126;
  --accent-fill-hover: #B9271D;
  --link: #1a5f8f;
  --link-visited: #5b4a8a;
  --mark: #fff1b8;
  --mark-ink: #2a2410;
  --shadow: 0 1px 2px rgb(20 30 25 / 5%), 0 4px 16px rgb(20 30 25 / 6%);
  --shadow-pop: 0 8px 30px rgb(20 30 25 / 16%);
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ring: rgb(20 30 25 / 10%);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --rise: 4px;
  --pop: 0.96;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151817;
    --surface: #1c201f;
    --surface-2: #232826;
    --rail: #191c1b;
    --ink: #e9ecea;
    --ink-2: #c5cbc8;
    --muted: #9aa29e;
    --faint: #737b77;
    --line: #2c3230;
    --line-strong: #3a413e;
    --accent: #FF5A4F;
    --accent-ink: #FF8A80;
    --accent-soft: #3B1E1B;
    --accent-fill: #D63126;
    --accent-fill-hover: #E5392D;
    --link: #8ab8e6;
    --link-visited: #b9a6e8;
    --mark: #4b4116;
    --mark-ink: #fff3c4;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    --shadow-pop: 0 10px 34px rgb(0 0 0 / 50%);
    --ring: rgb(255 255 255 / 9%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151817;
  --surface: #1c201f;
  --surface-2: #232826;
  --rail: #191c1b;
  --ink: #e9ecea;
  --ink-2: #c5cbc8;
  --muted: #9aa29e;
  --faint: #737b77;
  --line: #2c3230;
  --line-strong: #3a413e;
  --accent: #FF5A4F;
  --accent-ink: #FF8A80;
  --accent-soft: #3B1E1B;
  --accent-fill: #D63126;
  --accent-fill-hover: #E5392D;
  --link: #8ab8e6;
  --link-visited: #b9a6e8;
  --mark: #4b4116;
  --mark-ink: #fff3c4;
  --ring: rgb(255 255 255 / 9%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h, 58px) + 56px); -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button, a, label, select, summary { touch-action: manipulation; }
button, .filters, .suggestions, .scope-switch, .ai-toggle { user-select: none; -webkit-user-select: none; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
kbd { font-family: var(--sans); font-size: 11px; color: var(--faint); border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.subtle { display: block; color: var(--muted); font-size: 12px; }

/* Source icons */
.src-icon {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 18px; height: 18px; border-radius: 5px;
  font: 700 10px/1 var(--sans); font-style: normal; color: #fff;
  background: #7c8580;
}
.src-gdrive { background: #1f8f4e; }
.src-notion { background: #2b2b2b; }
.src-slack { background: #611f69; }
.src-telegram { background: #2a9bd8; }
.src-tape { background: #d9692b; }
.src-web { background: #4a6fa5; }
:root[data-theme="dark"] .src-notion { background: #5a5a5a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .src-notion { background: #5a5a5a; } }

/* Rail */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w, 244px);
  background: var(--rail); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 650; font-size: 19px; letter-spacing: -.3px; padding: 4px 8px 14px; }
.brand svg { width: 26px; height: 26px; color: var(--accent); stroke-width: 2; }
.brand-mobile { display: none; }
.new-search {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 10px;
  background: var(--surface); font-size: 14px; font-weight: 550; box-shadow: 0 0 0 1px var(--ring), 0 1px 2px rgb(0 0 0 / 4%);
}
.new-search kbd { margin-left: auto; }
.history-section { margin-top: 18px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.history-heading { display: flex; align-items: center; padding: 0 8px 6px; }
.history-heading h2 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 auto 0 0; letter-spacing: .2px; }
#clear-history { font-size: 12px; color: var(--muted); padding: 2px 4px; }
#close-history { display: none; }
#history { overflow-y: auto; min-height: 0; }
.history-row { display: flex; align-items: center; border-radius: 8px; }
.history-entry { flex: 1; min-width: 0; text-align: left; padding: 7px 8px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 8px; }
.history-entry.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 550; }
.history-remove { opacity: 0; width: 26px; height: 26px; color: var(--muted); border-radius: 6px; font-size: 16px; }
.history-remove:focus-visible { opacity: 1; }
.history-empty, .history-note { font-size: 12px; color: var(--faint); padding: 6px 8px; margin: 0; }
.account { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; text-align: left; font-size: 13px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-fill); color: #fff; font-weight: 650; font-size: 13px; }

/* Main */
main { margin-left: var(--rail-w, 244px); min-height: 100vh; min-height: 100dvh; --gutter: 24px; --col: max(var(--gutter), calc((100% - 720px) / 2)); }
.topbar { display: flex; align-items: center; justify-content: flex-end; height: 52px; padding: 0 24px; }
#toggle-history { display: none; color: var(--ink-2); padding: 8px; margin-left: -8px; }
.private { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.private .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.search-area { width: min(720px, calc(100% - 48px)); margin: 14vh auto 0; }
.intro { text-align: center; margin-bottom: 26px; }
h1 { font-size: 34px; font-weight: 650; letter-spacing: -.8px; line-height: 1.2; margin: 0 0 10px; }
.intro p { margin: 0; color: var(--muted); font-size: 15.5px; }

#search-form {
  background: var(--surface); border: 0; border-radius: 18px;
  padding: 8px 8px 8px 16px; box-shadow: 0 0 0 1px var(--ring), var(--shadow); transition: box-shadow 150ms ease;
}
#search-form:focus-within { box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent), var(--shadow); }
.search-box { display: flex; align-items: center; gap: 10px; }
.search-icon { color: var(--faint); width: 20px; height: 20px; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 17px; padding: 10px 0; }
.search-box input::placeholder { color: var(--faint); }
.search-box input::-webkit-search-cancel-button { display: none; }
#clear-query { display: grid; place-items: center; width: 32px; height: 32px; color: var(--muted); border-radius: 50%; }
#submit { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--accent-fill); color: #fff; }
.search-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 4px 2px 0; }
.scope-switch { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.scope-switch button { padding: 4px 12px; border-radius: 7px; font-size: 13px; color: var(--muted); }
.scope-switch button.selected { background: var(--surface); color: var(--ink); font-weight: 550; box-shadow: 0 1px 2px rgb(0 0 0 / 10%); }
.ai-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.ai-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 30px; height: 18px; border-radius: 10px; background: var(--line-strong); position: relative; transition: background-color 160ms ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 160ms var(--ease-out); box-shadow: 0 1px 2px rgb(0 0 0 / 25%); }
.ai-toggle input:checked + .switch { background: var(--accent); }
.ai-toggle input:checked + .switch::after { transform: translateX(12px); }
.ai-toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.suggestions button { padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; color: var(--ink-2); }
.home-footer { margin-top: 56px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.home-footer > span { font-size: 12px; color: var(--faint); }
.source-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; font-size: 13px; color: var(--muted); }
.source-badges span { display: inline-flex; align-items: center; gap: 6px; }

/* Results mode */
.searching .intro, .searching .suggestions, .searching .home-footer { display: none; }
.searching .topbar { display: none; }
.searching .search-area {
  position: sticky; top: 0; z-index: 10; width: auto; margin: 0;
  padding: 14px var(--col) 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
}
.searching #search-form { max-width: 720px; border-radius: 14px; padding: 4px 6px 4px 14px; box-shadow: 0 0 0 1px var(--ring), 0 1px 3px rgb(0 0 0 / 5%); }
.searching .search-box input { font-size: 16px; padding: 8px 0; }
.searching #submit { width: 34px; height: 34px; }
.searching .search-options { display: flex; }
.answer-capability { margin: 6px 0 2px; font-size: 12px; line-height: 1.5; color: var(--muted); }

.results-area { padding: 0 0 80px; }
.filters {
  position: sticky; top: var(--header-h, 58px); z-index: 9; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  padding: 6px var(--col) 0;
}
.filters::-webkit-scrollbar { display: none; }
.filters button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px 10px; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.filters button .src-icon { width: 15px; height: 15px; font-size: 8.5px; border-radius: 4px; }
.filters button.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

.content { padding: 18px var(--col) 0; }

/* Answer */
.answer-panel { padding: 4px 0 26px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.answer-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.answer-heading h2 { margin: 0; font-size: 17px; font-weight: 650; }
.spark { color: var(--accent); width: 20px; height: 20px; fill: color-mix(in srgb, var(--accent) 20%, transparent); }
.answer-badge { font-size: 10.5px; font-weight: 650; letter-spacing: .4px; color: var(--accent-ink); background: var(--accent-soft); padding: 2px 6px; border-radius: 5px; }
.answer-tools { margin-left: auto; display: flex; gap: 4px; }
.answer-tools button { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); padding: 5px 9px; border-radius: 8px; border: 1px solid transparent; }
.answer-tools svg { width: 15px; height: 15px; }
#stop { border-color: var(--line-strong); }

.source-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.source-strip:empty { display: none; }
.strip-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px; min-height: 76px;
  padding: 10px 11px; text-align: left; background: var(--surface-2); border: 1px solid transparent; border-radius: 10px;
  transition: background-color 150ms ease, border-color 150ms ease, transform 160ms var(--ease-out);
}
.strip-card.lit { background: var(--surface); border-color: var(--line-strong); }
.strip-title { font-size: 12.5px; line-height: 1.35; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.strip-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); min-width: 0; }
.strip-meta .src-icon { width: 14px; height: 14px; font-size: 8px; border-radius: 4px; }
.strip-meta span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-num { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--faint); }
.strip-more { align-items: flex-start; }
.strip-more .stack { display: flex; }
.strip-more .stack .src-icon { margin-right: -4px; box-shadow: 0 0 0 2px var(--surface-2); }

.answer-status { margin: 0 0 6px; font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.answer-status:empty { display: none; }
.answer-status.loading::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.answer-skeleton { display: grid; gap: 10px; padding: 6px 0; }
.answer-skeleton span { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.answer-skeleton span:nth-child(2) { width: 92%; }
.answer-skeleton span:nth-child(3) { width: 64%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.answer-body { font-size: 16px; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.answer-body > :first-child { margin-top: 0; }
.answer-body p { margin: 0 0 12px; }
.answer-body h3 { font-size: 16px; font-weight: 650; margin: 18px 0 6px; }
.answer-body ul, .answer-body ol { margin: 0 0 12px; padding-left: 22px; }
.answer-body li { margin: 0 0 6px; padding-left: 2px; }
.answer-body li::marker { color: var(--faint); }
.answer-body strong { font-weight: 650; }
.answer-body code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.answer-body.streaming > :last-child:not(ul, ol)::after, .answer-body.streaming > :is(ul, ol):last-child > li:last-child::after { content: ""; display: inline-block; width: 7px; height: 15px; margin-left: 3px; vertical-align: -2px; background: var(--accent); border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.cite {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin: 0 1px;
  vertical-align: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted); font-size: 10.5px; font-weight: 600; line-height: 1; text-decoration: none; font-variant-numeric: tabular-nums;
}
.cite:focus-visible { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.answer-foot { margin: 14px 0 0; font-size: 12px; color: var(--faint); }

.cite-card {
  position: fixed; z-index: 50; width: 320px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--ring), var(--shadow-pop); pointer-events: none;
  transform-origin: var(--origin, 50% 0); transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
@starting-style { .cite-card { opacity: 0; transform: scale(0.97); } }
.cite-card[data-instant] { transition-duration: 0ms; }
.cite-card .strip-meta { margin-bottom: 6px; }
.cite-card b { display: block; font-size: 14px; line-height: 1.35; margin-bottom: 5px; }
.cite-card p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* Result list */
.result-meta { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 13px; color: var(--muted); }
.sort-control { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.sort-control select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 8px; font-size: 13px; color: var(--ink); }
.notice, .query-context { font-size: 13.5px; line-height: 1.55; margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); }

#results { display: flex; flex-direction: column; }
.result { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 18px; padding: 16px 0 18px; border-bottom: 1px solid var(--line); }
.result:last-child { border-bottom: 0; }
.result-main { min-width: 0; }
.result-source { display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 4px; }
.result-source > .src-icon { width: 26px; height: 26px; border-radius: 8px; font-size: 12px; }
.src-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.src-name { font-size: 13.5px; color: var(--ink); font-weight: 500; }
.src-path { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-num { margin-left: auto; align-self: flex-start; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.result h3 { margin: 4px 0 4px; font-size: 19px; font-weight: 500; line-height: 1.35; letter-spacing: -.1px; overflow-wrap: anywhere; }
.result-title { color: var(--link); text-align: left; line-height: inherit; }
.result-title.seen { color: var(--link-visited); }
.snippet { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.snippet-date { color: var(--muted); }
mark { background: transparent; color: var(--ink); font-weight: 650; }
.result-actions { display: flex; align-items: center; gap: 4px; margin-top: 8px; margin-left: -8px; }
.result-actions button, .result-actions a { font-size: 12.5px; color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: 7px; }
.result-image { grid-column: 2; grid-row: 1; align-self: center; width: 112px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: zoom-in; }
.image-unavailable { grid-column: 2; font-size: 11px; color: var(--faint); width: 112px; }
.empty { padding: 40px 0; text-align: center; color: var(--muted); font-size: 15px; }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; font-weight: 600; }
.skeleton { height: 108px; padding: 16px 0; border-bottom: 1px solid var(--line); display: grid; gap: 9px; align-content: start; }
.skeleton span { height: 11px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton span:nth-child(1) { width: 28%; }
.skeleton span:nth-child(2) { width: 62%; height: 16px; }
.skeleton span:nth-child(3) { width: 94%; }
.skeleton span:nth-child(4) { width: 80%; }

/* Dialogs */
dialog {
  border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring), var(--shadow-pop); padding: 0;
  opacity: 0; transform: scale(var(--pop));
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out), overlay 150ms allow-discrete, display 150ms allow-discrete;
}
dialog[open] { opacity: 1; transform: none; transition-duration: 220ms; }
@starting-style { dialog[open] { opacity: 0; transform: scale(var(--pop)); } }
dialog::backdrop { background: rgb(15 20 18 / 45%); opacity: 0; transition: opacity 150ms ease, overlay 150ms allow-discrete, display 150ms allow-discrete; }
dialog[open]::backdrop { opacity: 1; transition-duration: 220ms; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }
#login { width: min(400px, calc(100% - 32px)); }
#login-form { padding: 30px; }
.dialog-mark svg { width: 34px; height: 34px; color: var(--accent); stroke-width: 2; }
#login h2 { font-size: 22px; margin: 12px 0 6px; letter-spacing: -.3px; }
#login p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
#login label { font-size: 13px; font-weight: 550; display: block; margin-bottom: 6px; }
#login input { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); outline: 0; }
#login input:focus { border-color: var(--accent); }
#login-error { color: #c0392b !important; min-height: 20px; margin: 8px 0 !important; font-size: 13px !important; }
.primary { width: 100%; padding: 11px; border-radius: 10px; background: var(--accent-fill); color: #fff; font-weight: 600; }

.preview-dialog { width: min(820px, calc(100% - 32px)); max-height: 88vh; padding: 0 28px 22px; }
.preview-toolbar { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 10px; background: var(--surface); font-size: 12.5px; color: var(--muted); z-index: 1; }
#close-preview { width: 32px; height: 32px; border-radius: 50%; font-size: 15px; color: var(--muted); flex-shrink: 0; }
.preview-dialog h2 { font-size: 22px; line-height: 1.35; letter-spacing: -.3px; margin: 0 0 16px; font-weight: 650; }
#preview-content { font-size: 15px; line-height: 1.7; color: var(--ink-2); }
#preview-content p { margin: 0 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
#preview-content mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; padding: 0 2px; font-weight: 500; }
.preview-zoom { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; }
.preview-image-frame { margin: 12px 0 20px; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.preview-image-frame img { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto; object-fit: contain; cursor: zoom-in; }
.preview-image-frame.zoomed { overflow: auto; max-height: 70vh; }
.preview-image-frame.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
.preview-footer { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 20px; display: flex; justify-content: space-between; gap: 16px; font-size: 12.5px; color: var(--muted); }
.preview-footer a { color: var(--link); white-space: nowrap; text-decoration: none; font-weight: 550; }


/* Hover only where the pointer can hover; touch keeps :active feedback */
@media (hover: hover) and (pointer: fine) {
  .new-search:hover { box-shadow: 0 0 0 1px var(--accent), 0 1px 2px rgb(0 0 0 / 4%); }
  #clear-history:hover { color: var(--ink); }
  .history-row:hover { background: var(--surface-2); }
  .history-row:hover .history-remove { opacity: 1; }
  .history-remove:hover { color: var(--ink); }
  .account:hover { background: var(--surface-2); }
  #clear-query:hover { background: var(--surface-2); color: var(--ink); }
  #submit:hover { background: var(--accent-fill-hover); }
  .suggestions button:hover { border-color: var(--accent); color: var(--accent-ink); }
  .filters button:hover { color: var(--ink); }
  .answer-tools button:hover { background: var(--surface-2); color: var(--ink); }
  .strip-card:hover { background: var(--surface); border-color: var(--line-strong); }
  .strip-more:hover .stack .src-icon { box-shadow: 0 0 0 2px var(--surface); }
  .cite:hover { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
  .result-title:hover { text-decoration: underline; text-underline-offset: 3px; }
  .result-actions button:hover, .result-actions a:hover { background: var(--surface-2); color: var(--ink); }
  #close-preview:hover { background: var(--surface-2); color: var(--ink); }
  .preview-footer a:hover { text-decoration: underline; }
}

/* Press feedback: instant confirmation that the UI heard the tap */
#submit, .new-search, .strip-card, .suggestions button, .primary, .scope-switch button,
.answer-tools button, .result-actions button, .result-actions a, #clear-query, #close-preview, .preview-zoom {
  transition: transform 160ms var(--ease-out), background-color 150ms ease, color 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
#submit:active, .new-search:active, .strip-card:active, .suggestions button:active, .primary:active, .scope-switch button:active,
.answer-tools button:active, .result-actions button:active, .result-actions a:active, #clear-query:active, #close-preview:active, .preview-zoom:active {
  transform: scale(0.97);
}
#status, .result-meta { font-variant-numeric: tabular-nums; }

/* Results arrive with a short cascade so the eye reads top-down; JS caps the index so late items never wait */
.rise { animation: rise 200ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); }
@keyframes rise { from { opacity: 0; transform: translateY(var(--rise)); } }

/* Mobile drawer + scrim */
.scrim { display: none; }
@media (max-width: 760px) {
  .history-open .rail { transform: none; transition: transform 260ms var(--ease-drawer); }
  @starting-style { .history-open .rail { transform: translateX(-100%); } }
  .history-open .scrim { display: block; position: fixed; inset: 0; z-index: 19; background: rgb(15 20 18 / 35%); opacity: 1; transition: opacity 200ms ease; }
  @starting-style { .history-open .scrim { opacity: 0; } }
  #history { overscroll-behavior: contain; }
  .rail { padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}
@media (pointer: coarse) {
  .sort-control select, #login input { font-size: 16px; }
}

/* Collapsible rail (desktop). Instant on purpose: width changes force layout, and this is a mouse/shortcut toggle */
.rail-top { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; }
.rail-top .brand { padding-bottom: 4px; padding-top: 4px; }
.rail-toggle { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); transition: transform 160ms var(--ease-out), background-color 150ms ease, color 150ms ease; }
.rail-toggle:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .rail-toggle:hover { background: var(--surface-2); color: var(--ink); } }
@media (min-width: 761px) {
  body.rail-collapsed { --rail-w: 60px; }
  .rail-collapsed .rail { padding: 20px 10px; align-items: center; }
  .rail-collapsed .rail-top { flex-direction: column; gap: 10px; padding-bottom: 8px; }
  .rail-collapsed .rail-top .brand { padding: 4px 0; }
  .rail-collapsed .rail-top .brand span,
  .rail-collapsed .new-search span, .rail-collapsed .new-search kbd,
  .rail-collapsed .history-section, .rail-collapsed .account-text { display: none; }
  .rail-collapsed .new-search { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .rail-collapsed .account { margin-top: auto; padding: 5px; }
  .rail-collapsed .history-section + .account, .rail-collapsed .account { margin-top: auto; }
}

/* Answer elapsed timer: ticks while working, then settles to the total */
.answer-timer { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.answer-timer.running { color: var(--accent-ink); }

/* Answer language selector */
.option-group { display: inline-flex; align-items: center; gap: 14px; }
.lang-select select {
  appearance: none; -webkit-appearance: none; border: 0; background: var(--surface-2); color: var(--ink-2);
  font-size: 13px; padding: 4px 24px 4px 10px; border-radius: 8px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) 52%, calc(100% - 9px) 52%; background-size: 4px 4px; background-repeat: no-repeat;
}
.lang-select select:disabled { opacity: .45; cursor: default; }
@media (pointer: coarse) { .lang-select select { font-size: 16px; } }
@media (max-width: 420px) { .option-group { gap: 10px; } }

/* Responsive */
@media (max-width: 900px) {
  .source-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .rail { display: none; }
  .rail-top { display: none; }
  .history-open .rail { display: flex; width: min(300px, 86vw); box-shadow: var(--shadow-pop); }
  .history-open .rail .brand, .history-open .rail .new-search kbd { display: none; }
  #close-history { display: block; padding: 4px 6px; margin-left: 6px; color: var(--muted); }
  main { margin-left: 0; }
  .topbar { justify-content: space-between; padding: 0 16px; }
  #toggle-history { display: inline-grid; }
  .brand-mobile { display: inline-flex; padding: 0; font-size: 17px; margin-right: auto; margin-left: 6px; }
  .brand-mobile svg { width: 22px; height: 22px; }
  .searching .topbar { display: flex; height: 46px; }
  .search-area { width: calc(100% - 32px); margin-top: 8vh; }
  h1 { font-size: 27px; }
  .intro p { font-size: 14.5px; }
  main { --gutter: 16px; }
  .searching .search-area { padding-top: 6px; }
  .search-box input { font-size: 16px; }
  .result h3 { font-size: 17.5px; }
  .result-image { width: 84px; height: 64px; }
  .history-remove { opacity: 1; }
  .preview-dialog { padding: 0 18px 18px; }
  .cite-card { display: none !important; }
}
@media (max-width: 420px) {
  .source-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .private { display: none; }
}
/* Reduced motion: gentler, not zero. Keep fades, drop movement. */
@media (prefers-reduced-motion: reduce) {
  :root { --rise: 0px; --pop: 1; }
  .answer-skeleton span, .skeleton span { animation: none; }
  .history-open .rail { transition: none; }
  *:active { transform: none !important; }
}
@media (hover: none) { .history-remove { opacity: 1; } }

/* Design review follow-ups */
#status { white-space: nowrap; }
.answer-body { max-width: 64ch; }
.cite { transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease; }
.strip-title, .cite-card b { overflow-wrap: anywhere; }
.result-image { opacity: 0; transition: opacity 200ms ease; }
.result-image.loaded { opacity: 1; }
@media (max-width: 760px) {
  /* Keep results chrome short: scope and AI toggles return when the search box is focused */
  .searching #search-form:not(.expanded) .search-options { display: none; }
}

.google-sign-in { display: block; text-align: center; text-decoration: none; padding: 12px; border-radius: 8px; }
.google-sign-in[hidden] { display: none; }
