:root {
  --brand: #800260;
  --brand-dark: #5d0046;
  --brand-soft: #f7edf4;
  --ink: #17131a;
  --muted: #756f78;
  --line: #e9e3e8;
  --bg: #f7f5f7;
  --white: #ffffff;
  --success: #18864b;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; min-height: 100dvh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.card { width: min(100%, 520px); background: var(--white); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 18px 60px rgba(43, 25, 39, .10); }
.start-card { padding: 38px; }
.brand-mark, .agent-logo { display: grid; place-items: center; background: var(--brand); color: white; font-weight: 800; }
.brand-mark { width: 58px; height: 58px; border-radius: 18px; font-size: 28px; margin-bottom: 24px; }
.eyebrow { font-size: 12px; letter-spacing: .14em; font-weight: 800; color: var(--brand); margin: 0 0 10px; }
h1 { font-size: clamp(30px, 6vw, 42px); line-height: 1.05; margin: 0 0 12px; letter-spacing: -.035em; }
.subtitle { color: var(--muted); line-height: 1.55; margin: 0 0 30px; }
label { display: block; font-size: 13px; font-weight: 750; margin: 18px 0 8px; }
input[type="text"] { width: 100%; border: 1px solid #d9d1d7; border-radius: 13px; padding: 14px 15px; outline: none; transition: .15s; background: #fff; }
input[type="text"]:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(128, 2, 96, .09); }
.primary { width: 100%; border: 0; border-radius: 13px; padding: 14px 18px; color: white; background: var(--brand); font-weight: 800; margin-top: 24px; }
.primary:hover { background: var(--brand-dark); }
.primary:disabled, .send-button:disabled { opacity: .55; cursor: wait; }
.privacy { font-size: 12px; color: #948c93; text-align: center; margin: 18px 0 0; }
.error { color: var(--danger); min-height: 20px; font-size: 13px; margin: 10px 0 0; }
.hidden { display: none !important; }

.chat-card { height: min(850px, calc(100dvh - 30px)); width: min(100%, 760px); display: grid; grid-template-rows: auto auto 1fr auto auto; overflow: hidden; }
.chat-header { display: flex; align-items: center; gap: 12px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.agent-logo { width: 42px; height: 42px; border-radius: 14px; font-size: 20px; flex: 0 0 auto; }
.header-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.header-copy strong { font-size: 15px; }
.header-copy span { color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #a0a0a0; }
.status-dot.online { background: var(--success); }
.ghost { margin-left: auto; border: 1px solid var(--line); background: white; color: var(--muted); border-radius: 10px; padding: 8px 10px; font-size: 12px; font-weight: 700; }
.ticket-strip { padding: 8px 18px; background: #fbf8fa; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.ticket-strip strong { color: var(--brand); }
.messages { overflow-y: auto; padding: 20px; background: linear-gradient(180deg, #fff 0%, #fcfafb 100%); }
.system-message { max-width: 500px; margin: 0 auto 20px; text-align: center; color: var(--muted); font-size: 12px; background: #f4f1f3; padding: 9px 12px; border-radius: 999px; }
.message-row { display: flex; margin: 10px 0; }
.message-row.mine { justify-content: flex-end; }
.bubble { max-width: min(78%, 500px); border-radius: 17px; padding: 10px 13px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.message-row.theirs .bubble { background: white; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.message-row.mine .bubble { background: var(--brand); color: white; border-bottom-right-radius: 5px; }
.sender { font-size: 11px; font-weight: 800; margin-bottom: 5px; color: var(--brand); }
.message-row.mine .sender { display: none; }
.content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; font-size: 14px; }
.time { margin-top: 6px; font-size: 10px; opacity: .65; text-align: right; }
.attachment { display: block; margin-top: 8px; border-radius: 11px; overflow: hidden; max-width: 100%; }
.attachment img, .attachment video { display: block; max-width: 100%; max-height: 360px; border-radius: 11px; }
.attachment audio { width: 100%; }
.file-link { color: inherit; text-decoration: underline; overflow-wrap: anywhere; }
.file-tray { border-top: 1px solid var(--line); padding: 8px 14px; background: #fff; display: flex; gap: 7px; flex-wrap: wrap; }
.file-chip { font-size: 11px; border: 1px solid var(--line); background: #f8f6f8; padding: 6px 8px; border-radius: 999px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { min-height: 66px; border-top: 1px solid var(--line); background: white; display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 9px; padding: 10px 12px; }
.attach-button { margin: 0; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-size: 25px; font-weight: 500; }
textarea { width: 100%; min-height: 42px; max-height: 130px; resize: none; border: 1px solid #ded7dc; border-radius: 14px; padding: 10px 12px; outline: none; line-height: 1.4; }
.send-button { width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--brand); color: white; font-size: 18px; font-weight: 800; }
.chat-error { min-height: 0; margin: 0; padding: 0 14px 10px; color: var(--danger); font-size: 12px; background: white; }
@media (max-width: 600px) {
  .shell { padding: 0; }
  .card { border-radius: 0; border: 0; width: 100%; }
  .start-card { min-height: 100dvh; padding: 32px 22px; display: flex; flex-direction: column; justify-content: center; }
  .chat-card { height: 100dvh; width: 100%; }
  .bubble { max-width: 86%; }
  .ghost { font-size: 11px; padding: 7px 8px; }
}
