/* Brand polish layered on top of Tailwind utility output. */

html { scroll-behavior: smooth; }

/* Custom scrollbars. */
* { scrollbar-width: thin; scrollbar-color: #D8D4FF transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D8D4FF; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #6055FC; }
::-webkit-scrollbar-track { background: transparent; }

/* ─── Layout: projects vs hero vs chat ────────────────────────────────── */
/* PROJECTS mode: only the picker grid is visible; chat/hero/composer hidden.
   HERO mode: chat is hidden, hero is centered, composer sits below hero,
     chips are visible.
   CHAT mode: hero is hidden, chips are hidden, chat fills space and scrolls,
     composer is pinned to the bottom. */

body[data-mode="projects"] #chat,
body[data-mode="projects"] #hero,
body[data-mode="projects"] #composer-wrap { display: none; }

body[data-mode="hero"] #projects-view,
body[data-mode="chat"] #projects-view { display: none; }

body[data-mode="hero"] #chat { display: none; }
body[data-mode="chat"] #hero { display: none; }
body[data-mode="chat"] #starter-chips { display: none; }

body[data-mode="hero"] #composer-wrap { padding-bottom: 4rem; }
body[data-mode="chat"] #composer-wrap {
  background: linear-gradient(to top, #F3F3F3 70%, rgba(250, 250, 252, 0));
  padding-top: 1rem;
}

.activity-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  border: 1px solid #D8D4FF;
  background: #F4F2FF;
  color: #4F46E5;
  border-radius: 0.65rem;
  padding: 0.42rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(96, 85, 252, 0.12);
}

.activity-pulse {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #6055FC;
  box-shadow: 0 0 0 0 rgba(96, 85, 252, 0.45);
  animation: activity-pulse 1.35s ease-out infinite;
  flex: 0 0 auto;
}

#activity[data-state="tools"] .activity-inner {
  border-color: #F5B25A;
  background: #FFF5D8;
  color: #8A5200;
}

#activity[data-state="tools"] .activity-pulse {
  background: #F5B25A;
  box-shadow: 0 0 0 0 rgba(245, 178, 90, 0.45);
}

#activity[data-state="writing"] .activity-inner {
  border-color: #7DD87D;
  background: #ECFCEB;
  color: #166534;
}

#activity[data-state="writing"] .activity-pulse {
  background: #22C55E;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.42);
}

#activity[data-state="stopping"] .activity-inner {
  border-color: #FCA5A5;
  background: #FFE4E4;
  color: #B91C1C;
}

#activity[data-state="stopping"] .activity-pulse {
  background: #DC2626;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.42);
}

@keyframes activity-pulse {
  70% { box-shadow: 0 0 0 0.45rem rgba(96, 85, 252, 0); }
  100% { box-shadow: 0 0 0 0 rgba(96, 85, 252, 0); }
}

#send[data-action="stop"],
#send[data-action="stopping"] {
  background: #DC2626;
}

#send[data-action="stop"]:hover,
#send[data-action="stopping"]:hover {
  background: #B91C1C;
}

/* ─── Project cards ───────────────────────────────────────────────────── */

.project-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  background: white;
  border: 1px solid #EDEDED;
  border-radius: 1rem;
  padding: 1.1rem 1.2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  min-height: 130px;
}
.project-card:hover {
  border-color: #D8D4FF;
  background: #F4F2FF;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(96, 85, 252, 0.12);
}
.project-card:focus-visible {
  outline: 3px solid rgba(96, 85, 252, 0.35);
  outline-offset: 2px;
}
.project-card .name {
  font-family: "Space Grotesk", ui-sans-serif, system-ui;
  font-weight: 700;
  font-size: 1.05rem;
  color: #151618;
  line-height: 1.3;
}
.project-card .meta {
  font-size: 0.75rem;
  color: #85858F;
  margin-top: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.project-card .added {
  font-size: 0.78rem;
  color: #707070;
  margin-top: auto;
  padding-top: 0.75rem;
}
.project-card .remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  color: #85858F;
  display: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}
.project-card { position: relative; }
.project-card:hover .remove,
.project-card:focus-within .remove { display: inline-flex; }
.project-card .remove:hover { background: #FFE4E4; color: #DC2626; }

.add-project-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: transparent;
  border: 2px dashed #D8D4FF;
  border-radius: 1rem;
  padding: 1.1rem 1.2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #6055FC;
  font-weight: 600;
  min-height: 130px;
}
.add-project-tile:hover {
  border-color: #6055FC;
  background: #F4F2FF;
}
.add-project-tile .plus {
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 0.4rem;
}

/* ─── Starter chips ────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  background: white;
  border: 1px solid #EDEDED;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #151618;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.chip:hover {
  border-color: #6055FC;
  background: #F4F2FF;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(96, 85, 252, 0.12);
}
.chip:active { transform: translateY(0); }
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

/* ─── Streaming caret ──────────────────────────────────────────────────── */

.assistant-pending {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  color: #4F46E5;
  background: #F4F2FF;
  border: 1px solid #D8D4FF;
  border-radius: 0.7rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(96, 85, 252, 0.1);
}

.assistant-pending[data-state="tools"] {
  color: #8A5200;
  background: #FFF5D8;
  border-color: #F5B25A;
}

.assistant-pending[data-state="writing"] {
  color: #166534;
  background: #ECFCEB;
  border-color: #7DD87D;
}

.assistant-pending[data-state="stopping"] {
  color: #B91C1C;
  background: #FFE4E4;
  border-color: #FCA5A5;
}

.pending-orb {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: currentColor;
  animation: pending-orb 1.1s ease-in-out infinite;
  flex: 0 0 auto;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding-top: 0.08rem;
}

.thinking-dots i {
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 999px;
  background: #6055FC;
  opacity: 0.35;
  animation: thinking-dot 1.2s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) { animation-delay: 0.16s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.32s; }

@keyframes thinking-dot {
  0%, 70%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes pending-orb {
  0%, 100% { transform: scale(0.85); opacity: 0.45; }
  50% { transform: scale(1.15); opacity: 1; }
}

.streaming::after {
  content: "▍";
  margin-left: 2px;
  animation: blink 1s steps(2, start) infinite;
  color: #6055FC;
}
@keyframes blink { to { visibility: hidden; } }

/* ─── Tool call cards ──────────────────────────────────────────────────── */

.message-row {
  position: relative;
}

.user-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #EDEDED;
  border-radius: 999px;
  background: white;
  color: #707070;
  line-height: 0;
  padding: 0.32rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.message-copy svg {
  display: block;
}

.assistant-actions {
  display: flex;
  margin-top: 0.3rem;
}

.message-row:hover .message-copy,
.message-row:focus-within .message-copy {
  opacity: 1;
}

.message-copy:hover,
.message-copy.copied {
  border-color: #D8D4FF;
  background: #F4F2FF;
  color: #4F46E5;
}

.user-row .message-copy {
  margin-top: 0.35rem;
}

@media (hover: none) {
  .message-copy {
    opacity: 1;
  }
}

.tool-group {
  width: min(100%, 46rem);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.74);
  color: #151618;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tool-group.has-error {
  border-color: rgba(220, 38, 38, 0.22);
  background: rgba(255, 255, 255, 0.86);
}

.tool-group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2rem;
  padding: 0.34rem 0.6rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.tool-group-summary:hover {
  background: rgba(96, 85, 252, 0.035);
}

.tool-group-summary::-webkit-details-marker {
  display: none;
}

.tool-group-left {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 0.4rem;
}

.tool-group-left::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #6055FC;
  box-shadow: 0 0 0 3px rgba(96, 85, 252, 0.1);
}

.tool-group.has-error .tool-group-left::before {
  background: #DC2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* A call stopped for approval is waiting, not broken — amber, not red. */
.tool-group.has-awaiting .tool-group-left::before {
  background: #F59E0B;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

/* Pulsing dot + coloured title while tools are running. */
.tool-group.is-running .tool-group-left::before {
  animation: tool-running-pulse 1.1s ease-in-out infinite;
}

.tool-group.is-running .tool-group-title {
  color: #6055FC;
}

@keyframes tool-running-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 3px rgba(96, 85, 252, 0.14);
  }
  50% {
    transform: scale(0.78);
    box-shadow: 0 0 0 6px rgba(96, 85, 252, 0.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool-group.is-running .tool-group-left::before {
    animation: none;
  }
}

.tool-group-chev {
  display: inline-block;
  color: #85858F;
  font-size: 0.65rem;
  transition: transform 0.15s ease;
}

.tool-group[open] > .tool-group-summary .tool-group-chev {
  transform: rotate(90deg);
}

.tool-group-title {
  font-size: 0.74rem;
  font-weight: 650;
  color: #555660;
}

.tool-group-meta {
  flex-shrink: 0;
  color: #85858F;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.tool-group.has-error .tool-group-meta {
  color: #B91C1C;
}

.tool-group.has-awaiting .tool-group-meta {
  color: #B45309;
}

.tool-list {
  display: grid;
  gap: 0.2rem;
  padding: 0.3rem 0.4rem 0.42rem;
  border-top: 1px solid rgba(21, 22, 24, 0.08);
  background: rgba(250, 250, 250, 0.72);
}

.tool-call {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.8rem;
  padding: 0.32rem 0.45rem;
  border-radius: 0.42rem;
}

.tool-call.error {
  background: rgba(255, 241, 242, 0.72);
}

.tool-call.awaiting {
  background: rgba(255, 251, 235, 0.8);
}

.tool-call .tool-name {
  overflow: hidden;
  color: #4F46E5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-call[data-status="done"] .tool-name {
  color: #555660;
  font-weight: 600;
}

.tool-call[data-status="error"] .tool-name {
  color: #B91C1C;
}

.tool-call[data-status="awaiting"] .tool-name {
  color: #B45309;
}

/* ── Web research calls: globe badge + query/domain detail + shimmer ── */

.tool-call.web {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.07), rgba(14, 165, 233, 0.10));
}

.tool-call.web.error {
  background: rgba(255, 241, 242, 0.72);
}

.tool-web-globe {
  flex: 0 0 auto;
  font-size: 0.82rem;
  line-height: 1;
}

.tool-call.web[data-status="running"] .tool-web-globe {
  animation: web-globe-pulse 1.4s ease-in-out infinite;
}

@keyframes web-globe-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.22); opacity: 0.65; }
}

/* Shimmering label while the search/fetch is in flight. */
.tool-call.web[data-status="running"] .tool-name {
  background: linear-gradient(90deg, #2563EB 0%, #0EA5E9 40%, #7DD3FC 50%, #0EA5E9 60%, #2563EB 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: web-shimmer 1.8s linear infinite;
}

@keyframes web-shimmer {
  from { background-position: 0% 0; }
  to { background-position: -220% 0; }
}

/* The query being searched / domain being read. */
.tool-web-detail {
  overflow: hidden;
  color: #0369A1;
  font-size: 0.72rem;
  font-style: italic;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 24rem;
}

.tool-call.web[data-status="done"] .tool-web-detail {
  color: #6B7280;
}

@media (prefers-reduced-motion: reduce) {
  .tool-call.web[data-status="running"] .tool-web-globe {
    animation: none;
  }
  .tool-call.web[data-status="running"] .tool-name {
    animation: none;
    background: none;
    color: #2563EB;
  }
}

/* Per-tool status icon: spinner while running, ✓ when done, ✕ on error. */
.tool-call-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  box-sizing: border-box;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  color: #FFFFFF;
}

.tool-call[data-status="running"] .tool-call-icon {
  border: 2px solid rgba(96, 85, 252, 0.22);
  border-top-color: #6055FC;
  animation: tool-spin 0.7s linear infinite;
}

.tool-call[data-status="done"] .tool-call-icon {
  background: #10B981;
}

.tool-call[data-status="done"] .tool-call-icon::after {
  content: "✓";
}

.tool-call[data-status="error"] .tool-call-icon {
  background: #EF4444;
}

.tool-call[data-status="error"] .tool-call-icon::after {
  content: "✕";
}

.tool-call[data-status="awaiting"] .tool-call-icon {
  background: #F59E0B;
}

.tool-call[data-status="awaiting"] .tool-call-icon::after {
  content: "!";
}

/* "waiting for approval" next to the paused call's name. */
.tool-call-note {
  overflow: hidden;
  color: #B45309;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes tool-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool-call[data-status="running"] .tool-call-icon {
    animation: none;
  }
}

/* ─── User bubble ──────────────────────────────────────────────────────── */

.user-message {
  background: linear-gradient(135deg, #6055FC 0%, #4F46E5 100%);
  color: white;
  border-radius: 1rem 1rem 0.25rem 1rem;
  padding: 0.7rem 1rem;
  max-width: 75%;
  align-self: flex-end;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(96, 85, 252, 0.2);
  font-size: 0.95rem;
}

/* ─── Markdown ────────────────────────────────────────────────────────── */

.assistant-md {
  font-size: 0.95rem;
  line-height: 1.55;
  color: #151618;
}
.assistant-md > * + * { margin-top: 0.75rem; }
.assistant-md strong { color: #151618; font-weight: 600; }
.assistant-md em { font-style: italic; color: #4A4A55; }
.assistant-md code {
  background: #FCFDD0;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  color: #4F46E5;
}
.assistant-md pre {
  background: #151618;
  color: #FCFDD0;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre;
}
.assistant-md pre code { background: transparent; color: inherit; padding: 0; }
.assistant-md ul { list-style: disc; padding-left: 1.25rem; }
.assistant-md ol { list-style: decimal; padding-left: 1.25rem; }
.assistant-md li + li { margin-top: 0.25rem; }
.assistant-md h1, .assistant-md h2, .assistant-md h3 {
  font-family: "Space Grotesk", ui-sans-serif, system-ui;
  font-weight: 600;
  color: #151618;
}
.assistant-md h1 { font-size: 1.25rem; }
.assistant-md h2 { font-size: 1.1rem; color: #4F46E5; }
.assistant-md h3 { font-size: 1rem; }
.assistant-md a { color: #6055FC; text-decoration: underline; }
.assistant-md blockquote {
  border-left: 3px solid #D8D4FF;
  padding-left: 0.75rem;
  color: #4A4A55;
  font-style: italic;
}

/* Markdown tables. */
.assistant-md .md-table {
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #EDEDED;
  border-radius: 0.5rem;
  overflow: hidden;
  font-size: 0.9rem;
  width: 100%;
  display: block;
  overflow-x: auto;
}
.assistant-md .md-table thead { background: #F4F2FF; }
.assistant-md .md-table th {
  text-align: left;
  font-family: "Space Grotesk", ui-sans-serif, system-ui;
  font-weight: 600;
  color: #4F46E5;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid #D8D4FF;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}
.assistant-md .md-table td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid #F4F4F8;
  vertical-align: top;
  color: #151618;
}
.assistant-md .md-table tbody tr:last-child td { border-bottom: none; }
.assistant-md .md-table tbody tr:hover { background: #FCFDD0; }
.assistant-md .md-table td code,
.assistant-md .md-table th code {
  font-size: 0.82em;
  padding: 0.05rem 0.3rem;
}

/* Scroll-to-bottom pill */
#scroll-pill {
  animation: pill-pop 0.18s ease-out;
}
@keyframes pill-pop {
  from { transform: translate(-50%, 8px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Markdown tables. */
.assistant-md .md-table {
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #EDEDED;
  border-radius: 0.5rem;
  overflow: hidden;
  font-size: 0.9rem;
  width: 100%;
  display: block;
  overflow-x: auto;
}
.assistant-md .md-table thead {
  background: #F4F2FF;
}
.assistant-md .md-table th {
  text-align: left;
  font-family: "Space Grotesk", ui-sans-serif, system-ui;
  font-weight: 600;
  color: #4F46E5;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid #D8D4FF;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}
.assistant-md .md-table td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid #F4F4F8;
  vertical-align: top;
  color: #151618;
}
.assistant-md .md-table tbody tr:last-child td {
  border-bottom: none;
}
.assistant-md .md-table tbody tr:hover {
  background: #FCFDD0;
}
.assistant-md .md-table td code,
.assistant-md .md-table th code {
  /* Keep code chips tight inside cells. */
  font-size: 0.82em;
  padding: 0.05rem 0.3rem;
}

/* Composer textarea auto-grow */
#input { max-height: 12rem; min-height: 56px; }

/* ─── Attachment pills (in composer) ──────────────────────────────────── */
.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.55rem 0.3rem 0.65rem;
  background: #F4F2FF;
  border: 1px solid #D8D4FF;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #4F46E5;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-pill .filename {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 18ch;
}
.attachment-pill .size {
  color: #85858F;
  font-weight: 400;
  font-size: 0.7rem;
}
.attachment-pill .remove {
  background: transparent;
  border: 0;
  color: #6055FC;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.attachment-pill .remove:hover {
  background: #6055FC;
  color: white;
}
.attachment-pill.uploading { opacity: 0.6; }
.attachment-pill.error {
  background: #FFE4E4;
  border-color: #FCA5A5;
  color: #B91C1C;
}

/* ─── Inline (assistant-side) file pill ───────────────────────────────── */
.user-attachment-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
  max-width: 75%;
  align-self: flex-end;
}
.user-attachment {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.55rem;
  background: white;
  border: 1px solid #D8D4FF;
  border-radius: 999px;
  font-size: 0.72rem;
  color: #4F46E5;
}

/* ─── Drop overlay ────────────────────────────────────────────────────── */
body.dragging-file #drop-overlay {
  opacity: 1;
}

/* ─── Header credits chip ─────────────────────────────────────────────── */
/* Out of credits: flip the yellow pill to a warning red so the user
   notices before an AI feature run fails. */
#credits-chip {
  position: relative;
  overflow: visible;
}

#credits-chip.credits-low {
  background: #FDE8E8;
  color: #B42318;
}

/* Floating "+N" / "−N" badge that rises and fades when the balance changes. */
.credit-delta {
  position: absolute;
  left: 50%;
  top: -0.35rem;
  transform: translate(-50%, 0);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
  animation: credit-delta-rise 1.1s ease-out forwards;
}

.credit-delta.up {
  color: #10B981;
}

.credit-delta.down {
  color: #EF4444;
}

@keyframes credit-delta-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 0.25rem);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -1.1rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .credit-delta {
    animation-duration: 0.01ms;
  }
}

.dario-animation {
  display: block;
  width: auto;
  height: clamp(7.5rem, 12vw, 9rem);
  max-width: min(18rem, 72vw);
  max-height: none;
  object-fit: contain;
  object-position: center;
  margin: 0 auto 1.25rem;
  opacity: 1;
}

/* ─── Andromeda platform UI refresh ──────────────────────────────────── */
:root {
  --an-purple: #6055FC;
  --an-purple-dark: #4F46E5;
  --an-purple-light: #D8D4FF;
  --an-purple-tint: #F4F2FF;
  --an-yellow: #F8FC7E;
  --an-yellow-soft: #FCFDD0;
  --an-teal: #63D7CC;
  --an-black: #151618;
  --an-gray-900: #24252A;
  --an-gray-700: #555660;
  --an-gray-600: #707070;
  --an-gray-500: #85858F;
  --an-gray-200: #EDEDED;
  --an-gray-100: #F3F3F3;
  --surface: #FFFFFF;
  --surface-subtle: #FAFAFA;
  --border: rgba(21, 22, 24, 0.1);
  --shadow-sm: 0 1px 2px rgba(21, 22, 24, 0.04);
  --shadow-md: 0 10px 24px rgba(21, 22, 24, 0.08);
  --radius-card: 0.5rem;
  --radius-control: 0.5rem;
}

html,
body {
  background: var(--an-gray-100);
  color: var(--an-black);
}

body {
  min-width: 320px;
}

button,
textarea,
input {
  letter-spacing: 0;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
.project-card:focus-visible,
.add-project-tile:focus-visible {
  outline: 3px solid rgba(96, 85, 252, 0.28);
  outline-offset: 2px;
}

.app-header {
  min-height: 4.1rem;
}

.app-header-inner {
  min-height: 4rem;
}

.header-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: 0.4rem 0.6rem;
  font-weight: 600;
}

.header-action:hover {
  border-color: var(--border);
  background: var(--surface-subtle);
}

#project-chip {
  max-width: min(38vw, 22rem);
}

#project-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#status-dot {
  box-shadow: 0 0 0 3px rgba(96, 85, 252, 0.08);
}

body[data-mode="hero"] #composer-wrap {
  padding-bottom: 1.5rem;
}

body[data-mode="chat"] #composer-wrap {
  background: linear-gradient(to top, var(--an-gray-100) 72%, rgba(243, 243, 243, 0));
  padding-top: 0.75rem;
}

#projects-view,
#chat {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 20rem),
    var(--an-gray-100);
}

#welcome-hero {
  gap: 0;
}

#welcome-intro,
#dario-intro {
  width: auto !important;
  height: clamp(7.5rem, 12vw, 9rem) !important;
  max-width: min(18rem, 72vw);
  max-height: none;
  object-fit: contain;
  object-position: center;
  margin-bottom: 1.25rem !important;
}

#welcome-hero p,
#hero p {
  color: var(--an-gray-700);
}

#projects-list h1,
#welcome-hero h1,
#hero h1,
#add-project-card h2 {
  letter-spacing: 0;
}

#welcome-hero h1,
#hero h1 {
  font-size: 2.5rem;
  line-height: 1.08;
}

#projects-list h1 {
  font-size: 2.25rem;
  line-height: 1.12;
}

#add-project-open,
#welcome-connect,
#add-project-submit {
  border-radius: var(--radius-control);
}

#projects-grid {
  align-items: stretch;
}

#add-project-card > div {
  border-color: var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

#add-project-error {
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-control);
  background: #FFF1F2;
  padding: 0.7rem 0.8rem;
}

.project-card {
  border-color: var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  min-height: 9.25rem;
  padding: 1rem;
}

.project-card::before {
  content: "";
  width: 2.15rem;
  height: 2.15rem;
  border-radius: var(--radius-control);
  background:
    linear-gradient(135deg, rgba(96, 85, 252, 0.16), rgba(99, 215, 204, 0.18)),
    var(--surface);
  border: 1px solid rgba(96, 85, 252, 0.14);
  margin-bottom: 0.8rem;
}

.project-card:hover {
  border-color: rgba(96, 85, 252, 0.28);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.project-card .name {
  color: var(--an-black);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
}

.project-card .meta {
  color: var(--an-gray-500);
}

.project-card .added {
  color: var(--an-gray-600);
}

.project-card .remove {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--an-gray-500);
}

.project-card .remove:hover {
  background: #FFF1F2;
  color: #DC2626;
}

.add-project-tile {
  min-height: 9.25rem;
  border: 1px dashed rgba(96, 85, 252, 0.42);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.54);
  color: var(--an-purple);
}

.add-project-tile:hover {
  border-color: var(--an-purple);
  background: var(--an-purple-tint);
  transform: translateY(-1px);
}

.add-project-tile .plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: var(--radius-control);
  background: var(--an-purple);
  color: #FFFFFF;
  font-size: 1.35rem;
}

#messages {
  width: 100%;
}

.message-row {
  width: 100%;
}

.assistant-row {
  display: grid !important;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.85rem !important;
  align-items: start;
}

.assistant-row > img {
  width: 2.25rem !important;
  height: 2.25rem !important;
  border-radius: var(--radius-control);
  background: white;
  border: 1px solid var(--border);
  padding: 0.18rem;
  margin-top: 0 !important;
}

.assistant-row > img.assistant-avatar {
  object-fit: cover !important;
  object-position: 58% 26%;
  background: var(--an-purple-tint);
}

.assistant-body {
  position: relative;
}

.assistant-content {
  max-width: 52rem;
  padding-top: 0.22rem;
}

.assistant-md {
  color: var(--an-black);
  font-size: 0.96rem;
  line-height: 1.65;
}

.assistant-md h1,
.assistant-md h2,
.assistant-md h3 {
  letter-spacing: 0;
}

.assistant-md h2 {
  color: var(--an-purple-dark);
}

.assistant-md code {
  background: var(--an-yellow-soft);
  color: var(--an-purple-dark);
}

.assistant-md pre {
  background: var(--an-black);
  color: var(--an-yellow-soft);
  border-radius: var(--radius-card);
}

.assistant-md .md-table {
  border-color: var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  display: block;
  width: fit-content;
  min-width: min(32rem, 100%);
  max-width: 100%;
}

.assistant-md .md-table th {
  background: var(--an-purple-tint);
  color: var(--an-purple-dark);
  letter-spacing: 0;
}

.assistant-md .md-table tbody tr:hover {
  background: rgba(248, 252, 126, 0.34);
}

.user-row {
  align-items: flex-end;
}

.user-message {
  max-width: min(78%, 48rem);
  border-radius: 1rem 1rem 0.25rem 1rem;
  background: var(--an-purple);
  box-shadow: 0 8px 20px rgba(96, 85, 252, 0.16);
  font-size: 0.96rem;
  line-height: 1.55;
}

.message-copy {
  border-color: var(--border);
  color: var(--an-gray-600);
  border-radius: 999px;
  font-weight: 600;
}

.message-copy:hover,
.message-copy.copied {
  border-color: rgba(96, 85, 252, 0.32);
  background: var(--an-purple-tint);
  color: var(--an-purple-dark);
}

.chip {
  border-color: var(--border);
  border-radius: 999px;
  color: var(--an-black);
  box-shadow: var(--shadow-sm);
}

.chip:hover {
  border-color: rgba(96, 85, 252, 0.36);
  background: var(--an-purple-tint);
  box-shadow: 0 8px 18px rgba(96, 85, 252, 0.1);
}

.chip .dot {
  flex: 0 0 auto;
}

#composer {
  filter: drop-shadow(0 12px 24px rgba(21, 22, 24, 0.08));
}

.composer-field {
  position: relative;
}

#input {
  display: block;
  min-height: 58px;
  max-height: 12rem;
  border-color: var(--border);
  border-radius: 0.85rem;
  color: var(--an-black);
  line-height: 1.5;
  box-shadow: none;
}

#input:disabled {
  background: #FAFAFA;
  color: var(--an-gray-600);
}

#send,
#attach {
  border-radius: var(--radius-control);
  top: 50%;
  transform: translateY(-50%);
}

#send {
  background: var(--an-purple);
}

#send:hover {
  background: var(--an-purple-dark);
}

#send[data-action="stop"],
#send[data-action="stopping"] {
  background: #DC2626;
}

.activity-inner,
.assistant-pending {
  border-color: rgba(96, 85, 252, 0.24);
  background: var(--an-purple-tint);
  color: var(--an-purple-dark);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.activity-pulse,
.pending-orb {
  background: currentColor;
}

.thinking-dots i {
  background: currentColor;
}

.attachment-pill {
  border-color: rgba(96, 85, 252, 0.24);
  background: var(--an-purple-tint);
  color: var(--an-purple-dark);
}

.attachment-icon,
.user-attachment-icon {
  display: inline-flex;
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}

.user-attachment-line {
  max-width: min(78%, 48rem);
}

.user-attachment {
  border-color: rgba(96, 85, 252, 0.28);
  color: var(--an-purple-dark);
}

#drop-overlay > div {
  border-radius: var(--radius-card);
}

#scroll-pill {
  border-radius: 999px;
  background: var(--an-purple);
  box-shadow: var(--shadow-md);
}

#activity {
  display: none !important;
}

body[data-mode="hero"] #hero {
  flex: 1 1 auto;
  justify-content: center;
  padding-top: 2rem;
  padding-bottom: 1.25rem;
}

body[data-mode="hero"] #composer-wrap {
  flex: 0 0 auto;
  padding-top: 0;
  padding-bottom: 1.25rem;
}

body[data-mode="hero"] #starter-chips {
  margin-top: 0.9rem;
}

body[data-mode="hero"] #starter-chips > .text-xs {
  margin-bottom: 0.65rem;
}

body[data-mode="hero"] #starter-chips .flex {
  align-items: center;
  justify-content: flex-start;
  row-gap: 0.55rem;
}

body[data-mode="hero"] #model-info {
  display: none;
}

@media (max-width: 760px) {
  .app-header {
    min-height: 3.75rem;
  }

  .app-header-inner {
    min-height: 3.75rem;
    gap: 0.6rem;
  }

  #project-chip {
    order: 3;
    flex-basis: 100%;
    max-width: 100%;
    margin-left: 0;
  }

  .app-header-inner {
    flex-wrap: wrap;
  }

  .header-action span {
    display: none;
  }

  .header-action {
    width: 2rem;
    padding: 0;
  }

  body[data-mode="hero"] #composer-wrap {
    padding-bottom: 1rem;
  }

  #welcome-hero,
  #hero {
    justify-content: flex-start;
    min-height: auto;
  }

  body[data-mode="hero"] #hero {
    padding-top: 1.75rem;
    padding-bottom: 0.75rem;
  }

  #welcome-intro,
  #dario-intro,
  .dario-animation {
    width: auto !important;
    height: clamp(6.5rem, 28vw, 7.75rem) !important;
    max-width: min(16rem, 78vw);
    max-height: none;
    margin-bottom: 0.9rem !important;
  }

  #starter-chips {
    margin-top: 0.75rem;
    max-width: min(100%, calc(100vw - 1.5rem));
  }

  body[data-mode="hero"] #starter-chips .flex,
  #starter-chips .flex {
    justify-content: flex-start;
    overflow-x: visible;
    flex-wrap: wrap;
    padding: 0;
    margin-left: 0;
    margin-right: 0;
  }

  .chip {
    flex: 0 1 auto;
    max-width: 100%;
    padding-inline: 0.8rem;
  }

  .assistant-row {
    grid-template-columns: 1.9rem minmax(0, 1fr);
    gap: 0.65rem !important;
  }

  .assistant-row > img {
    width: 1.9rem !important;
    height: 1.9rem !important;
  }

  .user-message,
  .user-attachment-line {
    max-width: 92%;
  }

  #messages {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  #composer-wrap {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* ── Choice pills (offer_choices tool) ──────────────────────────────── */
.choice-card {
  margin: 0.5rem 0;
}

.choice-prompt {
  font-family: "Space Grotesk", ui-sans-serif, system-ui;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--an-black);
  margin-bottom: 0.5rem;
}

.choice-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.choice-pill {
  font-family: "Space Grotesk", ui-sans-serif, system-ui;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--an-purple-light);
  background: var(--an-purple-tint);
  color: var(--an-purple-dark);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}

.choice-pill:hover:not(:disabled) {
  background: var(--an-purple-light);
  border-color: var(--an-purple);
}

.choice-pill:active:not(:disabled) {
  transform: translateY(1px);
}

.choice-pill:disabled {
  cursor: default;
  opacity: 0.55;
}

.choice-pill.picked {
  background: var(--an-purple);
  border-color: var(--an-purple);
  color: #ffffff;
  opacity: 1;
}

.choice-card.answered .choice-pill:not(.picked) {
  opacity: 0.4;
}

/* ── Approval card (confirmation-gated tool calls) ──────────────────── */
.confirm-card {
  border: 1px solid var(--an-purple-light);
  border-radius: 0.75rem;
  background: var(--an-purple-tint);
  padding: 0.75rem 0.9rem;
}

/* The Approve/Deny echo: the user tapped a button, so show a compact
   decision chip instead of a full message bubble carrying a raw command.
   See userDecisionLabel in app.js. */
.user-message.approved,
.user-message.denied {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--an-purple-tint);
  border: 1px solid var(--an-purple-light);
  color: var(--an-purple-dark);
  box-shadow: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.user-message.approved::before {
  content: "✓";
  font-size: 0.8rem;
}

.user-message.denied {
  background: var(--an-gray-100);
  border-color: var(--an-gray-200);
  color: var(--an-gray-700);
}

.user-message.denied::before {
  content: "✕";
  font-size: 0.72rem;
}

/* Labelled fields, not raw JSON — see renderConfirmArgs in app.js. */
.confirm-args {
  display: grid;
  gap: 0.3rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--an-gray-900);
  background: #ffffff;
  border: 1px solid var(--an-purple-light);
  border-radius: 0.5rem;
  padding: 0.55rem 0.7rem;
  margin: 0 0 0.6rem;
  max-height: 14rem;
  overflow: auto;
}

.confirm-arg {
  display: grid;
  grid-template-columns: minmax(6rem, 10rem) 1fr;
  gap: 0.2rem 0.75rem;
  align-items: baseline;
}

.confirm-arg + .confirm-arg {
  border-top: 1px solid rgba(21, 22, 24, 0.07);
  padding-top: 0.3rem;
}

.confirm-arg dt {
  color: var(--an-gray-700);
  font-size: 0.76rem;
  font-weight: 600;
}

.confirm-arg dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

/* Ids and nested payloads: monospaced so they can be checked character
   by character. Prose values stay in the body font. */
.confirm-arg dd.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--an-gray-700);
  white-space: pre-wrap;
}

@media (max-width: 520px) {
  .confirm-arg {
    grid-template-columns: 1fr;
  }
}

.choice-pill.approve {
  background: var(--an-purple);
  border-color: var(--an-purple);
  color: #ffffff;
}

.choice-pill.approve:hover:not(:disabled) {
  background: var(--an-purple-dark);
  border-color: var(--an-purple-dark);
}

.choice-pill.deny {
  background: transparent;
  border-color: var(--an-gray-200);
  color: var(--an-gray-700);
}

.choice-pill.deny:hover:not(:disabled) {
  background: var(--an-gray-100);
  border-color: var(--an-gray-500);
}

/* ─── Paper attachments ───────────────────────────────────────────────
   Pending files render as small dog-eared paper sheets on a "desk" row
   above the composer; once sent they tuck behind the chat bar with just
   their tops peeking out (#paper-peek, inside .composer-field). The
   mini content on each sheet is the file's real first lines, read
   client-side at attach time. */

#attachments {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 18px;
  padding: 6px 10px 16px;
}

.paper-wrap {
  position: relative;
  transition: transform 0.18s ease;
  animation: paper-in 0.25s ease;
}
@keyframes paper-in {
  from { transform: translateY(14px); opacity: 0; }
  to { opacity: 1; }
}
.paper-wrap:nth-child(4n + 1) { transform: rotate(-2.4deg); }
.paper-wrap:nth-child(4n + 2) { transform: rotate(1.8deg); }
.paper-wrap:nth-child(4n + 3) { transform: rotate(-1deg); }
.paper-wrap:nth-child(4n + 4) { transform: rotate(2.2deg); }
.paper-wrap:hover { transform: translateY(-6px) rotate(0deg); z-index: 3; }

.paper {
  position: relative;
  width: 84px;
  height: 104px;
  background: #fffdf8;
  border-radius: 2px;
  box-shadow:
    0 1px 2px rgba(21, 22, 24, 0.1),
    0 6px 14px rgba(21, 22, 24, 0.13),
    inset 0 0 24px rgba(120, 100, 60, 0.04);
  overflow: hidden;
}
.paper::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 15px 15px 0;
  border-color: var(--an-gray-100) var(--an-gray-100) #e7e2d6 #e7e2d6;
  box-shadow: -1px 1px 2px rgba(21, 22, 24, 0.12);
  z-index: 2;
}

.paper-mini {
  position: absolute;
  inset: 0;
  padding: 8px 7px 6px;
  font: 500 4.6px/1.55 ui-monospace, Menlo, monospace;
  color: #6b6b70;
  white-space: pre;
  overflow: hidden;
}
.paper-mini .hd { color: var(--an-black); font-weight: 700; }
.paper.grid .paper-mini {
  background:
    repeating-linear-gradient(to right, transparent 0 24px, rgba(96, 85, 252, 0.09) 24px 24.6px),
    repeating-linear-gradient(to bottom, transparent 0 7.1px, rgba(21, 22, 24, 0.05) 7.1px 7.6px);
  background-position: 7px 14px, 0 13px;
}
.paper.ruled .paper-mini {
  font-family: Georgia, serif;
  font-size: 5.2px;
  white-space: normal;
  color: #555;
  background: repeating-linear-gradient(to bottom, transparent 0 8px, rgba(21, 22, 24, 0.05) 8px 8.6px);
  background-position: 0 12px;
}
.paper.photo { padding: 6px 6px 0; background: #fff; }
.paper.photo::before { display: none; } /* polaroids don't dog-ear */
.paper.photo .paper-pic {
  height: 72px;
  border-radius: 1px;
  background: linear-gradient(160deg, var(--an-purple-light), var(--an-teal));
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  font-size: 22px;
}
.paper.error { outline: 2px solid #C63A2F33; }
.paper-stamp {
  position: absolute;
  top: 38px;
  left: 4px;
  right: 4px;
  text-align: center;
  transform: rotate(-9deg);
  font: 700 10px/1.6 Georgia, serif;
  color: #C63A2F;
  border: 1.5px solid #C63A2F;
  border-radius: 3px;
  background: #fffdf8ee;
  z-index: 3;
}

.paper-label {
  margin-top: 7px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.paper-sub {
  text-align: center;
  font-size: 10px;
  color: var(--an-gray-500);
}
.paper-sub .up { color: var(--an-purple-dark); }

.paper-rm {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: #fff;
  color: #C63A2F;
  font: 700 13px/1 Georgia, serif;
  box-shadow: 0 1px 5px rgba(21, 22, 24, 0.2);
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.7) rotate(-8deg);
  transition: all 0.13s;
  z-index: 4;
}
.paper-wrap:hover .paper-rm,
.peek-paper:hover .paper-rm { opacity: 1; transform: scale(1) rotate(-8deg); }
.paper-rm:hover { background: #C63A2F; color: #fff; }

.paper-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 14px;
  background: linear-gradient(to bottom, rgba(96, 85, 252, 0.28), rgba(96, 85, 252, 0));
  animation: paper-scan 1.4s linear infinite;
  z-index: 3;
}
@keyframes paper-scan {
  from { top: -14px; }
  to { top: 104px; }
}

/* ── Peeking sent papers, tucked behind the chat bar ── */
#paper-peek {
  position: absolute;
  top: -25px;
  left: 22px;
  right: 116px;
  height: 25px;
  z-index: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}
/* the field content must cover the papers' lower halves */
#input { position: relative; z-index: 1; }
#send, #attach { z-index: 2; }

.peek-paper {
  position: relative;
  width: 66px;
  height: 88px;
  flex: 0 0 auto;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.18s ease;
}
.peek-paper .paper {
  width: 66px;
  height: 88px;
}
.peek-paper .paper-mini { font-size: 4.2px; padding: 17px 6px 4px; }
.peek-paper:nth-child(2n) { transform: rotate(1.6deg); }
.peek-paper:nth-child(2n + 1) { transform: rotate(-1.4deg); }
.peek-paper:hover { transform: translateY(-40px) rotate(0deg); }
.peek-name {
  position: absolute;
  top: 3px;
  left: 4px;
  right: 14px;
  font-size: 6.5px;
  font-weight: 700;
  color: var(--an-gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 3;
}
.peek-more {
  align-self: flex-start;
  pointer-events: auto;
  font-size: 10px;
  font-weight: 700;
  color: var(--an-gray-500);
  background: #fffdf8;
  border: 1px solid var(--an-gray-200);
  border-radius: 99px;
  padding: 2px 8px;
  margin-top: 2px;
  box-shadow: 0 1px 3px rgba(21, 22, 24, 0.1);
}

/* ID selectors above outrank the .hidden utility — restore its power. */
#attachments.hidden,
#paper-peek.hidden { display: none; }

/* A paper Dario is currently reading: rises from behind the bar and
   glows while the scanner sweeps (driven by tool_start/tool_end). */
.peek-paper.reading {
  transform: translateY(-32px) rotate(0deg);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 2;
}
.peek-paper.reading .paper {
  box-shadow:
    0 1px 2px rgba(21, 22, 24, 0.1),
    0 10px 22px rgba(96, 85, 252, 0.35),
    inset 0 0 24px rgba(120, 100, 60, 0.04);
  animation: paper-read-pulse 1.2s ease-in-out infinite alternate;
}
@keyframes paper-read-pulse {
  from { outline: 2px solid rgba(96, 85, 252, 0.0); }
  to { outline: 2px solid rgba(96, 85, 252, 0.45); }
}
