/* Tax AI — the conversational workspace.
 *
 * Every rule here is scoped under `.tx`, which is set on the Tax AI root element and nowhere
 * else, or under `body.tx-focus`, which exists only while the Tax AI page is open and is removed
 * on the way out. Nothing in this file can reach the VAT workspace, the clients screen or the
 * audit trail — the same contract `vat.css` keeps for `.vx`.
 *
 * The shape comes from the design concepts: a dark jade rail holding the conversations, a calm
 * light canvas for the conversation itself, and a source panel that opens beside the answer
 * rather than over it, so reading a citation never costs you your place.
 *
 * Status colour is never the only signal. Every state that matters — checked, partly checked,
 * unavailable, unsourced, needs review — carries a word and a mark as well as a hue, because a
 * green dot that means "generated" and a green dot that means "verified" are the same green.
 */

.tx {
  --tx-ink: #0F1A17;
  --tx-ink-2: #2A3A34;
  --tx-mute: #5F6E68;
  --tx-faint: #77867F;                 /* 4.6:1 on the card, so a timestamp is still readable */
  --tx-paper: #F4F6F3;
  --tx-card: #FFFFFF;
  --tx-line: #DFE5E0;
  --tx-rail: #0B3A2E;
  --tx-rail-2: #0E4A3A;
  --tx-rail-ink: #EAF3EF;
  --tx-rail-mute: #9CBDB1;
  --tx-jade: #0F5C4A;
  --tx-jade-l: #E7F1EC;
  --tx-gold: #8A6114;
  --tx-gold-l: #FAF3E2;
  --tx-red: #A3231E;
  --tx-red-l: #FBEAE9;
  --tx-blue: #2F6DB0;
  --tx-blue-l: #EAF1FA;
  --tx-r: 12px;
  --tx-r-s: 8px;
  --tx-rail-w: 272px;
  --tx-panel-w: 380px;
  --tx-sh: 0 1px 2px rgba(15,26,23,.05), 0 10px 30px -16px rgba(15,26,23,.25);
}

/* The outer shell borrows the page, so the composer can sit at the bottom of the viewport. */
body.tx-focus .wrap { padding: 0; max-width: none; }
body.tx-focus .top .ctx { opacity: .55; }

/* Reading room. The Tax AI screen is for reading, and VITA's workspace menu is 250px of it.
   Hiding it is the user's choice and it is remembered. */
body.tx-wide .side { transform: translateX(-105%); }
html[dir=rtl] body.tx-wide .side { transform: translateX(105%); }
body.tx-wide .tx { inset-inline-start: 0; }

/* Fixed, so the composer can sit at the foot of the viewport rather than the foot of a long
 * page — but starting after VITA's own navigation, not underneath it. `inset-inline: 0` put the
 * conversation rail behind the workspace menu, where it was a sliver of green and nothing else.
 * The outer navigation becomes a drawer at 980px, and below that this takes the full width. */
.tx {
  position: fixed;
  inset-block-start: var(--top);
  inset-inline-start: var(--side);
  inset-inline-end: 0;
  inset-block-end: 0;
  display: flex;
  background: var(--tx-paper);
  color: var(--tx-ink);
  overflow: hidden;
}
@media (max-width: 980px) { .tx { inset-inline-start: 0; } }


/* The outer stylesheet styles bare headings for the rest of VITA — h4 there is an uppercase
 * 11.5px label. Inside this module a heading is a heading: a source's title came out shouting
 * in capitals because of it. Reset the ones this module draws rather than reaching outside. */
.tx h1, .tx h2, .tx h3, .tx h4 {
  text-transform: none; letter-spacing: normal; color: inherit; margin: 0;
}
.tx h3 { font-size: 14px; font-weight: 600; }
.tx h4 { font-size: 14px; font-weight: 600; }

/* ------------------------------------------------------------------ rail */

.tx-rail {
  inline-size: var(--tx-rail-w);
  flex: 0 0 auto;
  background: var(--tx-rail);
  color: var(--tx-rail-ink);
  display: flex;
  flex-direction: column;
  transition: inline-size .18s ease;
}
/* Collapsed: a column of icon buttons, centred and the same size, so it reads as a rail that
   has been put away rather than a panel that failed to draw. */
.tx.is-railshut .tx-rail { inline-size: 60px; }
.tx.is-railshut .tx-rail .tx-hide { display: none; }
.tx.is-railshut .tx-rail-h,
.tx.is-railshut .tx-rail-f { justify-content: center; padding-inline: 0; }
.tx.is-railshut .tx-railbtn { margin-inline-start: 0; }
.tx.is-railshut .tx-new {
  inline-size: 40px; block-size: 40px; margin: 8px auto; padding: 0;
  justify-content: center; border-radius: 10px;
}
.tx.is-railshut .tx-search { display: none; }
.tx.is-railshut .tx-list { padding-inline: 10px; }
.tx.is-railshut .tx-convrow { justify-content: center; }
.tx.is-railshut .tx-conv {
  inline-size: 40px; block-size: 40px; padding: 0; justify-content: center; flex: 0 0 auto;
}
.tx.is-railshut .tx-more { display: none; }
.tx.is-railshut .tx-group { display: none; }

.tx-rail-h { display: flex; align-items: center; gap: 8px; padding: 14px 14px 6px; }
.tx-brand { font-weight: 600; font-size: 12px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--tx-rail-mute); }
.tx-railbtn {
  margin-inline-start: auto; background: none; border: 0; color: var(--tx-rail-mute);
  cursor: pointer; padding: 6px; border-radius: var(--tx-r-s); line-height: 1;
}
.tx-railbtn:hover { color: var(--tx-rail-ink); background: rgba(255,255,255,.08); }

.tx-new {
  margin: 8px 14px; padding: 11px 14px; display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16);
  color: var(--tx-rail-ink); border-radius: var(--tx-r); cursor: pointer;
  font: inherit; font-weight: 600; inline-size: calc(100% - 28px);
}
.tx-new:hover { background: rgba(255,255,255,.16); }

.tx-search { margin: 4px 14px 10px; position: relative; }
.tx-search input {
  inline-size: 100%; padding: 9px 12px 9px 34px; border-radius: var(--tx-r);
  background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.12);
  color: var(--tx-rail-ink);
}
html[dir=rtl] .tx-search input { padding: 9px 34px 9px 12px; }
.tx-search input::placeholder { color: var(--tx-rail-mute); }
.tx-search .tx-ic { position: absolute; inset-inline-start: 11px; inset-block-start: 9px; color: var(--tx-rail-mute); }

.tx-list { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 10px; }
.tx-group { color: var(--tx-rail-mute); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; padding: 12px 8px 5px; }
.tx-conv {
  display: flex; align-items: center; gap: 9px; inline-size: 100%;
  padding: 9px 10px; border: 0; background: none; color: var(--tx-rail-ink);
  border-radius: var(--tx-r-s); cursor: pointer; font: inherit; text-align: start;
}
.tx-conv:hover { background: rgba(255,255,255,.08); }
.tx-conv[aria-current="true"] { background: rgba(255,255,255,.16); font-weight: 600; }
.tx-conv > span { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-convrow { display: flex; align-items: center; gap: 2px; }
.tx-convrow .tx-conv { flex: 1 1 auto; min-inline-size: 0; }
.tx-more {
  flex: 0 0 auto; opacity: 0; color: var(--tx-rail-mute); padding: 5px 6px; border-radius: 4px;
  background: none; border: 0; cursor: pointer;
}
.tx-convrow:hover .tx-more, .tx-convrow:focus-within .tx-more { opacity: 1; }

.tx-rail-f { border-block-start: 1px solid rgba(255,255,255,.12); padding: 10px 8px; }

/* ------------------------------------------------------------------ main */

.tx-main { flex: 1 1 auto; display: flex; flex-direction: column; min-inline-size: 0; }

.tx-head {
  display: flex; align-items: center; gap: 14px; padding: 0 18px; flex-wrap: nowrap;
  block-size: 58px; flex: 0 0 auto; background: var(--tx-card);
  border-block-end: 1px solid var(--tx-line);
}
.tx-title { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; flex: 0 0 auto; }
.tx-sub {
  color: var(--tx-mute); border-inline-start: 1px solid var(--tx-line);
  padding-inline-start: 14px; min-inline-size: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.tx-sp { flex: 1 1 auto; }

.tx-scroll { flex: 1 1 auto; overflow-y: auto; scroll-behavior: smooth; position: relative; }
.tx-thread { max-inline-size: 820px; margin: 0 auto; padding: 26px 20px 8px; }

/* ------------------------------------------------------------------ new chat */

.tx-hero { max-inline-size: 820px; margin: 0 auto; padding: 8vh 20px 0; text-align: center; }
.tx-hero-ic {
  inline-size: 72px; block-size: 72px; margin: 0 auto 22px; border-radius: 18px;
  background: var(--tx-jade-l); color: var(--tx-jade);
  display: grid; place-items: center;
}
.tx-hero h1 { font-size: clamp(26px, 4vw, 40px); margin: 0 0 10px; letter-spacing: -.02em; }
.tx-hero p { color: var(--tx-mute); margin: 0 0 30px; font-size: 15px; }
.tx-egs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.tx-eg {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--tx-card); border: 1px solid var(--tx-line); border-radius: var(--tx-r);
  cursor: pointer; font: inherit; text-align: start; color: inherit;
}
.tx-eg:hover { border-color: var(--tx-jade); box-shadow: var(--tx-sh); }
.tx-eg .tx-eg-ic {
  inline-size: 36px; block-size: 36px; flex: 0 0 auto; border-radius: 9px;
  background: var(--tx-jade-l); color: var(--tx-jade); display: grid; place-items: center;
}
.tx-eg b { font-weight: 600; }

/* ------------------------------------------------------------------ turns */

.tx-turn { margin-block-end: 22px; }
.tx-turn.me { display: flex; justify-content: flex-end; }
.tx-me {
  background: var(--tx-jade-l); border-radius: var(--tx-r) var(--tx-r) 2px var(--tx-r);
  padding: 11px 15px; max-inline-size: 76%; position: relative;
}
html[dir=rtl] .tx-me { border-radius: var(--tx-r) var(--tx-r) var(--tx-r) 2px; }
.tx-ai { display: flex; gap: 13px; }
.tx-avatar {
  inline-size: 34px; block-size: 34px; flex: 0 0 auto; border-radius: 9px;
  background: var(--tx-jade-l); color: var(--tx-jade); display: grid; place-items: center;
}
.tx-body { flex: 1 1 auto; min-inline-size: 0; }
.tx-who { display: flex; align-items: center; gap: 8px; margin-block-end: 6px; }
.tx-who b { font-size: 14px; }
.tx-time { color: var(--tx-faint); font-size: 12px; }

/* The parts of an answer need air between them or the headings read as bold sentences
   inside the prose rather than as the joints of the answer. */
.tx h3.tx-answer-h {
  font-size: 16px; font-weight: 700; margin: 0 0 8px; letter-spacing: -.01em;
}
.tx h4.tx-part {
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--tx-mute); margin: 20px 0 6px;
}
.tx h4.tx-part:first-child { margin-block-start: 0; }
.tx-ul { margin: 6px 0 0; padding-inline-start: 18px; }
.tx-ul li { margin-block-end: 3px; }
.tx-note--info .tx-sp, .tx-note span { min-inline-size: 0; }

.tx-prose > :first-child { margin-block-start: 0; }
.tx-prose > :last-child { margin-block-end: 0; }
.tx-prose p, .tx-prose ul, .tx-prose ol { margin: 0 0 10px; }
.tx-prose code { background: var(--tx-paper); padding: 1px 5px; border-radius: 4px; }
.tx-prose blockquote {
  margin: 0 0 10px; padding-inline-start: 12px; border-inline-start: 3px solid var(--tx-line);
  color: var(--tx-ink-2);
}

/* ------------------------------------------------------------------ status */

.tx-note {
  display: flex; align-items: flex-start; gap: 9px; padding: 10px 13px;
  border-radius: var(--tx-r-s); margin: 10px 0; font-size: 13.5px;
}
.tx-note--warn { background: var(--tx-gold-l); color: #5C400C; }
.tx-note--stop { background: var(--tx-red-l); color: #7A1A16; }
.tx-note--info { background: var(--tx-blue-l); color: #1D4C7E; }
.tx-note--calm { background: var(--tx-paper); color: var(--tx-ink-2); }

/* Every pill carries a border as well as a tint. On a white card the neutral tint alone was
 * invisible, so "Not checked" read as loose grey text rather than a status — which is the one
 * state that must never look like an absence of state. */
.tx-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.tx-pill--ok { background: var(--tx-jade-l); color: #0B4536; border-color: #BFDCD0; }
.tx-pill--part { background: var(--tx-gold-l); color: #5C400C; border-color: #E4D2A2; }
.tx-pill--none { background: var(--tx-paper); color: var(--tx-ink-2); border-color: var(--tx-line); }
.tx-pill--stop { background: var(--tx-red-l); color: #7A1A16; border-color: #E9BFBD; }
.tx-pill--busy { background: var(--tx-blue-l); color: #1D4C7E; border-color: #BED4EC; }

/* A mark as well as a colour, always. */
.tx-pill::before { font-weight: 700; }
.tx-pill--ok::before { content: "✓"; }
.tx-pill--part::before { content: "!"; }
.tx-pill--none::before { content: "–"; }
.tx-pill--stop::before { content: "✕"; }
.tx-pill--busy::before { content: "⟳"; }

/* One small mark where a run of citation markers used to be. Still a control — it opens the
   sources — but it reads as a footnote rather than as noise inside the sentence. */
.tx-ref {
  display: inline-flex; align-items: center; justify-content: center;
  min-inline-size: 16px; block-size: 16px; padding: 0 4px; margin-inline-start: 3px;
  border: 1px solid var(--tx-line); background: var(--tx-paper); color: var(--tx-mute);
  border-radius: 5px; font-size: 10.5px; font-weight: 600; cursor: pointer;
  vertical-align: 2px; line-height: 1;
}
.tx-ref:hover { border-color: var(--tx-jade); color: var(--tx-jade); }

.tx-srcbtns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tx-srcbtn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px;
  background: var(--tx-card); border: 1px solid var(--tx-line); border-radius: var(--tx-r-s);
  cursor: pointer; font: inherit; font-size: 13px; color: inherit;
}
.tx-srcbtn:hover { border-color: var(--tx-jade); }

.tx-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-block-start: 8px; }
.tx-tool {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px;
  background: none; border: 1px solid transparent; border-radius: var(--tx-r-s);
  cursor: pointer; font: inherit; font-size: 13px; color: var(--tx-mute);
}
.tx-tool:hover { background: var(--tx-paper); color: var(--tx-ink); }
.tx-tool[aria-pressed="true"] { background: var(--tx-jade-l); color: var(--tx-jade); }
.tx-tool:disabled { opacity: .45; cursor: not-allowed; }

.tx-elapsed { color: var(--tx-faint); font-size: 12.5px; margin-block-start: 3px; }
.tx-working {
  display: flex; align-items: center; gap: 13px; padding: 15px;
  background: var(--tx-card); border: 1px solid var(--tx-line); border-radius: var(--tx-r);
}
.tx-spin {
  inline-size: 22px; block-size: 22px; flex: 0 0 auto; border-radius: 50%;
  border: 2.5px solid var(--tx-jade-l); border-block-start-color: var(--tx-jade);
  animation: tx-spin .8s linear infinite;
}
@keyframes tx-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ composer */

.tx-composer { flex: 0 0 auto; padding: 10px 20px 14px; background: var(--tx-paper); }
.tx-composer-in { max-inline-size: 820px; margin: 0 auto; }
.tx-box {
  background: var(--tx-card); border: 1px solid var(--tx-line); border-radius: var(--tx-r);
  box-shadow: var(--tx-sh); padding: 10px 12px;
}
.tx-box:focus-within { border-color: var(--tx-jade); }
.tx-box textarea {
  inline-size: 100%; border: 0; outline: 0; resize: none; background: none;
  min-block-size: 24px; max-block-size: 200px; padding: 4px 2px; line-height: 1.5;
}
.tx-crow { display: flex; align-items: center; gap: 8px; margin-block-start: 6px; }
.tx-send {
  inline-size: 38px; block-size: 38px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--tx-jade); color: #fff; display: grid; place-items: center;
}
.tx-send:disabled { background: var(--tx-line); color: var(--tx-mute); cursor: not-allowed; }
.tx-stop { background: var(--tx-red); }
.tx-privacy { text-align: center; color: var(--tx-mute); font-size: 12.5px; margin: 8px 0 0; }

.tx-mode {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px;
  background: var(--tx-paper); border: 1px solid var(--tx-line); border-radius: var(--tx-r-s);
  cursor: pointer; font: inherit; font-size: 13px; color: inherit;
}
.tx-menu {
  position: absolute; z-index: 60; background: var(--tx-card); border: 1px solid var(--tx-line);
  border-radius: var(--tx-r); box-shadow: var(--tx-sh); padding: 6px; min-inline-size: 250px;
}
.tx-menu button {
  display: block; inline-size: 100%; text-align: start; padding: 9px 11px; border: 0;
  background: none; border-radius: var(--tx-r-s); cursor: pointer; font: inherit; color: inherit;
}
.tx-menu button:hover { background: var(--tx-paper); }
.tx-menu b { display: block; }
.tx-menu small { color: var(--tx-mute); }

/* Always in the DOM so showing it costs a class, not a re-render. */
.tx-jump { display: none; }
.tx-jump.is-on { display: inline-flex; }
.tx-jump {
  position: absolute; inset-block-end: 18px; inset-inline-start: 50%; transform: translateX(-50%);
  background: var(--tx-card); border: 1px solid var(--tx-line); border-radius: 999px;
  box-shadow: var(--tx-sh); padding: 8px 15px; cursor: pointer; font: inherit; font-size: 13px;
  align-items: center; gap: 7px; z-index: 20;
}

/* ------------------------------------------------------------------ sources panel */

.tx-panel {
  inline-size: var(--tx-panel-w); flex: 0 0 auto; background: var(--tx-card);
  border-inline-start: 1px solid var(--tx-line); display: flex; flex-direction: column;
  overflow: hidden;
}
.tx-panel-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.tx-panel-h h2 { font-size: 16px; margin: 0; }
.tx-panel-b { flex: 1 1 auto; overflow-y: auto; padding: 0 18px 18px; }
.tx-check {
  display: flex; align-items: flex-start; gap: 11px; padding: 12px 0;
  border-block-start: 1px solid var(--tx-line);
}
.tx-check:first-child { border-block-start: 0; }
.tx-check .tx-ic { color: var(--tx-mute); margin-block-start: 1px; }
.tx-check b { display: block; font-size: 13.5px; }
.tx-check small { color: var(--tx-mute); }
.tx-src {
  border: 1px solid var(--tx-line); border-radius: var(--tx-r); padding: 13px; margin-block-end: 11px;
}
.tx-src h4 { margin: 0 0 3px; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tx-src p { margin: 4px 0 0; color: var(--tx-mute); font-size: 13px; }
.tx-quote {
  margin: 9px 0 0; padding: 9px 11px; background: var(--tx-paper); border-radius: var(--tx-r-s);
  font-size: 13px; color: var(--tx-ink-2);
}

/* ------------------------------------------------------------------ responsive */

/* Below this the conversation and a 380px panel cannot both be comfortable — VITA's own
 * navigation has already taken 250px — so the panel floats over the conversation instead of
 * squeezing it. It was squeezing the header until "Tax AI" wrapped onto two lines. */
@media (max-width: 1400px) {
  .tx-panel {
    position: absolute; inset-block: 0; inset-inline-end: 0; z-index: 45;
    inline-size: min(380px, 92%); box-shadow: var(--tx-sh);
  }
}
@media (max-width: 1100px) { .tx { --tx-panel-w: 320px; } }

@media (max-width: 900px) {
  .tx-rail {
    position: absolute; inset-block: 0; inset-inline-start: 0; z-index: 50;
    transform: translateX(-100%); box-shadow: var(--tx-sh);
  }
  html[dir=rtl] .tx-rail { transform: translateX(100%); }
  .tx.is-railopen .tx-rail { transform: none; }
  .tx-panel {
    position: absolute; inset-block: 0; inset-inline-end: 0; z-index: 45;
    inline-size: min(420px, 100%);
  }
}

@media (max-width: 640px) {
  .tx-thread, .tx-composer-in, .tx-hero { padding-inline: 16px; }
  .tx-egs { grid-template-columns: 1fr; }
  .tx-me { max-inline-size: 88%; }
  .tx-head { padding: 0 12px; gap: 10px; }
  .tx-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tx *, .tx-scroll { transition: none !important; animation: none !important; scroll-behavior: auto; }
}

/* Focus is always visible, and never only a colour change. */
.tx :focus-visible {
  outline: 2px solid var(--tx-jade); outline-offset: 2px; border-radius: var(--tx-r-s);
}
.tx-rail :focus-visible { outline-color: #8FD6BE; }

.tx-sr {
  position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
