/* Qlipple AI assistant workspace, colorful structured Markdown typography, and bounded 360px-safe composer card. */
.cw {
  --cw-side: color-mix(in srgb, var(--paper) 70%, var(--surface));
  --cw-hair: var(--line);
  --cw-code: #0F172A; --cw-code-ink: #E2E8F0; --cw-code-head: #1E293B;
  --cw-glow: color-mix(in srgb, var(--teal) 18%, transparent);
  --cw-round: var(--card);
  --cw-lift: 0 2px 8px rgba(8,16,32,.06), 0 8px 24px rgba(8,16,32,.08);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1 1 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cw { --cw-code: #09111F; --cw-code-head: #152238; --cw-side: var(--surface); } }
:root[data-theme="dark"] .cw { --cw-code: #09111F; --cw-code-head: #152238; --cw-side: var(--surface); }
.cw button, .cw input, .cw textarea, .cw select { font-family: var(--font-body); }
.cw :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- chats history sheet ---- */
.cw-side-backdrop { position: fixed; inset: 0; z-index: 44; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.cw-side-backdrop[hidden], .cw-side[hidden] { display: none; }
.cw-side {
  position: fixed; left: 50%; top: calc(var(--header-h, 48px) + 12px); transform: translateX(-50%);
  width: min(calc(100vw - 24px), 520px); max-height: calc(100dvh - var(--header-h, 48px) - 32px);
  z-index: 45; display: flex; flex-direction: column; gap: var(--sp-3); min-height: 0;
  padding: var(--sp-4); background: var(--cw-side); border: 1px solid var(--nav-border);
  border-radius: 20px; box-shadow: 0 20px 48px rgba(15, 23, 42, .22);
}
.cw-side-top { display: flex; gap: var(--sp-2); order: -2; margin-top: 0; justify-content: space-between; align-items: center; }
.cw-brand { margin: 0; font: 700 1.25rem var(--font-display); letter-spacing: -0.02em; }
.cw-side .cw-searchbox { order: -1; }
.cw-nav { order: 0; display: grid; gap: 2px; }
.cw-nav-i { display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; padding: 0 var(--sp-3); border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: 600 0.95rem var(--font-body); text-align: left; cursor: pointer; text-decoration: none; }
.cw-nav-i:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.cw-nav-i svg { width: 20px; height: 20px; flex: none; }
.cw-side .cw-projects { order: 1; }
.cw-side .cw-list { order: 2; }
.cw-side-bot { order: 9; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding-top: var(--sp-2); }
.cw-new { flex: 0 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: 44px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-pill); cursor: pointer; background: var(--accent); color: #fff; font: 600 var(--fs-0) var(--font-body); transition: transform .12s, box-shadow .15s; }
.cw-new:hover { box-shadow: 0 6px 18px rgba(37,99,235,.35); } .cw-new:active { transform: scale(.98); }
.cw-new svg { width: 20px; height: 20px; }
.cw-searchbox { display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; padding: 0 var(--sp-3); border: 1px solid var(--field-border); border-radius: var(--r-card); background: var(--card); color: var(--muted); }
.cw-searchbox:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.cw-searchbox svg { width: 18px; height: 18px; flex: none; }
.cw-search { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; color: var(--ink); font-size: var(--fs-small); -webkit-appearance: none; appearance: none; outline: none; }
.cw-search::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.cw-search::placeholder { color: var(--muted); opacity: 1; }
.cw-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 calc(var(--sp-1) * -1); padding: 0 var(--sp-1) var(--sp-4); }
.cw-group { margin: var(--sp-4) 0 var(--sp-1); padding: 0 var(--sp-3); font: 600 .75rem var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cw-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cw-item { display: flex; align-items: center; background: var(--card); border: 1px solid var(--cw-hair, var(--line)); border-radius: 14px; padding-left: 2px; box-shadow: 0 1px 0 rgba(15,23,36,.04); }
.cw-item:nth-child(5n+1) { border-left: 4px solid #2D6CC0; } .cw-item:nth-child(5n+2) { border-left: 4px solid #1B9E77; }
.cw-item:nth-child(5n+3) { border-left: 4px solid #E08A00; } .cw-item:nth-child(5n+4) { border-left: 4px solid #C13584; }
.cw-item:nth-child(5n) { border-left: 4px solid #7A4FD0; }
.cw-item:hover, .cw-item:focus-within { background: color-mix(in srgb, var(--teal) 8%, var(--card)); border-color: color-mix(in srgb, var(--teal) 40%, var(--line)); }
.cw-item.is-active { background: color-mix(in srgb, var(--teal) 14%, var(--card)); box-shadow: 0 2px 10px rgba(15,23,36,.10); }
.cw-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; padding: 0 var(--sp-3); border: 0; background: transparent; color: var(--ink); text-align: left; font-size: var(--fs-small); font-weight: 600; cursor: pointer; border-radius: var(--r-card); }
.cw-open-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-pinned { width: 14px; height: 14px; flex: none; color: var(--teal-deep); }
.cw-dots { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); border-radius: var(--r-card); cursor: pointer; }
.cw-dots:hover, .cw-dots[aria-expanded="true"] { color: var(--ink); background: color-mix(in srgb, var(--ink) 9%, transparent); }
.cw-dots svg { width: 20px; height: 20px; }
.cw-rename { flex: 1; min-width: 0; min-height: 44px; margin: 0 var(--sp-1); padding: 0 var(--sp-3); border: 2px solid var(--teal); border-radius: var(--r-card); background: var(--card); color: var(--ink); font-size: var(--fs-small); font-weight: 600; outline: none; }
.cw-none { margin: var(--sp-4) var(--sp-3); color: var(--muted); font-size: var(--fs-small); }
.cw-menu { position: absolute; z-index: 6; width: 232px; margin: 0; padding: 8px; list-style: none; background: var(--card); border: 1px solid var(--cw-hair); border-radius: 20px; box-shadow: 0 12px 36px rgba(8, 16, 32, .28); }
.cw-pop { position: fixed; z-index: 1000; width: 232px; margin: 0; padding: 8px; list-style: none; background: var(--card); border: 1px solid var(--cw-hair); border-radius: 20px; color: var(--ink); box-shadow: 0 12px 36px rgba(8,16,32,.28); }
.cw-mi { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 44px; padding: 0 var(--sp-3); border: 0; border-radius: 12px; background: transparent; color: var(--ink); font-size: var(--fs-small); font-weight: 600; cursor: pointer; text-align: left; }
.cw-mi:hover, .cw-mi:focus-visible { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.cw-mi svg { width: 18px; height: 18px; flex: none; }
.cw-mi.is-danger { color: var(--error-deep); }

/* ---- pane & compact sub-toolbar ---- */
.cw-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.cw.is-temp .cw-pane { background: color-mix(in srgb, var(--ink) 4%, var(--surface)); }
.cw-head { position: relative; z-index: 3; display: flex; align-items: center; gap: var(--sp-2); min-height: 46px; padding: 6px var(--sp-3); border-bottom: 1px solid var(--cw-hair); background: var(--surface); }
.cw-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font: 600 var(--fs-small) var(--font-display); letter-spacing: -0.02em; color: var(--muted); }
.cw-head .cw-grow { flex: 1; }
.cw-round { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--cw-round); color: var(--ink); cursor: pointer; box-shadow: 0 1px 4px rgba(8,16,32,.08); transition: background .15s, transform .12s; }
.cw-round:hover { background: color-mix(in srgb, var(--ink) 8%, var(--card)); } .cw-round:active { transform: scale(.94); }
.cw-round svg { width: 19px; height: 19px; }
.cw-round.is-on { background: var(--ink); color: var(--on-ink); }
.cw-icon { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--cw-round); color: var(--ink); cursor: pointer; box-shadow: 0 1px 4px rgba(8,16,32,.08); }
.cw-icon:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.cw-icon svg { width: 19px; height: 19px; }
.cw-hist-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--nav-border); border-radius: 9999px; background: var(--cw-round); color: var(--ink); font: 600 .825rem var(--font-body); cursor: pointer; transition: background .15s, border-color .15s; }
.cw-hist-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--nav-border)); }
.cw-hist-btn svg { width: 17px; height: 17px; flex: none; }

/* Split workspace container: chat column + desktop live preview panel */
.cw-work { position: relative; flex: 1; min-height: 0; display: flex; overflow: hidden; }
.cw-chatcol { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cw-preview-pane { display: none; flex-direction: column; width: 0; min-width: 0; min-height: 0; border-left: 1px solid var(--cw-hair); background: var(--paper); }
@media (min-width: 1024px) {
  .cw.has-preview .cw-preview-pane:not([hidden]) { display: flex; width: clamp(380px, 44%, 560px); flex: none; }
}
@media (max-width: 1023.98px) {
  .cw-preview-pane.is-mobile-open:not([hidden]) { position: fixed; inset: var(--header-h, 48px) 0 0 0; z-index: 48; display: flex; width: 100%; }
}
.cw-pv-head { display: flex; align-items: center; gap: var(--sp-2); min-height: 48px; padding: 6px var(--sp-3); border-bottom: 1px solid var(--cw-hair); background: var(--card); }
.cw-pv-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 .95rem var(--font-display); }
.cw-pv-tabs { display: inline-flex; padding: 2px; border-radius: var(--r-pill); border: 1px solid var(--cw-hair); background: var(--paper); }
.cw-pv-tab { min-height: 36px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--muted); font: 600 .8125rem var(--font-body); cursor: pointer; }
.cw-pv-tab[aria-pressed="true"] { background: var(--accent); color: #fff; }
.cw-pv-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding: var(--sp-3); }
.cw-pv-iframe { flex: 1; width: 100%; min-height: 260px; border: 1px solid var(--cw-hair); border-radius: 14px; background: #fff; }
.cw-pv-code { flex: 1; margin: 0; padding: var(--sp-4); overflow: auto; border: 1px solid var(--cw-hair); border-radius: 14px; background: var(--cw-code); color: var(--cw-code-ink); font: .84rem/1.55 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.cw-pv-imgwrap { flex: 1; display: grid; place-items: center; border: 1px solid var(--cw-hair); border-radius: 14px; background: var(--card); padding: var(--sp-3); overflow: auto; }
.cw-pv-imgwrap img { max-width: 100%; max-height: 100%; border-radius: 10px; object-fit: contain; }
.cw-pv-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--cw-hair); background: var(--card); }
.cw-pv-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--nav-border); border-radius: var(--r-pill); background: var(--surface); color: var(--ink); font: 600 .85rem var(--font-body); cursor: pointer; }
.cw-pv-btn:hover { border-color: var(--accent); color: var(--accent); }
.cw-pv-btn.is-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cw-pv-btn.is-primary:hover { background: var(--teal-deep); color: #fff; }
.cw-pv-btn svg { width: 16px; height: 16px; }

.cw-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cw-thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-4) var(--sp-4) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-5); scroll-padding: var(--sp-5); }
.cw-thread > * { width: 100%; max-width: 780px; margin-inline: auto; }
.cw-older { align-self: center; min-height: 44px; padding: 0 var(--sp-4); border: 1px solid var(--field-border); border-radius: var(--r-pill); background: var(--card); color: var(--ink); font-weight: 600; font-size: var(--fs-small); cursor: pointer; width: auto; }
.cw-pill { position: absolute; left: 50%; bottom: var(--sp-3); transform: translateX(-50%); display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 40px; padding: 0 var(--sp-4); border: 1px solid var(--field-border); border-radius: var(--r-pill); background: var(--card); color: var(--ink); font-weight: 600; font-size: var(--fs-small); cursor: pointer; box-shadow: 0 6px 20px rgba(8, 16, 32, .2); }
.cw-pill svg { width: 18px; height: 18px; }
.cw-drop { position: absolute; inset: var(--sp-3); z-index: 4; display: grid; place-items: center; border: 2px dashed var(--teal); border-radius: var(--r-feature); background: color-mix(in srgb, var(--surface) 88%, var(--teal)); color: var(--teal-deep); font-weight: 600; pointer-events: none; text-align: center; }
.cw-drop svg { width: 40px; height: 40px; }

/* empty state */
.cw-empty { margin-block: 0; display: grid; justify-items: center; gap: var(--sp-2); text-align: center; padding-block: clamp(12px, 3dvh, 44px) var(--sp-4); }
.cw-logo { width: 52px; height: 52px; border-radius: 0; background: transparent; object-fit: contain; }
.cw-empty h2 { margin: 0; font: 700 clamp(1.35rem, 5vw, 2rem)/1.15 var(--font-display); letter-spacing: -0.02em; }
.cw-empty p { margin: 0; color: var(--muted); max-width: 46ch; }
.cw-guest-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  margin-top: 6px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--nav-border));
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
}
.cw-cards { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); width: 100%; }
.cw-card { display: flex; align-items: flex-start; gap: var(--sp-3); width: 100%; height: 100%; min-height: 70px; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--cw-hair); border-radius: var(--r-card); background: var(--card); color: var(--ink); text-align: left; font-size: var(--fs-small); line-height: 1.4; cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; }
.cw-card:hover { border-color: var(--teal); transform: translateY(-2px); box-shadow: 0 8px 22px var(--cw-glow); }
.cw-card svg { flex: none; width: 20px; height: 20px; margin-top: 2px; color: var(--teal-deep); }

/* messages */
.cw-msg { display: flex; gap: var(--sp-3); min-width: 0; }
.cw-user { flex-direction: column; align-items: flex-end; gap: var(--sp-1); }
.cw-bubble { max-width: min(86%, 620px); padding: 10px 16px; border-radius: 20px; background: color-mix(in srgb, var(--accent) 12%, var(--card)); color: var(--ink); overflow-wrap: anywhere; }
.cw-utext { margin: 0; white-space: pre-wrap; line-height: 1.55; }
.cw-pics { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.cw-pics:last-child { margin-bottom: 0; }
.cw-ai { align-items: flex-start; gap: 0; }
.cw-ai .cw-av { display: none; }
.cw-col { flex: 1; min-width: 0; max-width: 780px; }

/* ---- Rich, Colorful & Structured AI Markdown Typography ---- */
.cw-prose { font-size: 1rem; line-height: 1.65; overflow-wrap: anywhere; color: var(--ink); }
.cw-prose > :first-child { margin-top: 0; }
.cw-prose > :last-child { margin-bottom: 0; }
.cw-prose p { margin: 0 0 .85em; }

.cw-prose .md-h1,
.cw-prose h2.md-lv1 {
  margin: 1.15em 0 .5em;
  padding: 6px 12px;
  border-left: 4px solid var(--ai-h1);
  border-radius: 0 10px 10px 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--ai-h1) 12%, transparent), transparent 90%);
  color: var(--ai-h1);
  font: 700 1.24rem/1.25 var(--font-display);
  letter-spacing: -0.02em;
}
.cw-prose .md-h2,
.cw-prose h2.md-lv2,
.cw-prose h3 {
  margin: 1em 0 .42em;
  padding: 4px 10px;
  border-left: 3px solid var(--ai-h2);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--ai-h2) 8%, transparent);
  color: var(--ai-h2);
  font: 700 1.08rem/1.25 var(--font-display);
  letter-spacing: -0.015em;
}
.cw-prose .md-h3,
.cw-prose h2.md-lv3,
.cw-prose h4,
.cw-prose h5 {
  margin: .85em 0 .35em;
  padding-left: 10px;
  border-left: 3px solid var(--ai-h3);
  color: var(--ai-h3);
  font: 700 1rem/1.25 var(--font-display);
}

/* Custom colored pill bullets & numbered step badges */
.cw-prose ul.md-ul {
  list-style: none;
  margin: .35em 0 .95em;
  padding: 0;
  display: grid;
  gap: 8px;
}
.cw-prose ul.md-ul > li {
  position: relative;
  padding-left: 22px;
  margin: 0;
}
.cw-prose ul.md-ul > li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #4F46E5;
}
.cw-prose ul.md-ul > li:nth-child(3n+2)::before { background: #059669; }
.cw-prose ul.md-ul > li:nth-child(3n)::before { background: #D97706; }

.cw-prose ol.md-ol {
  list-style: none;
  counter-reset: md-step;
  margin: .35em 0 .95em;
  padding: 0;
  display: grid;
  gap: 8px;
}
.cw-prose ol.md-ol > li {
  position: relative;
  counter-increment: md-step;
  padding-left: 32px;
  margin: 0;
}
.cw-prose ol.md-ol > li::before {
  content: counter(md-step);
  position: absolute;
  left: 0;
  top: 0.2em;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-h1), var(--ai-h2));
  color: #fff;
  display: grid;
  place-items: center;
  font: 700 0.75rem/1 var(--font-body);
}

/* Nested sublists inside rich bullets */
.cw-prose li > ul, .cw-prose li > ol { margin-top: 6px; margin-bottom: 2px; }
.cw-prose strong { color: var(--ink); font-weight: 700; }

/* Semantic Callout Cards (Tip / Warning / Summary / Note) */
.cw-prose .md-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: .75em 0;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--callout-c, var(--ai-h2)) 28%, var(--line));
  border-left: 3px solid var(--callout-c, var(--ai-h2));
  background: color-mix(in srgb, var(--callout-c, var(--ai-h2)) 9%, var(--card));
  color: var(--ink);
}
.cw-prose .md-callout.is-tip { --callout-c: var(--ai-tip); }
.cw-prose .md-callout.is-warn { --callout-c: var(--ai-warn); }
.cw-prose .md-callout.is-summary { --callout-c: var(--ai-summary); }
.cw-prose .md-callout.is-note { --callout-c: var(--ai-h1); }
.cw-prose .md-callout-ic {
  flex: none;
  margin-top: 2px;
  color: var(--callout-c, var(--ai-h2));
  display: inline-grid;
  place-items: center;
}
.cw-prose .md-callout-ic svg { width: 18px; height: 18px; }
.cw-prose .md-callout-body { flex: 1; min-width: 0; }
.cw-prose .md-callout-body p { margin: 0; }

.cw-prose blockquote:not(.md-callout) {
  margin: .65em 0;
  border-left: 3px solid var(--ai-h2);
  background: color-mix(in srgb, var(--ai-h2) 8%, var(--card));
  border-radius: 0 12px 12px 0;
  padding: 8px 14px;
  color: var(--ink);
}
.cw-prose blockquote p { margin: 0; }
.cw-prose hr { border: 0; border-top: 1px solid var(--cw-hair); margin: 1em 0; }
.cw-prose code { padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, #E0603A 13%, transparent); color: #C2410C; font: .88em var(--font-mono); }
:root[data-theme="dark"] .cw-prose code { color: #FDBA74; }
.cw-prose a { color: var(--accent); font-weight: 600; text-decoration-thickness: 2px; }

/* Code blocks with dark/slate header bar, Copy & Live Preview controls */
.cw-code {
  margin: .75em 0 1em;
  border-radius: 14px;
  overflow: hidden;
  background: #0F172A;
  border: 1px solid #1E293B;
  color: #E2E8F0;
}
.cw-codehead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 10px 0 14px;
  background: #1E293B;
  color: #CBD5E1;
  font-size: .8rem;
  font-weight: 600;
}
.cw-codehead span {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.16);
  color: #F8FAFC;
}
.cw-codebar { display: inline-flex; align-items: center; gap: 6px; }
.cw-copy, .cw-pv-trig {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  color: #F8FAFC;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.28);
}
.cw-copy:hover, .cw-pv-trig:hover { background: rgba(255, 255, 255, 0.18); }
.cw-copy svg, .cw-pv-trig svg { width: 15px; height: 15px; }
.cw-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; color: #E2E8F0; font: .86rem/1.58 var(--font-mono); white-space: pre; }
.cw-code pre code { padding: 0; background: none; font: inherit; color: inherit; }

/* Thinking indicator & streaming stop/retry bar */
.cw-dots-wait { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--teal) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--teal) 28%, var(--cw-hair)); color: var(--teal-deep); font-size: var(--fs-small); font-weight: 600; animation: cw-think-pulse 1.5s ease-in-out infinite; }
.cw-dots-wait i { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); animation: cw-bounce 1.1s infinite ease-in-out; }
.cw-dots-wait i:nth-child(2) { animation-delay: .15s; } .cw-dots-wait i:nth-child(3) { animation-delay: .3s; }
.cw-dots-wait span { margin-left: 4px; }
@keyframes cw-bounce { 0%, 80%, 100% { opacity: .35; transform: scale(.75); } 40% { opacity: 1; transform: scale(1.12); } }
@keyframes cw-think-pulse { 0%, 100% { opacity: .82; } 50% { opacity: 1; } }
.cw-prose:not(:empty) + .cw-dots-wait { display: none; }

.cw-stream-bar { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); }
.cw-stop-inline, .cw-retry-inline { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--field-border); background: var(--card); color: var(--ink); font: 600 .85rem var(--font-body); cursor: pointer; }
.cw-stop-inline { border-color: color-mix(in srgb, var(--error) 45%, var(--field-border)); color: var(--error-deep); }
.cw-stop-inline:hover { background: var(--error-bg); }
.cw-retry-inline:hover { border-color: var(--accent); color: var(--accent); }
.cw-stop-inline svg, .cw-retry-inline svg { width: 16px; height: 16px; }

/* Clean evenly spaced action dock below each AI message */
.cw-acts,
.cw-acts-dock {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 3px 6px;
  border: 1px solid var(--cw-hair);
  border-radius: 9999px;
  background: var(--card);
}
.cw-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 34px;
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.cw-act:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.cw-act svg { width: 16px; height: 16px; }
.cw-act.is-on { color: var(--accent); background: var(--accent-soft); }
.cw-act.is-labeled span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
.cw-act:not(.is-labeled) { width: 34px; padding: 0; }
.cw-act:not(.is-labeled) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* pictures */
.cw-thumb { position: relative; display: block; width: 120px; height: 120px; padding: 0; border: 1px solid var(--cw-hair); border-radius: var(--r-card); overflow: hidden; background: color-mix(in srgb, var(--ink) 10%, var(--card)); cursor: zoom-in; }
.cw-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.cw-thumb.is-loaded img { opacity: 1; }
.cw-thumb:not(.is-loaded):not(.is-broken)::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--card) 70%, transparent) 50%, transparent 70%); background-size: 200% 100%; animation: cw-shimmer 1.2s infinite; }
@keyframes cw-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.cw-thumb.is-broken { display: grid; place-items: center; padding: var(--sp-2); color: var(--muted); font-size: .8125rem; text-align: center; cursor: default; }
.cw-genwrap { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.cw-fig { margin: 0; display: grid; gap: var(--sp-2); max-width: min(100%, 420px); }
.cw-thumb.cw-gen { width: min(100%, 420px); height: auto; aspect-ratio: 1; }
.cw-fig figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.cw-cap { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .8125rem; }
.cw-fig-post { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--cw-hair)); border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font: 600 .8125rem var(--font-body); cursor: pointer; }
.cw-fig-post:hover { background: var(--accent); color: #fff; }
.cw-fig-post svg { width: 15px; height: 15px; }

/* lightbox */
.cw-lightbox { max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh; padding: 0; border: 0; border-radius: 0; background: #000; color: #fff; }
.cw-lightbox::backdrop { background: #000; }
.cw-lb-bar { position: absolute; inset: 0 0 auto 0; z-index: 2; display: flex; align-items: center; gap: var(--sp-2); padding: max(12px, env(safe-area-inset-top)) var(--sp-3) var(--sp-2); }
.cw-lb-stage { height: 100%; display: grid; place-items: center; padding: 76px 0 24px; }
.cw-lightbox img { max-width: 100vw; max-height: calc(100dvh - 100px); width: auto; height: auto; border-radius: 0; object-fit: contain; }
.cw-lb-close, .cw-lb-round { position: static; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #2A2A2C; color: #fff; box-shadow: none; cursor: pointer; }
.cw-lb-close:hover, .cw-lb-round:hover { background: #3A3A3D; }
.cw-lb-close svg, .cw-lb-round svg { width: 22px; height: 22px; }
.cw-lb-share { min-height: 44px; padding: 0 var(--sp-5); border: 0; border-radius: var(--r-pill); background: #fff; color: #000; font: 600 1rem var(--font-body); cursor: pointer; }
.cw-lb-share:hover { background: #E8E8EA; }
.cw-lightbox :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* editing */
.cw-editbox { width: min(100%, 620px); display: grid; gap: var(--sp-2); }
.cw-edit { width: 100%; min-height: 84px; padding: var(--sp-3) var(--sp-4); border: 2px solid var(--teal); border-radius: var(--r-card); background: var(--card); color: var(--ink); font-size: var(--fs-0); line-height: 1.5; resize: vertical; }
.cw-editacts { display: flex; justify-content: flex-end; gap: var(--sp-2); }
.cw-save, .cw-cancel, .cw-retry { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 42px; padding: 0 var(--sp-4); border-radius: var(--r-pill); font-weight: 700; font-size: var(--fs-small); cursor: pointer; }
.cw-save { border: 0; background: var(--teal-deep); color: var(--on-teal); }
.cw-cancel { border: 1px solid var(--field-border); background: var(--card); color: var(--ink); }
.cw-retry { border: 1px solid var(--error-deep); background: transparent; color: var(--error-deep); margin-left: auto; }
.cw-retry:hover { background: color-mix(in srgb, var(--error) 12%, transparent); } .cw-retry svg { width: 16px; height: 16px; }

/* errors */
.cw-errwrap:empty { display: none; }
.cw-errwrap { padding: 0 var(--sp-4); }
.cw-err { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); max-width: 780px; margin: 0 auto var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid color-mix(in srgb, var(--error) 45%, transparent); border-radius: var(--r-card); background: var(--error-bg); color: var(--error-deep); }
.cw-err > svg { flex: none; width: 22px; height: 22px; }
.cw-err-t { display: grid; gap: 2px; flex: 1; min-width: 180px; font-size: var(--fs-small); }

/* ---- Bounded Composer Card Box (zero overflow on 360px screens) ---- */
.cw-dock {
  flex: 0 0 auto;
  padding: 6px var(--sp-3) calc(8px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, var(--surface) 22%);
}
.cw-foot { margin: 5px auto 0; max-width: 780px; text-align: center; font-size: .74rem; line-height: 1.35; color: var(--muted); }
.cw-composer-wrap { position: relative; max-width: 780px; margin: 0 auto; }
.cw-composer,
.cw-compose-card {
  position: relative;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--cw-hair);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--cw-lift);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.cw-composer:focus-within { border-color: var(--accent); }
.cw-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
  width: 100%;
}
.cw-input {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 40px;
  max-height: 160px;
  padding: 8px 6px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.45;
  resize: none;
  outline: none;
  align-self: center;
}
.cw .cw-input:focus-visible { outline: none; }
.cw-input::placeholder { color: var(--muted); opacity: 1; }
.cw-strip { list-style: none; margin: 0 0 var(--sp-2); padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.cw-rm { position: absolute; top: -10px; right: -10px; display: grid; place-items: center; width: 40px; height: 40px; border: 0; background: transparent; cursor: pointer; padding: 0; }
.cw-rm::before { content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--card); }
.cw-rm svg { position: relative; width: 13px; height: 13px; color: var(--on-ink); }

.cw-plus, .cw-mic {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.cw-plus:hover, .cw-mic:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.cw-plus svg, .cw-mic svg { width: 20px; height: 20px; }
.cw-mic.is-on { background: color-mix(in srgb, var(--error) 16%, transparent); color: var(--error-deep); animation: cw-pulse 1.2s infinite; }
@keyframes cw-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--error) 18%, transparent); } }
.cw-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform .12s, background .15s;
}
.cw-send svg { width: 19px; height: 19px; }
.cw-send:hover:not(:disabled) { background: #1D4ED8; }
.cw-send:active:not(:disabled) { transform: scale(.94); }
.cw-send:disabled { background: color-mix(in srgb, var(--ink) 14%, var(--card)); color: var(--muted); cursor: not-allowed; }
.cw-send.is-stop { background: var(--error-deep); color: #fff; }
.cw-count { font-size: .75rem; color: var(--muted); align-self: center; flex: none; }

.cw-chiprow { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 4px 6px; }
.cw-chiprow:not(:has(:not([hidden]))) { display: none; }
.cw-modechip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border: 0; border-radius: var(--r-pill); background: color-mix(in srgb, var(--accent) 14%, var(--card)); color: var(--accent); font: 600 .8rem var(--font-body); cursor: pointer; }
.cw-modechip svg { width: 16px; height: 16px; } .cw-modechip svg:last-child { width: 13px; height: 13px; opacity: .8; }
.cw-modechip:hover { background: color-mix(in srgb, var(--accent) 22%, var(--card)); }

.cw-plusmenu { position: absolute; z-index: 15; left: 0; bottom: calc(100% + 8px); width: min(260px, calc(100vw - 32px)); margin: 0; padding: 8px; list-style: none; background: var(--card); border: 1px solid var(--cw-hair); border-radius: 18px; box-shadow: 0 12px 36px rgba(8,16,32,.26); }
.cw-plusmenu .cw-mi { min-height: 44px; font-size: 0.94rem; font-weight: 600; border-radius: 12px; }
.cw-plusmenu .cw-mi svg { width: 20px; height: 20px; }
.cw-plusmenu[hidden], .cw-pop[hidden] { display: none; }

/* Compact Create Image Card Box inside Composer (zero Reference/Add picture, scrollable Ratio pills) */
.cw-imgopts {
  display: grid;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--cw-hair);
  border-radius: 14px;
  background: var(--surface);
  max-height: 180px;
  overflow-y: auto;
}
.cw-imgopts-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cw-optlabel {
  flex: none;
  width: 52px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
}
.cw-ratio-scroll {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
.cw-ratio-scroll::-webkit-scrollbar { display: none; }
.cw-seg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--cw-hair);
  border-radius: var(--r-pill);
  background: var(--card);
}
.cw-segb {
  flex: none;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.cw-segb.is-on { background: var(--accent); color: #fff; }
.cw-optsel {
  min-height: 34px;
  border: 1px solid var(--cw-hair);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--ink);
  padding: 0 10px;
  font: 600 .8rem var(--font-body);
  max-width: 140px;
}

/* help dialog */
.cw-help { width: min(92vw, 460px); }
.cw-keys { margin: 0; display: grid; gap: var(--sp-2) var(--sp-4); grid-template-columns: auto 1fr; align-items: center; }
.cw-keys dt { white-space: nowrap; } .cw-keys dd { margin: 0; color: var(--muted); text-align: right; font-size: var(--fs-small); }
.cw-keys kbd { display: inline-block; padding: 1px 8px; border: 1px solid var(--field-border); border-bottom-width: 2px; border-radius: 6px; background: var(--card); font: 600 .8125rem var(--font-mono); }

@media (max-width: 899.98px) {
  .cw { grid-template-columns: minmax(0, 1fr); }
  .cw-thread { padding-inline: var(--sp-3); }
  .cw-dock { padding: 4px var(--sp-2) calc(8px + env(safe-area-inset-bottom, 0px)); }
  .cw-foot { font-size: .7rem; }
  .cw-head { min-height: 44px; padding: 4px var(--sp-2); gap: 6px; }
  .cw-title { display: none; }
  .cw-hist-btn { margin-right: auto; padding: 0 10px; min-height: 36px; font-size: .8rem; }
  .cw-round, .cw-icon { width: 36px; height: 36px; }
  .cw-head > .cw-icon[aria-label="Keyboard shortcuts"] { display: none; }
  .cw-cards { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .cw-card { min-height: 54px; padding: 10px 12px; }
  .cw-empty { padding-block: 6px var(--sp-2); gap: 6px; }
  .cw-logo { width: 44px; height: 44px; }
  .cw-empty h2 { font-size: 1.32rem; }
  .cw-bubble { max-width: 92%; }
  .cw-new { max-width: none; }
}
@media (max-width: 419.98px) {
  .cw-compose-card, .cw-composer { padding: 6px; border-radius: 20px; }
  .cw-plus, .cw-mic, .cw-send { width: 36px; height: 36px; }
  .cw-plus svg, .cw-mic svg, .cw-send svg { width: 18px; height: 18px; }
  .cw-input { font-size: .92rem; padding: 8px 4px; }
  .cw-input:placeholder-shown { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (prefers-reduced-motion: reduce) {
  .cw *, .cw *::before, .cw *::after { animation: none !important; transition: none !important; }
}

/* Projects */
.cw-projects { padding: 0 var(--sp-3) var(--sp-2); display: grid; gap: var(--sp-1); }
.cw-projects-head { display: flex; align-items: center; justify-content: space-between; }
.cw-projects-head h2 { margin: 0; font: 600 var(--fs-small) var(--font-body); color: var(--muted); }
.cw-projects-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 160px; overflow: auto; }
.cw-projects-list .cw-open { width: 100%; display: flex; align-items: center; gap: 8px; }
.cw-projects-list svg { flex: none; width: 18px; height: 18px; }
.cw-projchip { display: inline-flex; align-items: center; gap: 6px; max-width: 180px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: 600 var(--fs-small) var(--font-body); cursor: pointer; }
.cw-projchip[hidden] { display: none; }
.cw-projchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-projchip svg { width: 16px; height: 16px; flex: none; }
.pj-dialog { display: grid; gap: var(--sp-3); max-width: 560px; width: calc(100vw - 32px); max-height: 90vh; overflow: auto; }
.pj-dialog[open] { display: grid; }
.pj-dialog h2, .pj-dialog h3 { margin: 0; }
.pj-h { font: 700 var(--fs-0) var(--font-display); }
.pj-list { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; gap: var(--sp-2); }
.pj-list li { display: flex; justify-content: space-between; gap: var(--sp-3); border: 1px solid var(--line); border-radius: 10px; padding: var(--sp-2) var(--sp-3); }
.pj-list p { margin: 0; }
.pj-rm { border: 0; background: none; color: #A3231C; font: 600 var(--fs-small) var(--font-body); cursor: pointer; min-height: 44px; }
.pj-add { display: grid; gap: var(--sp-2); justify-items: start; }
.pj-add .input { width: 100%; }
.pj-dialog .dialog-actions { flex-wrap: wrap; }

/* Settings, Library, Find bar, Voice */
.cw-lib { width: min(860px, 96vw); border-radius: 24px; }
.cw-libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px; max-height: 60vh; overflow: auto; margin: var(--sp-3) 0; }
.cw-libitem { width: auto; height: auto; aspect-ratio: 1; border-radius: 10px; overflow: hidden; }
.cw-libitem img { width: 100%; height: 100%; object-fit: cover; }
.cw-libmsg { grid-column: 1 / -1; color: var(--muted); }
.cs { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--surface); color: var(--ink); }
.cs-head { display: flex; align-items: center; gap: var(--sp-2); padding: max(10px, env(safe-area-inset-top)) var(--sp-3) 6px; min-height: 56px; }
.cs-title { flex: 1; margin: 0; text-align: center; font: 700 1.125rem var(--font-display); letter-spacing: -0.02em; }
.cs-gap { width: 44px; flex: none; }
.cs-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-3) var(--sp-4) 48px; width: 100%; max-width: 640px; margin: 0 auto; display: grid; gap: var(--sp-5); align-content: start; }
.cs-group h3 { margin: 0 0 var(--sp-2) var(--sp-3); font: 600 1rem var(--font-display); letter-spacing: -0.02em; color: var(--muted); }
.cs-card { border: 1px solid var(--cw-hair); border-radius: 24px; background: var(--card); overflow: hidden; }
.cs-row { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 60px; padding: 0 var(--sp-5); border: 0; border-bottom: 1px solid var(--cw-hair); background: transparent; color: var(--ink); font: 500 1rem var(--font-body); text-align: left; text-decoration: none; cursor: pointer; }
.cs-card > :last-child { border-bottom: 0; }
.cs-row:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.cs-row svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.cs-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-v { color: var(--muted); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.cs-row.is-danger { color: var(--error-deep); } .cs-row.is-accent { color: var(--accent); }
.cs-selrow { position: relative; }
.cs-sel { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--muted); font: 500 1rem var(--font-body); text-align: right; padding: 0 4px; min-height: 44px; max-width: 60%; cursor: pointer; }
.cs-note { margin: var(--sp-2) var(--sp-3) 0; color: var(--muted); font-size: .9375rem; line-height: 1.5; }
.cs-tabs { display: flex; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-2); max-width: 640px; width: 100%; margin: 0 auto; }
.cs-tab { min-height: 44px; padding: 0 var(--sp-5); border: 0; border-radius: var(--r-pill); background: transparent; color: var(--muted); font: 600 1rem var(--font-body); cursor: pointer; }
.cs-tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.cs-lib .cs-body { max-width: 900px; }
.cs-empty { display: grid; justify-items: center; gap: var(--sp-2); text-align: center; padding: 14vh var(--sp-4) 48px; }
.cs-empty h3 { margin: 0; font: 700 1.25rem var(--font-display); letter-spacing: -0.02em; } .cs-empty p { margin: 0; color: var(--muted); max-width: 34ch; }
.cs-empty-ic { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 9999px; border: 1px solid var(--nav-border); background: var(--card); color: var(--accent); }
.cs-empty-ic svg { width: 22px; height: 22px; }
.cw-file { display: flex; align-items: center; gap: 12px; margin: 10px 0; padding: 10px 12px; border: 1px solid var(--nav-border); border-radius: 14px; background: var(--surface, transparent); max-width: 460px; }
.cw-file-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9999px; border: 1px solid var(--nav-border); background: var(--card); color: var(--accent); flex: none; }
.cw-file-ic svg { width: 22px; height: 22px; }
.cw-file-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cw-file-t strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-file-t span { font-size: .8rem; opacity: .7; }
.cw-file-dl { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.cw-file-dl svg { width: 18px; height: 18px; }
.cw-modeltag { margin-top: 2px; font-size: .75rem; opacity: .65; }
.cw-chipfiles { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.cw-chipfile { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(127,127,127,.4); font-size: .85rem; }
.cw-chipfile svg { width: 16px; height: 16px; flex: none; }
.cw-find { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.cw-findin { flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(127,127,127,.4); background: transparent; color: inherit; font: inherit; }
.cw-findcount { font-size: .8rem; opacity: .7; min-width: 64px; text-align: center; }
.cw-find-b { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.cw-find-b svg { width: 20px; height: 20px; }
.cw-msg.is-match { outline: 1px dashed rgba(127,127,127,.5); outline-offset: 4px; border-radius: 12px; }
.cw-msg.is-found { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 12px; }
.cs-selbtn { min-height: 44px; padding: 0 14px; border: 0; background: transparent; color: inherit; font: 600 1rem inherit; cursor: pointer; border-radius: 999px; }
.cw-libcell { position: relative; border-radius: 12px; cursor: pointer; }
.cw-libcell.is-on { outline: 3px solid currentColor; outline-offset: -3px; }
.cw-libtick { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.45); color: transparent; }
.cw-libcell.is-on .cw-libtick { background: #fff; color: #000; }
.cw-libtick svg { width: 16px; height: 16px; }
.cw-selbar { position: sticky; bottom: 24px; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid rgba(127,127,127,.3); background: var(--surface, Canvas); }
.cw-selact { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(127,127,127,.45); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.cw-selact.is-danger { color: #d92d20; border-color: #d92d20; }
.cw-favlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cw-favlist li { display: flex; align-items: center; gap: 6px; border: 1px solid rgba(127,127,127,.3); border-radius: 14px; }
.cw-favopen { flex: 1; min-width: 0; text-align: left; padding: 12px 14px; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.cw-favopen span { font-size: .85rem; opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-favun { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.cw-favun svg { width: 20px; height: 20px; fill: currentColor; }
.cw-lb-menu { position: absolute; z-index: 3; top: 72px; right: 12px; margin: 0; padding: 6px; list-style: none; min-width: 190px; border-radius: 14px; background: #2a2a2d; color: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.cw-lb-menu .cw-mi { width: 100%; color: #fff; }
.cv-sheet { max-width: 460px; width: calc(100vw - 32px); display: grid; gap: var(--sp-3); }
.cv-sheet[open] { display: grid; }
.cv-voice { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: var(--sp-4); border: 0; background: var(--cv-bg, #0E1B30); color: #F2F6FB; }
.cv-voice[open] { display: grid; grid-template-rows: auto 1fr auto auto auto; justify-items: center; align-items: center; gap: var(--sp-3); }
.cv-voice::backdrop { background: #0E1B30; }
.cv-top { width: 100%; max-width: 560px; display: flex; align-items: center; justify-content: space-between; }
.cv-gear, .cv-end { display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: #F2F6FB; cursor: pointer; }
.cv-orb { position: relative; width: min(56vw, 260px); height: min(56vw, 260px); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #7FD6EA, #0E6F8A 60%, #0B3F52); box-shadow: 0 0 60px rgba(14,111,138,.55); }
.cv-talk { display: grid; place-items: center; width: 72px; height: 72px; border: 0; border-radius: 50%; background: #F2F6FB; color: #0E1B30; cursor: pointer; }
.cw-strip .cw-docli { width: auto; height: auto; max-width: min(100%, 320px); min-height: 56px; padding: 6px 8px 6px 10px; display: inline-flex; align-items: center; gap: 8px; border-radius: 14px; background: var(--surface); }
.cw-docchip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.cw-docchip svg { width: 22px; height: 22px; flex: none; color: var(--teal-deep); }
.cw-docchip span { display: grid; min-width: 0; }
.cw-docchip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-small); }
.cw-docchip small { color: var(--muted); font-size: .75rem; }
.cw-docpre { margin: 0; max-height: 60vh; overflow: auto; padding: var(--sp-3); border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: .85rem/1.55 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.cw-extras:empty { display: none; }
.cw-extras { display: grid; gap: 8px; margin-bottom: 8px; }
.cw-think { border: 1px solid color-mix(in srgb, #7A4FD0 35%, var(--line)); background: color-mix(in srgb, #7A4FD0 8%, var(--card)); border-radius: 12px; padding: 6px 12px; font-size: var(--fs-small); }
.cw-think summary { cursor: pointer; font-weight: 600; color: #5B34B0; display: flex; align-items: center; gap: 6px; min-height: 28px; }
.cw-think-body { white-space: pre-wrap; color: var(--muted); max-height: 180px; overflow: auto; padding: 4px 0 6px; }

/* Phone fit: code header labels stay on one line, reply actions sit in a plain row */
.cw-codehead { gap: 8px; }
.cw-codehead > span { flex: none; white-space: nowrap; }
.cw-codehead .cw-codebar { min-width: 0; }
.cw-codehead .cw-codebar button, .cw-codehead .cw-codebar button span { white-space: nowrap; }
.cw-codehead .cw-codebar button span { background: none; padding: 0; }
.cw-acts-dock { border-radius: 14px; }
@media (max-width: 479.98px) { .cw-codehead .cw-codebar button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } .cw-codehead .cw-codebar button { min-width: 44px; justify-content: center; } }

/* Archived chats panel */
.cw-archlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cw-archlist .cw-item { display: flex; align-items: center; gap: 2px; }
.cw-archlist .cw-open { flex: 1; min-width: 0; }

/* Phone fit: long chat titles are shortened with … instead of widening the list */
.cw-items, .cw-projects-list, .cw-archlist { grid-template-columns: minmax(0, 1fr); }
.cw-list, .cw-items > *, .cw-projects-list > *, .cw-archlist > * { min-width: 0; }
.cw-list { overflow-x: hidden; }
.cw-open-t { min-width: 0; }

/* Pictures keep the shape they were made in (no forced square crop) */
.cw-thumb.cw-gen { width: min(100%, 420px); height: auto; aspect-ratio: auto; min-height: 140px; }
.cw-thumb.cw-gen.is-loaded { min-height: 0; }
.cw-thumb.cw-gen img { width: 100%; height: auto; max-height: min(70dvh, 560px); object-fit: contain; }
.cw-thumb.cw-gen:not(.is-loaded) img { position: absolute; inset: 0; height: 100%; }

/* Image Library: a two-column wall that keeps every picture's own proportions */
.cw-libgrid { display: block; columns: 2; column-gap: 8px; max-height: none; overflow: visible; }
@media (min-width: 700px) { .cw-libgrid { columns: 3; } }
.cw-libitem { display: block; width: 100%; height: auto; aspect-ratio: auto; min-height: 120px; margin: 0 0 8px; break-inside: avoid; }
.cw-libitem.is-loaded { min-height: 0; }
.cw-libitem img { width: 100%; height: auto; object-fit: contain; }
.cw-libitem:not(.is-loaded) img { position: absolute; inset: 0; height: 100%; }
