/* app.css: the logged-in app's interactive pieces (Lilac & Co., 2026-10-23). Owner: app builder.
   Loads on app pages after tokens.css, eaf-art.css and site.css. Uses site.css tokens and the pixel frame (--pb/--pd/--pi).
   Sections: 1 chat thread  2 composer + cat  3 slash menu  4 document drawer  5 nudge + notes  6 community  7 flock watch
   Motion: every animation uses steps() and is off under reduced motion (tokens zero the --t-* durations; see the end too). */

/* =============================== 1 chat thread =============================== */
.art-band--app.is-shrinking { overflow: hidden; }
.thread { padding-bottom: 72px; }                     /* the last message clears the cat sitting on the message box */
.msg--user p { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg--ai .msg__body { overflow-wrap: break-word; }
.msg__avatar { display: inline-grid; place-items: center; }
.msg__head .chip { margin: 0; }
.msg__searched {
  margin-left: auto; font: 400 12px/1.4 var(--font-label); letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3);
}
.msg .claim { margin-right: 4px; vertical-align: 1px; }
.msg p + p { margin-top: 0; }
.msg strong { color: var(--heading); }

/* citation marks: small manila numbers that open the matching case file */
.cite-ref {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin: 0 1px; padding: 0 3px; border: 0; cursor: pointer;
  background: var(--manila); color: var(--manila-ink); font: 600 12px/1 var(--font-title); vertical-align: 2px;
  box-shadow: inset 0 -2px 0 var(--manila-2);
}
.cite-ref:hover { background: var(--manila-3); }
.cite-ref:focus-visible { outline-offset: 2px; }
.msg sup { font-size: 1em; line-height: 0; vertical-align: 0; margin: 0; }

/* thinking: three pixel dots that step (about 1 Hz) and a status line */
.thinking { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--text-2); font-size: 15px; }
.thinking__dots { display: inline-flex; gap: 4px; }
.thinking__dots i { width: 6px; height: 6px; background: var(--amber); opacity: 0.3; animation: think-dot 1.2s steps(1) infinite; }
.thinking__dots i:nth-child(2) { animation-delay: 0.4s; }
.thinking__dots i:nth-child(3) { animation-delay: 0.8s; }
@keyframes think-dot { 0% { opacity: 1; } 34% { opacity: 0.3; } }
.thinking__text::after { content: ""; }

/* streaming: a block cursor at the end of the text */
.msg__body.is-streaming > p:last-child::after {
  content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 3px; vertical-align: -0.15em; background: var(--brand);
}

/* case files under an answer */
.msg__files { align-items: flex-end; margin-top: var(--s5); padding-top: var(--s4); box-shadow: inset 0 3px 0 var(--border); }
.msg__files-label { flex: 1 0 100%; font: 400 12px/1.4 var(--font-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.msg .case-tab { max-width: 100%; }
.msg .case-tab__doc { overflow-wrap: anywhere; }
.msg .case-tab__doc b { display: block; margin: 1px 0 0; font-weight: 600; font-size: 13px; color: #5A4318; }
.msg .case-tab__doc b::before { content: "\00a7  "; }
@media (min-width: 700px) { .msg .case-tab { max-width: calc(50% - 4px); flex: 1 1 280px; } }
.msg.is-done .msg__files .case-tab { animation: tab-in 360ms steps(4) both; }
.msg.is-done .msg__files .case-tab:nth-of-type(2) { animation-delay: 90ms; }
.msg.is-done .msg__files .case-tab:nth-of-type(3) { animation-delay: 180ms; }
@keyframes tab-in { from { transform: translateY(12px); opacity: 0; } }

/* follow-up chips (also the demo town buttons on Flock Watch) */
.followups { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--s4); }
.followup {
  --pb: var(--border-strong); display: inline-flex; align-items: center; min-height: 44px; margin: var(--px); padding: 8px 14px; border: 0;
  background: var(--surface-2); color: var(--heading); font: 500 15px/1.3 var(--font-body); text-align: left; cursor: pointer;
  box-shadow: 0 -3px 0 0 var(--pb), 0 3px 0 0 var(--pb), -3px 0 0 0 var(--pb), 3px 0 0 0 var(--pb);
  transition: transform var(--t-fast) steps(2);
}
.followup::before { content: "?"; margin-right: 10px; font: 600 15px var(--font-title); color: var(--link); }
.followup:hover { background: var(--surface-3); transform: translateY(-2px); }

/* =============================== 2 composer + cat =============================== */
.composer.is-busy .btn--send { opacity: 0.6; }
.composer.is-spent { --pb: var(--blood-text); }
.composer.is-spent:focus-within { --pb: var(--focus); }
.composer__hint { align-items: center; flex-wrap: wrap; }
.composer__meter { margin-left: auto; font: 400 12px/1.4 var(--font-label); letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.composer__meter.is-empty { color: var(--blood-text); }
.composer__flag { display: inline-flex; align-items: center; gap: 6px; color: var(--lab-documented); font: 400 12px/1.4 var(--font-label); text-transform: uppercase; letter-spacing: 0.04em; }
.composer__flag[hidden] { display: none; }
.composer__flag .i { width: 14px; height: 14px; }
@media (max-width: 699px) { .composer__tip { display: none !important; } }

/* voice: three level bars step while "listening" (visual only) */
#voice-btn { position: relative; }
.voice-bars { display: none; position: absolute; right: 4px; bottom: 6px; gap: 2px; align-items: flex-end; height: 10px; }
.voice-bars i { width: 3px; height: 4px; background: var(--blood-text); animation: voice-bar 0.9s steps(3) infinite alternate; }
.voice-bars i:nth-child(2) { animation-delay: 0.3s; } .voice-bars i:nth-child(3) { animation-delay: 0.6s; }
@keyframes voice-bar { to { height: 10px; } }
.composer.is-listening #voice-btn { color: var(--blood-text); background: var(--surface-3); }
.composer.is-listening .voice-bars { display: inline-flex; }

/* the cat widget: let the engine's whole-pixel size stand (site.css forces 96 x 96) and seat it on the message box */
.cat-dock.eaf-cat { width: auto !important; height: auto !important; bottom: calc(100% - 13px); right: max(var(--gutter), calc(50% - 424px)); }
@media (max-width: 899px) { .cat-dock.eaf-cat { right: calc(var(--gutter) + 6px); bottom: calc(100% - 29px); } }
/* wide screens: the cat sits beside the box, on the same floor line, instead of on top of it */
@media (min-width: 1440px) {
  .cat-dock.eaf-cat { right: calc(50% - 430px - 112px); bottom: 43px; }
  .thread { padding-bottom: var(--s6); }
}
.cat-dock.eaf-cat:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

/* =============================== 3 slash menu =============================== */
.slash-menu {
  --pb: var(--border-strong); z-index: 45; padding: 6px; background: var(--surface-2); bottom: calc(100% - 4px);
  box-shadow: 0 -3px 0 0 var(--pb), 0 3px 0 0 var(--pb), -3px 0 0 0 var(--pb), 3px 0 0 0 var(--pb), 6px 6px 0 0 var(--shade);
  width: auto !important; max-width: 420px !important; right: auto; left: max(var(--gutter), calc(50% - 427px));
}
.slash-menu[hidden] { display: none; }
.slash-menu__head { margin: 4px 8px 6px; }
.slash-menu__item { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 12px; cursor: pointer; color: var(--text); }
.slash-menu__item[aria-selected="true"], .slash-menu__item:hover { background: var(--surface-3); color: var(--heading); box-shadow: inset 4px 0 0 var(--amber); }
.slash-menu__cmd { min-width: 88px; font: 600 16px var(--font-title); color: var(--heading); }
.slash-menu__desc { font-size: 15px; color: var(--text-2); }

/* =============================== 4 document drawer =============================== */
.doc-scrim { position: fixed; inset: 0; z-index: 125; background: rgb(8 6 5 / 0.4); opacity: 0; transition: opacity var(--t-med) steps(3); }
.doc-scrim.is-open { opacity: 1; }
.doc-scrim[hidden], .doc-drawer[hidden] { display: none; }
.doc-drawer {
  position: fixed; z-index: 130; top: 0; right: 0; bottom: 0; width: min(520px, 94vw); display: flex;
  transform: translateX(104%); transition: transform var(--t-med) steps(6);
}
.doc-drawer.is-open { transform: none; }
/* the manila folder the page sits in */
.doc-drawer__folder {
  position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 0 12px;
  background:
    linear-gradient(90deg, rgb(122 90 36 / 0.10) 3px, transparent 0) 0 0 / 9px 9px,
    var(--manila);
  box-shadow: inset 6px 0 0 var(--manila-2), inset 9px 0 0 var(--manila-edge), -6px 0 0 rgb(0 0 0 / 0.35);
  color: var(--manila-ink);
}
.doc-drawer__bar { display: flex; align-items: center; gap: 12px; padding: 12px 12px 10px 24px; }
.doc-drawer__tab {
  min-width: 0; padding: 6px 12px 5px; background: var(--manila-2); color: var(--manila-ink);
  font: 400 12px/1.3 var(--font-label); letter-spacing: 0.06em; text-transform: uppercase;
  clip-path: polygon(0 6px, 3px 6px, 3px 3px, 6px 3px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 3px, calc(100% - 3px) 3px, calc(100% - 3px) 6px, 100% 6px, 100% 100%, 0 100%);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-drawer__count { font: 400 12px/1.3 var(--font-label); letter-spacing: 0.05em; text-transform: uppercase; color: #5A4318; white-space: nowrap; }
.doc-drawer__close { margin-left: auto; color: var(--manila-ink); }
.doc-drawer__close:hover { background: var(--manila-3); color: var(--manila-ink); --pb: var(--manila-edge); }
.doc-drawer__close:focus-visible { outline-color: var(--manila-ink); outline-offset: 2px; }
.doc-drawer__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 18px 18px 27px; overscroll-behavior: contain; }
.doc-drawer__nav { display: flex; justify-content: space-between; gap: 8px; padding: 10px 18px 0 27px; box-shadow: inset 0 3px 0 rgb(122 90 36 / 0.35); }
.doc-drawer__nav .btn { background: var(--manila-3); color: var(--manila-ink); --pb: var(--manila-edge); }
.doc-drawer__nav .btn:hover { background: #F6E6BC; color: var(--manila-ink); }
.doc-drawer__nav .btn[disabled] { opacity: 0.45; }
.doc-drawer__nav .btn .i { width: 14px; height: 14px; }

/* the page: reuses .doc-slip (lined paper, highlighted lines, peeling redactions) */
.doc-page { margin: 12px 6px 9px 3px; padding: 22px 22px 16px 26px; }
.doc-page::before { /* the cut corner, in the folder's colour */
  content: ""; position: absolute; top: -3px; right: -3px; width: 24px; height: 24px; background: var(--manila);
  clip-path: polygon(0 0, 100% 0, 100% 100%, calc(100% - 3px) 100%, calc(100% - 3px) calc(100% - 3px), calc(100% - 6px) calc(100% - 3px), calc(100% - 6px) calc(100% - 6px), calc(100% - 9px) calc(100% - 6px), calc(100% - 9px) calc(100% - 9px), calc(100% - 12px) calc(100% - 9px), calc(100% - 12px) calc(100% - 12px), calc(100% - 15px) calc(100% - 12px), calc(100% - 15px) calc(100% - 15px), calc(100% - 18px) calc(100% - 15px), calc(100% - 18px) calc(100% - 18px), calc(100% - 21px) calc(100% - 18px), calc(100% - 21px) calc(100% - 21px), 0 calc(100% - 21px));
}
.doc-page::after { /* the folded-over flap */
  content: ""; position: absolute; top: 0; right: 0; width: 21px; height: 21px; background: #CDB585; filter: drop-shadow(-2px 2px 0 rgb(122 90 36 / 0.6));
  clip-path: polygon(0 0, 3px 0, 3px 3px, 6px 3px, 6px 6px, 9px 6px, 9px 9px, 12px 9px, 12px 12px, 15px 12px, 15px 15px, 18px 15px, 18px 18px, 21px 18px, 21px 21px, 0 21px);
}
.doc-page.is-open { animation: page-in var(--t-slow) steps(5) both; }
@keyframes page-in { from { transform: translateY(18px); opacity: 0; } }
.doc-page__clip { /* a pixel paper clip over the top edge */
  position: absolute; top: -3px; left: 22px; width: 15px; height: 36px;
  background:
    linear-gradient(#8C8C8C, #8C8C8C) 0 0 / 3px 30px no-repeat, linear-gradient(#8C8C8C, #8C8C8C) 12px 3px / 3px 33px no-repeat,
    linear-gradient(#8C8C8C, #8C8C8C) 0 0 / 15px 3px no-repeat, linear-gradient(#8C8C8C, #8C8C8C) 6px 6px / 3px 24px no-repeat,
    linear-gradient(#8C8C8C, #8C8C8C) 0 30px / 9px 3px no-repeat;
}
.doc-page .doc-slip__head { margin-top: 10px; padding-left: 26px; }
.doc-page__title { margin: 4px 0 12px; font: 600 21px/1.25 var(--font-title); color: #1E160A; text-wrap: balance; }
.doc-page__lines p { margin: 0; }
.doc-page .doc-slip__note { margin-top: 14px !important; padding-top: 8px; border-top: 3px dashed rgb(122 90 36 / 0.4); }
.doc-page .doc-redact { margin: 0 2px; }

@media (max-width: 699px) {
  .doc-drawer { top: auto; left: 0; width: auto; max-height: 86dvh; transform: translateY(104%); }
  .doc-drawer__folder { box-shadow: inset 0 6px 0 var(--manila-2), inset 0 9px 0 var(--manila-edge), 0 -6px 0 rgb(0 0 0 / 0.35);
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .doc-drawer__bar { padding: 16px 8px 8px 14px; }
  .doc-drawer__scroll { padding: 4px 12px 14px; }
  .doc-drawer__nav { padding: 10px 12px 0; }
  .doc-page { padding: 18px 16px 14px 18px; }
  .doc-page__title { font-size: 19px; }
}
html.doc-open { overflow: hidden; }
@media (min-width: 700px) { html.doc-open { overflow: auto; } }   /* desktop: the chat stays scrollable beside the panel */

/* =============================== 5 upgrade nudge, notes =============================== */
.nudge {
  --pb: var(--amber-lo); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s4); margin: var(--px);
  padding: var(--s5) var(--s6); background: var(--surface-2);
  box-shadow: 0 -3px 0 0 var(--pb), 0 3px 0 0 var(--pb), -3px 0 0 0 var(--pb), 3px 0 0 0 var(--pb), inset 0 6px 0 0 var(--amber), 6px 6px 0 0 var(--shade);
}
.nudge__key { display: grid; place-items: center; width: 56px; height: 56px; background: var(--surface-3); color: var(--link); box-shadow: inset 0 -3px 0 var(--edge); }
.nudge__key .i { width: 32px; height: 32px; }
.nudge__text .label { margin-bottom: 6px; color: var(--link); }
.nudge__title { margin: 0 0 8px; font-size: 24px; }
.nudge__text p { color: var(--text-2); margin-bottom: var(--s4); }
.nudge .btn-row .fine { margin: 0; }
.nudge.is-nudged { animation: nudge-shake 360ms steps(6); }
@keyframes nudge-shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
@media (max-width: 599px) { .nudge { grid-template-columns: minmax(0, 1fr); padding: var(--s4); } .nudge__key { width: 44px; height: 44px; } }

.msg--note { --pi: inset 0 3px 0 0 var(--amber-lo); }
.msg__cta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: var(--s3) !important; }
.msg__cta .fine { margin: 0; }
.cmd-list { margin: var(--s3) 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.cmd-list li { display: flex; align-items: baseline; gap: 12px; }
.cmd-list kbd { min-width: 88px; text-align: left; }

/* =============================== 6 community =============================== */
.post__avatar--you { background: var(--amber); }
.post.is-new { animation: tab-in 300ms steps(3) both; }
.room-compose .input:disabled + .btn { opacity: 0.55; }

/* =============================== 7 flock watch =============================== */
.flock-map { overflow: hidden; }
.flock-map__empty[hidden] { display: none; }
.flock-map__canvas { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); image-rendering: pixelated; image-rendering: crisp-edges; cursor: crosshair; }
.flock-map__plate {
  position: absolute; left: 12px; top: 12px; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; max-width: calc(100% - 64px);
  padding: 8px 12px; background: #F3E7C9; color: #2A2117; box-shadow: 0 0 0 3px #7A5A24, 4px 4px 0 3px rgb(42 33 23 / 0.25); font-size: 15px;
}
.flock-map__plate b { font: 600 18px var(--font-title); color: #1E160A; }
.flock-map__plate .chip { margin: 0; background: #FAF3E4; color: #8A4600; --pb: #B8741A; }
.flock-results { margin-top: var(--s5); }
.flock-results__msg { color: var(--text-2); }
.flock-results__msg b { color: var(--heading); }
.flock-towns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.flock-towns .followup::before { content: none; }
.flock-towns--more { margin-top: var(--s5); }
.flock-towns--more .label { flex: 1 0 100%; margin: 0 0 2px; }
.cam-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.cam {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 12px; align-items: center; width: 100%; min-height: 56px;
  padding: 8px 12px; border: 0; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; font: inherit;
  box-shadow: inset 0 0 0 3px var(--border);
}
.cam:hover { background: var(--surface-3); }
.cam.is-on { box-shadow: inset 0 0 0 3px var(--blood-text), inset 6px 0 0 var(--blood-text); background: var(--surface-3); }
.cam__n { grid-row: 1 / span 2; display: grid; place-items: center; width: 28px; height: 28px; background: #E0472E; color: #FFF4DE; font: 600 15px var(--font-title); box-shadow: inset 0 -3px 0 #8E2414; }
.cam__at { font: 600 16px/1.3 var(--font-title); color: var(--heading); }
.cam__meta { font-size: 14px; color: var(--text-2); }

/* =============================== reduced motion =============================== */
:root[data-motion="reduce"] .thinking__dots i, :root[data-motion="reduce"] .voice-bars i,
:root[data-motion="reduce"] .msg.is-done .case-tab, :root[data-motion="reduce"] .doc-page.is-open,
:root[data-motion="reduce"] .post.is-new, :root[data-motion="reduce"] .nudge.is-nudged { animation: none !important; }
:root[data-motion="reduce"] .thinking__dots i { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .thinking__dots i, :root:not([data-motion="full"]) .voice-bars i,
  :root:not([data-motion="full"]) .msg.is-done .case-tab, :root:not([data-motion="full"]) .doc-page.is-open,
  :root:not([data-motion="full"]) .post.is-new, :root:not([data-motion="full"]) .nudge.is-nudged { animation: none !important; }
  :root:not([data-motion="full"]) .thinking__dots i { opacity: 1; }
}

/* fixes after review */
.msg__files { align-items: stretch; }
.doc-page .doc-slip__stamp { transform: none; }   /* rotated pixel text blurs */
/* chat page: toasts drop from the top so they never cover the message box */
.page-chat .toast { top: 16px; bottom: auto; transform: translate(-50%, -220%); }
.page-chat .toast.is-on { transform: translate(-50%, 0); }
@media (max-width: 899px) { .page-chat .toast { top: 64px; } }
