:root {
  --grad: linear-gradient(135deg, #e1306c 0%, #c13584 45%, #7b3ff2 100%);
  --grey: #efefef;
  --text: #262626;
  --muted: #8e8e8e;
  --line: #dbdbdb;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: #1c1c1e; color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.stage { min-height: 100%; display: grid; place-items: center; padding: 24px; }

.phone {
  position: relative; width: 390px; height: 800px; max-height: calc(100vh - 48px);
  background: #000; border-radius: 52px; padding: 10px;
  box-shadow: 0 0 0 2px #2a2a2a, 0 30px 70px rgba(0,0,0,.28), 0 8px 20px rgba(0,0,0,.15);
  animation: rise .6s cubic-bezier(.2,.8,.2,1) both;
}
.notch {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 28px; background: #000; border-radius: 0 0 18px 18px; z-index: 5;
}
.screen {
  --grey: #262626; --text: #f5f5f5; --muted: #a0a0a5; --line: #2a2a2a; --bg: #000;
  --grad: linear-gradient(90deg, #4f7cff 0%, #8f3cff 100%);
  height: 100%; background: var(--bg); color: var(--text); border-radius: 40px; overflow: hidden; display: flex; flex-direction: column; }

.chat { display: flex; flex-direction: column; height: 100%; }
.statusbar {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 30px 4px 34px; color: #fff; background: var(--bg);
}
.clock { font-size: 15px; font-weight: 600; letter-spacing: .2px; font-variant-numeric: tabular-nums; }
.sys { display: flex; align-items: center; gap: 6px; }
.sys svg { fill: currentColor; height: 12px; width: auto; }


.chat-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 600; font-size: 14px; text-transform: uppercase;
}
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.who strong { font-size: 14px; display: flex; align-items: center; min-width: 0; }
.who strong #account { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 11.5px; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 4px; }
.back { display: grid; place-items: center; color: #fff; margin-right: -4px; }
.back svg { width: 26px; height: 26px; }
.verified { width: 14px; height: 14px; margin-left: 4px; fill: #1d9bf0; flex: none; }
.icon-btn { background: none; border: 0; width: 34px; height: 34px; display: grid; place-items: center; cursor: default; color: #fff; padding: 0; }
.icon-btn svg { width: 26px; height: 26px; }
.reset {
  font: inherit; font-size: 11px; color: var(--muted); background: none; border: 1px solid var(--line);
  border-radius: 12px; padding: 3px 8px; cursor: pointer; transition: .2s;
}
.reset:hover { color: var(--text); border-color: var(--muted); }

.messages {
  flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth; scrollbar-width: none;
}
.messages::-webkit-scrollbar { display: none; }
.msg {
  max-width: 74%; padding: 10px 16px; border-radius: 22px; font-size: 14.5px; line-height: 1.35;
  white-space: pre-wrap; overflow-wrap: anywhere; animation: pop .25s ease both;
}
.msg.agent { align-self: flex-start; background: var(--grey); transform-origin: left bottom; }
.msg.user { align-self: flex-end; color: #fff; background: var(--grad); background-attachment: fixed; transform-origin: right bottom; }
.status { align-self: flex-end; font-size: 11.5px; color: var(--muted); margin: 2px 6px 0; animation: pop .25s ease both; }
.msg.error { align-self: center; max-width: 90%; background: none; color: var(--muted); font-size: 12px; text-align: center; padding: 4px 8px; }
.msg + .msg.agent, .msg.agent + .msg.user, .msg.user + .msg.agent { margin-top: 6px; }

.typing { align-self: flex-start; background: var(--grey); border-radius: 22px; padding: 12px 15px; display: flex; gap: 4px; animation: pop .25s ease both; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #a8a8a8; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 16px; }
.input-wrap {
  flex: 1; display: flex; align-items: center; gap: 10px; background: #1e1f22; border: 1px solid transparent;
  border-radius: 26px; padding: 6px 14px 6px 6px; transition: border-color .2s;
}
.cam { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #5b4fe9; }
.cam svg { width: 19px; height: 19px; fill: #fff; }
.input-wrap:focus-within { border-color: var(--muted); }
textarea {
  flex: 1; border: 0; outline: 0; resize: none; font: inherit; font-size: 14.5px; line-height: 1.35;
  max-height: 96px; background: transparent; color: var(--text);
}
textarea::placeholder { color: var(--muted); }
.input-icons { display: flex; gap: 10px; padding-bottom: 1px; }
.input-icons svg { width: 22px; height: 22px; fill: var(--text); color: var(--text); }
.send {
  flex: none; width: 52px; height: 34px; margin: -1px -9px -1px 0; border: 0; border-radius: 17px; padding: 0; cursor: pointer;
  display: grid; place-items: center; background: #7b3ff2; transition: transform .15s, opacity .2s;
}
.send svg { width: 20px; height: 20px; fill: #fff; transform: rotate(8deg); }
.send:active { transform: scale(.94); }
.send:disabled { display: none; }
.input-wrap:has(.send:not(:disabled)) .input-icons { display: none; }

.avatar.photo { background-size: cover; background-position: center; }
.gear { position: fixed; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: #2a2a2d; color: #ddd; display: grid; place-items: center; cursor: pointer; z-index: 20; }
.gear:hover { background: #38383c; }
.gear svg { width: 21px; height: 21px; }
.panel {
  position: fixed; top: 64px; right: 16px; bottom: 16px; width: 340px; overflow-y: auto; z-index: 20;
  background: #26262a; color: #eee; border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); font-size: 13px;
}
.panel[hidden] { display: none; }
.panel h2 { font-size: 16px; margin-bottom: 4px; }
.panel label { display: flex; flex-direction: column; gap: 5px; color: #a0a0a5; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.panel label.check { flex-direction: row; align-items: center; gap: 8px; text-transform: none; font-size: 13px; color: #eee; }
.panel small { color: #77777c; font-size: 11px; margin-top: -6px; }
.panel input:not([type=checkbox]):not([type=file]), .panel select, .panel textarea {
  font: inherit; font-size: 13px; text-transform: none; letter-spacing: 0; color: #eee; background: #1a1a1d; border: 1px solid #38383c; border-radius: 8px; padding: 8px 10px; outline: 0;
}
.panel textarea { resize: vertical; }
.panel input:focus, .panel select:focus, .panel textarea:focus { border-color: #7b3ff2; }
.panel .apply { font: inherit; font-weight: 600; border: 0; border-radius: 10px; background: #7b3ff2; color: #fff; padding: 10px; cursor: pointer; flex: none; }
.panel .filebtn button { font: inherit; font-size: 13px; text-transform: none; letter-spacing: 0; width: 100%; color: #eee; background: #1a1a1d; border: 1px dashed #4a4a50; border-radius: 8px; padding: 10px; cursor: pointer; transition: .2s; }
.panel .filebtn button:hover { border-color: #7b3ff2; color: #fff; }
.panel .wipe { font: inherit; border: 1px solid #5a2a2a; border-radius: 10px; background: none; color: #ff7b7b; padding: 9px; cursor: pointer; flex: none; }
@media (max-width: 900px) { .gear, .panel { display: none !important; } }

@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 480px) {
  .stage { padding: 0; }
  .phone { width: 100%; height: 100dvh; max-height: none; border-radius: 0; padding: 0; background: #000; box-shadow: none; }
  .notch { display: none; }
  .screen { border-radius: 0; }
  .statusbar { padding-top: calc(14px + env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; scroll-behavior: auto !important; } }
