/* Layout: icon rail | centered research column | context panel. Research answers are documents, not chat bubbles. */
:root {
  --bg: #0b0a1c;
  --bg-2: #120f28;
  --bg-3: #1a1636;
  --bg-4: #221c44;
  --fg: #f4f4f8;
  --fg-2: rgba(244, 244, 248, 0.66);
  --fg-3: rgba(244, 244, 248, 0.42);
  --fg-4: rgba(244, 244, 248, 0.24);
  --line: rgba(255, 255, 255, 0.12);
  --line-hi: rgba(255, 255, 255, 0.26);
  --glass: rgba(255, 255, 255, 0.06);
  --h1: #7c6cff;
  --h2: #ff6fb5;
  --h3: #5ee7ff;
  --h4: #ffb86b;
  --holo: linear-gradient(
    90deg,
    #7c6cff,
    #ff6fb5 35%,
    #ffb86b 55%,
    #5ee7ff 80%,
    #7c6cff
  );
  --font-sans:
    "Inter", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --rail: 76px;
  --ctx: 340px;
  color-scheme: dark;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
svg {
  display: block;
}
h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
p {
  margin: 0;
}
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
:focus-visible {
  outline: 1px solid var(--h3);
  outline-offset: 3px;
}
.holo-text {
  background: var(--holo);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: holo 8s linear infinite;
}
@keyframes holo {
  to {
    background-position: 200% 0;
  }
}
.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  z-index: 50;
  opacity: 0.03;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .7 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--bg);
  overflow: hidden;
}
.sky i {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.7;
  animation: sky 26s ease-in-out infinite alternate;
}
.sky i:nth-child(1) {
  width: 70vw;
  height: 70vw;
  left: -20vw;
  top: -30vw;
  background: #3a2ab8;
}
.sky i:nth-child(2) {
  width: 60vw;
  height: 60vw;
  right: -20vw;
  top: -10vw;
  background: #7e2a8c;
  animation-delay: -9s;
}
.sky i:nth-child(3) {
  width: 50vw;
  height: 50vw;
  left: 20vw;
  bottom: -25vw;
  background: #135c86;
  animation-delay: -17s;
  opacity: 0.55;
}
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 80% 60% at 50% 40%,
    transparent 40%,
    rgba(11, 10, 28, 0.7) 100%
  );
}
@keyframes sky {
  to {
    transform: translate(6%, 8%) scale(1.12);
  }
}

/* shell */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  height: 100%;
  padding-top: env(safe-area-inset-top, 0px);
}
.rail {
  border-right: 1px solid var(--line);
  background: rgba(11, 10, 28, 0.45);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 6px;
}
.rail .mark {
  width: 36px;
  height: 36px;
  margin-bottom: 14px;
}
.rail a,
.rail button {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--fg-3);
  position: relative;
  transition:
    background 0.2s,
    color 0.2s;
}
.rail a svg,
.rail button svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rail a:hover,
.rail button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
}
.rail a.on {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.rail a.on::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 2px;
  background: var(--holo);
  background-size: 100% 300%;
}
.rail .tip {
  position: absolute;
  left: 58px;
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 9px;
  border-radius: 8px;
  background: #1a1a22;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--fg);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.rail a:hover .tip,
.rail button:hover .tip {
  opacity: 1;
}
.rail .spacer {
  flex: 1;
}
.rail .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--holo);
  background-size: 200% 100%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #0a0a0f;
  margin-top: 6px;
}
.main {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}
.main.has-ctx {
  grid-template-columns: 1fr var(--ctx);
}
.col {
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding-bottom: 140px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 28px;
  background: linear-gradient(
    180deg,
    rgba(11, 10, 28, 0.85),
    rgba(11, 10, 28, 0)
  );
  font-size: 13px;
  color: var(--fg-3);
}
.topbar .crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.topbar .crumb b {
  color: var(--fg);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.topbar .status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5ee7ff;
  box-shadow: 0 0 10px #5ee7ff;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}
.topbar .acts {
  display: flex;
  gap: 6px;
}
.topbar .acts button {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 12.5px;
  transition:
    border-color 0.2s,
    color 0.2s;
}
.topbar .acts button:hover {
  border-color: var(--line-hi);
  color: var(--fg);
}
.inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 28px;
}

/* home view */
.home {
  padding-top: clamp(40px, 10vh, 120px);
}
.home .hi {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--fg-3);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}
.home .hi::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--holo);
}
.home h1 {
  font-size: clamp(34px, 4.6vw, 52px);
  line-height: 1.15;
  margin-top: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.home h1 span {
  display: block;
  font-size: 0.5em;
  font-weight: 500;
  color: var(--fg-2);
  margin-top: 10px;
  letter-spacing: 0;
}

/* ask bar */
.ask {
  position: relative;
  margin-top: 36px;
  border-radius: 22px;
  background: rgba(12, 9, 30, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 30px 80px -30px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(24px);
  transition: box-shadow 0.3s;
}
.ask::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 23px;
  padding: 1px;
  background: var(--holo);
  background-size: 200% 100%;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0.35;
  animation: holo 6s linear infinite;
  pointer-events: none;
  transition: opacity 0.3s;
}
.ask:focus-within {
  box-shadow:
    0 0 0 6px rgba(124, 108, 255, 0.12),
    0 30px 80px -30px rgba(0, 0, 0, 0.9);
}
.ask:focus-within::before {
  opacity: 1;
}
.ask textarea {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--fg);
  font: inherit;
  font-size: 17px;
  line-height: 1.55;
  padding: 20px 22px 8px;
  max-height: 200px;
  min-height: 64px;
}
.ask textarea::placeholder {
  color: var(--fg-4);
}
.ask .bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px 14px;
}
.ask .modes {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.ask .modes button {
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--fg-2);
  border-radius: 999px;
  transition:
    color 0.2s,
    background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ask .modes button[aria-pressed="true"] {
  color: #0a0a0f;
  background: #fff;
}
.ask .tools {
  display: flex;
  gap: 2px;
  margin-left: 4px;
}
.ask .tools button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--fg-3);
  display: grid;
  place-items: center;
  transition:
    background 0.2s,
    color 0.2s;
}
.ask .tools button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
}
.ask .tools svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ask .hint {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--fg-4);
  text-transform: uppercase;
}
.send {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: #fff;
  color: #0a0a0f;
  display: grid;
  place-items: center;
  flex: none;
  transition:
    transform 0.2s var(--ease),
    opacity 0.2s;
}
.send:hover {
  transform: scale(1.04);
}
.send[disabled] {
  opacity: 0.5;
  cursor: default;
  transform: none;
}
.send svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* suggestion cards */
.sug {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 22px;
}
.sug button {
  text-align: left;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(16px);
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.3s var(--ease);
}
.sug button:hover {
  border-color: var(--line-hi);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
}
.sug .ic {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex: none;
  background: rgba(8, 6, 24, 0.5);
}
.sug .ic svg {
  width: 16px;
  height: 16px;
  stroke: var(--fg);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sug b {
  display: block;
  font-weight: 500;
  font-size: 14.5px;
}
.sug span {
  display: block;
  color: var(--fg-3);
  font-size: 12.5px;
  margin-top: 3px;
}
.recent {
  margin-top: 44px;
}
.recent .h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--fg-3);
  margin-bottom: 12px;
}
.recent .h b {
  color: var(--fg);
  font-weight: 500;
  font-size: 14px;
}
.recent .list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.recent .list button {
  text-align: left;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(16px);
  min-width: 0;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.recent .list button:hover {
  border-color: var(--line-hi);
  background: rgba(255, 255, 255, 0.05);
}
.recent .list b {
  display: block;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent .list span {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--fg-4);
  text-transform: uppercase;
}
.recent .list span i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--holo);
}

/* thread view */
.thread {
  padding-top: 8px;
}
.q {
  padding: 28px 0 18px;
  border-bottom: 1px solid var(--line);
}
.q + .q {
  margin-top: 40px;
}
.q .qh {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.q h2 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex: 1;
  min-width: 0;
}
.q .tag {
  font-size: 11px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--holo);
  background-size: 200% 100%;
  color: #0a0a0f;
  font-weight: 600;
  margin-top: 8px;
  flex: none;
}
.steps {
  display: flex;
  gap: 6px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.steps span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-4);
  text-transform: uppercase;
  transition:
    color 0.3s,
    border-color 0.3s;
}
.steps span i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-4);
}
.steps span.on {
  color: #fff;
  border-color: rgba(94, 231, 255, 0.5);
}
.steps span.on i {
  background: #5ee7ff;
  box-shadow: 0 0 10px #5ee7ff;
}
.steps span.done {
  color: var(--fg-2);
}
.steps span.done i {
  background: #fff;
}
.ans {
  padding: 26px 0 0;
}
.ans .sec {
  margin-top: 22px;
}
.ans .sh {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--fg-3);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.ans .sh::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.pts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pt {
  display: flex;
  gap: 16px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--fg-2);
}
.pt b {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
  padding-top: 7px;
  flex: none;
  width: 22px;
}
.pt strong {
  color: #fff;
  font-weight: 600;
  margin-right: 6px;
}
.sum {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--fg);
  border-left: 2px solid transparent;
  border-image: var(--holo) 1;
  border-image-slice: 1;
  border-image-width: 0 0 0 2px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 6, 24, 0.45);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel .row {
  display: grid;
  grid-template-columns: 1fr 140px 44px;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  color: var(--fg-2);
}
.panel .row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel .row i {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}
.panel .row i::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--w, 0%);
  background: var(--holo);
  background-size: 300% 100%;
  border-radius: 3px;
  animation: holo 6s linear infinite;
  transition: width 1.2s var(--ease);
}
.panel .row em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  text-align: right;
}
.panel .note {
  font-size: 14px;
  line-height: 1.7;
  color: var(--fg-2);
}
.srcs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.srcs > div {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  min-width: 0;
  font-size: 13px;
  color: var(--fg-2);
}
.srcs > div > i {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--holo);
  background-size: 200% 100%;
  opacity: 0.85;
  flex: none;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #0a0a0f;
  font-weight: 600;
}
.srcs > div b {
  display: block;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.srcs > div span {
  display: block;
  font-size: 11px;
  color: var(--fg-4);
}
.follow {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.follow button {
  text-align: left;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
  color: var(--fg-2);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  transition: color 0.2s;
}
.follow button::after {
  content: "→";
  color: var(--fg-4);
}
.follow button:hover {
  color: #fff;
}
.doc {
  font-size: 16px;
  line-height: 1.8;
  color: var(--fg-2);
}
.doc p {
  margin: 0 0 12px;
}
.doc strong {
  color: #fff;
  font-weight: 600;
}
.doc .sh {
  margin-top: 22px;
}
.doc .dl {
  margin: 0 0 12px;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.doc code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}
.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #5ee7ff;
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.ans .acts {
  display: flex;
  gap: 6px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.ans .acts button {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-3);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition:
    color 0.2s,
    border-color 0.2s;
}
.ans .acts button:hover {
  color: var(--fg);
  border-color: var(--line-hi);
}
.ans .acts svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* bottom ask (thread view) */
.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 28px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    180deg,
    rgba(11, 10, 28, 0),
    rgba(11, 10, 28, 0.85) 40%
  );
  pointer-events: none;
  z-index: 6;
}
.dock .ask {
  pointer-events: auto;
  margin: 0 auto;
  max-width: 860px;
}
.dock .ask textarea {
  min-height: 0;
  padding: 14px 18px 4px;
  font-size: 15.5px;
}
.main.has-ctx .dock {
  right: var(--ctx);
}

/* context panel */
.ctx {
  display: none;
  border-left: 1px solid var(--line);
  background: rgba(11, 10, 28, 0.45);
  backdrop-filter: blur(20px);
  overflow-y: auto;
  padding: 22px 20px;
  flex-direction: column;
  gap: 22px;
}
.main.has-ctx .ctx {
  display: flex;
}
.ctx .ch {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--fg-3);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ctx .ch span {
  color: var(--fg-4);
}
.ctx .card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.025);
  font-size: 13px;
  color: var(--fg-2);
}
.ctx .card b {
  display: block;
  color: var(--fg);
  font-weight: 500;
  margin-bottom: 4px;
}
.ctx .kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.ctx .kv:last-child {
  border-bottom: 0;
}
.ctx .kv span {
  color: var(--fg-3);
}
.ctx .kv b {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--fg);
}
.ctx .export {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  font-size: 13.5px;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.ctx .export:hover {
  border-color: var(--line-hi);
  background: rgba(255, 255, 255, 0.07);
}
.ctx .export svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ctx .warn {
  font-size: 12px;
  color: var(--fg-4);
  line-height: 1.6;
}

/* library view */
.lib {
  padding-top: 40px;
}
.lib h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.lib .f {
  display: flex;
  gap: 6px;
  margin-top: 18px;
}
.lib .f button {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--fg-2);
}
.lib .f button.on {
  background: #fff;
  color: #0a0a0f;
  border-color: #fff;
}
.lib .rows {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
}
.lib .rows button {
  text-align: left;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 18px;
  align-items: center;
  padding: 16px 4px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  transition: color 0.2s;
}
.lib .rows button:hover {
  color: #fff;
}
.lib .rows button:last-child {
  border-bottom: 1px solid var(--line);
}
.lib .rows .t {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-4);
  text-transform: uppercase;
}
.lib .rows .g {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-3);
}

.view {
  display: none;
}
.view.on {
  display: block;
}
.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: up 0.7s var(--ease) forwards;
}
@keyframes up {
  to {
    opacity: 1;
    transform: none;
  }
}

/* mobile */
.tabs {
  display: none;
}
@media (max-width: 1279px) {
  .main.has-ctx {
    grid-template-columns: 1fr;
  }
  .main.has-ctx .ctx {
    display: none;
  }
  .main.has-ctx .dock {
    right: 0;
  }
}
@media (max-width: 767px) {
  :root {
    --rail: 0px;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  .rail {
    display: none;
  }
  .tabs {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: calc(58px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(11, 10, 28, 0.8);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--line);
  }
  .tabs a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    color: var(--fg-3);
  }
  .tabs a.on {
    color: #fff;
  }
  .tabs svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .inner {
    padding: 0 16px;
  }
  .topbar {
    padding: 12px 16px;
  }
  .topbar .acts {
    display: none;
  }
  .home {
    padding-top: 28px;
  }
  .home h1 {
    font-size: 30px;
  }
  .sug {
    grid-template-columns: 1fr;
  }
  .recent .list {
    grid-template-columns: 1fr;
  }
  .col {
    padding-bottom: 200px;
  }
  .dock {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    padding: 12px 12px 10px;
  }
  .ask .hint {
    display: none;
  }
  .ask textarea {
    font-size: 16px;
  }
  .ask .bar {
    flex-wrap: wrap;
  }
  .ask .modes button {
    white-space: nowrap;
    padding: 6px 10px;
    font-size: 12px;
  }
  .ask .tools {
    margin-left: 0;
  }
  .ask .send {
    margin-left: auto;
  }
  .panel .row {
    grid-template-columns: 1fr 90px 40px;
  }
  .srcs {
    grid-template-columns: 1fr;
  }
  .q h2 {
    font-size: 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}

/* Usability refinements */
[hidden] {
  display: none !important;
}
button,
a,
input,
textarea,
select {
  touch-action: manipulation;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #b9a1ff;
  outline-offset: 4px;
}
.q h2,
.doc,
.card {
  overflow-wrap: anywhere;
}
.doc a {
  color: #c0adff;
  text-decoration: underline;
}
.doc pre {
  overflow: auto;
  padding: 16px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
}
.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.doc td,
.doc th {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
}
.table-scroll {
  overflow: auto;
}
.privacy-note {
  color: var(--fg-2);
  font-size: 13px;
  margin: 16px 0;
}
.file-note {
  color: #cbbcff;
  font-size: 12px;
  margin: 8px 0;
}
.error-note {
  border: 1px solid #9e6472;
  padding: 16px;
  border-radius: 12px;
  color: #f5c7d0;
}
.stop-btn,
#clearHistory,
#privacyBtn,
.mode-select {
  background: #211b38;
  color: #eee;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.stop-btn {
  margin: 8px 0;
}
.mode-select {
  display: none;
  max-width: 150px;
}
#historySearch {
  background: transparent;
  border: 1px solid var(--line);
  padding: 10px;
  color: var(--fg);
  border-radius: 8px;
  width: min(100%, 320px);
  margin: 10px 8px 14px 0;
}
.empty {
  padding: 20px;
  color: var(--fg-2);
}
dialog {
  max-width: 480px;
  width: calc(100% - 32px);
  margin: auto;
  background: #181329;
  color: #eee;
  border: 1px solid #665583;
  border-radius: 18px;
  padding: 26px;
}
dialog p {
  margin: 16px 0;
  line-height: 1.7;
  font-size: 14px;
}
dialog::backdrop {
  background: #0009;
}
dialog button {
  padding: 10px 20px;
  border-radius: 8px;
}
#toast {
  position: fixed;
  bottom: 190px;
  left: 50%;
  transform: translateX(-50%);
  background: #36274c;
  color: #fff;
  border: 1px solid #88709d;
  padding: 12px 18px;
  border-radius: 10px;
  z-index: 100;
  max-width: 90vw;
  font-size: 14px;
}
.status {
  font-size: 11px;
}
.ask .bar {
  gap: 6px;
}
@media (max-width: 600px) {
  .ask .modes {
    display: none;
  }
  .mode-select {
    display: block;
  }
  .topbar {
    gap: 8px;
    flex-wrap: wrap;
  }
  .topbar .crumb {
    max-width: 52%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .status {
    margin-left: auto;
  }
  .ask .tools {
    margin-left: auto;
  }
  .q h2 {
    font-size: 20px;
  }
  .col {
    padding-bottom: 250px;
  }
  .rail {
    display: none;
  }
}
.ask .tools button {
  width: auto;
  min-width: 64px;
  white-space: nowrap;
  padding: 6px 10px;
  color: #c7beda;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rail #privacyBtn {
  font-size: 11px;
  padding: 8px 2px;
  white-space: nowrap;
}
.doc {
  color: #e0daed;
  line-height: 1.9;
}
.doc p {
  margin: 12px 0;
}
.doc .sh {
  font-size: 15px;
  color: #cec3ec;
}
.status {
  color: #a49ab7;
}
.ctx .warn {
  color: #aaa0bc;
}
.ask textarea::placeholder {
  color: #9386aa;
}
.recent .list span {
  color: #a89cb9;
}
.q .steps {
  font-size: 12px;
  color: #aaa0be;
  margin: 16px 0;
}
.sum a {
  color: #c8b7ff;
}

.doc h1,
.doc h2,
.doc h3,
.doc h4 {
  font-size: 17px;
  color: #f1e9ff;
  margin: 22px 0 12px;
  line-height: 1.5;
}
.doc blockquote {
  border-left: 3px solid #9d83dc;
  padding: 8px 14px;
  margin: 16px 0;
  background: #ffffff06;
}
.doc li {
  margin: 5px 0;
}
.doc pre {
  white-space: pre;
  tab-size: 2;
}
.context-note {
  font-size: 12px;
  color: #c5afd8;
  background: #36244380;
  padding: 10px;
  border-radius: 8px;
  margin: 12px 0;
}
.record-tools {
  display: flex;
  gap: 8px;
  margin: 8px 0 20px;
}
.record-tools button,
.utility-button,
.record-row > [data-rename],
.record-row > [data-delete],
.dialog-actions button {
  border: 1px solid var(--line);
  background: #2c2142;
  color: #e0d4f3;
  padding: 8px 12px;
  border-radius: 8px;
}
.record-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.record-row > [data-open] {
  flex: 1;
  min-width: 0;
}
.record-row > [data-rename],
.record-row > [data-delete] {
  flex: 0 0 auto;
  font-size: 12px;
}
.record-row [data-open] > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-tools {
  position: fixed;
  right: 24px;
  bottom: 164px;
  z-index: 25;
  display: flex;
  gap: 5px;
  padding: 6px;
  background: #171024e8;
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(12px);
}
.thread-tools button {
  font-size: 12px;
  padding: 6px 10px;
  color: #d5c7e9;
}
.ask.drag-over {
  outline: 2px dashed #c1a1f2;
  background: #2b1a43;
}
.document-warnings {
  color: #efc79a;
}
#documentDialog {
  max-width: 720px;
}
#documentText {
  width: 100%;
  resize: vertical;
  min-height: 200px;
  max-height: 40vh;
  background: #110c20;
  color: #ece6f6;
  font: 14px/1.7 var(--font-sans);
  border: 1px solid #67557e;
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
#confirmDocument {
  background: #8b63cc;
  color: white;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.thread-tools button:focus-visible {
  outline: 2px solid #b59adb;
}
@media (min-width: 1280px) {
  .thread-tools {
    right: calc(var(--ctx) + 24px);
  }
}
@media (max-width: 767px) {
  .thread-tools {
    right: 12px;
    bottom: calc(230px + env(safe-area-inset-bottom, 0px));
    gap: 2px;
    padding: 4px;
  }
  .thread-tools button {
    font-size: 11px;
    padding: 4px 6px;
  }
  .record-row {
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .record-row > [data-open] {
    flex: 1 1 100%;
  }
  .record-row .t {
    display: none;
  }
  .record-row > [data-rename],
  .record-row > [data-delete] {
    min-height: 36px;
  }
  dialog {
    max-height: 90dvh;
    overflow: auto;
  }
}
@media print {
  html,
  body {
    height: auto !important;
    overflow: visible !important;
    background: white !important;
    color: #111 !important;
  }
  .grain,
  .sky,
  .rail,
  .topbar,
  .tabs,
  .dock,
  .ctx,
  .thread-tools,
  #toast,
  .stop-generation,
  .q .acts,
  .view:not(.on) {
    display: none !important;
  }
  .shell,
  .main,
  .col,
  .inner,
  .thread {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .q {
    break-inside: auto;
    margin-bottom: 30px;
    border-bottom: 1px solid #ccc;
  }
  .q h2,
  .doc,
  .doc h1,
  .doc h2,
  .doc h3,
  .doc p,
  .doc li,
  .q .steps,
  .sum,
  .doc a {
    color: #111 !important;
  }
  .doc table,
  .doc th,
  .doc td {
    border-color: #aaa !important;
  }
  .doc a {
    text-decoration: underline;
  }
  .doc a[href]:after {
    content: " (" attr(href) ")";
    font-size: 10px;
    overflow-wrap: anywhere;
  }
  .doc pre {
    white-space: pre-wrap;
    background: #f4f4f4 !important;
  }
  .doc thead {
    display: table-header-group;
  }
  .q .tag {
    background: none;
    color: #444;
  }
  .table-scroll {
    overflow: visible;
  }
  .context-note {
    color: #333;
    background: #eee;
  }
  .sum {
    background: none;
    border-color: #aaa;
  }
}

@media print {
  html {
    color-scheme: light;
  }
  .error-note {
    color: #333 !important;
    border-color: #999 !important;
  }
}

.account-chip{font-size:12px;color:#d9c8ed;white-space:nowrap;padding:6px 10px;border:1px solid #ad89c940;border-radius:14px;max-width:250px;overflow:hidden;text-overflow:ellipsis}.site-notice{margin:12px 22px;padding:12px 16px;border:1px solid #a576bd70;border-radius:10px;background:#39234070;white-space:pre-wrap;color:#dfcceb;font-size:13px}@media(max-width:767px){.account-chip{max-width:180px;font-size:11px}.topbar .status{display:none}.topbar .account-chip{margin-left:auto}.site-notice{margin:10px 16px}}
