/* Zaram inbox - mobile first, no framework, no build step. */
:root {
  --accent: #7C3AED;
  --accent-dark: #5B21B6;
  --bg: #FAFAFD;
  --panel: #FFFFFF;
  --line: #E6E6EF;
  --ink: #1B1B2B;
  --ink-dim: #6B6B84;
  --in-bubble: #F2F2F7;
  --out-bubble: #7C3AED;
  --out-ink: #FFFFFF;
  --danger: #DC2626;
  --unread: #FF5555;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14141F;
    --panel: #1B1B2B;
    --line: #2C2C3F;
    --ink: #F2F2F7;
    --ink-dim: #A0A0B4;
    --in-bubble: #262636;
    --out-bubble: #6D28D9;
  }
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: contain;
}

/* ---- shared chrome ---- */
.view { display: flex; flex-direction: column; height: 100%; }
.view[hidden] { display: none; }

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: var(--accent-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}
.bar h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-actions { display: flex; align-items: center; gap: 4px; }
.inline { display: inline; margin: 0; }
.icon-btn {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,.18); }
.icon-btn svg { width: 22px; height: 22px; display: block; fill: currentColor; }
#back { padding: 8px 6px 8px 2px; }
.sub-small { font-size: 12px; opacity: .85; }

.status {
  margin: 0;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ink-dim);
  min-height: 0;
}
.status.err { color: var(--danger); }
.status:empty { display: none; }
.empty { padding: 32px 24px; text-align: center; color: var(--ink-dim); }

/* ---- conversation list ---- */
.conversations { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conversations li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
}
.conversations li:active { background: var(--in-bubble); }
.avatar {
  flex: 0 0 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
}
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; justify-content: space-between; gap: 8px; }
.row-name { font-weight: 600; font-size: 15px; }
.row-when { font-size: 12px; color: var(--ink-dim); flex: 0 0 auto; }
.row-text {
  color: var(--ink-dim);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
li.is-unread .row-name, li.is-unread .row-text { color: var(--ink); font-weight: 600; }
.badge {
  flex: 0 0 auto;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--unread);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---- thread ---- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.day {
  align-self: center;
  font-size: 12px;
  color: var(--ink-dim);
  margin: 10px 0 4px;
}
.msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
}
.msg.in  { align-self: flex-start; background: var(--in-bubble); color: var(--ink);
           border-bottom-left-radius: 6px; }
.msg.out { align-self: flex-end; background: var(--out-bubble); color: var(--out-ink);
           border-bottom-right-radius: 6px; }
.meta { display: block; font-size: 11px; margin-top: 3px; opacity: .7; }
.msg.pending { opacity: .55; }

.reply {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px);
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.reply textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* 16px or iOS zooms the page on focus */
}
.reply button {
  flex: 0 0 auto;
  padding: 10px 16px;
  border: 0;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.reply button:disabled { opacity: .5; }

/* ---- login ---- */
.login-body { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 22px;
}
.brand { text-align: center; margin-bottom: 18px; }
.brand img { border-radius: 14px; }
.brand h1 { font-size: 20px; margin: 10px 0 2px; }
.sub { color: var(--ink-dim); font-size: 14px; margin: 0; }
.login-card label {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.login-card input {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  margin-bottom: 14px;
}
.login-card button {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.error {
  background: rgba(220, 38, 38, .12);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  margin: 0 0 14px;
}
.note { color: var(--ink-dim); font-size: 14px; }
code { font-size: 13px; background: var(--in-bubble); padding: 1px 4px; border-radius: 4px; }
