/* Wiki Agent — Claude-inspired warm palette */

:root {
  --bg: #F9F7F2;
  --bg-sidebar: #F3EFE7;
  --bg-chat: #F6F2EA;
  --bg-elev: #FFFFFF;
  --bg-hover: rgba(0,0,0,0.04);
  --bg-active: rgba(217,119,87,0.10);
  --bg-selection: rgba(217,119,87,0.22);

  --ink: #2B2A27;
  --ink-2: #4A4843;
  --ink-3: #7A7770;
  --ink-4: #A8A49B;

  --line: #E7E1D4;
  --line-strong: #D7D0BF;

  --accent: #C96442;        /* Claude-ish terracotta */
  --accent-soft: #E4A488;
  --accent-bg: #F5E6DD;
  --accent-ink: #8A3E22;

  --ok: #5B8C65;
  --warn: #C8893A;

  --body-width: 720px;
  --col-left: 264px;
  --col-right: 380px;

  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 6px;

  --shadow-sm: 0 1px 2px rgba(40,30,10,0.04), 0 1px 3px rgba(40,30,10,0.03);
  --shadow-md: 0 4px 16px rgba(40,30,10,0.06), 0 1px 3px rgba(40,30,10,0.04);
  --shadow-lg: 0 20px 40px rgba(40,30,10,0.10), 0 4px 12px rgba(40,30,10,0.06);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", "Noto Serif SC", "Georgia", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --anim-fast: 120ms;
  --anim: 200ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

::selection { background: var(--bg-selection); color: var(--ink); }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--col-left) 6px minmax(0, 1fr) 6px var(--col-right);
  height: 100%;
  overflow: hidden;
}

/* Resize handles between panels */
.resizer {
  position: relative;
  background: transparent;
  cursor: col-resize;
  z-index: 10;
  transition: background var(--anim-fast);
}
.resizer::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--line);
  transform: translateX(-0.5px);
  transition: background var(--anim-fast), width var(--anim-fast);
}
.resizer:hover::after,
.resizer.dragging::after {
  background: var(--accent);
  width: 2px;
}
.resizer:hover,
.resizer.dragging {
  background: rgba(217,119,87,0.06);
}
/* Grip dots, revealed on hover */
.resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 28px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0;
  transition: opacity var(--anim-fast);
}
.resizer:hover::before,
.resizer.dragging::before { opacity: 0.8; }

body.resizing { cursor: col-resize; user-select: none; }
body.resizing * { cursor: col-resize !important; user-select: none !important; }

/* ---------- Sidebar (left) ---------- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sb-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.sb-head .sb-book { flex: 1; min-width: 0; }
.sb-collapse-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  flex-shrink: 0;
  transition: all var(--anim-fast);
  margin-top: 2px;
}
.sb-collapse-btn:hover { background: var(--bg-hover); color: var(--ink); }

/* Floating "expand sidebar" button when collapsed */
.sb-expand-btn {
  position: fixed;
  left: 12px;
  top: 14px;
  z-index: 40;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: all var(--anim-fast);
  animation: floatIn 200ms var(--ease);
}
.sb-expand-btn:hover {
  color: var(--accent-ink);
  border-color: var(--accent-soft);
  background: var(--accent-bg);
}

/* Hide sidebar + left resizer when collapsed */
.app.sb-collapsed {
  grid-template-columns: 0 0 minmax(0, 1fr) 6px var(--col-right);
}
.app.sb-collapsed .sidebar { display: none; }
.app.sb-collapsed .resizer.resizer-left { display: none; }
.sb-book {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sb-book-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.sb-book-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.sb-search {
  padding: 12px 14px 0;
}
.sb-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  font-size: 13px;
  transition: border-color var(--anim);
}
.sb-search-box:focus-within { border-color: var(--accent-soft); }
.sb-search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
}
.sb-search-box input::placeholder { color: var(--ink-4); }
.sb-search-box kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-3);
}

.sb-tree {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 20px;
}
.sb-chapter {
  margin-bottom: 2px;
}
.sb-chapter-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  transition: background var(--anim-fast);
  position: relative;
}
.sb-chapter-head:hover { background: var(--bg-hover); }
.sb-ch-add {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  opacity: 0;
  transition: all var(--anim-fast);
}
.sb-chapter-head:hover .sb-ch-add { opacity: 1; }
.sb-ch-add:hover { background: var(--accent-bg); color: var(--accent-ink); }

.sb-foot {
  padding: 8px 10px 12px;
  border-top: 1px solid var(--line);
  position: relative;
}
.sb-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  color: var(--ink-3);
  font-size: 13px;
  transition: all var(--anim-fast);
}
.sb-add-btn:hover {
  border-style: solid;
  border-color: var(--accent-soft);
  color: var(--accent-ink);
  background: var(--accent-bg);
}
.sb-add-menu {
  position: absolute;
  bottom: 56px;
  left: 10px;
  right: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 30;
  animation: floatIn 160ms var(--ease);
}
.sb-add-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--ink);
  transition: background var(--anim-fast);
}
.sb-add-item:hover { background: var(--bg-hover); }
.sb-add-item.compact { padding: 6px 10px; font-size: 13px; gap: 8px; }
.sb-add-ico { font-size: 18px; line-height: 1; }
.sb-add-t { font-size: 13px; font-weight: 500; color: var(--ink); }
.sb-add-s { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.sb-add-hint { padding: 8px 10px 4px; font-size: 11.5px; color: var(--ink-3); }
.sb-picker { max-height: 260px; overflow-y: auto; }

.sb-entry.just-created {
  animation: justCreated 1.8s var(--ease) 1;
}
@keyframes justCreated {
  0% { background: #FFF3D9; }
  100% { background: transparent; }
}

.sb-caret {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  transition: transform var(--anim) var(--ease);
}
.sb-chapter.open > .sb-chapter-head .sb-caret { transform: rotate(90deg); }
.sb-emoji { font-size: 15px; line-height: 1; }
.sb-chapter-title { flex: 1; }
.sb-count {
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.sb-entries {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--anim) var(--ease);
}
.sb-entries > div { overflow: hidden; }
.sb-chapter.open .sb-entries { grid-template-rows: 1fr; }

.sb-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 30px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
  transition: background var(--anim-fast), color var(--anim-fast);
}
.sb-entry:hover { background: var(--bg-hover); }
.sb-entry.active {
  background: var(--bg-active);
  color: var(--accent-ink);
  font-weight: 500;
}
.sb-entry.active::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.sb-entry-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-entry-en {
  font-size: 10.5px;
  color: var(--ink-4);
  font-style: italic;
  flex-shrink: 0;
  max-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-entry.active .sb-entry-en { color: var(--accent); opacity: 0.7; }

/* subtle pulse when AI is "looking at" the entry */
.sb-entry.ai-focus::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1.5px var(--accent-soft);
  animation: aiPulse 1.4s var(--ease) infinite;
  pointer-events: none;
}
@keyframes aiPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ---------- Center: content ---------- */
.content {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.content-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  border-bottom: 1px solid transparent;
  transition: border-color var(--anim);
}
.content-top.scrolled { border-color: var(--line); background: rgba(249,247,242,0.85); backdrop-filter: blur(8px); }

.breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
  min-width: 0;
}
.breadcrumb span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb .sep { color: var(--ink-4); }
.breadcrumb .current { color: var(--ink-2); font-weight: 500; }

.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: all var(--anim-fast);
}
.top-btn:hover { border-color: var(--line-strong); background: #fff; }
.top-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.top-btn.primary:hover { background: #B75838; border-color: #B75838; }
.top-btn.ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.top-btn.ghost:hover { background: var(--bg-hover); color: var(--ink-2); }

.content-scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.article {
  max-width: var(--body-width);
  margin: 0 auto;
  padding: 40px 40px 200px;
  transition: max-width var(--anim);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 12px;
  color: var(--ink-3);
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.meta-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-soft); }

/* Rich content styling */
.article-body {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.72;
  color: var(--ink);
  outline: none;
}
.article-body:focus { outline: none; }

.article-body h1 {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 8px;
  color: var(--ink);
}
.article-body h1 .zh-en {
  display: block;
  font-size: 17px;
  font-weight: 400;
  font-style: italic;
  color: var(--ink-3);
  margin-top: 6px;
  letter-spacing: 0;
}
.article-body h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 40px 0 12px;
  color: var(--ink);
}
.article-body p { margin: 0 0 16px; }
.article-body .lede {
  font-size: 19px;
  color: var(--ink-2);
  margin: 16px 0 28px;
  line-height: 1.6;
}
.article-body ul {
  padding-left: 22px;
  margin: 0 0 20px;
}
.article-body li {
  margin-bottom: 10px;
  padding-left: 4px;
}
.article-body li::marker { color: var(--accent-soft); }
.article-body b { color: var(--accent-ink); font-weight: 600; }
.article-body blockquote {
  margin: 20px 0;
  padding: 14px 20px;
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--ink-2);
  font-size: 15.5px;
}

/* Editor mode */
.article-body.editing {
  background: var(--bg-elev);
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  min-height: 400px;
  margin: 0 -28px;
}
.article-body.editing:focus-within { border-color: var(--accent-soft); box-shadow: 0 0 0 4px rgba(217,119,87,0.08); }

/* Toolbar for edit mode */
.edit-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  margin-bottom: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.edit-toolbar .tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-2);
  transition: background var(--anim-fast);
}
.edit-toolbar .tb-btn:hover { background: var(--bg-hover); }
.edit-toolbar .tb-btn.active { background: var(--bg-active); color: var(--accent-ink); }
.edit-toolbar .tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* AI highlight flash on content (when AI applies a suggestion) */
.ai-applied { animation: aiApply 1.6s var(--ease) 1; }
@keyframes aiApply {
  0% { background: var(--accent-bg); }
  100% { background: transparent; }
}

/* ---------- Floating selection toolbar ---------- */
.float-toolbar {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transform: translate(-50%, -100%);
  margin-top: -10px;
  animation: floatIn 160ms var(--ease);
}
@keyframes floatIn {
  from { opacity: 0; transform: translate(-50%, -95%); }
  to { opacity: 1; transform: translate(-50%, -100%); }
}
.float-toolbar::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: var(--ink);
}
.ft-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: #fff;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  position: relative;
  z-index: 1;
  transition: background var(--anim-fast);
}
.ft-btn:hover { background: rgba(255,255,255,0.12); }
.ft-btn.accent { color: #FFD9C5; }
.ft-btn.accent:hover { background: rgba(217,119,87,0.25); }
.ft-sep { width: 1px; height: 16px; background: rgba(255,255,255,0.15); margin: 0 2px; }

/* ---------- Right: Chat ---------- */
.chat {
  background: var(--bg-chat);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-head {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.chat-head-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E4A488, #C96442);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(217,119,87,0.3);
}
.chat-title-group { flex: 1; min-width: 0; }
.chat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.chat-sub {
  font-size: 11.5px;
  color: var(--ink-3);
}
.chat-hist-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  transition: all var(--anim-fast);
}
.chat-hist-btn:hover { background: var(--bg-hover); color: var(--ink); }

.context-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--ink-2);
  max-width: 100%;
}
.context-chip svg { color: var(--accent); flex-shrink: 0; }
.context-chip .ctx-doc { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg { display: flex; gap: 10px; max-width: 100%; animation: msgIn 240ms var(--ease); }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg.ai .msg-avatar {
  background: linear-gradient(135deg, #E4A488, #C96442);
  color: #fff;
}
.msg.user .msg-avatar {
  background: var(--ink);
  color: #fff;
}
.msg-bubble {
  flex: 1;
  min-width: 0;
}
.msg-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 3px;
}
.msg-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  word-wrap: break-word;
}
.msg-text p { margin: 0 0 8px; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-text b { color: var(--accent-ink); }
.msg-text .quote-echo {
  display: block;
  margin: 6px 0;
  padding: 6px 10px;
  background: var(--bg-elev);
  border-left: 2px solid var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  color: var(--ink-2);
  font-style: italic;
}
.cursor-blink {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* suggestion card in AI message */
.ai-suggestion {
  margin-top: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ai-sugg-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--accent-bg);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-ink);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.ai-sugg-body {
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
  font-family: var(--font-serif);
}
.ai-sugg-actions {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: #FBF9F4;
}
.sugg-btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--anim-fast);
}
.sugg-btn.apply {
  background: var(--accent);
  color: #fff;
}
.sugg-btn.apply:hover { background: #B75838; }
.sugg-btn.apply:disabled { background: var(--ok); cursor: default; }
.sugg-btn.dismiss {
  color: var(--ink-3);
  background: transparent;
}
.sugg-btn.dismiss:hover { background: var(--bg-hover); color: var(--ink-2); }

/* Quoted input preview */
.chat-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-chat);
}
.quote-preview {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--ink-2);
  animation: quoteIn 180ms var(--ease);
}
@keyframes quoteIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.quote-preview-text {
  flex: 1;
  font-style: italic;
  max-height: 3.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
.quote-preview-close {
  color: var(--ink-4);
  font-size: 14px;
  padding: 2px;
  line-height: 1;
  flex-shrink: 0;
}
.quote-preview-close:hover { color: var(--ink); }

.prompt-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.prompt-chip {
  padding: 5px 10px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all var(--anim-fast);
}
.prompt-chip:hover {
  border-color: var(--accent-soft);
  color: var(--accent-ink);
  background: var(--accent-bg);
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 10px 10px 14px;
  transition: border-color var(--anim);
}
.chat-input-wrap:focus-within { border-color: var(--accent-soft); box-shadow: 0 0 0 4px rgba(217,119,87,0.08); }
.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 160px;
  min-height: 22px;
  padding: 2px 0;
}
.chat-input::placeholder { color: var(--ink-4); }
.send-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-4);
  color: #fff;
  flex-shrink: 0;
  transition: all var(--anim-fast);
}
.send-btn.ready { background: var(--accent); }
.send-btn.ready:hover { background: #B75838; transform: scale(1.05); }
.send-btn:disabled { cursor: default; }

/* History panel (popover) */
.history-pop {
  position: absolute;
  right: 16px;
  top: 56px;
  width: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  overflow: hidden;
  animation: floatIn 160ms var(--ease);
}
.history-pop h4 {
  margin: 0;
  padding: 12px 14px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.history-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 0 6px 6px;
}
.history-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--anim-fast);
}
.history-item:hover { background: var(--bg-hover); }
.history-item.active { background: var(--bg-active); }
.history-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: 11px;
  color: var(--ink-3);
}
.history-empty {
  padding: 10px 14px 14px;
  font-size: 12px;
  color: var(--ink-4);
  text-align: center;
}

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  bottom: 20px;
  right: 400px;
  width: 260px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  z-index: 50;
  animation: floatIn 180ms var(--ease);
}
.tweaks-panel h4 {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tweaks-panel h4 button { color: var(--ink-4); font-size: 14px; line-height: 1; }
.tweaks-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.tweaks-row:last-child { margin-bottom: 0; }
.tweaks-label {
  font-size: 12.5px;
  color: var(--ink-2);
  flex-shrink: 0;
}
.tweaks-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  min-width: 42px;
  text-align: right;
}
.tweaks-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
}
.tweaks-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.tweaks-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* Thinking indicator dots */
.thinking {
  display: inline-flex;
  gap: 3px;
  padding: 6px 0;
}
.thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-soft);
  animation: dotJump 1.2s var(--ease) infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotJump {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); background-clip: content-box; }

/* Save indicator */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-left: 8px;
  transition: opacity var(--anim);
}
.save-indicator.saving .dot { animation: saveSpin 0.8s linear infinite; }
.save-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.save-indicator.saving .dot {
  background: var(--warn);
  border-radius: 2px;
}
@keyframes saveSpin { to { transform: rotate(360deg); } }
