/* =====================================================================
   HTS AI Engine - chat pages (App 100, Phase 3)
   Colours come only from the --hts-* custom properties (HTS_BRANDING via
   HTS_APEX_PKG.page_init); greys are mixed from them. No colour literals.
   ===================================================================== */

:root {
  --hts-line: color-mix(in srgb, var(--hts-secondary) 14%, transparent);
  --hts-soft: color-mix(in srgb, var(--hts-secondary) 5%, transparent);
  --hts-soft-2: color-mix(in srgb, var(--hts-secondary) 9%, transparent);
  --hts-red-soft: color-mix(in srgb, var(--hts-primary) 10%, transparent);
  --hts-radius: 12px;
  --hts-chat-offset: 132px;   /* header + page padding: the chat fills the rest of the window */
}

.hts-offscreen { position: fixed; inset-inline-start: -9999px; top: 0; opacity: 0; }   /* CR-15: logical, so RTL pages get no huge scroll area */
.hts-muted { opacity: 0.72; }

/* ---------- buttons, chips, inputs ---------- */
.hts-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--hts-line);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.hts-btn:hover:not([disabled]) { background: var(--hts-soft-2); }
.hts-btn:focus-visible { outline: 2px solid var(--hts-primary); outline-offset: 1px; }
.hts-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.hts-btn--icon { width: 2rem; padding: 0; justify-content: center; border-color: transparent; }
.hts-btn--small { min-height: 1.75rem; padding: 0.125rem 0.625rem; font-size: 0.8125rem; }
.hts-btn--primary { background: var(--hts-primary); border-color: var(--hts-primary); color: var(--hts-text); }
.hts-btn--primary:hover:not([disabled]) { background: var(--hts-primary); filter: brightness(0.92); }
.hts-btn--danger { color: var(--hts-primary); }
.hts-btn[aria-pressed="true"] .fa { color: var(--hts-primary); }

.hts-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  background: var(--hts-soft-2);
  font-size: 0.75rem;
  line-height: 1.5;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hts-chip--card { background: var(--hts-red-soft); }
.hts-chip--test { background: var(--hts-red-soft); color: var(--hts-primary); }
.hts-chip-x { border: 0; background: transparent; padding: 0 0 0 0.25rem; cursor: pointer; color: inherit; opacity: 0.7; }
.hts-chip-x:hover { opacity: 1; }

.hts-input,
.hts-select {
  min-height: 2.25rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--hts-line);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
}
.hts-input:focus,
.hts-select:focus { outline: 2px solid var(--hts-primary); outline-offset: 0; }
.hts-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.hts-row > .hts-input { flex: 1 1 14rem; }

/* ---------- page 1 layout ---------- */
.hts-chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--hts-chat-offset));
  min-height: 28rem;
}
.hts-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 0 0.5rem;
  border-bottom: 1px solid var(--hts-line);
}
.hts-chat-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; min-width: 0; }
.hts-chat-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40vw;
}
.hts-chat-badges { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; }
.hts-chat-actions { display: flex; gap: 0.125rem; flex-shrink: 0; }

.hts-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--hts-red-soft);
  font-size: 0.875rem;
}
.hts-banner[hidden] { display: none; }

.hts-thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 0.25rem;
  scroll-behavior: smooth;
}

/* welcome + task cards */
.hts-welcome { max-width: 46rem; margin: 6vh auto 0; text-align: center; }
.hts-welcome h2 { margin: 0 0 0.25rem; font-size: 1.5rem; font-weight: 600; }
.hts-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.625rem;
  margin-top: 1.25rem;
}
.hts-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 0.5rem;
  border: 1px solid var(--hts-line);
  border-radius: var(--hts-radius);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.hts-card .fa { font-size: 1.375rem; color: var(--hts-primary); }
.hts-card:hover,
.hts-card.is-active { border-color: var(--hts-primary); background: var(--hts-red-soft); }

/* messages */
.hts-msg { display: flex; gap: 0.625rem; max-width: 52rem; margin: 0 auto 1.125rem; }
.hts-msg--user { justify-content: flex-end; }
.hts-msg-body { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.hts-msg--user .hts-msg-body { align-items: flex-end; max-width: 80%; }
.hts-msg--assistant .hts-msg-body { flex: 1 1 auto; }
.hts-avatar {
  flex: 0 0 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--hts-primary);
  color: var(--hts-text);
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hts-bubble { overflow-wrap: anywhere; line-height: 1.55; }
.hts-msg--user .hts-bubble {
  padding: 0.5rem 0.875rem;
  border-radius: var(--hts-radius) var(--hts-radius) 4px var(--hts-radius);
  background: var(--hts-secondary);
  color: var(--hts-text);
}
.hts-plain { white-space: pre-wrap; }
.hts-msg--failed .hts-bubble {
  padding: 0.5rem 0.875rem;
  border-radius: 8px;
  border-inline-start: 3px solid var(--hts-primary);
  background: var(--hts-red-soft);
}
.hts-msg-meta { display: flex; gap: 0.375rem; align-items: center; margin-top: 0.25rem; font-size: 0.75rem; opacity: 0.65; }
.hts-msg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.125rem; margin-top: 0.125rem; opacity: 0.75; }
.hts-msg:hover .hts-msg-actions,
.hts-msg-actions:focus-within { opacity: 1; }
.hts-alt { display: inline-flex; align-items: center; }
.hts-alt-pos { font-size: 0.75rem; min-width: 2.5rem; text-align: center; }
.hts-saved { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0 0.5rem; font-size: 0.75rem; color: var(--hts-primary); }

/* Markdown answers */
.hts-md > :first-child { margin-top: 0; }
.hts-md > :last-child { margin-bottom: 0; }
.hts-md p,
.hts-md ul,
.hts-md ol,
.hts-md blockquote,
.hts-md table { margin: 0 0 0.75rem; }
.hts-md h1,
.hts-md h2,
.hts-md h3 { margin: 1rem 0 0.5rem; font-weight: 600; line-height: 1.3; }
.hts-md h1 { font-size: 1.25rem; }
.hts-md h2 { font-size: 1.125rem; }
.hts-md h3 { font-size: 1rem; }
.hts-md blockquote { padding: 0.25rem 0.75rem; border-inline-start: 3px solid var(--hts-line); opacity: 0.85; }
.hts-md code { padding: 0.0625rem 0.3125rem; border-radius: 4px; background: var(--hts-soft-2); font-size: 0.875em; }
.hts-md pre,
.hts-pre {
  position: relative;
  padding: 0.75rem 2.75rem 0.75rem 0.875rem;
  border-radius: 8px;
  background: var(--hts-surface-dark);
  color: var(--hts-text);
  overflow-x: auto;
  direction: ltr;
  text-align: left;
}
.hts-md pre code { padding: 0; background: transparent; color: inherit; }
.hts-code-copy { position: absolute; top: 0.25rem; right: 0.25rem; color: var(--hts-text); opacity: 0.6; }
.hts-code-copy:hover { opacity: 1; background: transparent !important; }
.hts-md table { border-collapse: collapse; display: block; overflow-x: auto; }
.hts-md th,
.hts-md td { padding: 0.375rem 0.625rem; border: 1px solid var(--hts-line); }
.hts-md th { background: var(--hts-soft); }
.hts-md a { color: var(--hts-primary); }

/* thinking dots */
.hts-dots { display: inline-flex; gap: 0.25rem; padding: 0.625rem 0; }
.hts-dots i { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--hts-primary); animation: hts-blink 1.2s infinite both; }
.hts-dots i:nth-child(2) { animation-delay: 0.2s; }
.hts-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes hts-blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hts-dots i { animation: none; opacity: 0.6; } .hts-thread { scroll-behavior: auto; } }

/* composer */
.hts-composer { padding-top: 0.5rem; }
.hts-composer[hidden] { display: none; }
.hts-composer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; max-width: 52rem; margin: 0 auto 0.375rem; }
.hts-composer-tools:empty { display: none; }
.hts-project[hidden],
.hts-engine[hidden],
.hts-chip--test[hidden] { display: none; }
.hts-engine { max-width: 16rem; }
.hts-composer-box {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 52rem;
  margin: 0 auto;
  padding: 0.375rem 0.375rem 0.375rem 0.75rem;
  border: 1px solid var(--hts-line);
  border-radius: var(--hts-radius);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.hts-composer-box:focus-within { border-color: var(--hts-primary); }
.hts-composer-box .hts-input {
  flex: 1 1 auto;
  min-height: 2.25rem;
  max-height: 260px;
  padding: 0.375rem 0;
  border: 0;
  resize: none;
  outline: none;
}
.hts-send { flex: 0 0 2.25rem; width: 2.25rem; height: 2.25rem; border-radius: 8px; background: var(--hts-primary); color: var(--hts-text); }
.hts-send:hover:not([disabled]) { background: var(--hts-primary) !important; filter: brightness(0.92); }
.hts-send[hidden], .hts-stop[hidden], .hts-attach[hidden] { display: none; }
/* Phase 4 streaming: Stop replaces Send while an answer is generated (P1-03 streaming state) */
.hts-stop { flex: 0 0 auto; height: 2.25rem; border-radius: 8px; border-color: var(--hts-primary); color: var(--hts-primary); font-weight: 600; }
.hts-stop:hover:not([disabled]) { background: var(--hts-red-soft); }
.hts-attach { flex: 0 0 2.25rem; width: 2.25rem; height: 2.25rem; border: 0; background: transparent; }
.hts-files { display: flex; flex-wrap: wrap; gap: 0.375rem; max-width: 52rem; margin: 0 auto 0.375rem; }
.hts-files[hidden] { display: none; }
.hts-file--error { background: var(--hts-red-soft); color: var(--hts-primary); }
.hts-file--uploading { opacity: 0.8; }
.hts-streaming::after { content: "\258D"; margin-inline-start: 0.125rem; color: var(--hts-primary); animation: hts-caret 1s steps(2, start) infinite; }
@keyframes hts-caret { to { visibility: hidden; } }
.hts-composer-foot { display: flex; justify-content: space-between; max-width: 52rem; margin: 0.25rem auto 0; font-size: 0.6875rem; opacity: 0.6; }
.hts-count--over { color: var(--hts-primary); font-weight: 700; opacity: 1; }

/* ---------- sidebar (left column of page 1) ---------- */
.hts-side { display: flex; flex-direction: column; gap: 0.5rem; height: calc(100vh - var(--hts-chat-offset)); min-height: 28rem; }
.hts-side-top { display: flex; gap: 0.375rem; }
.hts-side-top .hts-new { flex: 1 1 auto; justify-content: center; }
.hts-side > .hts-select { width: 100%; }
.hts-side-list,
.hts-side-shared { overflow-y: auto; }
.hts-side-list { flex: 1 1 auto; }
.hts-side-shared { flex: 0 1 auto; max-height: 30%; }
.hts-side-group { margin: 0.75rem 0.25rem 0.25rem; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.6; }
.hts-side-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.4375rem 0.5rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  text-align: start;
  cursor: pointer;
}
.hts-side-item:hover { background: var(--hts-soft-2); }
.hts-side-item.is-active { background: var(--hts-red-soft); box-shadow: inset 3px 0 0 var(--hts-primary); }
[dir="rtl"] .hts-side-item.is-active { box-shadow: inset -3px 0 0 var(--hts-primary); }
.hts-side-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hts-side-extra { font-size: 0.6875rem; opacity: 0.6; white-space: nowrap; }
.hts-side-fav { font-size: 0.75rem; color: var(--hts-primary); }
.hts-side-empty { padding: 0.5rem; font-size: 0.875rem; }

/* ---------- dialogs (2, 21, 90), output (31) ---------- */
.hts-form { display: flex; flex-direction: column; gap: 0.875rem; }
.hts-field-label { display: block; margin-bottom: 0.25rem; font-size: 0.8125rem; font-weight: 600; }
.hts-field-help { margin-top: 0.25rem; font-size: 0.75rem; opacity: 0.7; }
.hts-check { display: inline-flex; align-items: center; gap: 0.375rem; margin-inline-end: 1rem; }
.hts-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.375rem; }
.hts-tag-input { width: 100%; }
.hts-subhead { margin: 0.5rem 0 0; font-size: 0.875rem; font-weight: 600; }
.hts-share-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--hts-line); }
.hts-share-name { flex: 1 1 auto; font-weight: 600; }

.hts-search { display: flex; flex-direction: column; gap: 0.75rem; }
.hts-search-input { width: 100%; font-size: 1rem; }
.hts-search-results { display: flex; flex-direction: column; gap: 0.25rem; max-height: 60vh; overflow-y: auto; }
.hts-search-item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.hts-search-item:hover,
.hts-search-item:focus-visible { border-color: var(--hts-line); background: var(--hts-soft); outline: none; }
.hts-search-title { font-weight: 600; }
.hts-search-snippet { font-size: 0.8125rem; opacity: 0.8; }
.hts-search-meta { display: flex; gap: 0.375rem; font-size: 0.75rem; opacity: 0.65; }
.hts-search mark { background: var(--hts-red-soft); color: inherit; padding: 0 0.0625rem; border-radius: 2px; }

.hts-output { max-width: 56rem; }
.hts-output-title { margin: 0 0 0.25rem; font-size: 1.25rem; font-weight: 600; }
.hts-output-body { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--hts-line); }

/* ---------- Phase 8: modify an output from the chat ---------- */
.hts-modify {
  display: flex; align-items: center; gap: 0.5rem; max-width: 52rem; margin: 0 auto 0.5rem;
  padding: 0.5rem 0.75rem; border: 1px solid var(--hts-primary); border-radius: var(--hts-radius);
  background: var(--hts-red-soft); font-size: 0.875rem;
}
.hts-modify[hidden] { display: none; }
.hts-modify > span:not(.fa) { flex: 1 1 auto; min-width: 0; }

/* ---------- Phase 8: library cards (page 30) ---------- */
.hts-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.75rem; }
.hts-lib-card {
  display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.75rem;
  border: 1px solid var(--hts-line); border-radius: var(--hts-radius);
  color: inherit; text-decoration: none; min-width: 0;
}
.hts-lib-card:hover,
.hts-lib-card:focus-visible { border-color: var(--hts-primary); background: var(--hts-soft); outline: none; }
.hts-lib-icon { flex: 0 0 auto; font-size: 1.5rem; color: var(--hts-primary); width: 1.75rem; text-align: center; }
.hts-lib-body { display: flex; flex-direction: column; gap: 0.125rem; flex: 1 1 auto; min-width: 0; }
.hts-lib-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hts-lib-meta { font-size: 0.75rem; opacity: 0.75; overflow-wrap: anywhere; }
.hts-lib-flags { display: flex; gap: 0.25rem; color: var(--hts-primary); }

/* ---------- Phase 8: output page (31) and file page (41) ---------- */
.hts-output-grid { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 1.25rem; margin-top: 1rem; }
.hts-output-side h3 { margin: 0 0 0.5rem; font-size: 0.9375rem; font-weight: 600; }
.hts-output-side h3 + * { margin-bottom: 1.25rem; }
.hts-output-preview { min-height: 6rem; }
.hts-versions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.hts-version { padding: 0.5rem 0.625rem; border: 1px solid var(--hts-line); border-radius: var(--hts-radius); font-size: 0.8125rem; }
.hts-version a { font-weight: 600; }
.hts-version--current { border-color: var(--hts-primary); background: var(--hts-red-soft); }
.hts-version-request { margin-top: 0.25rem; font-style: italic; opacity: 0.85; overflow-wrap: anywhere; }
.hts-preview-img { display: block; max-width: 100%; max-height: 70vh; height: auto; border: 1px solid var(--hts-line); border-radius: var(--hts-radius); }
.hts-preview-pdf { display: block; width: 100%; height: 75vh; border: 1px solid var(--hts-line); border-radius: var(--hts-radius); }
.hts-preview-media { display: block; width: 100%; max-height: 70vh; }
.hts-preview-text {
  margin: 0; padding: 0.75rem; max-height: 70vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  border: 1px solid var(--hts-line); border-radius: var(--hts-radius); background: var(--hts-soft); font-size: 0.8125rem;
}
.hts-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8125rem; }

/* history / library report helpers */
.hts-bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.hts-title-link { font-weight: 600; }
.hts-status { font-size: 0.75rem; }

@media (max-width: 640px) {
  :root { --hts-chat-offset: 112px; }
  .hts-chat-title { max-width: 55vw; }
  .hts-msg--user .hts-msg-body { max-width: 92%; }
  .hts-side { height: auto; min-height: 0; }
  .hts-output-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Phase 12 (P12-D6, D13): sources under an answer, tools used, tool activity while streaming */
.hts-answer-extras { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.4rem; }
.hts-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; font-size: 0.8125rem; }
.hts-sources-label { display: inline-flex; align-items: center; gap: 0.3rem; opacity: 0.75; }
.hts-chip--source { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hts-tools-used, .hts-tool-line { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8125rem; opacity: 0.75; }
.hts-tool-activity { margin-top: 0.35rem; display: flex; flex-direction: column; gap: 0.2rem; }
.hts-tool-activity[hidden] { display: none; }


/* ---------- Phase 13: AI availability banner and notifications drawer (page 60) ---------- */
.hts-ai-down {
  display: flex; align-items: center; gap: 0.5rem; max-width: 52rem; margin: 0 auto 0.5rem;
  padding: 0.5rem 0.75rem; border: 1px solid var(--hts-primary); border-radius: var(--hts-radius);
  background: var(--hts-red-soft); font-size: 0.875rem;
}
.hts-ai-down[hidden] { display: none; }
.hts-ai-down .fa { color: var(--hts-primary); }
.hts-notices { display: flex; flex-direction: column; gap: 0.5rem; }
.hts-notices-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.hts-notices-list { display: flex; flex-direction: column; gap: 0.375rem; }
.hts-notices-empty { padding: 1rem 0; }
.hts-notice {
  display: flex; align-items: flex-start; gap: 0.625rem; padding: 0.625rem 0.75rem;
  border: 1px solid var(--hts-line); border-radius: var(--hts-radius);
}
.hts-notice--unread { border-inline-start: 3px solid var(--hts-primary); background: var(--hts-soft); }
.hts-notice-icon { margin-top: 0.125rem; color: var(--hts-accent); }
.hts-notice--unread .hts-notice-icon { color: var(--hts-primary); }
.hts-notice-body { flex: 1 1 auto; min-width: 0; }
.hts-notice-title { font-weight: 600; overflow-wrap: anywhere; }
.hts-notice-text { margin-top: 0.125rem; font-size: 0.8125rem; white-space: pre-line; overflow-wrap: anywhere; }
.hts-notice-meta { display: flex; align-items: center; gap: 0.375rem; margin-top: 0.25rem; font-size: 0.75rem; }
.hts-notice-actions { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.375rem; }
.hts-chip--unread { background: var(--hts-red-soft); color: var(--hts-primary); }

/* Phase 14 (P14-D6): a remote image in an AI answer is replaced by this note (colours from the branding variables) */
.hts-img-blocked {
    display: inline-block;
    padding: 2px 6px;
    border: 1px dashed var(--hts-line);
    border-radius: var(--hts-radius);
    color: var(--hts-secondary);
    font-size: 0.9em;
    font-style: italic;
}


/* CR-03 (17.0.0): chosen engine unavailable - the alternative is offered with its cost tier and used only on confirmation */
.hts-engine-alt { margin: 0.75rem 0; padding: 0.75rem 1rem; border-inline-start: 4px solid var(--hts-primary);
                  background: var(--hts-soft-2); border-radius: 4px; }
.hts-engine-alt p { margin: 0 0 0.5rem; }
.hts-engine-alt-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- CR-05 B-1 / B-2: microphone and read-aloud (hts-voice) ----------
   Colours only from the --hts-* custom properties, as the rest of this file. */
.hts-voice { display: inline-flex; align-items: center; gap: 6px; }
.hts-voice-btn { display: inline-flex; align-items: center; justify-content: center; }
.hts-voice-btn:focus-visible,
.hts-voice-cancel:focus-visible,
.hts-voice-speak:focus-visible { outline: 2px solid var(--hts-primary); outline-offset: 2px; }
.hts-voice[data-state="recording"] .hts-voice-btn { color: var(--hts-primary); }
.hts-voice[data-state="transcribing"] .hts-voice-btn { opacity: .55; cursor: progress; }
.hts-voice.is-unavailable .hts-voice-btn { opacity: .4; cursor: not-allowed; }
.hts-voice-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; opacity: .72; white-space: nowrap; }
.hts-voice-status[hidden], .hts-voice-cancel[hidden], .hts-voice-time[hidden], .hts-voice-meter[hidden] { display: none; }
.hts-voice-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hts-primary); }
.hts-voice[data-state="recording"] .hts-voice-dot { animation: hts-voice-pulse 1.2s ease-in-out infinite; }
.hts-voice[data-state="transcribing"] .hts-voice-dot { animation: hts-voice-spin .9s linear infinite; border-radius: 2px; }
.hts-voice-time { font-variant-numeric: tabular-nums; min-width: 2.6em; }
.hts-voice-meter { width: 42px; height: 4px; border-radius: 2px; background: var(--hts-line); overflow: hidden; }
.hts-voice-meter span { display: block; height: 100%; width: 0; background: var(--hts-primary); transition: width .08s linear; }
.hts-voice-cancel,
.hts-voice-speak { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent;
  color: inherit; opacity: .72; padding: 4px; border-radius: 6px; cursor: pointer; }
.hts-voice-cancel:hover, .hts-voice-speak:hover { opacity: 1; background: var(--hts-soft-2); }
.hts-voice-speak[aria-pressed="true"] { color: var(--hts-primary); opacity: 1; }
@keyframes hts-voice-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
@keyframes hts-voice-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .hts-voice-dot { animation: none !important; }
  .hts-voice-meter span { transition: none; }
}
/* CR-06: a chat answering in the background (sidebar) */
.hts-side-run { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--hts-primary);
                animation: hts-pulse 1.2s ease-in-out infinite; }
@keyframes hts-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hts-side-run { animation: none; } }

/* ---------- CR-06: sidebar sections, collapse and drawer ---------- */
.hts-menu { display: none; }
.hts-side-group--row { display: flex; align-items: center; justify-content: space-between; }
.hts-side-add { min-height: 1.5rem; padding: 0 0.375rem; }
.hts-side-projects { flex: 0 1 auto; max-height: 30%; overflow-y: auto; }
.hts-side-icon { opacity: 0.7; }
.hts-side-more { width: 100%; justify-content: center; margin: 0.375rem 0; }
body.hts-side-collapsed .t-Body-side,
body.hts-side-collapsed #hts-sidebar { display: none; }
body.hts-side-collapsed .hts-menu { display: inline-flex; }
.hts-backdrop { position: fixed; inset: 0; z-index: 899; background: color-mix(in srgb, var(--hts-secondary) 45%, transparent); }
.hts-backdrop[hidden] { display: none; }
@media (max-width: 900px) {
  .hts-menu { display: inline-flex; }
  .hts-side-collapse { display: none; }
  #hts-sidebar { display: none; }
  body.hts-side-open #hts-sidebar {
    display: block; position: fixed; inset: 0 auto 0 0; z-index: 900; width: min(85vw, 20rem); padding: 0.75rem;
    background: Canvas; color: CanvasText; box-shadow: 0 0 24px color-mix(in srgb, var(--hts-secondary) 35%, transparent);
  }
  body.hts-side-open #hts-sidebar .hts-side { height: 100%; min-height: 0; }
}

/* ---------- CR-06: project home and form ---------- */
.hts-project { max-width: 52rem; margin: 0 auto; padding: 1rem 0.25rem; display: flex; flex-direction: column; gap: 1rem; }
.hts-project-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.hts-project-title { margin: 0 0 0.25rem; font-size: 1.375rem; }
.hts-project-meta { font-size: 0.8125rem; margin: 0; }
.hts-project-actions { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.hts-project-section { border: 1px solid var(--hts-line); border-radius: var(--hts-radius); padding: 0.75rem 1rem; }
.hts-project-section h3 { margin: 0 0 0.375rem; font-size: 0.9375rem; }
.hts-project-instr { width: 100%; resize: vertical; }
.hts-project-instr-text { white-space: pre-wrap; }
.hts-project-file-list { list-style: none; margin: 0 0 0.5rem; padding: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.hts-project-file { display: flex; align-items: center; gap: 0.5rem; min-height: 2.25rem; padding: 0.25rem 0.375rem; border-radius: 8px; }
.hts-project-file:hover { background: var(--hts-soft); }
.hts-project-file-icon { flex: none; width: 1rem; text-align: center; opacity: 0.7; }
.hts-project-file-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.0625rem; }
.hts-project-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hts-project-file-info { font-size: 0.75rem; opacity: 0.65; }
.hts-project-file-error,
.hts-project-file-warn { font-size: 0.75rem; overflow-wrap: anywhere; }
.hts-project-file-error { color: var(--hts-primary); }
.hts-project-file-warn { opacity: 0.8; }
.hts-project-file-state { flex: none; }
.hts-project-file-state.is-ok { background: color-mix(in srgb, var(--hts-accent, var(--hts-secondary)) 14%, transparent); }
.hts-project-file-state.is-error { background: var(--hts-red-soft); color: var(--hts-primary); }
.hts-project-file-actions { flex: none; display: inline-flex; gap: 0.125rem; }
.hts-project-upload { margin-top: 0.25rem; }
.hts-project-kb-off { display: flex; gap: 0.375rem; align-items: flex-start; margin: 0 0 0.5rem; padding: 0.5rem 0.75rem;
                      border-radius: 8px; background: var(--hts-soft-2); opacity: 1; }
.hts-project-section > .hts-field-help:last-child { margin-bottom: 0; }
.hts-project-hint { text-align: center; }
.hts-project-form { max-width: 40rem; margin: 1rem auto; }

/* ---------- CR-06: artifacts (cards and side panel) ---------- */
.hts-chat-layout { display: flex; gap: 1rem; min-width: 0; }
.hts-chat-layout > .hts-chat-wrap { flex: 1 1 auto; min-width: 0; }
.hts-artifact-cards { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.375rem 0; }
.hts-artifact-card {
  display: inline-flex; align-items: center; gap: 0.625rem; max-width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--hts-line); border-radius: 10px; background: var(--hts-soft); color: inherit; font: inherit;
  text-align: start; cursor: pointer;
}
.hts-artifact-card:hover, .hts-artifact-card:focus-visible { border-color: var(--hts-primary); outline: none; }
.hts-artifact-card-icon { font-size: 1.25rem; color: var(--hts-primary); }
.hts-artifact-card-body { display: flex; flex-direction: column; min-width: 0; }
.hts-artifact-card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hts-artifact-card-meta { font-size: 0.75rem; opacity: 0.7; }
.hts-artifact-panel {
  flex: 0 0 min(48%, 46rem); display: flex; flex-direction: column; min-width: 0;
  height: calc(100vh - var(--hts-chat-offset)); min-height: 28rem;
  border-inline-start: 1px solid var(--hts-line); padding-inline-start: 1rem;
}
.hts-artifact-panel[hidden] { display: none; }
.hts-artifact-head { display: flex; flex-direction: column; gap: 0.375rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--hts-line); }
.hts-artifact-heading { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.hts-artifact-title { margin: 0; font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.hts-artifact-tools { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.hts-artifact-tabs { display: flex; gap: 0.25rem; padding: 0.5rem 0 0.25rem; }
.hts-artifact-tab { border: 1px solid var(--hts-line); border-radius: 8px; background: transparent; color: inherit; font: inherit;
                    padding: 0.25rem 0.75rem; cursor: pointer; }
.hts-artifact-tab.is-active { border-color: var(--hts-primary); background: var(--hts-red-soft); }
.hts-artifact-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding-top: 0.5rem; }
.hts-artifact-code { margin: 0; padding: 0.75rem; border-radius: 8px; background: var(--hts-soft-2); overflow: auto; font-size: 0.8125rem; }
.hts-artifact-frame { width: 100%; height: 100%; min-height: 24rem; border: 1px solid var(--hts-line); border-radius: 8px; background: Canvas; }
@media (max-width: 900px) {
  body.hts-panel-open .hts-artifact-panel {
    position: fixed; inset: 0; z-index: 950; height: auto; padding: 0.75rem; border: 0; background: Canvas; color: CanvasText;
  }
}

/* ---------- CR-07: sources, citations and the passage preview ---------- */
button.hts-chip--source {
  border: 1px solid var(--hts-line); color: inherit; font: inherit; font-size: 0.75rem; line-height: 1.5; cursor: pointer;
}
button.hts-chip--source:hover { border-color: var(--hts-primary); background: var(--hts-red-soft); }
button.hts-chip--source:focus-visible,
.hts-cite-btn:focus-visible { outline: 2px solid var(--hts-primary); outline-offset: 1px; }
.hts-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hts-cite { line-height: 0; margin-inline-start: 0.0625rem; }
.hts-cite-btn {
  display: inline-block; min-width: 1.125rem; margin: 0 0.0625rem; padding: 0 0.25rem; border: 0; border-radius: 4px;
  background: var(--hts-red-soft); color: var(--hts-primary); font: inherit; font-size: 0.6875rem; font-weight: 600;
  line-height: 1.35; vertical-align: super; cursor: pointer;
}
.hts-cite-btn:hover { background: var(--hts-primary); color: var(--hts-text); }
.hts-kb-note { display: inline-flex; align-items: flex-start; gap: 0.375rem; font-size: 0.8125rem; opacity: 0.75; }
.hts-kb-note .fa { margin-top: 0.1875rem; }
.hts-kb-note--held .fa { color: var(--hts-primary); }
.hts-passage { display: flex; flex-direction: column; gap: 0.5rem; }
.hts-passage-meta { margin: 0; font-size: 0.75rem; opacity: 0.7; }
.hts-passage-text {
  margin: 0; padding: 0.75rem 1rem; border-inline-start: 3px solid var(--hts-primary); border-radius: 8px;
  background: var(--hts-soft); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6;
}
.hts-passage-error { display: flex; gap: 0.5rem; align-items: flex-start; padding: 0.75rem 1rem; border-radius: 8px;
                     background: var(--hts-red-soft); }
.hts-passage-error .fa { color: var(--hts-primary); margin-top: 0.1875rem; }

/* ---------- CR-07: small screens (spacing, overflow) ---------- */
@media (max-width: 640px) {
  .hts-thread { padding: 0.75rem 0; }
  .hts-msg { gap: 0.5rem; }
  .hts-avatar { flex-basis: 1.75rem; height: 1.75rem; }
  .hts-chip--source { max-width: 100%; }
  .hts-project { padding: 0.5rem 0; }
  .hts-project-section { padding: 0.625rem 0.75rem; }
  .hts-project-file { flex-wrap: wrap; }
  .hts-project-file-main { flex-basis: calc(100% - 1.5rem); }
  .hts-project-file-state { margin-inline-start: 1.5rem; }
  .hts-project-file-actions { margin-inline-start: auto; }
  .hts-composer-box { padding-inline-start: 0.5rem; }
  .hts-artifact-tools .hts-btn--small span { display: none; }
}

/* ---------- UI-1: polish (spacing, alignment, icons, hover, overflow) - layout only, no new colours ---------- */
/* smooth hover / focus feedback on every control (instant when the user prefers reduced motion) */
.hts-btn,
.hts-chip,
.hts-side-item,
.hts-artifact-tab,
.hts-cite-btn,
.hts-code-copy,
.hts-msg-actions,
button.hts-chip--source { transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s; }
@media (prefers-reduced-motion: reduce) {
  .hts-btn, .hts-chip, .hts-side-item, .hts-artifact-tab, .hts-cite-btn, .hts-code-copy, .hts-msg-actions,
  button.hts-chip--source { transition: none; }
}
.hts-btn .fa { flex: none; width: 1em; text-align: center; line-height: 1; }
.hts-btn--icon .fa { font-size: 0.9375rem; }

/* the project picker above the composer shares the class name of the project page: keep it a normal select */
.hts-composer-tools > select.hts-project {
  display: inline-block; max-width: 16rem; margin: 0; padding: 0.375rem 0.625rem; gap: 0; flex-direction: row;
}

/* message toolbar: lighter until the message is hovered or focused, compact icon buttons */
.hts-msg-actions { opacity: 0.55; }
.hts-msg:hover .hts-msg-actions,
.hts-msg-actions:focus-within { opacity: 1; }
.hts-msg-actions .hts-btn--icon { width: 1.875rem; min-height: 1.875rem; }
.hts-msg-actions .hts-btn--icon .fa { font-size: 0.875rem; }
@media (hover: none) { .hts-msg-actions { opacity: 0.8; } }

/* citations: one raise only (the sup), so the badge sits beside the word and the line height stays even */
.hts-cite { vertical-align: super; line-height: 0; font-size: inherit; margin-inline-start: 0.125rem; }
.hts-cite-btn { vertical-align: baseline; line-height: 1.3; position: relative; top: -0.0625rem; }

/* sources row: label and chips on one baseline, chips never wider than the column */
.hts-sources { align-items: center; row-gap: 0.375rem; }
.hts-sources-label { display: inline-flex; align-items: center; gap: 0.3125rem; }
.hts-chip--source { max-width: min(22rem, 100%); }
.hts-kb-note,
.hts-tools-used { line-height: 1.45; }

/* side panel heading: icon, title and its badge together; tools on their own line */
.hts-artifact-title { flex: 0 1 auto; }
.hts-artifact-heading > .hts-chip { flex: none; }
.hts-artifact-heading > .fa { flex: none; opacity: 0.8; }
.hts-artifact-tools { min-height: 2rem; }

/* project page: the instructions box stays inside its card; file rows keep their buttons in one column */
.hts-project-instr { display: block; box-sizing: border-box; max-width: 100%; margin-bottom: 0.5rem; }
.hts-project-file-actions { min-width: 4.25rem; justify-content: flex-end; }
.hts-project-file-icon { align-self: flex-start; margin-top: 0.3125rem; }
.hts-project-section h3 { line-height: 1.35; }

/* composer: icons centred in their buttons */
.hts-composer-box .hts-btn--icon { justify-content: center; }
/* composer box, its tools row and the thread share one 52rem column (the box border and padding no longer stick out) */
.hts-composer-box { box-sizing: border-box; }
.hts-composer-tools > [hidden] { display: none !important; }
.hts-composer-tools > .hts-chips:empty { display: none; }

/* ---------- CR-08: push-to-talk - the microphone has the size and look of the paperclip next to it ---------- */
.hts-composer-box .hts-voice-btn { flex: 0 0 2.25rem; width: 2.25rem; height: 2.25rem; border: 0; background: transparent; }
/* the text box gives way while recording (status, cancel and stop never leave the composer or cover Send) */
.hts-composer-box .hts-voice { flex: 0 0 auto; }
.hts-composer-box .hts-input { min-width: 0; }
@media (max-width: 640px) {
  .hts-composer-box .hts-voice { gap: 4px; }
  .hts-composer-box .hts-voice-meter { display: none; }
  /* phones: dot + time stay visible; the word is still announced (status region) */
  .hts-composer-box .hts-voice-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- CR-09: live status line of a streaming answer (hts-status.js) ---------- */
.hts-status { margin-top: 0.35rem; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8125rem; }
.hts-status[hidden] { display: none; }
.hts-status-line { display: flex; align-items: center; gap: 0.4rem; min-width: 0; opacity: 0.8; }
.hts-status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hts-status-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; opacity: 0.7; unicode-bidi: isolate; }
.hts-status-mark { flex: 0 0 auto; width: 0.75rem; height: 0.75rem; box-sizing: border-box; border-radius: 50%; }
.hts-status-line--running .hts-status-mark,
.hts-status-line--stopping .hts-status-mark { border: 2px solid var(--hts-line); border-top-color: var(--hts-primary); animation: hts-status-spin 0.9s linear infinite; }
.hts-status-line--done .hts-status-mark { background: var(--hts-secondary); opacity: 0.55; transform: scale(0.6); }
.hts-status-line--warn .hts-status-mark,
.hts-status-line--failed .hts-status-mark { background: var(--hts-primary); transform: scale(0.6); }
@keyframes hts-status-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .hts-status-line--running .hts-status-mark, .hts-status-line--stopping .hts-status-mark { animation: none; border-color: var(--hts-primary); }
}

/* ---------- AUD-02 ---------- */
/* Task 1: admin sidebar grouped by department */
.hts-side-dept { display: flex; align-items: center; gap: 0.375rem; width: 100%; min-height: 2rem; padding: 0.25rem 0.5rem;
  border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; text-align: start; }
.hts-side-dept:hover { background: var(--hts-soft-2); }
.hts-side-dept:focus-visible { outline: 2px solid var(--hts-primary); outline-offset: 1px; }
.hts-side-dept-caret { width: 0.75rem; transition: transform 0.15s; }
.hts-side-dept[aria-expanded="false"] .hts-side-dept-caret { transform: rotate(-90deg); }
[dir="rtl"] .hts-side-dept[aria-expanded="false"] .hts-side-dept-caret { transform: rotate(90deg); }
.hts-side-dept-items { padding-inline-start: 0.75rem; }
.hts-side-dept-items[hidden] { display: none; }
.hts-project-users { margin: 0 0 0.5rem; }
/* header tools */
.hts-chat-head-tools { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.hts-chat-global { border-inline-start: 1px solid var(--hts-line); padding-inline-start: 0.25rem; }
/* Task 3: one hint style */
.hts-tip { position: fixed; z-index: 1100; max-width: 18rem; padding: 0.3125rem 0.5rem; border-radius: 6px;
  background: var(--hts-secondary); color: var(--hts-text); font-size: 0.75rem; line-height: 1.35; pointer-events: none;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--hts-secondary) 30%, transparent); }
.hts-tip[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .hts-tip { animation: hts-tip-in 0.12s ease-out; } }
@keyframes hts-tip-in { from { opacity: 0; } to { opacity: 1; } }
/* Task 5: user manual */
.hts-help-search { width: 100%; margin: 0 0 0.75rem; }
.hts-help-item { border-bottom: 1px solid var(--hts-line); padding: 0.375rem 0; }
.hts-help-title { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; cursor: pointer; font-weight: 600; }
.hts-help-text { margin: 0.375rem 0 0.25rem; line-height: 1.55; white-space: pre-wrap; }
/* Task 4: appearance */
.hts-appearance h3 { margin: 0.75rem 0 0.375rem; font-size: 0.9375rem; font-weight: 600; }
.hts-ui-field { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0 0 0.5rem; }
.hts-ui-field .hts-select { min-width: 12rem; }
.hts-ui-actions { margin-top: 0.75rem; }
/* Task 12: elapsed time / estimate */
.hts-eta { margin-top: 0.25rem; font-size: 0.8125rem; opacity: 0.75; font-variant-numeric: tabular-nums; }
.hts-eta[hidden] { display: none; }

/* =====================================================================
   AUD-03 (18.6.0): dark premium chat. Tokens from hts-app.css (--hts-page,
   --hts-panel, --hts-fg ...), all mixed from the HTS_BRANDING colours.
   ===================================================================== */
:root {
  --hts-line: var(--hts-border);
  --hts-soft: color-mix(in srgb, var(--hts-fg) 4%, transparent);
  --hts-soft-2: var(--hts-hover);
  --hts-red-soft: var(--hts-red-16);
  --hts-radius: 16px;
}

/* chat column: clean, centred */
.hts-chat-wrap { font-family: var(--hts-font); }
.hts-chat-head { padding: 0.25rem 0.25rem 0.75rem; border-bottom-color: var(--hts-border); }
.hts-chat-title { font-size: 1.05rem; font-weight: 640; letter-spacing: -0.005em; }
.hts-chat-global { padding-inline-start: 0.375rem; margin-inline-start: 0.25rem; border-inline-start: 1px solid var(--hts-border); }
.hts-btn { border-radius: var(--hts-r-sm); border-color: var(--hts-border); transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s; }
.hts-btn:hover:not([disabled]) { background: var(--hts-hover); border-color: var(--hts-border-2); }
.hts-btn--icon { color: var(--hts-fg-2); }
.hts-btn--icon:hover:not([disabled]) { color: var(--hts-fg); }
.hts-btn:focus-visible, .hts-card:focus-visible, .hts-side-item:focus-visible { outline: none; box-shadow: var(--hts-ring); }
.hts-btn--primary { background: var(--hts-red-grad); border-color: transparent; box-shadow: 0 6px 18px var(--hts-red-40); }
.hts-btn--primary:hover:not([disabled]) { background: var(--hts-red-grad); filter: brightness(1.08); }
.hts-chip { background: var(--hts-hover); border: 1px solid var(--hts-border); color: var(--hts-fg-2); }
.hts-chip--card { background: var(--hts-red-08); border-color: var(--hts-red-16); color: var(--hts-fg); }
.hts-input, .hts-select { border-radius: var(--hts-r-sm); border-color: var(--hts-border-2); background: var(--a-field-input-background-color); }
.hts-input:focus, .hts-select:focus { outline: none; border-color: var(--hts-primary); box-shadow: var(--hts-ring); }
.hts-select option { background: var(--hts-panel); color: var(--hts-fg); }

/* welcome: large greeting, glass task cards */
.hts-welcome { margin-top: 9vh; }
.hts-welcome h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.25rem); font-weight: 680; letter-spacing: -0.025em;
  background: linear-gradient(90deg, var(--hts-fg), color-mix(in srgb, var(--hts-fg) 55%, var(--hts-primary)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hts-welcome p { color: var(--hts-fg-2); }
.hts-cards { gap: 0.75rem; margin-top: 2rem; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); }
.hts-card {
  align-items: flex-start; text-align: start; padding: 1rem 1rem 0.95rem;
  background: var(--hts-glass); border: 1px solid var(--hts-border); border-radius: var(--hts-r);
  box-shadow: var(--hts-shadow);
  transition: transform 0.15s, border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.hts-card .fa {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 10px;
  background: var(--hts-red-16); font-size: 1.05rem;
}
.hts-card:hover, .hts-card.is-active {
  transform: translateY(-2px); border-color: var(--hts-red-40);
  background: linear-gradient(160deg, var(--hts-red-08), var(--hts-glass) 60%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--hts-red-16);
}

/* messages: answers on the page, questions in a raised bubble */
.hts-msg { max-width: 48rem; margin-bottom: 1.5rem; }
.hts-avatar {
  flex-basis: 2rem; background: var(--hts-red-grad); box-shadow: 0 4px 14px var(--hts-red-40);
  font-size: 0.65rem; letter-spacing: 0.04em;
}
.hts-bubble { line-height: 1.65; font-size: 0.97rem; }
.hts-msg--user .hts-bubble {
  padding: 0.65rem 1rem; border-radius: 18px 18px 6px 18px;
  background: var(--hts-panel-2); color: var(--hts-fg); border: 1px solid var(--hts-border);
}
[dir="rtl"] .hts-msg--user .hts-bubble { border-radius: 18px 18px 18px 6px; }
.hts-msg--failed .hts-bubble { background: var(--hts-red-08); border: 1px solid var(--hts-red-16); border-inline-start: 3px solid var(--hts-primary); }
.hts-msg-meta { color: var(--hts-fg-2); opacity: 1; }
.hts-msg-actions { opacity: 0; transition: opacity 0.15s; }
.hts-msg:hover .hts-msg-actions, .hts-msg-actions:focus-within, .hts-msg:last-child .hts-msg-actions { opacity: 1; }
.hts-md h1, .hts-md h2, .hts-md h3 { letter-spacing: -0.01em; }
.hts-md code { background: var(--hts-hover); border: 1px solid var(--hts-border); }
.hts-md pre, .hts-pre {
  background: color-mix(in srgb, var(--hts-page) 80%, var(--hts-secondary)); border: 1px solid var(--hts-border);
  border-radius: var(--hts-r-sm); box-shadow: inset 0 1px 0 var(--hts-border);
}
.hts-md table { border-radius: var(--hts-r-sm); }
.hts-md th { background: var(--hts-panel-2); }
.hts-md a { color: color-mix(in srgb, var(--hts-primary) 70%, var(--hts-text)); }

/* composer: floating glass box with a red focus glow */
.hts-composer { padding-top: 0.75rem; }
.hts-composer-box {
  padding: 0.5rem 0.5rem 0.5rem 1rem; border-radius: 20px;
  background: var(--hts-glass); border: 1px solid var(--hts-border-2);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hts-composer-box:focus-within { border-color: var(--hts-red-40); box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35), var(--hts-ring); }
.hts-composer-box .hts-input { background: transparent; box-shadow: none; font-size: 0.97rem; }
.hts-send { border-radius: 12px; background: var(--hts-red-grad); box-shadow: 0 6px 16px var(--hts-red-40); }
.hts-send[disabled] { box-shadow: none; filter: grayscale(0.6); }
.hts-stop { border-radius: 12px; background: var(--hts-red-08); }
.hts-composer-foot { color: var(--hts-fg-2); opacity: 1; }
.hts-banner, .hts-ai-down, .hts-modify { border-radius: var(--hts-r-sm); background: var(--hts-red-08); border: 1px solid var(--hts-red-16); }

/* sidebar */
#hts-sidebar, .t-Body-side { background: color-mix(in srgb, var(--hts-page) 65%, var(--hts-panel)); border-inline-end: 1px solid var(--hts-border); }
.hts-side { gap: 0.625rem; }
.hts-side-top .hts-new { background: var(--hts-red-grad); color: var(--hts-text); border-color: transparent; box-shadow: 0 6px 16px var(--hts-red-40); font-weight: 600; }
.hts-side-top .hts-new:hover:not([disabled]) { background: var(--hts-red-grad); filter: brightness(1.08); }
.hts-side-group { color: var(--hts-fg-2); opacity: 1; font-size: 0.66rem; letter-spacing: 0.08em; }
.hts-side-item { color: var(--hts-fg-2); border-radius: var(--hts-r-sm); transition: background-color 0.12s, color 0.12s; }
.hts-side-item:hover { background: var(--hts-hover); color: var(--hts-fg); }
.hts-side-item.is-active { background: linear-gradient(90deg, var(--hts-red-16), var(--hts-red-08)); color: var(--hts-fg); }

/* side panels (help, appearance, artifacts), search, notices, library */
.hts-artifact-panel { background: var(--hts-panel); border-color: var(--hts-border); }
.hts-search-item:hover, .hts-search-item:focus-visible { background: var(--hts-hover); border-color: var(--hts-border-2); }
.hts-lib-card, .hts-notice, .hts-version, .hts-project-file, .hts-artifact-card {
  background: var(--hts-panel); border: 1px solid var(--hts-border); border-radius: var(--hts-r);
}
.hts-lib-card:hover, .hts-artifact-card:hover { border-color: var(--hts-red-40); background: var(--hts-panel-2); }
.hts-notice--unread { background: var(--hts-red-08); }
.hts-img-blocked { color: var(--hts-fg-2); }
.hts-tip { background: var(--hts-raised); color: var(--hts-fg); border: 1px solid var(--hts-border-2); border-radius: 8px; box-shadow: var(--hts-shadow-lg); }

/* small screens: drawer uses the panel colour */
@media (max-width: 900px) {
  body.hts-side-open #hts-sidebar { background: var(--hts-panel); color: var(--hts-fg); box-shadow: var(--hts-shadow-lg); }
}
@media (prefers-reduced-motion: reduce) {
  .hts-card, .hts-card:hover { transition: none; transform: none; }
}
/* AUD-03 fix 4: chat and project list hover = same as the menus */
.hts-side-item:hover { background: var(--hts-red-08); color: var(--hts-fg); }
.hts-side-item:hover .hts-side-icon, .hts-side-item:hover .fa { color: var(--hts-primary); opacity: 1; }

/* =====================================================================
   CR-13 (18.7.0): Artifacts section - sidebar entry, gallery, cards, card menu. Tokens only (Dark and Light).
   ===================================================================== */
.hts-side-artifacts { margin: 0.125rem 0 0.25rem; font-weight: 600; color: var(--hts-fg); }
.hts-side-artifacts .hts-side-icon { color: var(--hts-primary); opacity: 1; }
.hts-side-artifacts.is-active { background: linear-gradient(90deg, var(--hts-red-16), var(--hts-red-08)); box-shadow: inset 3px 0 0 var(--hts-primary); }
[dir="rtl"] .hts-side-artifacts.is-active { box-shadow: inset -3px 0 0 var(--hts-primary); }
.hts-side-art-count:empty { display: none; }

.hts-gal { max-width: 78rem; margin: 0 auto; padding: 0.25rem 0.25rem 2rem; }
.hts-gal-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0.25rem 0 0.75rem; }
.hts-gal-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; flex: 1 1 32rem; }
.hts-gal-search-wrap { position: relative; flex: 1 1 16rem; display: flex; align-items: center; }
.hts-gal-search-wrap > .fa { position: absolute; inset-inline-start: 0.75rem; color: var(--hts-fg-2); pointer-events: none; }
.hts-gal-search { width: 100%; padding-inline-start: 2.1rem; }
.hts-gal-type, .hts-gal-project { max-width: 14rem; }
.hts-gal-starred[aria-pressed="true"] { border-color: var(--hts-red-40); background: var(--hts-red-08); color: var(--hts-fg); }
.hts-gal-starred[aria-pressed="true"] .fa { color: var(--hts-primary); }
.hts-gal-info { margin: 0 0 0.75rem; font-size: 0.8125rem; }
.hts-gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: 1rem; }
.hts-gal-more { display: flex; margin: 1.25rem auto 0; }
.hts-gal-more[hidden] { display: none; }

.hts-acard {
  position: relative; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--hts-border); border-radius: var(--hts-r);
  background: var(--hts-panel); box-shadow: var(--hts-shadow); overflow: visible;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.hts-acard:hover, .hts-acard:focus-within { transform: translateY(-2px); border-color: var(--hts-red-40);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--hts-red-16); }
.hts-acard-open { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; text-align: start; }
.hts-acard-open:focus-visible { outline: none; box-shadow: var(--hts-ring); border-radius: var(--hts-r) var(--hts-r) 0 0; }
.hts-acard-thumb {
  position: relative; height: 9.5rem; overflow: hidden; border-radius: var(--hts-r) var(--hts-r) 0 0; border-bottom: 1px solid var(--hts-border);
  background: linear-gradient(160deg, var(--hts-red-08), var(--hts-panel-2) 55%); display: grid; place-items: center;
}
.hts-acard-thumb::after { content: ""; position: absolute; inset: auto 0 0 0; height: 2.5rem;
  background: linear-gradient(transparent, var(--hts-panel)); pointer-events: none; }
.hts-acard-thumb-icon { font-size: 2.25rem; color: var(--hts-primary); opacity: 0.85; }
.hts-acard-snippet {
  align-self: start; justify-self: stretch; margin: 0; padding: 0.75rem 0.85rem; max-height: 100%; overflow: hidden;
  font: 0.7rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--hts-fg-2);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.hts-acard-thumb--markdown .hts-acard-snippet { font-family: var(--hts-font); font-size: 0.75rem; }
.hts-acard-frame { position: absolute; top: 0; left: 0; width: 250%; height: 250%; border: 0; transform: scale(0.4); transform-origin: 0 0;
  pointer-events: none; background: var(--hts-text); }
.hts-acard-foot { display: flex; align-items: flex-start; gap: 0.25rem; padding: 0.7rem 0.5rem 0.75rem 0.9rem; }
.hts-acard-body { flex: 1 1 auto; min-width: 0; }
.hts-acard-headline { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.hts-acard-type { color: var(--hts-primary); flex: none; }
.hts-acard-title { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 0.92rem; font-weight: 650; color: var(--hts-fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hts-acard-flags { display: inline-flex; gap: 0.35rem; flex: none; font-size: 0.75rem; }
.hts-acard-star { color: var(--hts-primary); }
.hts-acard-shared { color: var(--hts-fg-2); }
.hts-acard-meta, .hts-acard-owner { margin: 0.3rem 0 0; font-size: 0.75rem; color: var(--hts-fg-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hts-acard-owner { font-style: italic; }
.hts-acard-rename { width: 100%; min-height: 1.9rem; padding: 0.2rem 0.5rem; font-size: 0.9rem; }
.hts-acard-menu-btn { flex: none; }

.hts-amenu {
  position: absolute; z-index: 30; inset-inline-end: 0.5rem; bottom: 2.75rem; min-width: 12rem; padding: 0.3rem;
  border: 1px solid var(--hts-border-2); border-radius: var(--hts-r-sm); background: var(--hts-panel-2); box-shadow: var(--hts-shadow-lg);
  display: flex; flex-direction: column;
}
.hts-amenu-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.5rem 0.65rem; border: 0; border-radius: 8px;
  background: transparent; color: var(--hts-fg); font: inherit; font-size: 0.85rem; text-align: start; cursor: pointer;
}
.hts-amenu-item .fa { width: 1rem; text-align: center; color: var(--hts-fg-2); }
.hts-amenu-item:hover, .hts-amenu-item:focus-visible { outline: none; background: var(--hts-red-08); }
.hts-amenu-item:hover .fa, .hts-amenu-item:focus-visible .fa { color: var(--hts-primary); }
.hts-amenu-item--danger, .hts-amenu-item--danger .fa { color: var(--hts-primary); }

.hts-gal-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 3.5rem 1rem;
  border: 1px dashed var(--hts-border-2); border-radius: var(--hts-r); text-align: center; color: var(--hts-fg-2); }
.hts-gal-empty h3 { margin: 0.25rem 0 0; color: var(--hts-fg); font-size: 1.1rem; }
.hts-gal-empty p { margin: 0 0 0.5rem; max-width: 34rem; }
.hts-gal-empty-icon { display: grid; place-items: center; width: 3.25rem; height: 3.25rem; border-radius: 14px;
  background: var(--hts-red-16); color: var(--hts-primary); font-size: 1.4rem; }
@media (prefers-reduced-motion: reduce) { .hts-acard, .hts-acard:hover { transition: none; transform: none; } }
.hts-ashare {
  position: absolute; z-index: 31; inset: auto 0.5rem 0.5rem 0.5rem; padding: 0.75rem; border: 1px solid var(--hts-border-2);
  border-radius: var(--hts-r-sm); background: var(--hts-panel-2); box-shadow: var(--hts-shadow-lg);
}
.hts-ashare-note { margin: 0 0 0.5rem; font-size: 0.75rem; color: var(--hts-fg-2); }
.hts-ashare-row { display: flex; align-items: center; gap: 0.4rem; }
.hts-ashare-url { flex: 1 1 auto; min-width: 0; font-size: 0.75rem; }

/* ===== CR-14: my AI budget in a project (composer bar, project home section, Request more form) ===== */
.hts-budget { margin: 0 0 .5rem; padding: .5rem .75rem; border-radius: var(--hts-r, 10px); border: 1px solid var(--hts-border, rgba(127,127,127,.25));
  background: var(--hts-panel-2, transparent); font-size: .875rem; }
.hts-budget--warn { border-color: rgba(214, 158, 46, .55); }
.hts-budget--reached { border-color: var(--hts-red-40, rgba(204, 31, 41, .4)); background: var(--hts-red-08, rgba(204, 31, 41, .08)); }
.hts-budget-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.hts-budget-row > .fa { color: var(--hts-red, #cc1f29); }
.hts-budget-text { flex: 1 1 16rem; }
.hts-budget-form { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: flex-end; margin-block-start: .6rem; }
.hts-budget-field { display: flex; flex-direction: column; gap: .25rem; font-size: .8125rem; }
.hts-budget-field--wide { flex: 1 1 18rem; }
.hts-budget-amount { inline-size: 9rem; }
.hts-budget-reason { inline-size: 100%; resize: vertical; }
.hts-project-budget .hts-budget-item { margin-block-end: .75rem; }
.hts-budget-bar { block-size: .5rem; border-radius: 999px; background: var(--hts-border, rgba(127,127,127,.2)); overflow: hidden; margin-block-end: .35rem; }
.hts-budget-fill { display: block; block-size: 100%; border-radius: inherit; background: #2f9e6e; }
.hts-budget-fill.is-warn { background: #d69e2e; }
.hts-budget-fill.is-over { background: var(--hts-red, #cc1f29); }

/* ===== CR-15: right-to-left (Arabic). Layout rules above use logical properties; only direction-bearing icons flip.
   Code, numbers in code blocks and the composer's own text keep their natural direction (dir="auto"). ===== */
[dir="rtl"] .hts-btn .fa-chevron-left, [dir="rtl"] .hts-btn .fa-chevron-right,
[dir="rtl"] .hts-btn .fa-send, [dir="rtl"] .hts-btn .fa-paper-plane, [dir="rtl"] .hts-btn .fa-reply { transform: scaleX(-1); }
[dir="rtl"] .hts-md pre, [dir="rtl"] .hts-md code, [dir="rtl"] .hts-artifact-code { direction: ltr; text-align: left; }
.hts-ui-lang { min-inline-size: 10rem; }

/* ---- M10 batch 2: About panel, help metadata, contextual help links ---- */
.hts-about h3 { margin: 1rem 0 0.5rem; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }
.hts-about-versions { display: grid; gap: 0.25rem; }
.hts-about-row { display: grid; grid-template-columns: 1fr auto auto; gap: 0.75rem; align-items: baseline; padding: 0.375rem 0.5rem;
  border-radius: 8px; background: var(--hts-panel-2, rgba(255,255,255,.04)); }
.hts-about-note { padding: 0.5rem 0; border-bottom: 1px solid var(--hts-line, rgba(255,255,255,.08)); }
.hts-about-note-head { display: flex; justify-content: space-between; gap: 0.75rem; }
.hts-about-note p { margin: 0.25rem 0 0; }
.hts-about-copy { margin-top: 1rem; font-size: 0.75rem; }
.hts-help-meta { margin-top: 0.5rem; font-size: 0.6875rem; }
.hts-project-budget h3 { display: flex; align-items: center; gap: 0.375rem; }
.hts-help-link { opacity: 0.7; }
.hts-help-link:hover, .hts-help-link:focus-visible { opacity: 1; }

/* CR-23-02: project instructions editor, file readability, project rules, extracted-text preview */
.hts-project-instr { min-height: 15rem; line-height: 1.5; tab-size: 4; }
.hts-project-instr.is-invalid { border-color: var(--hts-primary); outline: 1px solid var(--hts-primary); }
.hts-project-instr-bar { align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
.hts-project-instr-count { font-size: 0.75rem; opacity: 0.75; font-variant-numeric: tabular-nums; }
.hts-project-instr-count.is-error { color: var(--hts-primary); opacity: 1; font-weight: 600; }
.hts-project-instr-state { font-size: 0.75rem; overflow-wrap: anywhere; }
.hts-project-instr-state.is-ok { opacity: 0.75; }
.hts-project-instr-state.is-dirty { font-weight: 600; }
.hts-project-instr-state.is-error { color: var(--hts-primary); font-weight: 600; }
.hts-project-file-state.is-partial { background: color-mix(in srgb, var(--hts-secondary) 18%, transparent); }
.hts-project-file-rules { flex: none; background: var(--hts-red-soft); color: var(--hts-primary); }
.hts-project-file-rules-toggle.is-on .fa { color: var(--hts-primary); }
.hts-kb-preview-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: color-mix(in srgb, var(--hts-secondary) 45%, transparent); }
.hts-kb-preview { display: flex; flex-direction: column; gap: 0.5rem; width: min(56rem, 100%); max-height: calc(100vh - 2rem);
  padding: 0.75rem 1rem; border-radius: var(--hts-radius); background: var(--hts-panel, Canvas); color: var(--hts-fg, CanvasText);
  border: 1px solid var(--hts-line); box-shadow: 0 0.5rem 2rem color-mix(in srgb, var(--hts-secondary) 30%, transparent); }
.hts-kb-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.hts-kb-preview-head h3 { margin: 0; font-size: 0.9375rem; overflow-wrap: anywhere; }
.hts-kb-preview-part { max-width: 18rem; }
.hts-kb-preview-meta { margin: 0; font-size: 0.75rem; }
.hts-kb-preview-text { flex: 1 1 auto; min-height: 12rem; margin: 0; padding: 0.5rem 0.75rem; overflow: auto; white-space: pre-wrap;
  overflow-wrap: anywhere; border: 1px solid var(--hts-line); border-radius: 8px; background: var(--hts-soft); font-size: 0.8125rem; }

/* =====================================================================================================================
   CR-24: Memory page, memory cards, project memory section, "Memory used" under answers
   ===================================================================================================================== */
.hts-mem { max-width: 52rem; margin: 0 auto; padding: 0.5rem 0 2rem; }
.hts-mem-list { display: flex; flex-direction: column; gap: 0.6rem; }
.hts-mem-card { border: 1px solid var(--hts-border); border-radius: var(--hts-r, 10px); background: var(--hts-panel); padding: 0.7rem 0.9rem; }
.hts-mem-card.is-proposed { border-color: var(--hts-red-40); background: var(--hts-red-08); }
.hts-mem-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.hts-mem-id { font-size: 0.75rem; color: var(--hts-fg-2); font-variant-numeric: tabular-nums; }
.hts-mem-title { margin: 0; font-size: 0.95rem; flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.hts-mem-text { margin: 0.35rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.hts-mem-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; font-size: 0.8rem; }
.hts-mem-source { color: var(--hts-primary); }
.hts-mem-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; justify-content: flex-end; }
.hts-mem-state--ok { border-color: var(--hts-border); }
.hts-mem-state--proposed { border-color: var(--hts-red-40); color: var(--hts-primary); }
.hts-mem-state--off { opacity: 0.75; text-decoration: none; }
.hts-mem-link { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.hts-mem-modal { max-width: 40rem; width: calc(100vw - 2rem); }
.hts-mem-form { display: flex; flex-direction: column; gap: 0.5rem; }
.hts-mem-form .hts-field { display: flex; flex-direction: column; gap: 0.2rem; flex: 1 1 12rem; }
.hts-mem-content-input { min-height: 7rem; resize: vertical; }
.hts-mem-stale { color: var(--hts-primary); min-height: 1em; }
.hts-mem-form-actions { justify-content: flex-end; margin-top: 0.5rem; }
.hts-mem-history { margin: 0; padding-inline-start: 1.25rem; max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.hts-mem-snap { font-size: 0.85rem; overflow-wrap: anywhere; }
.hts-project-memory .hts-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.hts-project-memory-mode { max-width: 100%; }
.hts-chip--proposed { border-style: dashed; }
.hts-mem-used { margin-top: 0.25rem; }

/* =====================================================================
   UI-03 (App 100 chat): spacing, alignment and hierarchy refinement.
   Appended at the end of hts-chat.css. Layout and decoration only - no new colours,
   no behaviour change, logical properties only (RTL safe).
   ===================================================================== */
:root {
  --hts-radius: 8px;
  --hts-col: 52rem;                       /* one reading column for thread, tools row and composer */
  --hts-chat-offset: calc(var(--js-sticky-top, 49px) + 53px);   /* header + content padding 16/8 + one-line footer 29 */
}

/* ---------- chat page frame: the chat fills the window exactly (no second page scrollbar) ---------- */
html.page-1 .t-Body-contentInner { padding: var(--hts-s4) var(--hts-s5) var(--hts-s2); }
html.page-1 .t-Footer { padding: 0; border-top: 1px solid var(--hts-border); }
html.page-1 .t-Footer-body, html.page-1 .t-Footer-top { display: none; }
html.page-1 .hts-footer { padding: 0.375rem var(--hts-s4); }

/* ---------- sidebar: inner margins, one scroll area, New chat and Skills pinned ---------- */
#hts-sidebar, .t-Body-side { background: var(--hts-panel); }
.hts-side {
  gap: var(--hts-s1);
  height: calc(100vh - var(--js-sticky-top, 49px)); min-height: 0;
  padding: var(--hts-s3) var(--hts-s3) 0; box-sizing: border-box;
}
.hts-side-top { gap: var(--hts-s1); margin-bottom: var(--hts-s2); }
.hts-side-top .hts-new { min-height: 2.25rem; box-shadow: none; font-weight: 600; }
.hts-side-top .hts-new:hover:not([disabled]) { filter: brightness(0.94); }
.hts-side-top .hts-btn--icon { width: 2.25rem; min-height: 2.25rem; }
/* projects get a real share of the column (was ~2 rows); the chat list keeps the rest */
.hts-side-projects { flex: 0 0 auto; max-height: 38%; }
.hts-side-list { flex: 1 1 0; min-height: 6rem; }
.hts-side > .hts-select { flex: none; margin: var(--hts-s2) 0 0; min-height: 2rem; font-size: 0.875rem; }
.hts-side-group { margin: var(--hts-s3) var(--hts-s2) var(--hts-s1); font-size: 0.6875rem; letter-spacing: 0.06em; }
.hts-side-group--row { margin-inline-end: 0; }
.hts-side-item, .hts-side-dept { min-height: 2rem; padding: 0.375rem var(--hts-s2); border-radius: var(--hts-r-sm); font-size: 0.875rem; }
.hts-side-dept { font-weight: 600; color: var(--hts-fg); }
.hts-side-item.is-active, .hts-side-artifacts.is-active { background: var(--hts-red-08); color: var(--hts-fg); }
.hts-side-artifacts { margin: 0; }
.hts-side-dept-items { padding-inline-start: var(--hts-s4); }
.hts-side-more { margin: var(--hts-s2) 0; }
.hts-cap-entry { flex: none; margin: 0 calc(-1 * var(--hts-s3)); padding: var(--hts-s3) var(--hts-s4); width: auto;
  border-radius: 0; border-top: 1px solid var(--hts-border); }

/* ---------- chat header: quiet icon buttons, title keeps its room ---------- */
.hts-chat-head { min-height: 2.75rem; padding: 0 0 var(--hts-s3); }
.hts-chat-title { font-size: 1rem; font-weight: 600; max-width: none; }
.hts-chat-heading { flex: 1 1 auto; flex-wrap: nowrap; }
.hts-chat-head .hts-btn--icon { width: 2rem; min-height: 2rem; border-color: transparent; }
.hts-menu { flex: none; }
/* the welcome screen already greets the user: no second identical title in the bar */
.hts-chat-wrap:has(.hts-welcome) .hts-chat-title { visibility: hidden; }
.hts-chat-wrap:has(.hts-welcome) .hts-chat-head { border-bottom-color: transparent; }

/* ---------- thread: one column shared with the composer ---------- */
.hts-thread { padding: var(--hts-s4) var(--hts-s2); }
.hts-msg { max-width: var(--hts-col); margin-bottom: var(--hts-s5); gap: var(--hts-s3); }
.hts-avatar { box-shadow: none; }
.hts-msg--user .hts-bubble { border-radius: 12px 12px 4px 12px; }
[dir="rtl"] .hts-msg--user .hts-bubble { border-radius: 12px 12px 12px 4px; }

/* ---------- welcome: plain heading, compact task list that fits above the composer ---------- */
.hts-welcome { max-width: var(--hts-col); margin-top: clamp(1rem, 6vh, 3.5rem); }
.hts-welcome h2 {
  background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--hts-fg);
  font-size: clamp(1.375rem, 2vw, 1.75rem); font-weight: 650; letter-spacing: -0.015em;
}
.hts-cards { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--hts-s2); margin-top: var(--hts-s5); }
.hts-card {
  flex-direction: row; align-items: center; gap: var(--hts-s3);
  min-height: 3rem; padding: var(--hts-s2) var(--hts-s3);
  background: var(--hts-panel); border-radius: var(--hts-r); box-shadow: none;
  font-size: 0.9375rem;
}
.hts-card .fa { flex: none; width: 2rem; height: 2rem; border-radius: var(--hts-r-sm); background: var(--hts-red-08); font-size: 1rem; }
.hts-card:hover, .hts-card.is-active { transform: none; box-shadow: none; background: var(--hts-red-08); border-color: var(--hts-red-40); }

/* ---------- composer: aligned tools row, flat box ---------- */
.hts-composer { padding-top: var(--hts-s3); }
.hts-composer-tools, .hts-composer-box, .hts-composer-foot, .hts-files, .hts-modify, .hts-ai-down { max-width: var(--hts-col); }
.hts-composer-tools { gap: var(--hts-s2); margin-bottom: var(--hts-s2); }
.hts-composer-tools > .hts-select { min-height: 2rem; padding: 0.25rem var(--hts-s2); font-size: 0.875rem; }
.hts-composer-tools > select.hts-project, .hts-engine { max-width: 15rem; }
.hts-skill-chip {
  background: var(--a-field-input-background-color); border-color: var(--hts-border-2);
  min-height: 2rem; padding: 0 var(--hts-s3); border-radius: var(--hts-r-sm);
  font-size: 0.875rem; color: var(--hts-fg);
}
.hts-composer-box {
  padding: 0.375rem 0.375rem 0.375rem var(--hts-s3); border-radius: 12px;
  background: var(--hts-panel); -webkit-backdrop-filter: none; backdrop-filter: none;
  box-shadow: var(--hts-shadow);
}
.hts-composer-box:focus-within { border-color: var(--hts-primary); box-shadow: var(--hts-ring); }
.hts-send { border-radius: var(--hts-r); box-shadow: none; }
.hts-send:hover:not([disabled]) { filter: brightness(0.94); }
.hts-composer-foot { margin-top: var(--hts-s1); font-size: 0.75rem; }

/* ---------- lists and galleries: no lift-on-hover ---------- */
.hts-acard:hover, .hts-acard:focus-within { transform: none; box-shadow: none; }
.hts-acard { box-shadow: none; }
.hts-gal-grid { gap: var(--hts-s4); }

/* ---------- tablets and phones ---------- */
@media (max-width: 900px) {
  body.hts-side-open #hts-sidebar { padding: 0; }
  body.hts-side-open #hts-sidebar .hts-side { padding: var(--hts-s3) var(--hts-s3) 0; }
}
@media (max-width: 640px) {
  :root { --hts-chat-offset: calc(var(--js-sticky-top, 49px) + 41px); }
  html.page-1 .t-Body-contentInner { padding: var(--hts-s2) var(--hts-s3) var(--hts-s1); }
  /* header: title on its own line, tools scroll sideways instead of crushing the title */
  .hts-chat-head { flex-wrap: wrap; row-gap: var(--hts-s1); padding-bottom: var(--hts-s2); }
  .hts-chat-heading { flex: 1 1 100%; }
  .hts-chat-title { max-width: none; }
  .hts-chat-head-tools { flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; }
  .hts-chat-actions { flex: none; }
  .hts-chat-wrap:has(.hts-welcome) .hts-chat-head-tools { flex: 0 0 auto; margin-inline-start: auto; }
  .hts-chat-wrap:has(.hts-welcome) .hts-chat-heading { flex: 1 1 auto; }
  .hts-thread { padding: var(--hts-s3) 0; }
  .hts-cards { grid-template-columns: 1fr 1fr; }
  .hts-composer-foot { display: none; }
  html.page-1 .hts-footer { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- selects: own caret with inner padding (the native arrow sat on the border) ---------- */
.hts-select {
  -webkit-appearance: none; appearance: none;
  padding-inline-end: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}
[dir="rtl"] .hts-select { background-position: 10px 55%, 15px 55%; }

/* ---------- the chat page never scrolls: only the conversation does ---------- */
html.page-1, html.page-1 body { height: 100%; overflow: hidden; }

/* =====================================================================
   UI-03 b: Claude-style chat - quiet chrome, one composer box with a + menu
   ===================================================================== */
/* header and chat bar: hairlines only */
.t-Header { box-shadow: none; }
.hts-chat-head { border-bottom: 0; }

/* sidebar: New chat as a plain row with a red round icon, sentence-case section labels */
.hts-side-top .hts-new {
  justify-content: flex-start; gap: var(--hts-s2); padding-inline: var(--hts-s2);
  background: transparent; border-color: transparent; color: var(--hts-fg); filter: none;
}
.hts-side-top .hts-new .fa {
  display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--hts-primary); color: var(--hts-text); font-size: 0.75rem;
}
.hts-side-top .hts-new:hover:not([disabled]) { background: var(--hts-hover); filter: none; }
.hts-side-top .hts-btn--icon { border-color: transparent; }
.hts-side-group { text-transform: none; letter-spacing: 0; font-size: 0.75rem; font-weight: 500; }
.hts-side .hts-cap-entry { display: none; }          /* moved into the composer + menu */

/* composer: tools row sits inside the box, on its bottom line (no DOM change) */
.hts-composer { display: grid; grid-template-columns: minmax(0, var(--hts-col)); justify-content: center; }
.hts-composer > * { grid-column: 1; min-width: 0; }
.hts-composer > .hts-budget, .hts-composer > .hts-ai-down, .hts-composer > .hts-modify, .hts-composer > .hts-files { margin-inline: 0; }
.hts-composer > .hts-composer-box { grid-row: 10; margin: 0; }
.hts-composer > .hts-composer-tools {
  grid-row: 10; align-self: end; z-index: 1; position: relative;
  margin: 0 5.5rem 0.5rem 3rem; max-width: none; flex-wrap: nowrap; gap: var(--hts-s1); min-width: 0;
}
.hts-composer > .hts-composer-foot { grid-row: 11; margin-inline: 0; }
.hts-composer-box {
  flex-wrap: wrap; align-items: center; gap: var(--hts-s1);
  padding: var(--hts-s3) var(--hts-s2) var(--hts-s2); border-radius: 16px; min-height: 6.5rem;
  border-color: var(--hts-border-2);
}
.hts-composer-box .hts-input { flex: 1 1 100%; order: -1; min-height: 3rem; padding: 0 var(--hts-s2); font-size: 1rem; }
.hts-composer-box .hts-attach { display: none; }      /* reached from the + menu */
.hts-composer-box .hts-voice { margin-inline-start: auto; }
.hts-composer-box .hts-send, .hts-composer-box .hts-stop { height: 2rem; }
.hts-composer-box .hts-send { flex-basis: 2rem; width: 2rem; }
.hts-composer > .hts-composer-tools > .hts-select {
  flex: 0 1 auto; min-width: 0; min-height: 2rem; max-width: 11rem;
  border-color: transparent; background-color: transparent; color: var(--hts-fg-2); font-size: 0.8125rem;
}
.hts-composer > .hts-composer-tools > .hts-select:hover { background-color: var(--hts-hover); color: var(--hts-fg); }
.hts-composer-tools > .hts-chips .hts-chip { max-width: 10rem; }
.hts-skill-chip[aria-pressed="false"] { display: none; }   /* choosing a skill is in the + menu; an active skill stays visible */
.hts-skill-chip[aria-pressed="true"] { min-height: 1.75rem; border-radius: 999px; font-size: 0.8125rem; }
.hts-composer-tools .hts-skill-menu { position: absolute; bottom: calc(100% + var(--hts-s3)); inset-inline-start: 0; margin: 0;
  background: var(--hts-panel); border-color: var(--hts-border-2); border-radius: var(--hts-r); box-shadow: var(--hts-shadow-lg); color: var(--hts-fg); }

/* the + button and its menu */
.hts-plus { flex: 0 0 2rem; width: 2rem; height: 2rem; min-height: 2rem; border: 1px solid var(--hts-border-2) !important; border-radius: var(--hts-r); color: var(--hts-fg-2); }
.hts-plus[aria-expanded="true"] { background: var(--hts-hover); color: var(--hts-fg); }
.hts-composer-box { position: relative; }
.hts-plus-menu {
  position: absolute; z-index: 60; bottom: calc(100% + var(--hts-s2)); inset-inline-start: 0; min-width: 15rem;
  padding: var(--hts-s1); border: 1px solid var(--hts-border-2); border-radius: var(--hts-r);
  background: var(--hts-panel); color: var(--hts-fg); box-shadow: var(--hts-shadow-lg);
}
.hts-plus-item {
  display: flex; align-items: center; gap: var(--hts-s3); width: 100%; min-height: 2.25rem; padding: 0 var(--hts-s3);
  border: 0; border-radius: var(--hts-r-sm); background: transparent; color: inherit; font: inherit; font-size: 0.875rem; text-align: start; cursor: pointer;
}
.hts-plus-item .fa { width: 1rem; text-align: center; color: var(--hts-fg-2); }
.hts-plus-item:hover, .hts-plus-item:focus-visible { outline: none; background: var(--hts-hover); }
.hts-plus-item:hover .fa, .hts-plus-item:focus-visible .fa { color: var(--hts-primary); }
.hts-plus-sep { height: 1px; margin: var(--hts-s1) 0; background: var(--hts-border); }

/* empty chat: greeting, composer, then task shortcuts - centred like a fresh Claude chat */
.hts-chat-wrap:has(.hts-welcome) .hts-chat-head { margin-bottom: auto; }
.hts-chat-wrap:has(.hts-welcome) .hts-thread,
.hts-chat-wrap:has(.hts-welcome) .hts-welcome { display: contents; }
.hts-chat-wrap:has(.hts-welcome) .hts-welcome > h2 { order: 1; margin: 0 auto var(--hts-s1); text-align: center; }
.hts-chat-wrap:has(.hts-welcome) .hts-welcome > p { order: 2; margin: 0 auto var(--hts-s5); text-align: center; }
.hts-chat-wrap:has(.hts-welcome) .hts-composer { order: 3; padding-top: 0; }
.hts-chat-wrap:has(.hts-welcome) .hts-cards {
  order: 4; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--hts-s2);
  width: 100%; max-width: var(--hts-col); margin: var(--hts-s4) auto auto; padding-bottom: var(--hts-s6);
}
.hts-chat-wrap:has(.hts-welcome) .hts-card {
  min-height: 2.25rem; padding: 0 var(--hts-s3); gap: var(--hts-s2); border-radius: var(--hts-r);
  background: transparent; border-color: var(--hts-border-2); font-size: 0.875rem; color: var(--hts-fg-2);
}
.hts-chat-wrap:has(.hts-welcome) .hts-card .fa { width: auto; height: auto; background: none; font-size: 0.875rem; }
.hts-chat-wrap:has(.hts-welcome) .hts-card:hover { color: var(--hts-fg); background: var(--hts-hover); border-color: var(--hts-border-2); }
.hts-chat-wrap:has(.hts-welcome) .hts-card.is-active { color: var(--hts-fg); border-color: var(--hts-red-40); background: var(--hts-red-08); }
.hts-welcome h2 { font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 600; }

@media (max-width: 640px) {
  .hts-composer > .hts-composer-tools { margin-inline: 2.75rem 5rem; }
  .hts-composer > .hts-composer-tools > .hts-select { flex: 1 1 0; max-width: none; padding-inline-start: var(--hts-s1); }
  .hts-chat-head { margin-bottom: var(--hts-s2); }
  .hts-chat-wrap:has(.hts-welcome) .hts-cards { padding-bottom: var(--hts-s3); }
}

/* =====================================================================
   UI-04 (App 100 only): every other screen - side panels, content pages, lists, dialogs.
   Appended at the end of hts-chat.css (not loaded by the Admin Console). Tokens only, logical properties.
   ===================================================================== */

/* ---------- side panels (Help, Appearance, About, artifact viewer): title and close on one line, inner margins ---------- */
.hts-artifact-panel { padding-inline: var(--hts-s4); background: var(--hts-panel); }
.hts-artifact-head { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--hts-s2); padding: var(--hts-s3) 0; border-bottom-color: var(--hts-border); }
.hts-artifact-heading { flex: 1 1 auto; min-width: 0; gap: var(--hts-s2); }
.hts-artifact-heading > .fa { color: var(--hts-fg-2); }
.hts-artifact-title { font-size: 0.9375rem; font-weight: 600; }
.hts-artifact-tools { flex: 0 0 auto; margin-inline-start: auto; min-height: 0; gap: var(--hts-s1); }
.hts-artifact-tools .hts-btn--icon { border-color: transparent; }
.hts-artifact-body { padding: var(--hts-s3) 0 var(--hts-s4); }
.hts-artifact-tabs { gap: var(--hts-s1); }
.hts-artifact-tab { min-height: 2rem; border-radius: var(--hts-r-sm); font-size: 0.875rem; }

/* Help: quiet list of articles */
.hts-help-search { margin: 0 0 var(--hts-s3); }
.hts-help-item { padding: 0; border-bottom-color: var(--hts-border); }
.hts-help-title { min-height: 2.5rem; padding: var(--hts-s2) var(--hts-s1); font-weight: 500; font-size: 0.875rem; list-style: none; }
.hts-help-title::-webkit-details-marker { display: none; }
.hts-help-title::after { content: ""; flex: none; width: 6px; height: 6px; margin-inline-end: var(--hts-s1);
  border-inline-end: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); opacity: 0.5; }
details[open] > .hts-help-title::after { transform: rotate(225deg); }
.hts-help-title:hover { color: var(--hts-primary); }
.hts-help-text { margin: 0 var(--hts-s1) var(--hts-s3); font-size: 0.875rem; color: var(--hts-fg-2); }

/* Appearance and About: section titles, aligned rows */
.hts-appearance h3, .hts-about h3 { margin: var(--hts-s5) 0 var(--hts-s2); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--hts-fg-2); opacity: 1; }
.hts-appearance h3:first-child, .hts-about h3:first-child { margin-top: var(--hts-s1); }
.hts-ui-field { min-height: 2.25rem; margin-bottom: var(--hts-s2); font-size: 0.875rem; }
.hts-ui-field .hts-select { min-width: 13rem; min-height: 2rem; font-size: 0.875rem; }
.hts-appearance .hts-row { gap: var(--hts-s2); }
.hts-appearance .hts-check { margin: 0; min-height: 2rem; padding: 0 var(--hts-s3); border: 1px solid var(--hts-border-2); border-radius: var(--hts-r-sm); font-size: 0.8125rem; }
.hts-ui-actions { display: flex; gap: var(--hts-s2); margin-top: var(--hts-s4); }
.hts-about-row { padding: var(--hts-s2) var(--hts-s3); border-radius: var(--hts-r-sm); font-size: 0.875rem; }
.hts-about-note { padding: var(--hts-s3) 0; border-bottom-color: var(--hts-border); font-size: 0.875rem; }

/* ---------- content pages (History, Favorites, Library, My Files, User Manual, Profile) ---------- */
.t-Body-title { background: var(--hts-panel); border-bottom: 1px solid var(--hts-border); }
.t-BreadcrumbRegion { padding: var(--hts-s3) var(--hts-s5) var(--hts-s4); }
.t-BreadcrumbRegion-title, .t-Breadcrumb-item.is-active .t-Breadcrumb-label { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.01em; }
.t-Breadcrumb-item:not(.is-active) .t-Breadcrumb-label, .t-Breadcrumb-item:not(.is-active) a { font-size: 0.8125rem; color: var(--hts-fg-2); }
.t-Region { border-radius: var(--hts-r); }
.t-Region-header { min-height: 3rem; }
.t-Region-title { font-size: 0.9375rem; font-weight: 600; }
.t-Region-body { padding: var(--hts-s4); }
/* reports: neutral headers and links - red is kept for actions and state */
.t-Report-colHead, .a-IRR-header, .a-GV-header, .a-IRR-table th, .a-IRR-header a, .a-IRR-headerLink, .t-Report-colHead a { color: var(--hts-fg-2); }
.a-IRR-table td a, .t-Report-cell a, .hts-title-link { color: var(--hts-fg); font-weight: 500; text-decoration: none; }
.a-IRR-table td a:hover, .t-Report-cell a:hover, .hts-title-link:hover { color: var(--hts-primary); text-decoration: underline; }
.a-IRR-table td, .t-Report-cell { padding-block: var(--hts-s2); vertical-align: middle; }
.hts-bulkbar { gap: var(--hts-s2); }
.hts-bulkbar .t-Button, .hts-bulkbar .hts-btn { min-height: 2rem; }
/* footer on content pages: one quiet line */
.t-Footer-body { display: none; }
.t-Footer { padding: var(--hts-s2) var(--hts-s5); }
.t-Footer-top { display: none; }
/* key / value lists (Profile) */
.hts-kv { gap: var(--hts-s2) var(--hts-s5); font-size: 0.875rem; }
.hts-kv dt { font-weight: 500; color: var(--hts-fg-2); }
.hts-badge { padding: 0.125rem var(--hts-s2); border-radius: var(--hts-r-sm); font-size: 0.75rem; }

/* ---------- folders view (Artifacts, Library, My Files) ---------- */
.hts-ws { gap: var(--hts-s5); }
.hts-ws-tree { padding: var(--hts-s2); background: var(--hts-panel); border-color: var(--hts-border); border-radius: var(--hts-r); box-shadow: none; }
.hts-ws-node { min-height: 2rem; padding: 0.25rem var(--hts-s2); border-radius: var(--hts-r-sm); font-size: 0.875rem; }
.hts-ws-node .fa { width: 1rem; text-align: center; color: var(--hts-fg-2); }
.hts-ws-node.is-current { background: var(--hts-red-08); color: var(--hts-fg); }
.hts-ws-node.is-current .fa { color: var(--hts-primary); }
.hts-ws-crumbs { font-size: 1rem; }
.hts-ws-crumb { color: var(--hts-fg-2); }
.hts-ws-list { background: var(--hts-panel); border-color: var(--hts-border); border-radius: var(--hts-r); }
.hts-ws-row { min-height: 3rem; padding-inline: var(--hts-s3); border-top-color: var(--hts-border); }
.hts-ws-icon { color: var(--hts-fg-2); }
.hts-ws-meta { color: var(--hts-fg-2); font-size: 0.75rem; }
.hts-gal { padding: 0 var(--hts-s1) var(--hts-s6); }
.hts-gal-tools { margin: 0 0 var(--hts-s4); }
.hts-gal-filters { flex-wrap: nowrap; }
.hts-gal-filters > .hts-select { flex: 0 1 12rem; min-width: 8rem; }
.hts-gal-search-wrap { flex: 1 1 14rem; }
.hts-acard, .hts-lib-card { border-radius: var(--hts-r); }
.hts-acard-thumb { border-radius: var(--hts-r) var(--hts-r) 0 0; background: var(--hts-panel-2); }
.hts-acard-thumb::after { display: none; }

/* ---------- memory, project page ---------- */
.hts-mem > .hts-field-help { margin: 0 0 var(--hts-s4); font-size: 0.875rem; color: var(--hts-fg-2); opacity: 1; }
.hts-mem-list { gap: var(--hts-s2); }
.hts-mem-card { padding: var(--hts-s3) var(--hts-s4); border-radius: var(--hts-r); }
.hts-project { gap: var(--hts-s4); padding-top: var(--hts-s2); }
.hts-project-title { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.hts-project-section { padding: var(--hts-s4); background: var(--hts-panel); border-color: var(--hts-border); border-radius: var(--hts-r); }
.hts-project-section h3 { margin-bottom: var(--hts-s2); font-size: 0.9375rem; font-weight: 600; }

/* ---------- dialogs and drawers (Search, Notifications, Skills & Connectors) ---------- */
.t-Dialog-page .hts-footer, .t-Drawer-page .hts-footer { display: none; }
.hts-search { gap: var(--hts-s3); }
.hts-search-item { padding: var(--hts-s2) var(--hts-s3); border-radius: var(--hts-r-sm); }
.hts-notice { padding: var(--hts-s3); border-radius: var(--hts-r); }
.hts-notices-empty { padding: var(--hts-s5) 0; text-align: center; color: var(--hts-fg-2); }

@media (max-width: 640px) {
  .t-BreadcrumbRegion { padding-inline: var(--hts-s3); }
  .t-Region-body { padding: var(--hts-s3); }
  .hts-gal-filters { flex-wrap: wrap; }
  .hts-ws { gap: var(--hts-s3); }
  .hts-artifact-panel { padding-inline: var(--hts-s3); }
}

/* =====================================================================
   UI-05 (App 100 only): main navigation menu (Chat, Search chats, History ...) + small fixes.
   Appended at the end of hts-chat.css. Tokens only, logical properties.
   ===================================================================== */
/* the menu: same surface as the chat sidebar, hairline divider, room under the header */
.t-Body-nav, .t-TreeNav, .t-TreeNav .a-TreeView { background-color: var(--hts-panel); }
.t-Body-nav { border-inline-end: 1px solid var(--hts-border); }
.t-TreeNav > ul { padding: var(--hts-s3) 0; }
/* compact rows, one radius, aligned icons */
html body .t-TreeNav .a-TreeView-content {
  display: flex; align-items: center; gap: var(--hts-s3);
  min-height: 2.25rem; margin: 1px var(--hts-s3); padding: 0 var(--hts-s3);
  border-radius: var(--hts-r-sm); box-shadow: none;
}
html body .t-TreeNav .a-TreeView-label { padding: 0; margin: 0; font-size: 0.875rem; font-weight: 400; line-height: 2.25rem; color: var(--hts-fg-2); }
html body .t-TreeNav .a-TreeView-node .a-TreeView-content > .fa { flex: none; width: 1rem; margin: 0; font-size: 1rem; text-align: center; color: var(--hts-fg-2); }
html body .t-TreeNav .a-TreeView-node .a-TreeView-row, html body .t-TreeNav .a-TreeView-node .a-TreeView-row[class] { height: calc(2.25rem + 2px); border: 0 !important; box-shadow: none !important; background: transparent !important; }
html body .t-TreeNav .a-TreeView-node, html body .t-TreeNav .a-TreeView-content { border: 0; }
/* hover and the open page: one flat tint, no gradient or side bar */
html body .t-TreeNav .a-TreeView-content.is-hover { background: var(--hts-hover); }
html body .t-TreeNav .a-TreeView-content.is-hover .a-TreeView-label, html body .t-TreeNav .a-TreeView-content.is-hover > .fa { color: var(--hts-fg); }
html body .t-TreeNav .a-TreeView-node--topLevel > .a-TreeView-content.is-current--top,
html body .t-TreeNav .a-TreeView-node--topLevel > .a-TreeView-content.is-current,
html body .t-TreeNav .a-TreeView-content.is-current { background: var(--hts-red-08); box-shadow: none; }
html body .t-TreeNav .a-TreeView-content.is-current .a-TreeView-label,
html body .t-TreeNav .a-TreeView-content.is-current--top .a-TreeView-label { color: var(--hts-fg); font-weight: 600; }
html body .t-TreeNav .a-TreeView-content.is-current > .fa,
html body .t-TreeNav .a-TreeView-content.is-current--top > .fa { color: var(--hts-primary); }
/* "Artifacts" links to the chat page too, so APEX marks it current as well: only the selected row is emphasised */
html body .t-TreeNav .a-TreeView-content:not(.is-selected) .a-TreeView-label.is-current { font-weight: 400; color: var(--hts-fg-2); }
/* User Manual had the same book icon as Library */
html body .t-TreeNav .a-TreeView-content:has(a[href*="user-manual"]) > .fa::before { content: "\eb08"; }
/* Admin Console is a different area: separated from the user items */
html body .t-TreeNav .a-TreeView-node--topLevel:has(a[href*="hts-admin"]) {
  margin-top: var(--hts-s2); padding-top: var(--hts-s2); border-top: 1px solid var(--hts-border);
}
/* collapsed (icons only): centred icons, same tint */
body.js-navCollapsed .t-TreeNav .a-TreeView-content { justify-content: center; margin-inline: var(--hts-s1); padding: 0; }

/* phones: small panel buttons keep their icon (CR-07 hid every span, so the Arabic button looked empty) */
@media (max-width: 640px) {
  .hts-artifact-tools .hts-btn--small span.fa { display: inline-block; }
}

/* =====================================================================
   UI-06 (App 100 only): Artifacts, Library and My Files (folder views).
   Appended at the end of hts-chat.css. Selectors start with .hts-ws / .hts-gal so they win over the
   style block the folder view injects at run time. Tokens only, logical properties.
   ===================================================================== */
.hts-thread { overflow-x: hidden; }
.hts-ws { gap: var(--hts-s5); }
.hts-ws .hts-ws-main { min-width: 0; }

/* folder tree */
.hts-ws .hts-ws-tree { padding: var(--hts-s2); background: var(--hts-panel); border: 1px solid var(--hts-border); border-radius: var(--hts-r); }
.hts-ws .hts-ws-node { min-height: 2rem; padding: 0 var(--hts-s2); gap: var(--hts-s2); border-radius: var(--hts-r-sm); font-size: 0.875rem; color: var(--hts-fg-2); }
.hts-ws .hts-ws-node .fa { flex: none; width: 1rem; text-align: center; color: var(--hts-fg-2); }
.hts-ws .hts-ws-node:hover, .hts-ws .hts-ws-node:focus-visible { background: var(--hts-hover); color: var(--hts-fg); }
.hts-ws .hts-ws-node.is-current { background: var(--hts-red-08); color: var(--hts-fg); font-weight: 600; }
.hts-ws .hts-ws-node.is-current .fa { color: var(--hts-primary); }
/* Font APEX has no fa-user-o: the Personal folder showed no icon */
.hts-ws .fa-user-o::before { content: "\f007"; }

/* heading, toolbar on one line: search, type, then the actions */
.hts-ws .hts-ws-crumbs { margin: 0 0 var(--hts-s3); font-size: 1rem; font-weight: 600; }
.hts-ws .hts-ws-crumb { color: var(--hts-fg-2); }
.hts-ws .hts-ws-crumbs li + li::before { color: var(--hts-fg-2); }
.hts-ws .hts-gal-tools { flex-wrap: wrap; align-items: center; gap: var(--hts-s2); margin: 0 0 var(--hts-s2); }
.hts-ws .hts-gal-filters { flex: 1 1 22rem; min-width: 0; flex-wrap: nowrap; gap: var(--hts-s2); }
.hts-ws .hts-gal-search-wrap { flex: 1 1 12rem; min-width: 8rem; }
.hts-gal-search-wrap > .fa { inset-inline-start: 0.75rem; font-size: 0.875rem; }
.hts-gal-search-wrap > .hts-input { width: 100%; min-height: 2.25rem; padding-inline-start: 2.125rem; font-size: 0.875rem; }
.hts-ws .hts-gal-filters > .hts-select { flex: 0 0 9.5rem; min-width: 0; min-height: 2.25rem; font-size: 0.875rem; }
.hts-ws .hts-ws-actions { flex: none; gap: var(--hts-s2); margin-inline-start: auto; }
.hts-ws .hts-ws-actions .hts-btn { min-height: 2.25rem; padding: 0 var(--hts-s3); font-size: 0.875rem; box-shadow: none; }
.hts-ws .hts-ws-actions .hts-btn--primary:hover:not([disabled]) { filter: brightness(0.94); }
.hts-ws .hts-gal-info { margin: 0 0 var(--hts-s2); font-size: 0.75rem; color: var(--hts-fg-2); opacity: 1; }

/* the list: quiet rows, actions show on hover */
.hts-ws .hts-ws-list { background: var(--hts-panel); border: 1px solid var(--hts-border); border-radius: var(--hts-r); overflow: hidden; }
.hts-ws .hts-ws-row { min-height: 3.25rem; padding: 0 var(--hts-s2) 0 var(--hts-s3); border-top: 1px solid var(--hts-border); }
.hts-ws .hts-ws-row:first-child { border-top: 0; }
.hts-ws .hts-ws-row:hover { background: var(--hts-hover); }
.hts-ws .hts-ws-open { padding: var(--hts-s2) 0; grid-template-columns: 1.75rem minmax(0, 1fr); column-gap: var(--hts-s3); }
.hts-ws .hts-ws-icon { font-size: 1.125rem; color: var(--hts-fg-2); }
.hts-ws .hts-ws-row[data-kind=FOLDER] .hts-ws-icon, .hts-ws .hts-ws-row[data-kind=SUB] .hts-ws-icon { color: var(--hts-primary); }
.hts-ws .hts-ws-name { font-size: 0.875rem; font-weight: 500; color: var(--hts-fg); }
[dir="ltr"] .hts-ws .hts-ws-name { text-align: left; }
[dir="rtl"] .hts-ws .hts-ws-name { text-align: right; }
.hts-ws .hts-ws-meta { font-size: 0.75rem; color: var(--hts-fg-2); }
.hts-ws .hts-ws-menu-btn { border-color: transparent; opacity: 0.45; }
.hts-ws .hts-ws-row:hover .hts-ws-menu-btn, .hts-ws .hts-ws-menu-btn:focus-visible, .hts-ws .hts-ws-menu-btn[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .hts-ws .hts-ws-menu-btn { opacity: 0.8; } }

/* empty folder */
.hts-ws .hts-gal-empty { padding: var(--hts-s6) var(--hts-s4); background: var(--hts-panel); border: 1px dashed var(--hts-border-2); border-radius: var(--hts-r); }
.hts-ws .hts-gal-empty h3 { font-size: 1rem; font-weight: 600; }
.hts-ws .hts-gal-empty-icon { width: 2.5rem; height: 2.5rem; border-radius: var(--hts-r); font-size: 1.125rem; background: var(--hts-red-08); }

/* a document open next to the list: the tree moves above the list, the viewer keeps a fair share */
.hts-chat-layout > .hts-artifact-panel { flex-basis: min(46%, 44rem); }
.hts-chat-layout:has(> .hts-artifact-panel:not([hidden])) .hts-ws { grid-template-columns: minmax(0, 1fr); gap: var(--hts-s3); }
.hts-chat-layout:has(> .hts-artifact-panel:not([hidden])) .hts-ws-tree { position: static; max-height: 10rem; }
.hts-artifact-fileinfo { margin: 0 0 var(--hts-s2); font-size: 0.75rem; color: var(--hts-fg-2); }
.hts-artifact-body .hts-preview-pdf, .hts-artifact-frame { border-color: var(--hts-border); border-radius: var(--hts-r); }

@media (max-width: 640px) {
  .hts-ws .hts-gal-filters { flex-basis: 100%; }
  .hts-ws .hts-gal-filters > .hts-select { flex-basis: 8rem; }
}

/* =====================================================================
   UI-07 (App 100 only): Library (page 30) and My Files (page 40) as clean file browsers.
   Appended at the end of hts-chat.css. Tokens only, logical properties.
   ===================================================================== */
/* page header: no white band, title on the page itself, aligned with the content column */
html.page-30 .t-Body-title, html.page-40 .t-Body-title { background: transparent; border-bottom: 0; box-shadow: none; }
html.page-30 .t-BreadcrumbRegion, html.page-40 .t-BreadcrumbRegion { border: 0; box-shadow: none; }
html.page-30 .t-BreadcrumbRegion, html.page-40 .t-BreadcrumbRegion { max-width: 80rem; margin: 0 auto; padding: var(--hts-s5) var(--hts-s5) 0; }
html.page-30 .t-Breadcrumb-item:not(.is-active), html.page-40 .t-Breadcrumb-item:not(.is-active) { display: none; }
html.page-30 .t-Breadcrumb-item.is-active .t-Breadcrumb-label, html.page-40 .t-Breadcrumb-item.is-active .t-Breadcrumb-label,
html.page-30 .t-BreadcrumbRegion-title, html.page-40 .t-BreadcrumbRegion-title { font-size: 1.5rem; font-weight: 600; }
html.page-30 .t-Body-contentInner, html.page-40 .t-Body-contentInner { max-width: 80rem; margin: 0 auto; padding: var(--hts-s4) var(--hts-s5) var(--hts-s6); }

/* two panes: a plain folder list on the left, the files on the right */
html.page-30 .hts-ws, html.page-40 .hts-ws { grid-template-columns: 15rem minmax(0, 1fr); gap: var(--hts-s6); }
html.page-30 .hts-ws .hts-ws-tree, html.page-40 .hts-ws .hts-ws-tree {
  top: var(--hts-s4); max-height: calc(100vh - 10rem); padding: 0; background: transparent; border: 0;
}
html.page-30 .hts-ws .hts-ws-node:not(.is-current):hover, html.page-40 .hts-ws .hts-ws-node:not(.is-current):hover { background: var(--hts-panel); }
html.page-30 .hts-ws .hts-ws-node.is-current, html.page-40 .hts-ws .hts-ws-node.is-current { background: var(--hts-panel); box-shadow: inset 0 0 0 1px var(--hts-border); }

/* folder heading with its count on the same line, then the toolbar (all folder views) */
.hts-ws .hts-ws-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: var(--hts-s3); }
.hts-ws .hts-ws-main > * { grid-column: 1 / -1; }
.hts-ws .hts-ws-main > nav { grid-column: 1; }
.hts-ws .hts-ws-main > .hts-gal-info { grid-column: 2; grid-row: 1; margin: 0; }
.hts-ws .hts-ws-crumbs { font-size: 1.0625rem; }
.hts-ws .hts-gal-tools { margin-bottom: var(--hts-s3); }
.hts-ws .hts-gal-search-wrap { max-width: 28rem; }

/* file rows: icon tile, name, details; folders tinted */
.hts-ws .hts-ws-row { min-height: 3.5rem; }
.hts-ws .hts-ws-open { grid-template-columns: 2.25rem minmax(0, 1fr); }
.hts-ws .hts-ws-icon {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: var(--hts-r);
  background: var(--hts-panel-2); font-size: 1rem;
}
.hts-ws .hts-ws-row[data-kind=FOLDER] .hts-ws-icon, .hts-ws .hts-ws-row[data-kind=SUB] .hts-ws-icon { background: var(--hts-red-08); }
.hts-ws .hts-ws-meta { margin-top: 0.125rem; }

@media (max-width: 900px) {
  html.page-30 .hts-ws, html.page-40 .hts-ws { grid-template-columns: minmax(0, 1fr); gap: var(--hts-s4); }
  html.page-30 .hts-ws .hts-ws-tree, html.page-40 .hts-ws .hts-ws-tree {
    position: static; max-height: none; display: flex; overflow-x: auto; scrollbar-width: none;
  }
  html.page-30 .hts-ws-tree > ul, html.page-40 .hts-ws-tree > ul { display: flex; gap: var(--hts-s1); padding-bottom: var(--hts-s1); }
  html.page-30 .hts-ws-tree li, html.page-40 .hts-ws-tree li, html.page-30 .hts-ws-tree ul ul, html.page-40 .hts-ws-tree ul ul { display: contents; }
  html.page-30 .hts-ws .hts-ws-node, html.page-40 .hts-ws .hts-ws-node { white-space: nowrap; border: 1px solid var(--hts-border-2); background: var(--hts-panel); }
  html.page-30 .t-BreadcrumbRegion, html.page-40 .t-BreadcrumbRegion { padding: var(--hts-s4) var(--hts-s3) 0; }
  html.page-30 .t-Body-contentInner, html.page-40 .t-Body-contentInner { padding: var(--hts-s3) var(--hts-s3) var(--hts-s5); }
}

/* =====================================================================
   UI-08 (App 100 only): file page (41) and library item page (31) - preview left, details right.
   Appended at the end of hts-chat.css. Tokens only, logical properties.
   ===================================================================== */
/* header: the generic page name ("File", "Output") gives way to the file name below; the trail stays as a way back */
html.page-31 .t-Body-title, html.page-41 .t-Body-title { background: transparent; border-bottom: 0; box-shadow: none; }
html.page-31 .t-BreadcrumbRegion, html.page-41 .t-BreadcrumbRegion { max-width: 80rem; margin: 0 auto; padding: var(--hts-s4) var(--hts-s5) 0; border: 0; box-shadow: none; }
html.page-31 .t-Breadcrumb-item.is-active, html.page-41 .t-Breadcrumb-item.is-active,
html.page-31 .t-BreadcrumbRegion-title, html.page-41 .t-BreadcrumbRegion-title { display: none !important; }
html.page-31 .t-Breadcrumb-item:not(.is-active) .t-Breadcrumb-label, html.page-41 .t-Breadcrumb-item:not(.is-active) .t-Breadcrumb-label { font-size: 0.8125rem; }
html.page-31 .t-Body-contentInner, html.page-41 .t-Body-contentInner { max-width: 80rem; margin: 0 auto; padding: var(--hts-s2) var(--hts-s5) var(--hts-s6); }
.hts-output-title { margin: 0 0 var(--hts-s1); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }

/* file page (41): APEX puts details and preview in separate rows - place them side by side */
html.page-41 .t-Body-contentInner > .container { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: var(--hts-s5); align-items: start; }
html.page-41 .container > .row { margin: 0; }
html.page-41 .container > .row:not(:has(.t-Region, .hts-output-preview)) { display: none; }
html.page-41 .container > .row:has(.hts-kv) { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: var(--hts-s4); }
html.page-41 .container > .row:has(.hts-output-preview) { grid-column: 1; grid-row: 1; }
html.page-41 .container > .row:has(.a-IRR, .t-Report) { grid-column: 1; grid-row: 2; }
html.page-41 .container .col { width: 100%; max-width: 100%; flex: 1 1 100%; padding: 0; }
html.page-41 .container > .row:has(.hts-kv) .t-Region-header { display: none; }
html.page-41 .container > .row:has(.hts-kv) .hts-output-title { font-size: 1.125rem; margin-bottom: var(--hts-s3); }
html.page-41 .container > .row:has(.hts-kv) .t-Button--hot { width: 100%; min-height: 2.25rem; margin-top: var(--hts-s4); justify-content: center; box-shadow: none; }

/* library item page (31): wider, actions as one tidy row, side column like the file page */
html.page-31 .hts-output { max-width: none; }
html.page-31 .hts-output > .hts-muted { font-size: 0.8125rem; color: var(--hts-fg-2); opacity: 1; }
html.page-31 .hts-output > .hts-row { gap: var(--hts-s2); margin-top: var(--hts-s3); }
html.page-31 .hts-output > .hts-row .hts-btn { min-height: 2.25rem; padding: 0 var(--hts-s3); font-size: 0.875rem; box-shadow: none; }
.hts-output-grid { grid-template-columns: minmax(0, 1fr) 20rem; gap: var(--hts-s5); margin-top: var(--hts-s4); }
.hts-output-side { padding: var(--hts-s4); background: var(--hts-panel); border: 1px solid var(--hts-border); border-radius: var(--hts-r); align-self: start; position: sticky; top: var(--hts-s4); }
.hts-output-side h3 { margin: 0 0 var(--hts-s2); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--hts-fg-2); }
.hts-output-side h3 + * { margin-bottom: var(--hts-s5); }
.hts-version { border-color: var(--hts-border); border-radius: var(--hts-r-sm); }

/* shared: details list and preview frame */
.hts-output-side .hts-kv, html.page-41 .hts-kv { grid-template-columns: 6.5rem minmax(0, 1fr); gap: var(--hts-s2) var(--hts-s3); font-size: 0.8125rem; }
.hts-output-side .hts-kv dd, html.page-41 .hts-kv dd { overflow-wrap: anywhere; }
.hts-output-preview { min-height: 0; }
.hts-output-preview .hts-preview-pdf { height: calc(100vh - 11rem); min-height: 28rem; border: 1px solid var(--hts-border); border-radius: var(--hts-r); background: var(--hts-panel); }
.hts-output-preview .hts-preview-img, .hts-output-preview .hts-preview-text { border-color: var(--hts-border); border-radius: var(--hts-r); }

@media (max-width: 900px) {
  html.page-41 .t-Body-contentInner > .container, .hts-output-grid { grid-template-columns: minmax(0, 1fr); }
  html.page-41 .container > .row:has(.hts-kv) { grid-column: 1; grid-row: 1; position: static; }
  html.page-41 .container > .row:has(.hts-output-preview) { grid-row: 2; }
  html.page-41 .container > .row:has(.a-IRR, .t-Report) { grid-row: 3; }
  .hts-output-side { position: static; }
  .hts-output-preview .hts-preview-pdf { height: 70vh; min-height: 20rem; }
  html.page-31 .t-BreadcrumbRegion, html.page-41 .t-BreadcrumbRegion { padding-inline: var(--hts-s3); }
  html.page-31 .t-Body-contentInner, html.page-41 .t-Body-contentInner { padding-inline: var(--hts-s3); }
}

/* CR-38: artifact version picker and older-version note; RTL alignment of titles whose text sets its own direction
   (dir="auto" aligns a Latin name to the left even on an RTL page); file page details in the reading direction */
.hts-artifact-tools .hts-artifact-version { width: auto; max-width: 15rem; min-height: 2rem; padding-block: 0; font-size: 0.8125rem; }
.hts-artifact-oldver { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hts-s2); margin: var(--hts-s2) 0 0;
  padding: var(--hts-s2) var(--hts-s3); border: 1px solid var(--hts-border); border-radius: var(--hts-r); background: var(--hts-soft); font-size: 0.8125rem; }
.hts-artifact-oldver > span:not(.fa) { flex: 1 1 12rem; }
[dir="rtl"] .hts-output-title, [dir="rtl"] .hts-artifact-title, [dir="rtl"] .hts-artifact-fileinfo,
[dir="rtl"] .hts-ws-crumbs [dir="auto"], [dir="rtl"] .hts-kv dd[dir="auto"] { text-align: right; }
[dir="rtl"] .t-Button--iconLeft .t-Icon { margin-inline-start: 0; margin-inline-end: 0.25rem; }

