:root {
  --imsg-blue: #0b93f6;
  --recv-gray: #e9e9eb;
  --sf: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--sf);
  background: linear-gradient(160deg, #e6f5f0 0%, #dcefe9 40%, #cfe8e2 100%);
  overflow: hidden;
}

/* ---- viewport / phone frame ---- */
.wa-viewport {
  height: 100vh; width: 100vw;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.wa-phone {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 900px;
  background: #000;
  border-radius: 46px;
  padding: 8px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4), 0 0 0 2px #2a2a2a;
  overflow: hidden;
}
@media (max-width: 440px) {
  .wa-viewport { padding: 0; }
  .wa-phone { border-radius: 0; padding: 0; max-height: none; box-shadow: none; }
}
.wa-home, .wa-convo {
  position: relative;
  height: 100%;
  border-radius: 40px;
  overflow: hidden;
  display: flex; flex-direction: column;
  background: #fff;
}
@media (max-width: 440px) { .wa-home, .wa-convo { border-radius: 0; } }

/* ---- status bar ---- */
.wa-statusbar {
  height: 46px; flex: 0 0 46px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: relative; z-index: 5;
  font-weight: 600; font-size: 15px;
}
.wa-notch {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
  width: 90px; height: 26px; background: #000; border-radius: 20px;
}
.wa-time { min-width: 40px; }
.wa-status-right { display: flex; align-items: center; gap: 5px; }
.wa-sig { font-size: 9px; letter-spacing: -1px; }
.wa-wifi { font-size: 11px; }
.wa-battery {
  width: 24px; height: 12px; border: 1.5px solid currentColor; border-radius: 3px;
  padding: 1px; position: relative;
}
.wa-battery-fill { height: 100%; border-radius: 1px; transition: width .5s; }

/* ---- HOME ---- */
.wa-home { color: #fff; background-size: cover; background-position: center; }
.wa-home .wa-statusbar { color: #fff; }
.wa-home-scroll { flex: 1; overflow-y: auto; padding: 6px 18px 30px; -webkit-overflow-scrolling: touch; }
.wa-home-title { font-size: 42px; font-weight: 800; margin: 6px 0 0; letter-spacing: -1px; text-shadow: 0 2px 20px rgba(0,0,0,0.5); }
.wa-home-sub { margin: 2px 0 20px; font-size: 15px; opacity: .85; font-style: italic; }

.wa-featured {
  border-radius: 26px; overflow: hidden; cursor: pointer;
  background: rgba(20,10,20,0.55); backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 22px; box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}
.wa-featured-img { height: 150px; background-size: cover; background-position: center; position: relative; }
.wa-live {
  position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.55); padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 1px;
}
.wa-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff2d2d; box-shadow: 0 0 8px #ff2d2d; animation: wa-pulse 1.2s infinite; }
@keyframes wa-pulse { 0%,100%{opacity:1;transform:scale(1);} 50%{opacity:.4;transform:scale(1.4);} }
.wa-featured-body { padding: 14px 16px 18px; }
.wa-featured-title { font-size: 20px; font-weight: 700; }
.wa-featured-sub { font-size: 13px; opacity: .8; margin: 4px 0 12px; }
.wa-help-btn {
  background: #ff2d2d; color: #fff; border: none; font-weight: 700; font-size: 15px;
  padding: 10px 24px; border-radius: 22px; cursor: pointer; font-family: var(--sf);
  box-shadow: 0 6px 16px rgba(255,45,45,0.4);
}
.wa-help-btn:active { transform: scale(.96); }

.wa-grid-label { font-size: 12px; font-weight: 700; letter-spacing: 2px; opacity: .7; margin: 6px 4px 12px; }
.wa-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 460px) { .wa-grid { grid-template-columns: repeat(3, 1fr); } }
.wa-card {
  cursor: pointer; border-radius: 22px; overflow: hidden;
  background: rgba(20,10,20,0.5); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1); transition: transform .15s;
}
.wa-card:active { transform: scale(.95); }
.wa-card-img { height: 110px; background-size: cover; background-position: center; position: relative; }
.wa-card-badge { position: absolute; top: 8px; right: 8px; font-size: 18px; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6)); }
.wa-card-title { font-size: 14px; font-weight: 700; padding: 8px 10px 2px; line-height: 1.2; }
.wa-card-danger { font-size: 10px; opacity: .75; padding: 0 10px 10px; font-weight: 600; }

.wa-settings { display: flex; gap: 10px; margin: 26px 0 14px; }
.wa-set-btn {
  flex: 1; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; padding: 10px; border-radius: 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: var(--sf); backdrop-filter: blur(8px);
}
.wa-set-btn:active { transform: scale(.97); }
.wa-home-footer { text-align: center; font-size: 12px; opacity: .7; margin-top: 8px; }
.wa-home-footer a { color: #fff; text-decoration: underline; }

/* ---- CONVERSATION ---- */
.wa-convo { background: #fff; color: #000; }
.wa-convo.wa-shake { animation: wa-shake .45s; }
@keyframes wa-shake {
  0%,100%{transform:translate(0,0);} 20%{transform:translate(-4px,2px);}
  40%{transform:translate(4px,-2px);} 60%{transform:translate(-3px,-2px);} 80%{transform:translate(3px,2px);}
}

.wa-header {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px 12px; background: rgba(250,250,252,0.9); backdrop-filter: blur(14px);
  border-bottom: 0.5px solid #dcdce0;
}
.wa-back { background: none; border: none; color: var(--imsg-blue); font-size: 34px; line-height: 1; cursor: pointer; width: 34px; }
.wa-facetime { background: none; border: none; color: var(--imsg-blue); font-size: 22px; cursor: pointer; width: 34px; }
.wa-contact { display: flex; flex-direction: column; align-items: center; }
.wa-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #d0d0d5; }
.wa-contact-name { font-size: 12px; font-weight: 600; margin-top: 3px; }
.wa-chev { color: #b0b0b5; }

.wa-messages { flex: 1; overflow-y: auto; padding: 12px 12px 4px; -webkit-overflow-scrolling: touch; }
.wa-imessage-label { text-align: center; font-size: 11px; color: #8e8e93; margin: 4px 0 14px; font-weight: 600; }

.wa-row { display: flex; margin: 3px 0; }
.wa-row-them { justify-content: flex-start; }
.wa-row-me { justify-content: flex-end; }
.wa-bubble {
  max-width: 74%; padding: 9px 14px; border-radius: 20px; font-size: 16px; line-height: 1.35;
  word-wrap: break-word; animation: wa-pop .22s ease-out;
}
@keyframes wa-pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.wa-bubble-them { background: var(--recv-gray); color: #000; border-bottom-left-radius: 6px; }
.wa-bubble-me { background: var(--imsg-blue); color: #fff; border-bottom-right-radius: 6px; }
.wa-delivered { text-align: right; font-size: 11px; color: #8e8e93; margin: 1px 4px 6px; }

.wa-img-bubble { max-width: 62%; border-radius: 18px; overflow: hidden; background: #000; animation: wa-pop .22s; }
.wa-img { width: 100%; display: block; filter: brightness(.85) contrast(1.1); }
.wa-img-cap { padding: 6px 10px; color: #eee; font-size: 13px; background: #111; }

.wa-sys { text-align: center; color: #c0392b; font-size: 13px; font-weight: 600; margin: 10px 0; animation: wa-pop .3s; }

.wa-typing { display: flex; gap: 4px; align-items: center; padding: 12px 16px; }
.wa-dot { width: 8px; height: 8px; border-radius: 50%; background: #9a9a9f; animation: wa-blink 1.2s infinite; }
.wa-dot:nth-child(2){animation-delay:.2s;} .wa-dot:nth-child(3){animation-delay:.4s;}
@keyframes wa-blink { 0%,60%,100%{opacity:.3;transform:translateY(0);} 30%{opacity:1;transform:translateY(-3px);} }

/* ---- choices tray ---- */
.wa-choices {
  flex: 0 0 auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px;
  background: rgba(248,248,250,0.92); backdrop-filter: blur(10px); border-top: 0.5px solid #e2e2e6;
  animation: wa-slideup .25s ease-out;
}
@keyframes wa-slideup { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.wa-choice {
  background: #fff; border: 1.5px solid #d5d5da; border-radius: 22px; padding: 12px 16px;
  font-size: 15px; font-family: var(--sf); text-align: left; cursor: pointer; color: #111;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05); transition: transform .12s, background .12s;
}
.wa-choice:active { transform: scale(.98); background: #eef4ff; border-color: var(--imsg-blue); }

/* ---- cut menu animation ---- */
.wa-cutmenu {
  flex: 0 0 auto; padding: 8px 14px; background: rgba(248,248,250,0.95);
  border-top: 0.5px solid #e2e2e6; animation: wa-cutfade .25s;
}
@keyframes wa-cutfade { from { opacity: 0; } to { opacity: 1; } }
.wa-cut-ctx {
  display: inline-block; background: #2a2a2e; color: #fff; font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 12px; margin-bottom: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.wa-cut-text {
  background: #cfe0ff; color: #333; font-size: 14px; padding: 6px 12px; border-radius: 10px;
  margin: 4px 0; animation: wa-cutaway .9s forwards;
}
@keyframes wa-cutaway {
  0% { opacity: 1; transform: translateX(0) scale(1); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translateX(60px) scale(.6); height: 0; padding: 0; margin: 0; }
}

/* ---- input bar ---- */
.wa-inputbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: rgba(250,250,252,0.95); border-top: 0.5px solid #e2e2e6;
}
.wa-plus { width: 34px; height: 34px; border-radius: 50%; background: #e5e5ea; color: #6b6b70; font-size: 24px; display: flex; align-items: center; justify-content: center; }
.wa-input {
  flex: 1; min-height: 36px; border: 1.5px solid #d5d5da; border-radius: 20px;
  display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 14px;
  font-size: 16px; transition: border-color .2s;
}
.wa-input-active { border-color: var(--imsg-blue); }
.wa-input-text { color: #111; }
.wa-input-ph { color: #b0b0b5; }
.wa-caret { display: inline-block; width: 2px; height: 18px; background: var(--imsg-blue); margin-left: 1px; vertical-align: middle; animation: wa-caret 1s step-end infinite; }
@keyframes wa-caret { 0%,50%{opacity:1;} 51%,100%{opacity:0;} }
.wa-mic { color: #8e8e93; font-size: 18px; padding-right: 8px; }
.wa-send {
  width: 30px; height: 30px; border-radius: 50%; background: var(--imsg-blue); color: #fff;
  border: none; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  animation: wa-pop .2s;
}

/* ---- keyboard ---- */
.wa-keyboard { flex: 0 0 auto; background: #d1d3d9; padding: 6px 4px 8px; user-select: none; }
.wa-suggest { display: flex; justify-content: space-around; padding: 6px 0 10px; font-size: 15px; color: #333; }
.wa-suggest-mid { padding: 0 20px; border-left: 0.5px solid #b0b0b5; border-right: 0.5px solid #b0b0b5; }
.wa-krow { display: flex; justify-content: center; gap: 5px; margin: 4px 2px; }
.wa-krow-last { justify-content: space-between; padding: 0 2px; }
.wa-key {
  background: #fff; border-radius: 6px; min-width: 28px; height: 40px; flex: 1;
  display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 400;
  box-shadow: 0 1px 0 rgba(0,0,0,0.25); max-width: 34px;
}
.wa-key-active { background: #a5c8ff; transform: scale(1.15); }
.wa-key-fn { background: #adb3bd; max-width: 44px; min-width: 40px; }
.wa-krow-bottom { display: flex; gap: 5px; margin: 4px 2px 0; }
.wa-key-123 { flex: 0 0 auto; min-width: 44px; }
.wa-key-space { flex: 1; max-width: none; font-size: 14px; }
.wa-key-return { flex: 0 0 auto; min-width: 74px; max-width: 90px; background: #adb3bd; cursor: pointer; }

/* ---- ending overlay ---- */
.wa-ending {
  position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 30px;
  animation: wa-fadein .8s; color: #fff;
}
.wa-ending-bad { background: radial-gradient(circle at center, #300 0%, #000 80%); }
.wa-ending-good { background: radial-gradient(circle at center, #06381f 0%, #011a0f 80%); }
@keyframes wa-fadein { from { opacity: 0; } to { opacity: 1; } }
.wa-ending-icon { font-size: 72px; margin-bottom: 12px; animation: wa-pulse 1.6s infinite; }
.wa-ending-title { font-size: 30px; font-weight: 800; letter-spacing: 2px; }
.wa-ending-label { font-size: 14px; opacity: .8; margin: 10px 0 30px; }
.wa-ending-btns { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 260px; }
.wa-ending-btn {
  padding: 14px; border-radius: 24px; border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; font-family: var(--sf);
}
.wa-ending-retry { background: #fff; color: #111; border: none; }
.wa-ending-btn:active { transform: scale(.97); }

/* scrollbars */
.wa-messages::-webkit-scrollbar, .wa-home-scroll::-webkit-scrollbar { width: 0; }