:root {
  --page: #eef0ee;
  --page-ink: #1b2420;
  --page-muted: #5c6a63;
  --panel: #ffffff;
  --line: #d6dbd7;
  --accent: #0b7a63;
  --accent-ink: #ffffff;
  --danger: #b3402f;

  /* The phone keeps WhatsApp's own palette. */
  --wa-header: #0b7a63;
  --wa-header-ink: #ffffff;
  --wa-wall: #ece5dd;
  --wa-wall-dot: #e2d9cf;
  --wa-out: #d9fdd3;
  --wa-in: #ffffff;
  --wa-ink: #111b21;
  --wa-meta: #667781;
  --wa-link: #027eb5;
  --wa-tick-read: #34b7f1;
  --wa-composer: #f0f2f5;
  --wa-input: #ffffff;
  --wa-chip: #fdf4c5;
  --wa-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #101513;
    --page-ink: #e6ece8;
    --page-muted: #93a39a;
    --panel: #19201d;
    --line: #2b3530;
    --accent: #2fbf9f;
    --accent-ink: #06221b;
    --danger: #ef7a68;

    --wa-header: #1f2c34;
    --wa-wall: #0b141a;
    --wa-wall-dot: #111d24;
    --wa-out: #005c4b;
    --wa-in: #202c33;
    --wa-ink: #e9edef;
    --wa-meta: #8696a0;
    --wa-link: #53bdeb;
    --wa-composer: #1f2c34;
    --wa-input: #2a3942;
    --wa-chip: #182229;
    --wa-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.5);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--page-ink);
  font: 14px/1.45 "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- page chrome ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.bar-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.bar-title strong {
  font-size: 16px;
  letter-spacing: 0.02em;
}

.bar-title span {
  color: var(--page-muted);
}

.bar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
}

a.chip {
  color: inherit;
  text-decoration: none;
}

.chip:hover,
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.stage {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 24px 20px 40px;
  overflow-x: auto;
}

.phones {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

/* ---------- a phone ---------- */

.phone-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 372px;
  flex: none;
}

.phone-setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.phone-setup label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--page-muted);
  font-size: 12px;
}

.phone-setup input {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--page-ink);
}

.phone-setup .wide {
  grid-column: 1 / -1;
}

.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 700px;
  border: 9px solid #12181b;
  border-radius: 34px;
  overflow: hidden;
  background: var(--wa-wall);
  color: var(--wa-ink);
}

.wa-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--wa-header);
  color: var(--wa-header-ink);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 600;
  flex: none;
}

.wa-head .who {
  min-width: 0;
  flex: 1;
}

.wa-head .who strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-head .who span {
  display: block;
  font-size: 12px;
  opacity: 0.85;
}

.wa-head .remove {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  font-size: 18px;
  line-height: 1;
}

.wa-head .remove:hover {
  opacity: 1;
}

.wa-chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background-color: var(--wa-wall);
  background-image: radial-gradient(var(--wa-wall-dot) 1.2px, transparent 1.3px);
  background-size: 18px 18px;
}

.wa-day {
  align-self: center;
  margin: 6px 0 8px;
  padding: 4px 10px;
  border-radius: 7px;
  background: var(--wa-chip);
  color: var(--wa-meta);
  font-size: 12px;
  box-shadow: var(--wa-shadow);
}

.wa-empty {
  margin: auto;
  max-width: 250px;
  padding: 10px 14px;
  text-align: center;
  border-radius: 8px;
  background: var(--wa-chip);
  color: var(--wa-meta);
  font-size: 13px;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  gap: 3px;
}

.msg.out {
  align-self: flex-end;
  align-items: flex-end;
}

.msg.in {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  position: relative;
  padding: 6px 8px 5px 9px;
  border-radius: 8px;
  box-shadow: var(--wa-shadow);
  background: var(--wa-in);
  min-width: 64px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg.out .bubble {
  background: var(--wa-out);
  border-top-right-radius: 0;
}

.msg.in .bubble {
  border-top-left-radius: 0;
}

.bubble .body {
  white-space: pre-wrap;
  font-size: 14.2px;
  line-height: 1.38;
}

.bubble .body.media {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--wa-meta);
  font-style: italic;
}

.bubble .tag {
  display: block;
  margin-bottom: 2px;
  color: var(--wa-meta);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bubble .foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  margin-top: 1px;
  color: var(--wa-meta);
  font-size: 11px;
  line-height: 1;
}

.ticks {
  display: inline-flex;
  font-size: 13px;
  letter-spacing: -0.28em;
}

.ticks.read {
  color: var(--wa-tick-read);
}

.ticks.failed {
  color: var(--danger);
  letter-spacing: 0;
  font-weight: 700;
}

.retry {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--danger);
  font-size: 11.5px;
  text-decoration: underline;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  min-width: 190px;
}

.choice {
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--wa-in);
  color: var(--wa-link);
  font-weight: 500;
  text-align: center;
  box-shadow: var(--wa-shadow);
}

.choice:hover {
  filter: brightness(0.97);
}

.sheet {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 3;
  max-height: 70%;
  overflow-y: auto;
  padding: 12px 14px 16px;
  border-radius: 14px 14px 0 0;
  background: var(--wa-composer);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.3);
}

.sheet h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--wa-meta);
  font-weight: 600;
}

.sheet button.option {
  display: block;
  width: 100%;
  padding: 11px 6px;
  border: 0;
  border-bottom: 1px solid var(--wa-wall-dot);
  background: transparent;
  text-align: left;
}

.sheet button.cancel {
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: var(--wa-link);
}

.wa-compose {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  background: var(--wa-composer);
}

.wa-compose textarea {
  flex: 1;
  min-height: 38px;
  max-height: 110px;
  padding: 8px 12px;
  border: 0;
  border-radius: 20px;
  background: var(--wa-input);
  color: var(--wa-ink);
  resize: none;
  line-height: 1.3;
}

.round {
  width: 38px;
  height: 38px;
  flex: none;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--wa-meta);
  font-size: 19px;
}

.round.send {
  background: var(--wa-header);
  color: #fff;
}

.attach-menu {
  position: absolute;
  left: 8px;
  bottom: 54px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: 6px;
  border-radius: 12px;
  background: var(--wa-in);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}

.attach-menu button {
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.attach-menu button:hover {
  background: var(--wa-composer);
}

/* ---------- developer tools ---------- */

.dev {
  flex: none;
  width: 330px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.dev[hidden] {
  display: none;
}

.dev h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.dev fieldset {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.dev legend {
  padding: 0 6px;
  color: var(--page-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dev label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
}

.dev input,
.dev select,
.dev textarea {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--page);
  color: var(--page-ink);
}

.dev .row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dev .row.end {
  justify-content: flex-end;
}

.dev button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
}

.dev button.primary,
dialog button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.dev button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.hint {
  margin: 0;
  color: var(--page-muted);
  font-size: 12.5px;
}

.steps {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--page-muted);
}

.steps li + li {
  margin-top: 4px;
}

dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--page-ink);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

dialog h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

dialog p {
  margin: 0 0 12px;
  color: var(--page-muted);
}

dialog input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--page);
  color: var(--page-ink);
}

dialog button {
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
}

.error {
  color: var(--danger);
}

@media (max-width: 720px) {
  .stage {
    flex-direction: column;
    align-items: stretch;
  }

  .phones {
    flex-direction: column;
    align-items: center;
  }

  .dev {
    width: auto;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .msg {
    animation: pop 0.14s ease-out;
  }

  @keyframes pop {
    from {
      opacity: 0;
      transform: translateY(4px);
    }
  }
}
