/* رابط السر — dark mystery theme, RTL, mobile-first */

:root {
  --bg: #0c0a14;
  --bg2: #14101f;
  --bg3: #1c1730;
  --card: #171326;
  --border: #2a2342;
  --border2: #3a3158;
  --text: #efeaff;
  --text2: #a99fc7;
  --text3: #6e648d;
  --accent: #a855f7;
  --accent2: #7c3aed;
  --accent-soft: rgba(168, 85, 247, 0.14);
  --green: #34d399;
  --red: #f87171;
  --orange: #fb923c;
  --bubble-owner: #2d2450;
  --bubble-guest: #3b2f66;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Tajawal", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(800px 400px at 10% 110%, rgba(168, 85, 247, 0.10), transparent 60%),
    var(--bg);
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ─── layout shells ─────────────────────────── */
.shell {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 10px;
}
.topbar .back {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.topbar .back:active { transform: scale(0.94); }

/* ─── landing / claim ───────────────────────── */
.landing { text-align: center; padding-top: 11vh; }

.landing .logo {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 8px 30px rgba(168, 85, 247, 0.45));
  animation: floaty 4s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.landing h1 {
  margin-top: 18px;
  font-size: clamp(34px, 8vw, 46px);
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #f5f3ff 20%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.landing .tagline {
  margin-top: 10px;
  color: var(--text2);
  font-size: 17px;
  line-height: 1.7;
  max-width: 340px;
  margin-inline: auto;
}

.claim-card {
  margin-top: 34px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px 18px;
  text-align: right;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.claim-card label {
  display: block;
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 8px;
  font-weight: 500;
}
.claim-row { display: flex; gap: 10px; }
.claim-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1.5px solid var(--border2);
  border-radius: 14px;
  padding: 0 14px;
  transition: border-color 0.2s;
}
.claim-input-wrap:focus-within { border-color: var(--accent); }
.claim-input-wrap .prefix {
  color: var(--text3);
  font-size: 14px;
  direction: ltr;
  white-space: nowrap;
  user-select: none;
}
.claim-input-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  padding: 15px 8px;
  direction: ltr;
  text-align: left;
  min-width: 0;
}
.claim-input-wrap input::placeholder { color: var(--text3); font-weight: 400; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  border-radius: 14px;
  padding: 15px 22px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; box-shadow: none; }

.claim-note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text3);
  text-align: center;
  line-height: 1.6;
}

.result-card {
  margin-top: 34px;
  background: var(--card);
  border: 1.5px solid var(--accent);
  border-radius: 22px;
  padding: 24px 18px;
  box-shadow: 0 0 40px rgba(168, 85, 247, 0.2);
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }

.result-card .done { font-size: 40px; }
.result-card h2 { margin-top: 10px; font-size: 20px; font-weight: 800; }
.result-card p { color: var(--text2); font-size: 14px; margin-top: 6px; line-height: 1.6; }

.link-box {
  margin-top: 16px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 13.5px;
  color: var(--accent);
  direction: ltr;
  text-align: left;
  word-break: break-all;
  line-height: 1.5;
  user-select: all;
}
.result-actions { display: flex; gap: 10px; margin-top: 14px; }
.result-actions .btn-primary { flex: 1; font-size: 15px; padding: 13px; }
.btn-ghost {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  transition: background 0.15s;
}
.btn-ghost:active { background: var(--border); }

.key-warn {
  margin-top: 14px;
  background: rgba(251, 146, 60, 0.1);
  border: 1px solid rgba(251, 146, 60, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--orange);
  line-height: 1.7;
  text-align: right;
}

/* ─── chat page ─────────────────────────────── */
.chat-page { display: flex; flex-direction: column; height: 100dvh; max-width: 520px; margin: 0 auto; width: 100%; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(12, 10, 20, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.avatar.online::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0;
  width: 12px; height: 12px;
  background: var(--green);
  border: 2.5px solid var(--bg);
  border-radius: 50%;
}
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who .name { font-weight: 800; font-size: 16px; direction: ltr; text-align: right; }
.chat-head .who .status { font-size: 12.5px; color: var(--green); margin-top: 1px; }
.chat-head .who .status.off { color: var(--text3); }
.lock-badge {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--green);
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}
.msg-list::-webkit-scrollbar { width: 4px; }
.msg-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.day-sep {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  margin: 14px 0 8px;
}
.msg-row { display: flex; margin-top: 6px; }
.msg-row.mine { justify-content: flex-start; }   /* RTL: mine = right visually via direction */
.msg-row.theirs { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 11px 14px 7px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
  position: relative;
  animation: msgin 0.22s ease;
}
@keyframes msgin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.msg-row.mine .bubble {
  background: var(--bubble-guest);
  border-top-right-radius: 6px;
  border: 1px solid rgba(168, 85, 247, 0.18);
}
.msg-row.theirs .bubble {
  background: var(--bubble-owner);
  border-top-left-radius: 6px;
  border: 1px solid var(--border2);
}
.bubble .meta {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--text3);
}
.bubble .meta .tick { color: var(--accent); font-size: 12px; }

.typing-row { display: flex; margin-top: 6px; }
.typing {
  background: var(--bubble-owner);
  border: 1px solid var(--border2);
  border-radius: 18px;
  border-top-left-radius: 6px;
  padding: 13px 16px;
  display: flex;
  gap: 5px;
}
.typing i {
  width: 7px; height: 7px;
  background: var(--text3);
  border-radius: 50%;
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* icebreakers */
.icebar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px 2px;
  scrollbar-width: none;
}
.icebar::-webkit-scrollbar { display: none; }
.ice {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}
.ice:active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); transform: scale(0.96); }

/* notify banner */
.notify-banner {
  margin: 6px 16px 0;
  background: var(--accent-soft);
  border: 1px dashed rgba(168, 85, 247, 0.45);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text);
}
.notify-banner .txt { flex: 1; line-height: 1.5; }
.notify-banner button {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 10px;
  white-space: nowrap;
}
.notify-banner .x { color: var(--text3); font-size: 18px; padding: 0 4px; }

/* composer */
.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 10px 16px calc(12px + var(--safe-b));
  background: rgba(12, 10, 20, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1;
  background: var(--bg2);
  border: 1.5px solid var(--border2);
  border-radius: 22px;
  color: var(--text);
  font-size: 15.5px;
  padding: 13px 18px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.composer textarea:focus { border-color: var(--accent); }
.composer textarea::placeholder { color: var(--text3); }
.send-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center;
  font-size: 20px;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.4);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.4; box-shadow: none; }

/* thread / empty states */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 12px;
}
.empty .icon { font-size: 56px; opacity: 0.8; }
.empty h3 { font-size: 19px; font-weight: 800; }
.empty p { color: var(--text2); font-size: 14.5px; line-height: 1.7; max-width: 300px; }

/* ─── inbox (owner) ────────────────────────── */
.inbox-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 6px;
}
.inbox-title h1 { font-size: 24px; font-weight: 800; }
.unread-pill {
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 800;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.thread {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-top: 10px;
  transition: border-color 0.15s;
  cursor: pointer;
}
.thread:active { border-color: var(--accent); }
.thread .body { flex: 1; min-width: 0; }
.thread .row1 { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.thread .alias { font-weight: 700; font-size: 15.5px; }
.thread .time { font-size: 11.5px; color: var(--text3); white-space: nowrap; }
.thread .snippet {
  color: var(--text2);
  font-size: 13.5px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
}
.thread .unread {
  width: 20px; height: 20px;
  background: var(--accent);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.owner-bar {
  display: flex;
  gap: 8px;
  padding: 4px 0 2px;
}
.owner-bar .btn-ghost { flex: 1; font-size: 13.5px; padding: 11px; text-align: center; }
.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--red);
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 700;
  font-size: 15px;
}
.btn-danger:active { background: rgba(248, 113, 113, 0.25); }

/* notify prefs */
.pref-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-top: 14px;
}
.pref-card h3 { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.pref-card p { font-size: 13px; color: var(--text2); line-height: 1.6; margin-bottom: 12px; }
.pref-row { display: flex; gap: 10px; }
.pref-opt {
  flex: 1;
  background: var(--bg2);
  border: 1.5px solid var(--border2);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text2);
  transition: all 0.15s;
}
.pref-opt .ico { display: block; font-size: 24px; margin-bottom: 6px; }
.pref-opt.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

/* toast */
#toast {
  position: fixed;
  bottom: calc(24px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 99;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* blocked overlay */
.blocked-overlay {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 40px 24px;
}
.blocked-overlay .icon { font-size: 60px; }
.blocked-overlay h3 { color: var(--red); font-size: 20px; }

/* utility */
.grow { flex: 1; }
.hidden { display: none !important; }
