:root {
  --green: #008069; --green-dark: #00664f; --accent: #25d366; --out: #d9fdd3; --in: #ffffff;
  --text: #111b21; --muted: #667781; --tick: #53bdeb; --wall: #efeae2; --link: #027eb5;
  --shadow: 0 1px .5px rgba(11,20,26,.13);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #d1d7db; font-family: "Segoe UI", Helvetica, Roboto, Arial, sans-serif; color: var(--text); }
body { display: flex; justify-content: center; align-items: center; }
.phone { position: relative; width: 100%; max-width: 420px; height: 100dvh; max-height: 900px; display: flex; flex-direction: column;
  background: var(--wall); overflow: hidden; }
@media (min-width: 500px) { .phone { border-radius: 28px; height: 92dvh; box-shadow: 0 20px 60px rgba(0,0,0,.25); border: 10px solid #111; } }

/* header */
.bar { position: relative; display: flex; align-items: center; gap: 4px; padding: 8px 4px 8px 2px; background: var(--green); color: #fff; z-index: 3; }
.icon { background: none; border: 0; color: inherit; padding: 8px; display: grid; place-items: center; cursor: pointer; border-radius: 50%; }
.icon svg { width: 22px; height: 22px; fill: currentColor; }
.icon.small svg { width: 24px; height: 24px; }
.back svg { width: 24px; height: 24px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #fff; display: grid; place-items: center; overflow: hidden; flex: none; }
.avatar img { width: 32px; height: 32px; }
.who { flex: 1; min-width: 0; padding-left: 6px; }
.name { font-size: 16.5px; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.verified { width: 16px; height: 16px; }
.status { font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: absolute; right: 8px; top: 52px; background: #fff; color: var(--text); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.2); padding: 6px 0; min-width: 210px; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 12px 18px; font-size: 15px; cursor: pointer; }

/* chat */
.chat { flex: 1; overflow-y: auto; padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 2px;
  background-color: var(--wall);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23d6cfc4' stroke-width='1.2' opacity='.55'%3E%3Cpath d='M18 22c6-8 16-8 22 0M70 18l8 8-8 8-8-8zM98 60a8 8 0 1016 0 8 8 0 10-16 0M20 80c4 6 12 6 16 0M60 92h16M64 64c-4 4-4 10 0 14M92 100l6-10 6 10z'/%3E%3C/g%3E%3C/svg%3E"); }
.day { align-self: center; margin: 6px 0; }
.day span { background: #fff; color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.notice { align-self: center; max-width: 92%; background: #ffeecd; color: #54656f; font-size: 12.5px; text-align: center; padding: 6px 10px; border-radius: 8px; margin: 4px 0 10px; box-shadow: var(--shadow); }

.msg { position: relative; max-width: 82%; padding: 6px 8px 8px 9px; border-radius: 8px; font-size: 14.6px; line-height: 1.38;
  box-shadow: var(--shadow); word-wrap: break-word; white-space: pre-wrap; margin-top: 2px; animation: pop .16s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.msg.out { align-self: flex-end; background: var(--out); border-top-right-radius: 0; }
.msg.in { align-self: flex-start; background: var(--in); border-top-left-radius: 0; }
.msg.tail.out::before, .msg.tail.in::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; }
.msg.tail.out::before { right: -8px; background: var(--out); clip-path: polygon(0 0, 100% 0, 0 100%); }
.msg.tail.in::before { left: -8px; background: var(--in); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.msg.gap { margin-top: 8px; }
.meta { float: right; margin: 6px 0 -4px 10px; font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.ticks { width: 16px; height: 11px; }
.ticks path { fill: #8696a0; } .ticks.read path { fill: var(--tick); }
.msg img.photo { display: block; width: 100%; max-width: 260px; border-radius: 6px; margin: -2px -3px 4px; cursor: zoom-in; }
.msg.photo-only { padding: 3px; }
.msg.photo-only .meta { position: absolute; right: 8px; bottom: 6px; color: #fff; text-shadow: 0 0 3px rgba(0,0,0,.6); margin: 0; }
.msg b { font-weight: 600; }
.heard { font-style: italic; color: #54656f; }

/* interactive buttons */
.btns { align-self: flex-start; max-width: 82%; width: 82%; display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.btns button { background: #fff; border: 0; border-radius: 8px; padding: 10px; color: var(--link); font-size: 14.5px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; gap: 6px; }
.btns button:disabled { color: #8696a0; cursor: default; }
.btns svg { width: 16px; height: 16px; fill: currentColor; }

/* voice */
.voice { display: flex; align-items: center; gap: 8px; min-width: 230px; padding: 2px 0 6px; }
.voice .play { width: 34px; height: 34px; border: 0; background: none; color: #54656f; cursor: pointer; display: grid; place-items: center; }
.voice .play svg { width: 28px; height: 28px; fill: currentColor; }
.wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; }
.wave i { width: 3px; border-radius: 2px; background: #b7c0c5; }
.wave i.on { background: #54656f; }
.msg.out .wave i.on { background: #1e8a6e; }
.vdur { font-size: 11px; color: var(--muted); position: absolute; left: 52px; bottom: 6px; }
.vavatar { width: 40px; height: 40px; border-radius: 50%; background: #dfe5e7; display: grid; place-items: center; position: relative; flex: none; }
.vavatar img { width: 30px; }
.vavatar .mic { position: absolute; right: -4px; bottom: -2px; width: 18px; height: 18px; fill: var(--tick); }

/* typing */
.typing { align-self: flex-start; background: #fff; border-radius: 8px; border-top-left-radius: 0; padding: 12px 14px; box-shadow: var(--shadow); display: flex; gap: 4px; margin-top: 8px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #a0aab0; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* input */
.input { display: flex; align-items: flex-end; gap: 6px; padding: 6px 6px calc(8px + env(safe-area-inset-bottom)); background: transparent; }
.field { flex: 1; display: flex; align-items: flex-end; background: #fff; border-radius: 24px; padding: 2px 4px; box-shadow: var(--shadow); color: #8696a0; min-height: 48px; }
.field textarea { flex: 1; border: 0; outline: 0; resize: none; font: inherit; font-size: 16px; padding: 13px 4px; max-height: 120px; color: var(--text); background: transparent; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: var(--shadow); }
.round svg { width: 24px; height: 24px; fill: currentColor; }
.round.rec { background: #e53935; animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(229,57,53,.2); } }

.attach { position: absolute; left: 10px; right: 10px; bottom: 66px; background: #fff; border-radius: 16px; padding: 20px 10px; display: flex; justify-content: space-around; box-shadow: 0 6px 24px rgba(0,0,0,.18); z-index: 4; }
.attach button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: #54656f; cursor: pointer; }
.attach .ai { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; }
.attach .ai svg { width: 26px; height: 26px; fill: #fff; }

.recording { position: absolute; left: 6px; right: 60px; bottom: calc(8px + env(safe-area-inset-bottom)); height: 48px; background: #fff; border-radius: 24px; display: flex; align-items: center; gap: 10px; padding: 0 16px; z-index: 5; box-shadow: var(--shadow); font-size: 15px; }
.recording .dot { width: 10px; height: 10px; border-radius: 50%; background: #e53935; animation: blink 1s infinite; }
.recording .hint { flex: 1; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recording .cancel { border: 0; background: none; color: #e53935; font-weight: 600; cursor: pointer; }

.preview { position: absolute; inset: 0; background: #0b141a; z-index: 10; display: flex; flex-direction: column; }
.preview .ptop { padding: 8px; color: #fff; }
.preview img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.preview .pbottom { display: flex; gap: 8px; padding: 10px; align-items: center; }
.preview input { flex: 1; border: 0; border-radius: 24px; padding: 13px 16px; font-size: 16px; background: #2a3942; color: #fff; outline: 0; }

.sheet { position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 9; display: flex; align-items: flex-end; }
.sheet-card { background: #fff; width: 100%; border-radius: 16px 16px 0 0; padding: 14px 14px 22px; display: flex; flex-direction: column; gap: 6px; }
.sheet-title { font-weight: 600; padding: 6px 4px 10px; }
.sheet-card button { text-align: left; border: 0; background: #f0f2f5; border-radius: 10px; padding: 13px 14px; font-size: 15px; cursor: pointer; }
.sheet-card .ghost { background: none; text-align: center; color: var(--green); font-weight: 600; }
.loc { display: block; width: 240px; }
.loc .map { height: 120px; border-radius: 6px; background: linear-gradient(135deg, #cfe8c4, #e8f0d8 40%, #d8e7f3); position: relative; margin: -2px -3px 6px; }
.loc .map::after { content: "📍"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -70%); font-size: 30px; }
.loc .lname { font-weight: 500; }
.lightbox { position: absolute; inset: 0; background: rgba(0,0,0,.92); z-index: 20; display: grid; place-items: center; }
.lightbox img { max-width: 100%; max-height: 100%; }
