:root {
  color-scheme: light;
  --ink: #1c1c1a;
  --muted: #5e5e58;
  --line: #e3e1da;
  --paper: #fffcf7;
  --sidebar: #f6f4ee;
  --accent: #163a5f;
  --note: #f3f7f4;
  --warning: #fbf6ee;
  --shadow: 0 16px 40px rgba(28, 28, 26, 0.12);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}
a { color: var(--accent); }
button, input { font: inherit; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 16px;
  background: rgba(255, 252, 247, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand img { width: 28px; height: 28px; }
.menu {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
}
.search { position: relative; flex: 1; max-width: 420px; }
.search input, .composer input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
}
.search input:focus, .composer input:focus, .ask-open:focus-visible, .app-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  max-height: 320px;
  overflow: auto;
}
.results a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}
.results a:hover, .results a[aria-selected="true"] { background: var(--sidebar); }
.results small { display: block; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.app-link, .ask-open, .suggest, .send {
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
}
.ask-open, .send { background: var(--ink); color: #fff; border-color: var(--ink); }
.send:disabled, .composer input:disabled { opacity: 0.6; cursor: default; }

.layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.nav {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow: auto;
  padding: 18px 14px 32px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}
.group { margin: 0 0 16px; }
.group p {
  margin: 0 0 6px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav a {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.nav a:hover { background: rgba(0, 0, 0, 0.04); }
.nav a[aria-current="page"] { background: #fff; font-weight: 650; }

.page { padding: 36px 40px 80px; max-width: 820px; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 0.82rem; }
.page h1 { margin: 0 0 8px; font-size: 2rem; letter-spacing: -0.03em; line-height: 1.15; }
.lede { margin: 0 0 28px; color: var(--muted); font-size: 1.05rem; }
.prose h2 { margin: 2rem 0 0.6rem; font-size: 1.35rem; letter-spacing: -0.02em; }
.prose h3 { margin: 1.5rem 0 0.4rem; font-size: 1.08rem; }
.prose p, .prose ul, .prose ol { margin: 0.7rem 0; }
.prose li { margin: 0.25rem 0; }
.prose a { text-underline-offset: 2px; }
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.4rem; font-size: 0.95rem; }
.prose th, .prose td { border-bottom: 1px solid var(--line); text-align: left; padding: 8px 10px 8px 0; vertical-align: top; }
.prose pre {
  overflow: auto;
  background: #f4f3ee;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }
.prose blockquote { margin: 1rem 0; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 1rem 0 1.5rem; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.card:hover { border-color: var(--ink); }
.card a { color: inherit; font-weight: 650; text-decoration: none; }
.card a::after { content: ""; position: absolute; inset: 0; }
.card span { color: var(--muted); }
.note, .warning { margin: 1rem 0; padding: 12px 14px; border-radius: 12px; }
.note { background: var(--note); }
.warning { background: var(--warning); }
.note p:last-child, .warning p:last-child { margin-bottom: 0; }
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.pager a { color: inherit; text-decoration: none; }
.pager a:hover { text-decoration: underline; }

.ask {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  width: min(400px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 88px));
  display: none;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.ask.open { display: flex; }
.ask header, .composer { padding: 12px 14px; }
.ask header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.ask header p { margin: 2px 0 0; color: var(--muted); font-size: 0.82rem; }
.ask header button { border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; }
.thread { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 95%; padding: 10px 12px; border-radius: 12px; }
.bubble.user { align-self: flex-end; background: var(--ink); color: #fff; }
.bubble.assistant { align-self: flex-start; background: var(--sidebar); }
.bubble p { margin: 0.35rem 0; }
.bubble p:first-child { margin-top: 0; }
.bubble ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.bubble a { color: inherit; }
.suggests { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.suggest { border-radius: 12px; text-align: left; }
.composer { display: flex; gap: 8px; border-top: 1px solid var(--line); }
.composer input { border-radius: 12px; }
.error { color: #8a3b12; }

.logout { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px; }
.logout:hover { color: var(--ink); }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; }
.login-card h1 { margin: 12px 0 6px; font-size: 1.6rem; }
.login-card .lede { margin-bottom: 18px; }
.login-card label { display: block; margin: 12px 0 4px; font-size: 0.85rem; }
.login-card input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.login-card .send, .login-card .app-link { width: 100%; text-align: center; margin-top: 12px; }
.login-card .error { min-height: 1.2em; }
.brand-lock { display: flex; align-items: center; gap: 10px; font-weight: 650; }

@media (max-width: 860px) {
  .menu { display: inline-flex; }
  .layout { grid-template-columns: 1fr; }
  .nav {
    display: none;
    position: fixed;
    z-index: 25;
    top: 60px;
    left: 0;
    width: min(320px, 88vw);
    height: calc(100vh - 60px);
  }
  .nav.open { display: block; }
  .page { padding: 28px 18px 88px; }
  .cards { grid-template-columns: 1fr; }
  .app-link span { display: none; }
}
