/* Reem AI (spec §6.2, mockups in docs/superpowers/specs/2026-11-05-reem-ai-mockups/).
   Works on Safari 12: no flexbox gap (margins instead), no dynamic viewport units, no :has(),
   no aspect-ratio. */

:root {
  --ground: #fbf3f1;
  --dot: #f0d9df;
  --mine: #f6d5de;
  --reply: #ffffff;
  --text: #3a2a33;
  --muted: #6e5562;
  --placeholder: #7a6470;
  --accent: #b4466a;
  --attach: #ede4f7;
  --attach-icon: #5b3f86;
  --border: #ebd7dd;
  --bar-border: #f0dde2;
  --fs: 18px;
  --fs-preview: 15px;
  --fs-time: 12px;
  --radius: 20px;
  --bubble-max: 82%;
  --column: 100%;
  --control: 54px;
  --bar: 64px;
  --flower-pink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'%3E%3Cg fill='%23F3C6D1' fill-opacity='.85'%3E%3Ccircle cx='14' cy='7' r='5'/%3E%3Ccircle cx='20.7' cy='11.8' r='5'/%3E%3Ccircle cx='18.1' cy='19.7' r='5'/%3E%3Ccircle cx='9.9' cy='19.7' r='5'/%3E%3Ccircle cx='7.3' cy='11.8' r='5'/%3E%3C/g%3E%3Ccircle cx='14' cy='14' r='3' fill='%23F6E3A1'/%3E%3C/svg%3E");
  --flower-lilac: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'%3E%3Cg fill='%23DCCFF0' fill-opacity='.8'%3E%3Ccircle cx='14' cy='7' r='5'/%3E%3Ccircle cx='20.7' cy='11.8' r='5'/%3E%3Ccircle cx='18.1' cy='19.7' r='5'/%3E%3Ccircle cx='9.9' cy='19.7' r='5'/%3E%3Ccircle cx='7.3' cy='11.8' r='5'/%3E%3C/g%3E%3Ccircle cx='14' cy='14' r='3' fill='%23F6E3A1'/%3E%3C/svg%3E");
  --sparkle-pink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 0C7.6 4.2 9.8 6.4 14 7C9.8 7.6 7.6 9.8 7 14C6.4 9.8 4.2 7.6 0 7C4.2 6.4 6.4 4.2 7 0Z' fill='%23EBB3C2'/%3E%3C/svg%3E");
  --sparkle-lilac: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 0C7.6 4.2 9.8 6.4 14 7C9.8 7.6 7.6 9.8 7 14C6.4 9.8 4.2 7.6 0 7C4.2 6.4 6.4 4.2 7 0Z' fill='%23C9B6E6'/%3E%3C/svg%3E");
}

@media (min-width: 700px) {
  :root {
    --radius: 22px;
    --bubble-max: 78%;
    --column: 640px;
    --control: 60px;
    --bar: 76px;
  }
}

@media (orientation: landscape) and (min-width: 1000px) {
  :root {
    --column: 720px;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: "Tajawal", "Geeza Pro", "Arial", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow: hidden;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: var(--app-height, 100vh);
  display: flex;
  flex-direction: column;
  background-color: var(--ground);
  background-image: var(--flower-lilac), var(--flower-pink), var(--flower-pink), var(--flower-lilac),
    var(--flower-pink), var(--sparkle-pink), var(--sparkle-lilac), var(--sparkle-pink),
    radial-gradient(var(--dot) 1.3px, transparent 1.5px);
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat,
    no-repeat, repeat;
  background-position: right 18px top 18%, left 16px top 38%, right 44px top 60%, left 40px bottom 14%,
    right 30% bottom 9%, left 70px top 24%, right 96px top 48%, left 48% bottom 22%, 0 0;
  background-size: 30px, 26px, 18px, 36px, 22px, 14px, 10px, 12px, 22px 22px;
}

@media (min-width: 700px) {
  .app {
    background-size: 52px, 44px, 38px, 60px, 30px, 16px, 12px, 18px, 26px 26px;
  }
}

/* Header */

.bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--bar);
  padding: env(safe-area-inset-top) 14px 0 12px;
  background: rgba(251, 243, 241, 0.92);
  border-bottom: 1px solid var(--bar-border);
}

.bar-start {
  display: flex;
  align-items: center;
  min-width: 0;
}

.back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: 4px;
  margin-right: -8px;
  border-radius: 50%;
  color: #5b3f4e;
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  margin-left: 8px;
}

.brand {
  font-family: "Baloo Bhaijaan 2", "Tajawal", sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

@media (min-width: 700px) {
  .brand {
    font-size: 29px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }
}

.size {
  display: flex;
  align-items: center;
  padding: 2px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.size-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #5b3f4e;
}

.size-btn[disabled] {
  opacity: 0.35;
  cursor: default;
}

.size-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

/* Scrolling area and the centered column */

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.column {
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 14px 16px 12px;
}

/* Chats list */

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  margin-top: 4px;
  padding: 0 20px;
  border-radius: 20px;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
  font-size: var(--fs);
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(180, 70, 106, 0.25);
}

.new-chat svg {
  margin-left: 10px;
}

.earlier {
  margin: 22px 4px 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.chat-row {
  display: flex;
  align-items: center;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(58, 42, 51, 0.05);
}

.avatar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin-left: 12px;
  border-radius: 50%;
  background: #f9e1e7;
}

.avatar.lilac {
  background: #eee6f8;
}

.row-text {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: block;
  font-size: var(--fs);
  font-weight: 700;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-preview {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-preview);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-date {
  flex: none;
  align-self: flex-start;
  margin-top: 4px;
  margin-right: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* Messages */

.thread {
  display: flex;
  flex-direction: column;
}

.day-chip {
  align-self: center;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.msg {
  max-width: var(--bubble-max);
  margin-top: 12px;
  padding: 12px 14px 8px;
  border-radius: var(--radius);
  font-size: var(--fs);
  line-height: 1.7;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg.mine {
  align-self: flex-start; /* the right side, in right-to-left */
  background: var(--mine);
  border-top-right-radius: 6px;
}

.msg.reply {
  align-self: center;
  background: var(--reply);
  box-shadow: 0 1px 2px rgba(58, 42, 51, 0.06), 0 6px 18px rgba(180, 70, 106, 0.07);
}

@media (min-width: 700px) {
  .msg {
    padding: 14px 18px 10px;
  }
}

.msg-text {
  white-space: pre-wrap;
}

.msg-text a {
  color: var(--accent);
  text-decoration: underline;
}

.msg-time {
  margin-top: 4px;
  font-size: var(--fs-time);
  color: var(--muted);
  text-align: left;
}

.msg-photo {
  display: block;
  margin: 0 0 8px;
}

.msg-photo img {
  display: block;
  max-width: 100%;
  height: 140px;
  border-radius: 14px;
  object-fit: cover;
}

.msg-file {
  display: flex;
  align-items: center;
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-preview);
}

.msg-file svg {
  flex: none;
  margin-left: 8px;
}

.msg-note {
  margin-top: 6px;
  font-size: var(--fs-time);
  color: var(--accent);
  font-weight: 700;
}

.retry {
  display: inline-block;
  margin-top: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  font-size: var(--fs-preview);
  font-weight: 700;
}

.typing {
  display: flex;
  align-items: center;
  align-self: center;
  margin-top: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--reply);
  box-shadow: 0 1px 2px rgba(58, 42, 51, 0.06), 0 6px 18px rgba(180, 70, 106, 0.07);
}

.typing span {
  width: 9px;
  height: 9px;
  margin: 0 3px;
  border-radius: 50%;
  background: #e9a3b5;
  -webkit-animation: blink 1.2s infinite ease-in-out;
  animation: blink 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) {
  background: #d7a9e0;
  -webkit-animation-delay: 0.2s;
  animation-delay: 0.2s;
}

.typing span:nth-child(3) {
  -webkit-animation-delay: 0.4s;
  animation-delay: 0.4s;
}

@-webkit-keyframes blink {
  0%, 80%, 100% { opacity: 0.35; }
  40% { opacity: 1; }
}

@keyframes blink {
  0%, 80%, 100% { opacity: 0.35; }
  40% { opacity: 1; }
}

.holding {
  align-self: center;
  margin-top: 8px;
  max-width: var(--bubble-max);
  font-size: var(--fs-preview);
  color: var(--muted);
  text-align: center;
}

/* Composer */

.composer {
  flex: none;
  padding: 10px 0 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.composer .column {
  padding-top: 0;
  padding-bottom: 0;
}

.previews {
  display: flex;
  flex-wrap: wrap;
}

.preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 0 8px 8px;
  border-radius: 14px;
  background: #ead9e8;
  overflow: hidden;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview.loading {
  opacity: 0.55;
}

.preview-remove {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(58, 42, 51, 0.6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer-row {
  display: flex;
  align-items: flex-end;
}

.field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  min-height: var(--control);
  padding: 0 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 4px 14px rgba(180, 70, 106, 0.08);
}

.field textarea {
  flex: 1;
  min-width: 0;
  max-height: 140px;
  margin: 0;
  padding: 12px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: var(--fs);
  line-height: 1.5;
}

.field textarea::-webkit-input-placeholder {
  color: var(--placeholder);
}

.field textarea::placeholder {
  color: var(--placeholder);
}

.round {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control);
  height: var(--control);
  margin-right: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
}

.round.attach {
  background: var(--attach);
  color: var(--attach-icon);
}

.round.send {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(180, 70, 106, 0.28);
}

.round[disabled] {
  opacity: 0.5;
  cursor: default;
}

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Setup: only the add-to-home-screen line */

.setup {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.setup svg {
  width: 96px;
  height: 96px;
  margin-bottom: 20px;
}

.setup p {
  max-width: 420px;
  margin: 0;
  font-size: 22px;
  line-height: 1.7;
  font-weight: 500;
}

/* A photo shown full size, inside the page */

.msg-photo {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  background: rgba(58, 42, 51, 0.88);
}

.overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
}

.overlay-close {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
