/* CASI full-screen chat (/casi). Builds on styles.css tokens. */
.chat-page { height: 100dvh; overflow: hidden; background: var(--bg-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cx { display: grid; grid-template-columns: 360px 1fr; height: 100dvh; }

/* Rail */
.cx-rail { background: #fff; border-right: 1px solid var(--line); padding: 28px 32px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.rail-photo { aspect-ratio: 4 / 5; border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-top: 10px; }
.rail-h { font-size: 28px; letter-spacing: -0.03em; margin-top: 6px; }
.rail-p { color: var(--ink-2); font-size: 16px; }
.rail-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: 15px; color: var(--ink-2); }
.rail-list li { display: flex; gap: 10px; align-items: flex-start; }
.rail-list svg { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 3px; }
.rail-fine { font-size: 13px; color: var(--muted); padding-top: 16px; border-top: 1px solid var(--line); margin-top: auto; }
.rail-legal { font-size: 12.5px; color: var(--muted); }
.rail-legal a { color: var(--ink-2); }

/* Main */
.cx-main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.cx-head { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.cx-back { display: none; width: 40px; height: 40px; border-radius: 10px; place-items: center; color: var(--ink); }
.cx-back svg { width: 20px; height: 20px; }
.cx-back:hover { background: var(--bg-soft); }
.cx-ava { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.cx-ava .ph-fallback svg, .b-ava svg { width: 62%; max-width: none; min-width: 0; }
.cx-id { display: grid; line-height: 1.25; }
.cx-id b { font-size: 16px; letter-spacing: .02em; }
.cx-id span { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.online { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px rgba(21,146,90,.16); }
.cx-restart { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-2); background: #fff; border-radius: 999px; font: 500 14px/1 var(--font); color: var(--ink-2); cursor: pointer; }
.cx-restart svg { width: 16px; height: 16px; }
.cx-restart:hover { background: var(--bg-soft); color: var(--ink); }

.cx-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.cx-log { max-width: 760px; margin: 0 auto; padding: 32px 24px 24px; display: flex; flex-direction: column; gap: 6px; }

.row { display: flex; gap: 10px; align-items: flex-end; animation: msg .45s var(--ease) both; }
@keyframes msg { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.row.bot + .row.user, .row.user + .row.bot { margin-top: 14px; }
.b-ava { width: 32px; height: 32px; border-radius: 50%; flex: none; overflow: hidden; display: grid; place-items: center; background: linear-gradient(160deg, #e8f3ef, #f7f3ec); }
.b-ava img { width: 100%; height: 100%; object-fit: cover; }
.row.bot.cont .b-ava { visibility: hidden; }
.b-body { max-width: min(560px, 82%); }
.b-body > p { background: #fff; border: 1px solid var(--line); padding: 12px 16px; border-radius: 18px 18px 18px 6px; font-size: 16px; line-height: 1.5; color: var(--ink); box-shadow: 0 1px 2px rgba(11,23,32,.04); }
.row.bot.cont .b-body > p { border-bottom-left-radius: 18px; }
.b-body.wide { max-width: min(520px, 88%); width: 100%; }
.row.user { justify-content: flex-end; }
.u-bubble { background: var(--accent); color: #fff; padding: 11px 16px; border-radius: 18px 18px 6px 18px; max-width: 78%; font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; }

.typing { display: inline-flex; gap: 5px; background: #fff; border: 1px solid var(--line); padding: 15px 16px; border-radius: 18px 18px 18px 6px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #8a979f; animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); }
.card-t { font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.card-s { color: var(--ink-2); font-size: 15px; margin-bottom: 16px; }
.card-s.small { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.card-s.sandbox { font-size: 12.5px; color: #8a4b00; background: #fff4e5; padding: 8px 10px; border-radius: 8px; margin: 12px 0 0; }
.plan ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plan li { display: grid; grid-template-columns: 76px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; font-size: 14.5px; background: var(--bg-soft); }
.plan li.start { background: var(--accent-tint); outline: 1.5px solid var(--accent); }
.pk { font: 500 11.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.tag { font-size: 11.5px; font-weight: 600; color: #fff; background: var(--accent); padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.prog ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14.5px; color: var(--muted); }
.prog li { display: flex; align-items: center; gap: 10px; transition: color .3s; }
.pi { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; position: relative; }
.prog li.run { color: var(--ink); }
.prog li.run .pi { border-color: var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
.prog li.ok { color: var(--ink); }
.prog li.ok .pi { background: var(--accent); border-color: var(--accent); }
.prog li.ok .pi::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.cta .btn { width: 100%; }

/* Dock */
.cx-dock { border-top: 1px solid var(--line); background: #fff; padding: 12px 24px calc(12px + env(safe-area-inset-bottom)); }
.chips, .composer, .cx-fine { max-width: 712px; margin: 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.chips:not(:empty) { margin-bottom: 12px; }
.chip { min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--accent); background: #fff; color: var(--accent); font: 600 15px/1 var(--font); cursor: pointer; transition: background .2s, color .2s, transform .2s var(--ease); animation: msg .4s var(--ease) both; animation-delay: calc(var(--i) * 50ms); }
.chip:hover { background: var(--accent); color: #fff; }
.chip:active { transform: scale(.97); }
.composer { display: flex; gap: 8px; align-items: center; background: var(--bg-soft); border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 5px 5px 18px; transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint); background: #fff; }
.composer.focus-step { border-color: var(--accent); background: #fff; }
.composer input { flex: 1; min-width: 0; border: 0; background: transparent; font: 400 16px/1.4 var(--font); color: var(--ink); padding: 10px 0; outline: none; }
.composer input::placeholder { color: #6b7880; }
.composer button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.composer button:hover { background: var(--accent-h); }
.composer button svg { width: 18px; height: 18px; }
.composer[aria-busy="true"] button { opacity: .5; cursor: progress; }
.cx-fine { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 10px; text-align: center; }
.cx-fine svg { width: 14px; height: 14px; flex: none; }

@media (max-width: 960px) {
  .cx { grid-template-columns: 1fr; }
  .cx-rail { display: none; }
  .cx-back { display: grid; }
  .cx-head { padding: 10px 12px; }
  .cx-restart span { display: none; }
  .cx-restart { padding: 0; width: 40px; justify-content: center; }
  .cx-log { padding: 20px 14px 16px; }
  .cx-dock { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  /* One swipeable row of quick replies keeps the dock short on phones. */
  .chips { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; white-space: nowrap; }
  .b-body { max-width: 84%; }
  .b-body.wide { max-width: 90%; }
  .plan li { grid-template-columns: 64px 1fr; }
  .plan li .tag { grid-column: 2; justify-self: start; }
}
