/* ----------------------------------------------------------------------------
   Claude Data Viewer — styles
   ---------------------------------------------------------------------------- */

:root {
  --bg: #fafaf7;
  --bg-elevated: #ffffff;
  --bg-sunken: #f3f1ec;
  --border: #e6e2da;
  --border-strong: #d4cec1;
  --text: #1f1d1a;
  --text-muted: #6b6962;
  --text-faint: #9a978f;
  --accent: #c96442;          /* Anthropic warm orange */
  --accent-soft: #f4e0d6;
  --accent-text: #8a3517;
  --human-bg: #f7f3ec;
  --assistant-bg: #ffffff;
  --tool-bg: #f5f1e8;
  --thinking-bg: #f4ede0;
  --thinking-border: #e6d8b8;
  --code-bg: #f6f3ec;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;
  --font-serif: "Charter", "Iowan Old Style", "Georgia", "Songti SC", serif;
}

[data-theme="dark"] {
  --bg: #1a1816;
  --bg-elevated: #221f1c;
  --bg-sunken: #161412;
  --border: #2e2a26;
  --border-strong: #3d3833;
  --text: #ece8e0;
  --text-muted: #a09b91;
  --text-faint: #6e6961;
  --accent: #e08a6c;
  --accent-soft: #3d2a22;
  --accent-text: #f0a685;
  --human-bg: #25211d;
  --assistant-bg: #1f1c19;
  --tool-bg: #211e1a;
  --thinking-bg: #2a2520;
  --thinking-border: #463d31;
  --code-bg: #1b1815;
  --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; color: inherit; }

/* Consistent focus ring across the app — only when keyboard-focused, never on mouse click. */
:focus { outline: none; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Welcome page floating controls (lang + theme) ---- */
.welcome-controls {
  position: fixed;
  top: 18px;
  right: 18px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.6);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
          backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 999px;
  z-index: 5;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 18px rgba(164, 72, 42, 0.06);
}
[data-theme="dark"] .welcome-controls {
  background: rgba(34, 31, 28, 0.65);
  border-color: rgba(255,255,255,0.08);
}
.welcome-controls .iconbtn {
  width: 30px; height: 30px;
}

/* Language toggle — small monospace label that flips between EN and 中 */
.lang-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.lang-toggle .lang-label {
  display: inline-block;
  min-width: 14px;
  text-align: center;
  line-height: 1;
}

/* ---- Dropzone / welcome screen ---- */
.dropzone {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  background:
    radial-gradient(ellipse 60% 40% at 50% -10%, var(--accent-soft) 0%, transparent 65%),
    var(--bg);
}
.dropzone-inner {
  max-width: 680px;
  width: 100%;
  text-align: center;
}
.brand .logo {
  width: 64px; height: 64px;
  margin: 0 auto 24px;
  display: grid; place-items: center;
  border-radius: 16px;
  box-shadow:
    0 1px 1px rgba(164, 72, 42, 0.14),
    0 8px 20px rgba(164, 72, 42, 0.18),
    0 24px 48px rgba(164, 72, 42, 0.10);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.brand .logo:hover { transform: translateY(-1px) rotate(-2deg); }
.brand .logo svg {
  width: 100%; height: 100%;
  display: block;
  border-radius: 16px;
}
.brand-name {
  font-family: var(--font-serif);
  font-weight: 500;
  font-style: italic;
  font-size: 60px;
  line-height: 1;
  margin: 0 0 18px;
  letter-spacing: -2px;
  color: var(--text);
}
.brand-tagline {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 19px;
  margin: 0 0 10px;
  letter-spacing: -0.3px;
  color: var(--text);
}
.brand-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 auto 40px;
  line-height: 1.65;
  max-width: 440px;
}
/* Wrapper that contains both the dropzone and the floating demo nudge.
   Position context for the absolutely-placed `.demo-zip-hint`. */
.drop-row {
  position: relative;
}
.drop-target {
  display: block;
  border: 1.5px dashed var(--border-strong);
  border-radius: 18px;
  padding: 48px 24px;
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.drop-target:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(201, 100, 66, 0.12);
}
.drop-target:hover .drop-icon { transform: translateY(2px); }
.drop-target.dragging {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(201, 100, 66, 0.18);
}
.drop-icon {
  width: 40px; height: 40px;
  margin: 0 auto 16px;
  color: var(--accent);
  display: grid; place-items: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.drop-icon svg {
  width: 100%; height: 100%;
}
.drop-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}
.drop-sub {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}
.drop-target code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--bg-sunken);
  padding: 1px 5px;
  border-radius: 4px;
}
.link-style {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.loaded-hint {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}
.export-hint {
  margin: 18px auto 0;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.6;
  max-width: 460px;
}
.export-hint a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.export-hint a:hover { color: var(--accent-text); }
.link {
  background: none; border: none; padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.link.danger { color: #b8442b; }
.features {
  margin-top: 44px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  text-align: left;
}
@media (min-width: 640px) {
  .features { grid-template-columns: 1fr 1fr 1fr; }
}
.feature {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}
.feature strong {
  color: var(--text);
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.1px;
}
.footer-note {
  margin-top: 36px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ---- Demo zip nudge ----------------------------------------------------
   A small tilted "file" card to the right of the dropzone, with a hand-drawn
   arrow pointing at it. Drag onto the dropzone (or click) to load a sample
   export. The whole thing is intentionally quiet — a graceful "by the way"
   invitation that respects the rest of the welcome screen's restraint. */
.demo-zip-hint {
  /* Default (wide viewports): a small tile floating to the right of the
     dropzone. On narrow viewports we restyle below to inline-stack under
     the dropzone (see @media block at the end of this section). */
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translate(28px, -50%);
  width: 152px;
  pointer-events: none;        /* arrow doesn't intercept clicks */
  z-index: 2;
}

.demo-zip-arrow {
  position: absolute;
  top: -100px;
  left: -200px;
  width: 260px;
  height: 170px;
  color: var(--accent);
  pointer-events: none;
}
.demo-zip-arrow-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.65;
  /* Draw-in animation: the line traces itself once on load (1.5s, after a
     0.6s settle delay), then rests with a slow opacity breath. The path's
     actual length is ~277 units (measured via getTotalLength); we round up
     to 280 so the dashoffset finishes precisely at path-end. */
  stroke-dasharray: 280;
  stroke-dashoffset: 280;
  animation: demo-arrow-draw 1.5s 0.6s cubic-bezier(0.65, 0, 0.35, 1) forwards,
             demo-arrow-pulse 5s 2.4s ease-in-out infinite;
}
/* SVG `marker-end` ignores stroke-dashoffset — if the marker were attached
   from frame 0 it would render at the path's terminus the whole time the
   line is still drawing. We instead attach the marker via JS *after* the
   draw completes (see app.js wire()), so the arrowhead arrives precisely
   when the pen tip reaches it. */
@keyframes demo-arrow-draw {
  to { stroke-dashoffset: 0; }
}
@keyframes demo-arrow-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.78; }
}

.demo-zip-card {
  position: relative;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  padding: 14px 12px 12px;
  background: linear-gradient(168deg, #fffdf7 0%, #fcf2dd 100%);
  border: 1px solid #ead7b6;
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.65),
    0 1px 2px rgba(0,0,0,0.04),
    0 8px 18px rgba(164,72,42,0.10);
  transform: rotate(-6deg);
  cursor: grab;
  font: inherit;
  color: var(--text);
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.32s ease;
  animation: demo-card-bob 5.5s ease-in-out infinite;
}
/* A single faint backsheet — just enough to suggest depth, no fanfare. */
.demo-zip-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  z-index: -1;
  transform: translate(2px, 3px) rotate(1.4deg);
  opacity: 0.45;
}

@keyframes demo-card-bob {
  0%, 100% { transform: rotate(-6deg)   translateY(0); }
  50%      { transform: rotate(-5.2deg) translateY(-2px); }
}

.demo-zip-card:hover {
  transform: rotate(-2.5deg) translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 2px 4px rgba(0,0,0,0.05),
    0 14px 28px rgba(164,72,42,0.16);
  animation: none;
}
.demo-zip-card:active { cursor: grabbing; }
.demo-zip-card.dragging {
  opacity: 0.5;
  transform: rotate(-10deg) scale(0.94);
  animation: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
/* Desktop click feedback: a brief shake to remind the visitor that
   *dragging*, not clicking, is the intended interaction here. The CTA on
   the card already says so; this gives that hint a small physical echo. */
.demo-zip-card.nudge {
  animation: demo-card-nudge 0.55s ease-in-out;
}
@keyframes demo-card-nudge {
  0%   { transform: rotate(-6deg)   translateY(0); }
  20%  { transform: rotate(-9deg)   translateY(-2px); }
  45%  { transform: rotate(-3.5deg) translateY(-4px); }
  70%  { transform: rotate(-7.5deg) translateY(-2px); }
  100% { transform: rotate(-6deg)   translateY(0); }
}

.demo-zip-stamp {
  position: absolute;
  top: -7px;
  right: -10px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: #fff;
  background: var(--accent);
  padding: 2.5px 7px 2px;
  border-radius: 999px;
  transform: rotate(9deg);
  box-shadow: 0 2px 5px rgba(164,72,42,0.30);
}
.demo-zip-icon {
  width: 42px;
  height: 52px;
  display: block;
  margin-bottom: 2px;
  filter: drop-shadow(0 2px 3px rgba(164,72,42,0.14));
}
.demo-zip-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.demo-zip-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.1px;
}
.demo-zip-meta {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
  letter-spacing: 0.1px;
}
.demo-zip-cta {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  color: var(--accent-text);
  line-height: 1.3;
  letter-spacing: -0.1px;
}

/* Dropzone highlight while the demo card is being dragged. */
/* While the demo card is being dragged, highlight the dropzone so the
   target is unmistakable. The `body.demo-dragging` class is toggled by
   app.js on dragstart/dragend (the card and the drop-target are not DOM
   siblings, so a CSS-only selector wouldn't reach far enough). */
body.demo-dragging .drop-target {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  box-shadow: 0 8px 32px rgba(201, 100, 66, 0.18);
}

/* Dark theme: warm-dark "envelope" with the same restrained shadow profile. */
[data-theme="dark"] .demo-zip-card {
  background: linear-gradient(168deg, #2a241e 0%, #38291f 100%);
  border-color: #4a3a2c;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 1px 2px rgba(0,0,0,0.30),
    0 10px 22px rgba(0,0,0,0.40);
}
[data-theme="dark"] .demo-zip-arrow-line { opacity: 0.85; }

/* Smaller laptops: pull the card a hair closer to keep it on-screen. */
@media (min-width: 1100px) and (max-width: 1300px) {
  .demo-zip-hint  { transform: translate(16px, -50%); width: 144px; }
  .demo-zip-arrow { left: -188px; }
}

/* Honor `prefers-reduced-motion`: skip the bob, the draw-in, and the
   opacity pulse, and just show everything in its rest state. The arrowhead
   is revealed immediately by the JS path that pairs with this. */
@media (prefers-reduced-motion: reduce) {
  .demo-zip-card,
  .demo-zip-card.nudge,
  .demo-zip-arrow-line {
    animation: none !important;
  }
  .demo-zip-arrow-line {
    stroke-dashoffset: 0 !important;
  }
}

/* Below ~1100px there's no horizontal room for the floating card. Put it
   inline under the dropzone instead, hide the curved arrow, and reshape the
   card into a horizontal "tap to try" tile. Drag still works, but tap is
   the primary affordance on touch. */
@media (max-width: 1099px) {
  .demo-zip-hint {
    position: static;
    transform: none;
    width: 100%;
    max-width: 420px;
    margin: 14px auto 0;
    pointer-events: auto;
  }
  .demo-zip-arrow { display: none; }
  .demo-zip-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
      "icon label cta"
      "icon meta  cta";
    align-items: center;
    column-gap: 14px;
    row-gap: 2px;
    text-align: left;
    padding: 12px 14px;
    transform: rotate(-1.5deg);
    animation: none;
  }
  .demo-zip-card::before,
  .demo-zip-card::after { display: none; }
  .demo-zip-icon {
    grid-area: icon;
    width: 36px; height: 44px;
    margin-bottom: 0;
    align-self: center;
  }
  .demo-zip-stamp { top: -7px; right: -8px; }
  .demo-zip-label { grid-area: label; align-self: end; text-align: left; line-height: 1.2; }
  .demo-zip-meta  { grid-area: meta;  align-self: start; text-align: left; line-height: 1.3; }
  .demo-zip-cta {
    grid-area: cta;
    margin-top: 0;
    white-space: nowrap;
    align-self: center;
  }
  .demo-zip-card:hover {
    transform: rotate(0deg) translateY(-1px);
  }
}

/* Phones and small tablets: drop the CTA, the DEMO stamp + tilt does the talking. */
@media (max-width: 480px) {
  .demo-zip-card {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "icon label"
      "icon meta";
  }
  .demo-zip-cta { display: none; }
}

/* ---- Loading overlay ---- */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text {
  color: white;
  margin-top: 16px;
  font-size: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- App layout ---- */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex: 0 0 auto;
}
.topbar-left {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.topbar-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-style: italic;
  font-size: 19px;
  margin: 0;
  white-space: nowrap;
  letter-spacing: -0.4px;
  color: var(--text);
}
.iconbtn.home {
  width: 30px; height: 30px;
  padding: 0;
  border: none;
  background: transparent;
}
.iconbtn.home svg {
  width: 100%; height: 100%;
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(164, 72, 42, 0.2), 0 2px 6px rgba(164, 72, 42, 0.12);
  transition: transform 0.1s ease;
}
.iconbtn.home:hover svg { transform: scale(1.05); }
.user-badge {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg-sunken);
  border-radius: 999px;
  white-space: nowrap;
}
.topbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search input {
  width: 100%;
  padding: 7px 30px 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.kbd {
  position: absolute;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  pointer-events: none;
  border: 1px solid var(--border);
  padding: 0 5px;
  border-radius: 4px;
  background: var(--bg-elevated);
}
.topbar-right {
  display: flex; align-items: center; gap: 12px;
  margin-left: auto;
}
.stat { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.iconbtn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-muted);
  transition: background-color 0.12s, color 0.12s, transform 0.12s;
}
.iconbtn:hover {
  background: var(--bg-sunken);
  color: var(--text);
}
.iconbtn:active { transform: scale(0.94); }
.iconbtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--bg-sunken);
  color: var(--text);
}

/* Animated sun ↔ moon swap */
.theme-toggle .theme-icon {
  position: relative;
  overflow: visible;
}
.theme-toggle .theme-sun,
.theme-toggle .theme-rays line {
  transform-origin: 12px 12px;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.theme-toggle .theme-moon {
  transform-origin: 12px 12px;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Light theme → show sun */
[data-theme="light"] .theme-toggle .theme-moon {
  opacity: 0;
  transform: rotate(-60deg) scale(0.4);
}
[data-theme="light"] .theme-toggle .theme-sun {
  opacity: 1;
}
[data-theme="light"] .theme-toggle .theme-rays line {
  opacity: 1;
}
/* Dark theme → show moon */
[data-theme="dark"] .theme-toggle .theme-sun {
  opacity: 0;
  transform: scale(0.4);
}
[data-theme="dark"] .theme-toggle .theme-rays line {
  opacity: 0;
  transform: scale(0.4);
}
[data-theme="dark"] .theme-toggle .theme-moon {
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .theme-toggle .theme-sun,
  .theme-toggle .theme-rays line,
  .theme-toggle .theme-moon { transition: opacity 0.15s linear; transform: none !important; }
}

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  min-width: 0;
  padding: 8px 2px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: -0.1px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.filters {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.list-meta {
  font-size: 11px;
  color: var(--text-faint);
  display: flex; justify-content: space-between; align-items: center;
}
.select {
  width: 100%;
  padding: 5px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12px;
}
.select:focus { outline: 1px solid var(--accent); }

.sidebar-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 4px 0;
  /* Soft edge fade so the scroll feels less abrupt at the bottom */
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 calc(100% - 12px), transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 calc(100% - 12px), transparent 100%);
}
.sidebar-list:focus { outline: none; }
.sb-item {
  padding: 11px 14px 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.1s ease, padding-left 0.15s ease;
  position: relative;
}
.sb-item:hover {
  background: var(--bg-sunken);
}
.sb-item.active {
  background: var(--accent-soft);
  padding-left: 19px;
}
.sb-item.active .sb-title { color: var(--accent-text); }
.sb-item.active::before {
  content: ""; position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.sb-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.sb-meta {
  font-size: 11px;
  color: var(--text-faint);
  display: flex; gap: 8px; align-items: center;
}
.sb-meta .dot { color: var(--border-strong); }
.sb-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.sb-empty-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: -0.1px;
}
.sb-empty-sub {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
  margin-bottom: 12px;
}
.sb-empty q {
  font-style: italic;
  color: var(--text-muted);
}
.sb-empty-clear {
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---- Content ---- */
.content {
  overflow-y: auto;
  background: var(--bg);
  min-height: 0;
}
.empty-state {
  height: 100%;
  display: grid; place-items: center;
  color: var(--text-faint);
  font-size: 14px;
}

.viewer {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 32px 96px;
}
@media (max-width: 720px) {
  .viewer { padding: 20px 16px 60px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 240px; }
}
.viewer-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.viewer-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: -0.4px;
  word-break: break-word;
}
.viewer-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  align-items: center;
}
.viewer-meta .pill {
  padding: 2px 9px;
  background: var(--bg-sunken);
  border-radius: 999px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  letter-spacing: 0.1px;
}
.viewer-meta > span:not(.pill) { font-variant-numeric: tabular-nums; }
.viewer-actions {
  margin-top: 12px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.btn {
  padding: 5px 12px;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.1s;
}
.btn:hover { background: var(--bg-sunken); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-text); border-color: var(--accent-text); }

/* ---- Messages ---- */
.message {
  margin-bottom: 18px;
  padding: 18px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--assistant-bg);
  transition: border-color 0.15s ease;
}
.message:hover { border-color: var(--border-strong); }
.message.human { background: var(--human-bg); }
.message-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.role-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.role-badge.human {
  background: rgba(94, 122, 67, 0.13);
  color: #4a6633;
}
.role-badge.assistant {
  background: var(--accent-soft);
  color: var(--accent-text);
}
[data-theme="dark"] .role-badge.human { background: rgba(160, 200, 132, 0.13); color: #b3cc92; }
.message-time {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  letter-spacing: 0.1px;
}

.message-body {
  font-size: 14.5px;
  line-height: 1.65;
  word-wrap: break-word;
}
.message-body > *:first-child { margin-top: 0; }
.message-body > *:last-child { margin-bottom: 0; }
.message-body p { margin: 0.7em 0; }
.message-body h1, .message-body h2, .message-body h3, .message-body h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 1.2em 0 0.4em;
}
.message-body h1 { font-size: 1.6em; }
.message-body h2 { font-size: 1.35em; }
.message-body h3 { font-size: 1.15em; }
.message-body h4 { font-size: 1.0em; }
.message-body ul, .message-body ol { padding-left: 1.5em; margin: 0.7em 0; }
.message-body li { margin: 0.25em 0; }
.message-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 12px;
  margin: 0.7em 0;
  color: var(--text-muted);
}
.message-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 1.5px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--accent-text);
  letter-spacing: -0.05px;
}
.message-body pre code {
  border: none;
  color: inherit;
  padding: 0;
  background: transparent;
  letter-spacing: 0;
}
.message-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 1em 0;
  position: relative;
}
.message-body pre:hover .code-copy {
  opacity: 1;
  transform: translateY(0);
}
.code-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease, color 0.12s, background-color 0.12s;
}
.code-copy:hover {
  color: var(--text);
  background: var(--bg-sunken);
}
.code-copy.copied {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.code-copy svg { width: 11px; height: 11px; }
@media (hover: none) {
  /* Touch devices: keep button visible since there's no hover */
  .code-copy { opacity: 0.7; }
}
.message-body pre code {
  background: transparent;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.55;
}
.message-body table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
  display: block;
  overflow-x: auto;
}
.message-body th, .message-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.message-body th { background: var(--bg-sunken); font-weight: 600; }
.message-body img { max-width: 100%; border-radius: var(--radius-sm); }
.message-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }

/* ---- Show-details toggle ---- */
/* Default: thinking + tool blocks are hidden inside .viewer (without show-details class) */
.viewer:not(.show-details) .special-block.thinking,
.viewer:not(.show-details) .special-block.tool { display: none; }
.viewer.show-details .hidden-indicator { display: none; }

.hidden-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text-faint);
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.1s;
}
.hidden-indicator:hover {
  color: var(--text-muted);
  border-color: var(--text-faint);
  border-style: solid;
}

/* Toggle control — looks like an actual switch (track + sliding knob), not a button */
.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 7px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.switch-control:hover {
  background: var(--bg-sunken);
  color: var(--text);
  border-color: var(--border-strong);
}
.switch-track {
  position: relative;
  display: block;
  width: 26px; height: 14px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background-color 0.18s ease;
  flex-shrink: 0;
}
.switch-knob {
  position: absolute;
  top: 1px; left: 1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(0,0,0,0.04);
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.switch-label { white-space: nowrap; }
.switch-count {
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  background: var(--bg-sunken);
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
  border-radius: 999px;
  border: 1px solid var(--border);
}
/* On state */
.switch-control[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}
.switch-control[aria-pressed="true"] .switch-track {
  background: var(--accent);
}
.switch-control[aria-pressed="true"] .switch-knob {
  transform: translateX(12px);
}
.switch-control[aria-pressed="true"] .switch-count {
  color: var(--accent-text);
  background: rgba(255, 255, 255, 0.5);
  border-color: transparent;
}
[data-theme="dark"] .switch-control[aria-pressed="true"] .switch-count {
  background: rgba(0, 0, 0, 0.25);
}
@media (prefers-reduced-motion: reduce) {
  .switch-knob, .switch-track, .switch-control { transition: none; }
}

/* Action group — three small buttons that read as actions, with icons */
.action-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  background: var(--bg-sunken);
  border-radius: 8px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background-color 0.1s, color 0.1s;
}
.action-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
.action-btn:active { transform: translateY(0.5px); }
.action-btn svg {
  width: 13px; height: 13px;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: color 0.1s;
}
.action-btn:hover svg { color: var(--accent); }
@media (max-width: 540px) {
  .action-btn span { display: none; }
  .action-btn { padding: 5px 8px; }
}

/* ---- Special blocks: thinking, tool_use, tool_result ---- */
.special-block {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  overflow: hidden;
}
.special-block summary {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-sunken);
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  user-select: none;
  transition: background-color 0.12s, color 0.12s;
}
.special-block summary::-webkit-details-marker { display: none; }
.special-block summary::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transform-origin: 60% 60%;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  opacity: 0.6;
}
.special-block[open] summary::before { transform: rotate(45deg); }
.special-block summary:hover {
  color: var(--text);
  background: var(--accent-soft);
}
.special-block summary:hover::before { opacity: 1; }
.special-block .block-content {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
}

.special-block.thinking {
  background: var(--thinking-bg);
  border-color: var(--thinking-border);
}
.special-block.thinking summary { background: transparent; }
.special-block.thinking .block-content {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-muted);
}
.special-block.thinking .summaries {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--thinking-border);
  list-style: none;
  padding-left: 0;
}
.special-block.thinking .summaries li {
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text);
  margin: 2px 0;
}
.special-block.thinking .summaries li::before { content: "› "; color: var(--text-faint); }

.special-block.tool .block-content { background: var(--tool-bg); }
.special-block.tool .tool-tag {
  display: inline-block;
  font-weight: 600;
  color: var(--text);
}
.special-block.tool .tool-msg {
  color: var(--text);
  font-weight: 400;
}
.special-block.tool .tool-faint {
  color: var(--text-faint);
  font-weight: 400;
}
.tool-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.tool-meta code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
  word-break: break-all;
}
pre.tool-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  background: transparent;
  border: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  max-height: 400px;
  overflow-y: auto;
}

/* display_content rich link card */
.rich-link {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  margin: 6px 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.rich-link + .rich-link { margin-top: 6px; }
.rl-icon {
  width: 20px; height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
  background: var(--bg-sunken);
  object-fit: contain;
}
.rl-icon-fallback {
  width: 20px; height: 20px;
  border-radius: 4px;
  background: var(--bg-sunken);
  flex-shrink: 0;
  margin-top: 2px;
}
.rl-body { flex: 1; min-width: 0; }
.rl-title {
  font-size: 13px;
  font-weight: 500;
  word-break: break-word;
}
.rl-title a { color: var(--accent); text-decoration: none; }
.rl-title a:hover { text-decoration: underline; }
.rl-url {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  word-break: break-all;
  margin-top: 2px;
}
.rl-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* display_content text + table */
.dc-text { font-size: 13px; margin: 4px 0; }
.dc-table {
  border-collapse: collapse;
  font-size: 12px;
  margin: 6px 0;
  width: auto;
}
.dc-table td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-family: var(--font-mono);
  word-break: break-word;
  max-width: 480px;
}

/* Conversation summary card */
.summary-card {
  margin: 0 0 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.summary-card summary {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-sunken);
  user-select: none;
  display: flex; align-items: center; gap: 8px;
  transition: background-color 0.12s, color 0.12s;
}
.summary-card summary::-webkit-details-marker { display: none; }
.summary-card summary::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transform-origin: 60% 60%;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  opacity: 0.55;
}
.summary-card[open] summary::before { transform: rotate(45deg); }
.summary-card summary:hover {
  color: var(--text);
  background: var(--accent-soft);
}
.summary-card summary:hover::before { opacity: 1; }
.summary-body {
  padding: 16px 20px;
  font-size: 13.5px;
  line-height: 1.65;
}
.summary-body > *:first-child { margin-top: 0; }
.summary-body > *:last-child { margin-bottom: 0; }
.summary-body.markdown p { margin: 0.6em 0; }
.summary-body.markdown h1,
.summary-body.markdown h2,
.summary-body.markdown h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  margin: 1em 0 0.4em;
}
.summary-body.markdown h1 { font-size: 1.2em; }
.summary-body.markdown h2 { font-size: 1.1em; }
.summary-body.markdown h3 { font-size: 1.0em; }
.summary-body.markdown ul, .summary-body.markdown ol { padding-left: 1.5em; margin: 0.6em 0; }
.summary-body.markdown li { margin: 0.2em 0; }
.summary-body.markdown code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
}
.summary-body.markdown strong { color: var(--text); }
.special-block.artifact .block-content {
  padding: 0;
}

/* ---- Visualize widgets (Claude's chart/SVG/HTML deliverables) ---- */
.special-block.widget {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}
.widget-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.widget-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.widget-title {
  color: var(--text);
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: 12.5px;
  word-break: break-all;
}
.widget-subtitles {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  padding: 6px 14px 0;
  font-size: 11px;
  color: var(--text-muted);
}
.widget-subtitles span::before { content: "·  "; color: var(--text-faint); }
.widget-subtitles span:first-child::before { content: ""; }
.widget-iframe {
  display: block;
  width: 100%;
  height: 580px;
  border: none;
  background: var(--bg-elevated);
  resize: vertical;
  min-height: 240px;
  max-height: 1200px;
}
.widget-source {
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
}
.widget-source summary {
  padding: 6px 14px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-faint);
  user-select: none;
  display: flex; align-items: center; gap: 6px;
  transition: color 0.12s, background-color 0.12s;
}
.widget-source summary::-webkit-details-marker { display: none; }
.widget-source summary::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transform-origin: 60% 60%;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  opacity: 0.7;
}
.widget-source[open] summary::before { transform: rotate(45deg); }
.widget-source summary:hover { color: var(--text-muted); background: var(--bg-elevated); }
.widget-source pre {
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--code-bg);
  font-size: 11.5px;
  max-height: 320px;
  overflow: auto;
}

/* ---- File panels (create_file, str_replace, view) ---- */
.special-block.widget.file-panel summary,
.special-block.widget.file-edit summary {
  background: var(--bg-sunken);
}
.file-path {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.file-panel-body { padding: 0; }
.file-panel-actions {
  display: flex; gap: 8px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.file-panel-rendered.markdown {
  margin: 0;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
.file-panel pre {
  margin: 0;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--border);
  max-height: 600px;
  overflow: auto;
}

/* str_replace as side-by-side or stacked diff */
.diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
@media (max-width: 760px) {
  .diff { grid-template-columns: 1fr; }
}
.diff-pane { background: var(--bg-elevated); }
.diff-head {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
}
.diff-old .diff-head { color: #b8442b; }
.diff-new .diff-head { color: #2d6a3f; }
[data-theme="dark"] .diff-old .diff-head { color: #e08368; }
[data-theme="dark"] .diff-new .diff-head { color: #7fbb8e; }
.diff-pane pre {
  margin: 0;
  border: none;
  border-radius: 0;
  max-height: 320px;
  overflow: auto;
  font-size: 12px;
}

.file-list { margin: 0; padding-left: 1.4em; }
.file-list li { margin: 4px 0; font-size: 13px; }

/* ---- Shared chevron for all expandable rows ---- */
/* CSS-drawn chevron — pixel-crisp at any DPI, scales with font-size, no SVG load. */
.chevron {
  display: inline-block;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transform-origin: 60% 60%;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.12s;
  flex-shrink: 0;
  margin-right: 2px;
}
[open] > summary .chevron { transform: rotate(45deg); }
summary:hover .chevron { border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .chevron { transition: none; }
}

/* ---- File index at top of conversation ---- */
.file-index {
  margin: 0 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}
.file-index summary {
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-sunken);
  transition: background-color 0.12s;
  outline: none;
  border-bottom: 1px solid transparent;
}
.file-index summary:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.file-index summary:hover .file-index-count {
  background: var(--bg-elevated);
}
.file-index summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.file-index[open] summary {
  border-bottom-color: var(--border);
}
.file-index summary::-webkit-details-marker { display: none; }
.file-index-title { color: var(--text); }
.file-index-count {
  background: var(--accent-soft);
  color: var(--accent-text);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.file-index-list {
  list-style: none;
  margin: 0; padding: 0;
}
.file-index-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.file-index-main { flex: 1; min-width: 0; }
.file-index-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}
.file-index-path {
  font-size: 11px;
  color: var(--text-faint);
  word-break: break-all;
  margin-top: 2px;
}
.file-index-meta {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.file-index-tag {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.file-index-size {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.btn.small { padding: 3px 10px; font-size: 11.5px; }

.file-index-sub {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 400;
}
.file-index-note {
  padding: 10px 16px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.file-index-note strong { color: var(--text); }
.file-index-tag.binary {
  background: var(--bg-sunken);
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px dashed var(--border-strong);
}
.file-index-tag.muted {
  color: var(--text-faint);
  font-size: 11px;
}
.file-index-size.binary-note {
  color: var(--text-faint);
  font-style: italic;
  cursor: help;
}
.file-index-mime {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 2px;
  font-family: var(--font-mono);
}
.file-index-item.is-binary {
  background: linear-gradient(to right, transparent 0%, var(--bg-sunken) 100%);
  opacity: 0.92;
}

/* Other named tools shown as deliverables */
.compose-variant {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 8px 0;
  background: var(--bg-elevated);
}
.compose-variant + .compose-variant { margin-top: 12px; }
.compose-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chart-table { font-size: 11px; max-width: 100%; }
.chart-table th {
  background: var(--bg-sunken);
  padding: 4px 8px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.ask-question {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 6px 0;
  background: var(--bg-elevated);
}
.ask-q { font-weight: 500; margin-bottom: 6px; }
.ask-opts {
  margin: 4px 0 0;
  padding-left: 1.4em;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---- Skeleton placeholders (shown while heavy content renders) ---- */
.sk {
  background: linear-gradient(
    90deg,
    var(--bg-sunken) 0%,
    var(--border) 40%,
    var(--border) 60%,
    var(--bg-sunken) 100%
  );
  background-size: 220% 100%;
  border-radius: 5px;
  animation: sk-shimmer 1.5s ease-in-out infinite;
}
@keyframes sk-shimmer {
  0%   { background-position: 220% 0; }
  100% { background-position: -120% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; opacity: 0.7; }
}
.sk-title    { width: 65%; height: 32px; margin-bottom: 14px; }
.sk-meta     { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.sk-pill     { height: 18px; border-radius: 999px; }
.sk-pill.w1  { width: 72px; }
.sk-pill.w2  { width: 96px; }
.sk-pill.w3  { width: 120px; }
.sk-actions  { display: flex; gap: 8px; margin: 16px 0 24px; }
.sk-btn      { width: 110px; height: 26px; border-radius: 6px; }
.sk-msg      { padding: 16px 20px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 16px; background: var(--assistant-bg); }
.sk-msg.h    { background: var(--human-bg); }
.sk-role     { width: 56px; height: 16px; border-radius: 999px; margin-bottom: 12px; }
.sk-line     { height: 13px; margin: 8px 0; border-radius: 3px; }
.sk-line.l1  { width: 100%; }
.sk-line.l2  { width: 92%; }
.sk-line.l3  { width: 78%; }
.sk-line.l4  { width: 60%; }
.sk-doc      { height: 38px; border-radius: 8px; margin: 8px 0; }
.sk-card     { height: 120px; border-radius: 10px; margin: 12px 0; }

/* Subtle fade-in when the real content replaces the skeleton */
.viewer.fade-in {
  animation: fade-in 180ms ease-out;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .viewer.fade-in { animation: none; }
}

/* Sidebar item: tactile click feedback */
.sb-item { transition: background-color 0.08s ease; }
.sb-item:active { background: var(--accent-soft); }

/* KaTeX adjustments */
.katex { font-size: 1.05em; }
.katex-display {
  margin: 0.8em 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.katex-display > .katex { display: inline-block; }
.artifact-meta {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.artifact-meta .pill { background: var(--bg-elevated); padding: 1px 6px; border-radius: 4px; }
.artifact-content { padding: 12px 14px; }
.artifact-content pre { margin: 0; }

.attachment-card {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.attachment-card summary {
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  display: flex; align-items: center; gap: 8px;
  transition: background-color 0.12s;
}
.attachment-card summary::-webkit-details-marker { display: none; }
.attachment-card summary::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transform-origin: 60% 60%;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  opacity: 0.6;
}
.attachment-card[open] summary::before { transform: rotate(45deg); }
.attachment-card summary:hover { background: var(--bg-sunken); }
.attachment-card summary:hover::before { opacity: 1; border-color: var(--accent); }
.attachment-card .att-name { font-weight: 500; }
.attachment-card .att-meta { color: var(--text-faint); font-size: 11px; }
.attachment-card pre {
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--code-bg);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}
.file-ref {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 4px 4px 0;
}
.file-ref::before { content: "📄"; }
.file-note {
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
}

/* ---- Project / memory views ---- */
.project-doc {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}
.project-doc summary {
  padding: 10px 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex; gap: 10px; align-items: center;
  user-select: none;
  transition: background-color 0.12s;
}
.project-doc .doc-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  color: var(--text);
}
.project-doc .doc-size {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.project-doc .project-doc-download {
  flex-shrink: 0;
  text-decoration: none;
  font-weight: 500;
}
.project-doc .project-doc-download:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.project-doc summary::-webkit-details-marker { display: none; }
.project-doc summary::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transform-origin: 60% 60%;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  opacity: 0.6;
}
.project-doc[open] summary::before { transform: rotate(45deg); }
.project-doc summary:hover { background: var(--bg-sunken); }
.project-doc summary:hover::before { opacity: 1; border-color: var(--accent); }
.project-doc .doc-content {
  padding: 0 16px 16px;
  font-size: 13.5px;
  line-height: 1.65;
}
.section-header {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  margin: 32px 0 12px;
  letter-spacing: -0.2px;
}
.section-header:first-child { margin-top: 0; }
.kv-row { display: flex; gap: 12px; padding: 6px 0; font-size: 13px; }
.kv-row .k { color: var(--text-muted); min-width: 120px; flex: 0 0 auto; }
.kv-row .v { color: var(--text); }

.memory-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  font-size: 14px;
  line-height: 1.65;
}
.memory-block + .memory-block { margin-top: 16px; }
/* Plain-text rendering — for system prompts that should be shown literally */
.memory-block.code {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--code-bg);
  word-break: break-word;
}
/* Rendered markdown — for memory content that uses **bold**, headings etc. */
.memory-block.markdown { font-family: var(--font-sans); }
.memory-block.markdown > *:first-child { margin-top: 0; }
.memory-block.markdown > *:last-child { margin-bottom: 0; }
.memory-block.markdown p { margin: 0.7em 0; }
.memory-block.markdown h1,
.memory-block.markdown h2,
.memory-block.markdown h3,
.memory-block.markdown h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 1.2em 0 0.4em;
}
.memory-block.markdown h1 { font-size: 1.4em; }
.memory-block.markdown h2 { font-size: 1.2em; }
.memory-block.markdown h3 { font-size: 1.05em; }
.memory-block.markdown ul,
.memory-block.markdown ol { padding-left: 1.5em; margin: 0.6em 0; }
.memory-block.markdown li { margin: 0.2em 0; }
.memory-block.markdown blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 12px;
  margin: 0.7em 0;
  color: var(--text-muted);
}
.memory-block.markdown code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
}
.memory-block.markdown pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0.8em 0;
}
.memory-block.markdown pre code { background: transparent; padding: 0; }
.memory-block.markdown hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.memory-card {
  margin: 16px 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.memory-card-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 500;
}
.memory-card-body {
  padding: 16px 20px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  font-family: var(--font-serif);
}

mark {
  background: #fef9c3;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}
[data-theme="dark"] mark { background: #5a4a14; color: #f5e8a3; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 9999;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---- Help dialog ---- */
.help-dialog {
  border: none;
  padding: 0;
  border-radius: var(--radius);
  max-width: 560px;
  width: calc(100% - 40px);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 24px 48px rgba(0,0,0,0.18);
}
.help-dialog::backdrop {
  background: rgba(40, 28, 20, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.help-content { padding: 24px 28px 22px; }
.help-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.help-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.4px;
  margin: 0;
  color: var(--text);
}
.help-close {
  width: 28px; height: 28px;
  border: none; background: transparent;
  font-size: 20px;
  color: var(--text-muted);
  border-radius: 6px;
  display: grid; place-items: center;
  cursor: pointer;
}
.help-close:hover { background: var(--bg-sunken); color: var(--text); }
.help-content section { margin-bottom: 18px; }
.help-content h3 {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -0.1px;
}
.help-lede {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-muted);
  font-style: italic;
}
.help-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.65; color: var(--text-muted); }
.help-list li { margin: 2px 0; }
.help-list li::marker { color: var(--accent); }
.help-faint { margin: 8px 0 0; font-size: 12px; color: var(--text-faint); line-height: 1.55; }
.help-content p { margin: 0; font-size: 13px; line-height: 1.65; color: var(--text-muted); }

.shortcut-list {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 13px;
}
.shortcut-list dt { margin: 0; }
.shortcut-list dd { margin: 0; color: var(--text-muted); align-self: center; }
kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 2px 8px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--text);
  min-width: 26px;
  text-align: center;
  font-weight: 500;
}

.help-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
}
.help-footer a { color: var(--accent); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
