/* Westwing-Buddy — Lovable-Friendly · parchment cream / warm-dark, DM Sans humanist.
   Design tokens follow the 4-token model: bg, surface, text, accent.
   Never use pure #000 / pure #fff; every neutral is tinted toward the warm hue. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto,
               "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  display: block;
}

/* --- Tokens ---------------------------------------------------------- */
:root {
  --bg:             #f7f4ed;               /* parchment */
  --surface:        #fcfbf8;               /* soft off-white */
  --surface-warm:   #f2ecdf;               /* deeper cream */
  --text:           #1c1c1c;
  --text-82:        rgba(28,28,28,0.82);
  --text-muted:     #5f5f5d;
  --text-40:        rgba(28,28,28,0.40);
  --border-soft:    #eceae4;
  --border-strong:  rgba(28,28,28,0.40);
  --accent-peach:   #ffb894;
  --accent-peach-b: #ffd9c2;
  --accent-hot:     #f26b3a;
  --success:        #2f9e64;
  --success-tint:   #e5f3ec;
  --err:            #c53f5c;
  --err-tint:       #fbe6ea;
  --inset-shadow:
    rgba(255,255,255,0.2) 0px 0.5px 0px 0px inset,
    rgba(0,0,0,0.2) 0px 0px 0px 0.5px inset,
    rgba(0,0,0,0.05) 0px 1px 2px 0px;
  --focus-shadow:   rgba(0,0,0,0.10) 0px 4px 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #1c1a17;
    --surface:       #262320;
    --surface-warm:  #2f2b26;
    --text:          #f2eee5;
    --text-82:       rgba(242,238,229,0.86);
    --text-muted:    #a3a09a;
    --text-40:       rgba(242,238,229,0.42);
    --border-soft:   #38342d;
    --border-strong: rgba(242,238,229,0.35);
    --accent-peach:  #ffb894;
    --accent-peach-b:#3a2b1e;
    --accent-hot:    #ff8455;
    --success:       #5fcc90;
    --success-tint:  #1c3a29;
    --err:           #ff7a92;
    --err-tint:      #3a1c25;
    --inset-shadow:
      rgba(255,255,255,0.08) 0px 0.5px 0px 0px inset,
      rgba(0,0,0,0.35) 0px 0px 0px 0.5px inset,
      rgba(0,0,0,0.35) 0px 1px 2px 0px;
    --focus-shadow:  rgba(0,0,0,0.40) 0px 4px 12px;
  }
}

/* --- Layout scaffold -------------------------------------------------- */
.app {
  width: 100%;
  max-width: 820px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100vh;
  background: var(--bg);
}

/* --- Header ---------------------------------------------------------- */
header {
  padding: 20px 26px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}
header::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 60%;
  background: radial-gradient(60% 100% at 30% 0%, rgba(255,184,148,0.18), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
header > * { position: relative; z-index: 1; }
header .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  font-size: 22px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 9999px;
  box-shadow: var(--inset-shadow);
}
header .brand { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.6px; line-height: 1.1; }
header .tagline { font-size: 13px; color: var(--text-muted); }

#health {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  background: var(--success-tint);
  color: var(--success);
  border: 1px solid var(--border-soft);
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--inset-shadow);
}
#health::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(47,158,100,0.18);
}
#health.err { background: var(--err-tint); color: var(--err); }
#health.err::before { background: var(--err); box-shadow: 0 0 0 3px rgba(197,63,92,0.18); }

/* --- User chip + logout ------------------------------------------------ */
#user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 9999px;
  font-size: 12.5px;
  color: var(--text);
  box-shadow: var(--inset-shadow);
}
#user-chip[hidden] { display: none; }
#user-name { font-weight: 500; }
#logout, #admin-link {
  border: 0; background: transparent; cursor: pointer;
  padding: 2px 8px; margin-left: 4px;
  border-radius: 9999px;
  color: var(--text-muted);
  font-family: inherit; font-size: 14px;
  text-decoration: none;
  transition: background .12s, color .12s;
}
#logout:hover, #admin-link:hover { background: var(--surface-warm); color: var(--text); }

/* --- Chat surface ---------------------------------------------------- */
main {
  overflow-y: auto;
  padding: 24px 26px 14px;
  background: var(--bg);
  scroll-behavior: smooth;
}
#chat { display: flex; flex-direction: column; gap: 22px; }

/* --- Messages -------------------------------------------------------- */
.msg { display: flex; flex-direction: column; max-width: 92%; }
.msg .body {
  font-size: 16px; line-height: 1.58;
  white-space: pre-wrap; word-wrap: break-word;
  color: var(--text-82);
}
.msg .body strong { color: var(--accent-hot); font-weight: 600; }
.msg .body em { color: var(--text-muted); font-style: italic; }
.msg .body code {
  padding: 1px 6px;
  font-family: 'DM Sans', ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9em;
  background: var(--surface-warm);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
}

.msg-user { align-self: flex-end; max-width: 78%; }
.msg-user .body {
  background: var(--surface-warm);
  color: var(--text);
  padding: 12px 18px;
  border: 1px solid var(--border-soft);
  border-radius: 18px 18px 6px 18px;
}

.msg-bot { align-self: flex-start; max-width: 94%; position: relative; padding-top: 4px; }
.msg-bot::before {
  content: "🛋️";
  position: absolute;
  left: -4px; top: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 9999px;
  box-shadow: var(--inset-shadow);
  z-index: 2;
}
.msg-bot .body,
.msg-bot .citations,
.msg-bot .status { margin-left: 30px; }
.msg-bot .body {
  background: var(--surface);
  color: var(--text-82);
  padding: 16px 20px;
  border: 1px solid var(--border-soft);
  border-radius: 6px 18px 18px 18px;
}
.msg-bot .body.typing::after {
  content: " ";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--accent-hot);
  animation: pulse 1.2s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.5; }
  50%      { transform: scale(1);   opacity: 1; }
}

/* --- Citations (kompakt, kollabierbar — Hermes-Style) --------------- */
.citations {
  /* Kein Rand, kein Farb-Kasten mehr. Der Chip ist inline und leicht. */
  margin-bottom: 8px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  font-size: 12.5px;
  line-height: 1.4;
}
.citations[hidden] { display: none; }

.cit-details {
  display: inline-block;
  max-width: 100%;
}
.cit-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 9999px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;      /* remove default marker; we use a rotating caret instead */
  transition: background .12s, color .12s;
}
.cit-details > summary::-webkit-details-marker { display: none; }
.cit-details > summary::before {
  content: "▸";
  font-size: 10px;
  color: var(--text-muted);
  transition: transform .15s ease;
  margin-right: 2px;
}
.cit-details[open] > summary::before { transform: rotate(90deg); }
.cit-details > summary:hover {
  background: var(--accent-peach-b);
  color: var(--text);
}
.cit-details > summary:focus-visible {
  outline: 2px solid var(--accent-hot);
  outline-offset: 2px;
}
.cit-summary-label { font-weight: 500; color: var(--text); }
.cit-redact { color: var(--text-muted); }

/* Expanded list — only visible when the user opens the chip. */
.cit-list {
  list-style: none;
  margin: 8px 0 0 0;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cit-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
  color: var(--text-82);
  border-bottom: 1px dashed var(--border-soft);
}
.cit-list li:last-child { border-bottom: none; }
.cit-list .cit-doc {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  color: var(--text);
  flex-shrink: 0;
}
.cit-list .cit-crumb {
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cit-list .cit-score {
  padding: 1px 6px;
  background: var(--accent-peach-b);
  color: #5c2a10;
  border-radius: 9999px;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* --- Status --------------------------------------------------------- */
.status { margin-top: 8px; padding-left: 4px; font-size: 12px; color: var(--text-muted); font-weight: 500; min-height: 14px; }
.status.err { color: var(--err); }

/* --- Composer ------------------------------------------------------- */
#composer {
  padding: 14px 22px 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
#q {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 160px;
  padding: 13px 16px;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#q::placeholder { color: var(--text-40); }
#q:focus {
  border-color: var(--border-strong);
  box-shadow: var(--focus-shadow);
}
#send {
  padding: 12px 20px;
  background: var(--text);
  color: var(--surface);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 9999px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  box-shadow: var(--inset-shadow);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#send::after { content: "→"; font-size: 16px; }
#send:hover:not(:disabled) { opacity: 0.9; }
#send:active:not(:disabled) { opacity: 0.8; transform: scale(0.98); }
#send:disabled { opacity: 0.5; cursor: not-allowed; }
#send:focus-visible { outline: none; box-shadow: var(--focus-shadow), var(--inset-shadow); }

/* --- Footer --------------------------------------------------------- */
footer {
  padding: 12px 22px;
  background: var(--bg);
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-muted);
  gap: 10px;
  flex-wrap: wrap;
}
footer a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}
footer a:hover { color: var(--accent-hot); text-decoration-color: var(--accent-hot); }
footer code { font-family: 'DM Sans', inherit; }

/* --- KB stats inline panel (opened by clicking the footer link) ----- */
.kb-panel {
  align-self: stretch;
  margin: 12px 0;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  font-size: 13px;
  color: var(--text-82);
}
.kb-panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.kb-panel ul { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; }
.kb-panel li code {
  font-family: 'DM Sans', inherit;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- A11y ----------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --- Responsive ----------------------------------------------------- */
@media (max-width: 600px) {
  header, main, #composer, footer { padding-left: 16px; padding-right: 16px; }
  header h1 { font-size: 19px; }
  header .tagline { display: none; }
  .msg-bot::before { left: -4px; width: 26px; height: 26px; font-size: 14px; }
  .msg-bot .body,
  .msg-bot .citations,
  .msg-bot .status { margin-left: 22px; }
  #health { font-size: 11px; }
}

/* --- App-shell layout (sidebar + main) ---------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}
.app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app-shell.sidebar-collapsed .sidebar { display: none; }

.sidebar {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  min-height: 100vh;
  position: sticky; top: 0;
  max-height: 100vh;
}

.sidebar-head {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.new-chat-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500;
  transition: background .12s, border-color .12s;
  box-shadow: var(--inset-shadow);
}
.new-chat-btn:hover { background: var(--surface-warm); }
.new-chat-btn > span:first-child {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 9999px;
  background: var(--accent-peach-b);
  color: var(--accent-hot);
  font-weight: 600;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.conv-empty {
  padding: 20px 14px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}
.conv-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-82);
  font-size: 13.5px;
  transition: background .12s;
  border: 1px solid transparent;
  position: relative;
}
.conv-item:hover { background: var(--surface-warm); }
.conv-item.active {
  background: var(--surface-warm);
  border-color: var(--border-soft);
  color: var(--text);
  font-weight: 500;
}
/* Streaming indicator: pulsing dot on the left edge for chats with an
   in-flight LLM response (multi-chat parallel-stream UX). */
.conv-item.streaming::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-hot);
  box-shadow: 0 0 0 0 var(--accent-hot);
  animation: conv-pulse 1.4s ease-in-out infinite;
}
@keyframes conv-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(242,107,58,0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(242,107,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(242,107,58,0); }
}
.conv-item .conv-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item .conv-delete {
  opacity: 0;
  border: 0; background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  transition: opacity .12s, background .12s, color .12s;
}
.conv-item:hover .conv-delete { opacity: 1; }
.conv-item .conv-delete:hover { background: var(--err-tint); color: var(--err); }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
}
.foot-user {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.foot-actions {
  display: inline-flex; align-items: center; gap: 2px;
}
.foot-actions #admin-link,
.foot-actions #logout {
  padding: 4px 8px;
  margin-left: 0;
}

/* --- Main pane needs its own layout since it's now the right column ----- */
.app-main {
  display: flex; flex-direction: column;
  min-width: 0;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
}
.app-main > header {
  position: sticky;
  padding-left: 26px; padding-right: 26px;
}
.app-main > main {
  overflow: visible;
  padding: 22px 26px 24px;
}
.app-main > form {
  padding: 12px 26px 14px;
}
.app-main > footer {
  padding: 10px 26px 16px;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 6px 10px;
  margin-right: 4px;
  border-radius: 8px;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-warm); color: var(--text); }

/* Mobile: sidebar becomes overlay */
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .18s;
    box-shadow: 8px 0 24px rgba(0,0,0,0.08);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
  .app-shell.sidebar-collapsed .sidebar { display: flex; transform: translateX(-100%); }
}

/* Dark mode carries the sidebar tokens through */
@media (prefers-color-scheme: dark) {
  .sidebar { background: var(--surface); border-right-color: var(--border-soft); }
  .new-chat-btn { background: var(--surface); }
  .new-chat-btn:hover { background: var(--surface-warm); }
}

/* --- Sidebar search ---------------------------------------------------- */
.search-row {
  margin-top: 8px;
  position: relative;
}
.search-row input {
  width: 100%;
  padding: 8px 30px 8px 12px;
  font: inherit; font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.search-row input::placeholder { color: var(--text-muted); }
.search-row input:focus {
  border-color: var(--border-strong);
  box-shadow: var(--focus-shadow);
}
#search-clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  border: 0; background: transparent;
  color: var(--text-muted); cursor: pointer;
  padding: 2px 6px; border-radius: 6px;
  font-size: 12px;
}
#search-clear:hover { background: var(--surface-warm); color: var(--text); }

.search-result {
  display: block;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s;
  color: var(--text-82);
}
.search-result:hover { background: var(--surface-warm); }
.search-result .conv-title-line {
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-result .snippet {
  font-size: 13px; line-height: 1.4;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.search-result .snippet mark {
  background: var(--accent-peach-b);
  color: var(--accent-hot);
  padding: 0 2px; border-radius: 3px;
  font-weight: 500;
}
.search-result .role-tag {
  display: inline-block;
  font-size: 10px; font-weight: 500;
  padding: 1px 6px;
  border-radius: 9999px;
  margin-right: 6px;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border-soft);
}
.search-result .role-tag.user {
  background: var(--accent-peach-b); color: var(--accent-hot);
  border-color: transparent;
}

/* --- Flash on jump-to-message ------------------------------------------ */
.msg.flash .body {
  animation: msg-flash 1.5s ease-out;
}
@keyframes msg-flash {
  0%   { box-shadow: 0 0 0 3px var(--accent-peach); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* --- Conv-item export button ------------------------------------------ */
.conv-item .conv-export {
  opacity: 0;
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  transition: opacity .12s, background .12s, color .12s;
}
.conv-item:hover .conv-export { opacity: 1; }
.conv-item .conv-export:hover { background: var(--accent-peach-b); color: var(--accent-hot); }

/* =============================================================================
   UX #1 / #2 / #3 — Toast, Dialog, Loading skeleton (Squad-Review Phase 3)
   ========================================================================== */

/* ---- Toast ------------------------------------------------------------- */
#toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent-hot);
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  font-size: 14px;
  max-width: 420px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease;
  cursor: pointer;
}
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast.toast-error   { border-left-color: #d93a3a; }
.toast.toast-success { border-left-color: #3d9970; }
.toast.toast-warning { border-left-color: #d99a2f; }
.toast.toast-info    { border-left-color: var(--accent-hot); }

/* ---- Dialog ------------------------------------------------------------ */
.ui-dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
  min-width: min(420px, 90vw);
  max-width: 560px;
}
.ui-dialog::backdrop {
  background: rgba(0,0,0,0.44);
  backdrop-filter: blur(2px);
}
.ui-dialog-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px;
  margin: 0;
}
.ui-dialog-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.ui-dialog-body {
  font-size: 14px;
  color: var(--text-82);
  line-height: 1.45;
}
.ui-dialog-body p { margin: 0; }
.ui-dialog-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.ui-dialog-input {
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 14px;
  background: var(--surface-warm);
  color: var(--text);
}
.ui-dialog-input:focus-visible {
  outline: 2px solid var(--accent-hot);
  outline-offset: 1px;
}
.ui-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 0;
  margin: 0;
  list-style: none;
}
.ui-dialog-actions .btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  font-size: 14px;
  cursor: pointer;
  background: var(--surface-warm);
  color: var(--text);
}
.ui-dialog-actions .btn:hover { background: var(--accent-peach-b); }
.ui-dialog-actions .btn-primary {
  background: var(--accent-hot);
  color: white;
  border-color: var(--accent-hot);
}
.ui-dialog-actions .btn-primary:hover { filter: brightness(1.05); }
.ui-dialog-actions .btn:focus-visible {
  outline: 2px solid var(--accent-hot);
  outline-offset: 2px;
}

/* ---- Chat loading skeleton (UX #3) ------------------------------------ */
.chat-loading {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 8px;
  opacity: 0.7;
}
.chat-loading .skeleton-msg {
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--surface-warm) 0%,
    var(--border-soft) 50%,
    var(--surface-warm) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
}
.chat-loading .skeleton-msg.short { width: 60%; }
.chat-loading .skeleton-msg.long  { width: 88%; align-self: flex-end; }
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
