/* ═══════════════════════════════════════════════════════════════
   مِرسال (Mersal) — Warm Minimalist & Soft Tactile UI
   Light (default) + Dark themes · Arabic RTL / English LTR
   ═══════════════════════════════════════════════════════════════ */

/* ───────── design tokens: LIGHT ───────── */
:root, html[data-theme="light"] {
  --bg-page: #F6F3EA;
  --bg-bar: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-pill: #EFECE1;
  --bg-muted: #EAE6DA;
  --bg-red: #FCEEEF;
  --bg-promo: #F9E6E6;

  --tx: #1F1D1A;
  --tx-2: #6E685C;
  --tx-mute: #9E978B;
  --tx-on-btn: #FFFFFF;
  --accent: #D92D20;
  --online: #2E7D5B;

  --bd: #E8E3D8;
  --bd-input: #E2DDD0;
  --bd-red: #E8B9B9;
  --bd-promo: #E0B4B4;

  --btn: #D92D20;
  --btn-hover: #B91C1C;
  --btn-active: #991B1B;
  --sec-bg: #E6E2D6;
  --sec-hover: #DCD7C8;
  --sec-bd: #D8D2C5;
  --sq-bg: #EFECE1;
  --sq-bd: #E2DDD0;
  --sq-ic: #5C564B;
  --des-bg: #FBEAE8;
  --des-bd: #F2C6C2;
  --des-tx: #C93B2B;

  /* crypto data colours (readable on warm light surfaces) */
  --c-pk: #2563A8;
  --c-sk: #C93B2B;
  --c-ct: #A86A0B;
  --c-ss: #2E7D5B;
  --c-key: #7B4FB0;
  --c-nonce: #A86A0B;
  --c-tag: #A23F8E;

  --shadow: 0 1px 2px rgba(70, 50, 20, .05), 0 8px 24px -12px rgba(70, 50, 20, .14);
  --shadow-press: inset 0 1px 2px rgba(70, 50, 20, .12);
  --term-bg: #1C1915;
  --term-tx: #D9D2C3;
  color-scheme: light;
}

/* ───────── design tokens: DARK ───────── */
html[data-theme="dark"] {
  --bg-page: #141210;
  --bg-bar: #181512;
  --bg-card: #1E1B18;
  --bg-pill: #282420;
  --bg-muted: #26231F;
  --bg-red: #281716;
  --bg-promo: #241615;

  --tx: #F5F2EB;
  --tx-2: #A39C90;
  --tx-mute: #6E685E;
  --tx-on-btn: #141210;
  --accent: #EF4444;
  --online: #4ADE80;

  --bd: #2E2924;
  --bd-input: #332E28;
  --bd-red: #5C2824;
  --bd-promo: #4D2320;

  --btn: #EF4444;
  --btn-hover: #DC2626;
  --btn-active: #B91C1C;
  --sec-bg: #221F1C;
  --sec-hover: #2C2824;
  --sec-bd: #332E28;
  --sq-bg: #24201C;
  --sq-bd: #332E28;
  --sq-ic: #A39C90;
  --des-bg: #2C1817;
  --des-bd: #522522;
  --des-tx: #F87171;

  --c-pk: #7DB4F0;
  --c-sk: #F58A7C;
  --c-ct: #F2B35A;
  --c-ss: #6FE0A0;
  --c-key: #B99AF0;
  --c-nonce: #F2B35A;
  --c-tag: #E69BD6;

  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px -14px rgba(0, 0, 0, .65);
  --shadow-press: inset 0 1px 3px rgba(0, 0, 0, .5);
  --term-bg: #0E0C0A;
  --term-tx: #D0C9BB;
  color-scheme: dark;
}

/* ───────── language-aware typography ───────── */
html[lang="ar"] { --font: 'IBM Plex Sans Arabic', 'Tajawal', 'Segoe UI', sans-serif; }
html[lang="en"] { --font: 'Inter', 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', 'Segoe UI', sans-serif; }
:root { --mono: 'JetBrains Mono', Consolas, 'Courier New', monospace; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font); font-size: 14px; font-weight: 500;
  background: var(--bg-page); color: var(--tx);
  overflow: hidden; -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}
button, input, textarea { font-family: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--tx-mute); font-size: 12px; font-weight: 400; }
b { font-weight: 700; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.ic { width: 20px; height: 20px; flex-shrink: 0; }
.ic.sm { width: 15px; height: 15px; }
* { scrollbar-width: thin; scrollbar-color: var(--bd-input) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--bd-input); border-radius: 8px; }

/* theme/locale smooth surfaces */
.card, .topbar, .btn, .sq-btn, .tab, .bubble, .field input, .step-card, .pkt, .hv, .why-card {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease, box-shadow .25s ease, transform .15s ease;
}

/* ═════════ logo (with the red kasrah under the first letter) ═════════ */
.logo { font-weight: 800; font-size: 22px; line-height: 1.1; color: var(--tx); display: inline-flex; white-space: nowrap; }
.logo.lg { font-size: 42px; }
.logo-ar { letter-spacing: 0; position: relative; color: var(--accent); }
/* the word with its kasra is drawn in red underneath; the same word WITHOUT the kasra is
   painted on top in the normal colour (marks have zero advance, so glyphs align exactly)
   ⇒ only the kasra remains red, and the word stays one connected, correctly-shaped word */
.logo-ar::after {
  content: attr(data-base); position: absolute; inset: 0; color: var(--tx);
  -webkit-text-stroke: 0.6px var(--tx); white-space: nowrap; pointer-events: none;
}
.logo-en { letter-spacing: -0.5px; }
html[lang="ar"] .logo-en, html[lang="en"] .logo-ar { display: none; }
.letter-with-kasrah { position: relative; display: inline-block; }
.letter-with-kasrah::after {
  content: ""; position: absolute; inset-inline-start: 50%; bottom: -0.2em;
  width: 0.42em; height: 0.085em; border-radius: 2px; background: var(--accent);
  transform: translateX(-50%) rotate(-32deg);
}
html[dir="rtl"] .letter-with-kasrah::after { transform: translateX(50%) rotate(-32deg); }

/* ═════════ surfaces ═════════ */
.card { background: var(--bg-card); border: 1px solid var(--bd); border-radius: 20px; box-shadow: var(--shadow); }
.card-inner { background: var(--bg-card); border: 1px solid var(--bd); border-radius: 20px; padding: 16px; }

/* ═════════ buttons ═════════ */
.btn {
  font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 14px; padding: 0 18px; height: 44px; cursor: pointer;
  white-space: nowrap; user-select: none;
}
.btn small { font-weight: 500; opacity: .85; font-size: 11.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--btn); color: var(--tx-on-btn); box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 14px -8px var(--btn); }
.btn-primary:hover:not(:disabled) { background: var(--btn-hover); }
.btn-primary:active:not(:disabled) { background: var(--btn-active); transform: translateY(1px); box-shadow: var(--shadow-press); }
.btn-secondary { background: var(--sec-bg); color: var(--tx); border-color: var(--sec-bd); }
.btn-secondary:hover:not(:disabled) { background: var(--sec-hover); }
.btn-destructive { background: var(--des-bg); color: var(--des-tx); border-color: var(--des-bd); }
.btn-destructive:hover:not(:disabled) { filter: brightness(.97); transform: translateY(-1px); }
.btn-lg { height: 50px; width: 100%; font-size: 15px; }
.btn-block { width: 100%; height: 50px; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 12.5px; border-radius: 11px; }
.btn.pulsing { animation: softPulse 2s ease-in-out infinite; }
@keyframes softPulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--btn) 18%, transparent); } }

.sq-btn {
  width: 42px; height: 42px; border-radius: 14px; display: inline-grid; place-items: center; cursor: pointer;
  background: var(--sq-bg); border: 1px solid var(--sq-bd); color: var(--sq-ic); flex-shrink: 0;
}
.sq-btn:hover { color: var(--tx); transform: translateY(-1px); }
.sq-btn:active { transform: translateY(1px); box-shadow: var(--shadow-press); }
.sq-btn.static { cursor: default; pointer-events: none; }
.sq-btn.destructive { background: var(--des-bg); border-color: var(--des-bd); color: var(--des-tx); }
.sq-btn.active { color: var(--accent); border-color: var(--bd-red); background: var(--bg-red); }
.sq-btn .ic-sun { display: none; }
html[data-theme="dark"] .sq-btn .ic-moon { display: none; }
html[data-theme="dark"] .sq-btn .ic-sun { display: block; }

.lang-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; height: 34px; cursor: pointer;
  border-radius: 9999px; background: var(--bg-pill); border: 1px solid var(--bd-input); font-size: 12px; font-weight: 700; color: var(--tx-mute);
}
.lang-pill i { font-style: normal; opacity: .5; }
.lang-pill:hover { border-color: var(--bd-red); }
html[lang="ar"] .lang-pill [data-l="ar"], html[lang="en"] .lang-pill [data-l="en"] { color: var(--accent); }

.circle-btn {
  width: 46px; height: 46px; border-radius: 9999px; display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--bd-input); color: var(--sq-ic);
}
.circle-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--bd-red); }
.circle-btn.primary { background: var(--btn); border-color: transparent; color: var(--tx-on-btn); box-shadow: 0 6px 14px -8px var(--btn); }
.circle-btn.primary:hover:not(:disabled) { background: var(--btn-hover); color: var(--tx-on-btn); }
.circle-btn:active:not(:disabled) { transform: scale(.94); }
.circle-btn:disabled { opacity: .45; cursor: not-allowed; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 5px 11px; border-radius: 9999px; background: var(--bg-pill); border: 1px solid var(--bd-input); color: var(--tx-2); direction: ltr; }
.chip-red { background: var(--bg-red); border-color: var(--bd-red); color: var(--accent); }

/* ═════════ login ═════════ */
.login-screen { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.login-tools { position: fixed; top: 16px; inset-inline-end: 16px; display: flex; gap: 8px; align-items: center; z-index: 5; }
.login-card { width: min(460px, 100%); padding: 32px 30px 24px; text-align: center; display: flex; flex-direction: column; gap: 16px; animation: rise .6s cubic-bezier(.2,.8,.2,1); border-radius: 22px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.emblem { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto; display: grid; place-items: center; background: var(--btn); color: var(--tx-on-btn); box-shadow: 0 12px 24px -12px var(--btn); }
.emblem .ic { width: 34px; height: 34px; }
.login-title { display: flex; justify-content: center; padding-bottom: 6px; }
.login-sub { color: var(--tx-2); font-size: 14.5px; margin-top: -6px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: start; margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--tx-2); font-weight: 600; }
.field small { color: var(--tx-mute); font-weight: 400; }
.field input { font-size: 15px; background: var(--bg-page); border: 1px solid var(--bd-input); border-radius: 14px; padding: 13px 14px; outline: none; color: var(--tx); }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.form-error { color: var(--des-tx); font-size: 13px; min-height: 18px; text-align: center; }
.login-hint { font-size: 12.5px; color: var(--tx-2); line-height: 1.9; background: var(--bg-red); border: 1px solid var(--bd-red); padding: 11px 13px; border-radius: 14px; }
.engine-line { font-size: 11.5px; color: var(--tx-mute); }
.engine-line b { font-family: var(--mono); color: var(--online); font-weight: 600; }

/* ═════════ app shell ═════════ */
.app { height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 0 16px 16px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 68px; margin: 0 -16px;
  padding: 10px 16px; background: var(--bg-bar); border-bottom: 1px solid var(--bd); flex-wrap: wrap;
}
.top-start { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand { display: flex; align-items: center; }
.device { display: flex; align-items: center; gap: 10px; }
.device-text { display: flex; flex-direction: column; gap: 2px; font-size: 14px; line-height: 1.2; }
.device-text b { font-size: 14px; font-weight: 700; }
.device-status-line { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--tx-2); }
.device .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.device.online .dot { background: var(--online); box-shadow: 0 0 0 3px color-mix(in srgb, var(--online) 22%, transparent); }
.device.online .device-status-line { color: var(--online); }

.security-badge { display: flex; align-items: center; gap: 10px; padding: 7px 14px; border-radius: 14px; border: 1px solid; }
.security-badge .sb-title { font-size: 13px; font-weight: 700; }
.security-badge .sb-sub { font-family: var(--mono); font-size: 10px; opacity: .8; font-weight: 500; }
.security-badge.insecure { color: var(--c-ct); border-color: color-mix(in srgb, var(--c-ct) 35%, transparent); background: color-mix(in srgb, var(--c-ct) 9%, transparent); }
.security-badge.working { color: var(--c-key); border-color: color-mix(in srgb, var(--c-key) 35%, transparent); background: color-mix(in srgb, var(--c-key) 9%, transparent); }
.security-badge.working .ic { animation: spin 2s linear infinite; }
.security-badge.secure { color: var(--online); border-color: color-mix(in srgb, var(--online) 40%, transparent); background: color-mix(in srgb, var(--online) 9%, transparent); }
@keyframes spin { to { transform: rotate(360deg); } }
.top-actions { display: flex; align-items: center; gap: 8px; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 0.9fr) minmax(460px, 1.25fr); gap: 14px; }
.panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--bd); }
.panel-head h2 { font-size: 18px; font-weight: 700; }
.room-line { font-size: 12px; color: var(--tx-mute); margin-top: 2px; font-weight: 400; }
.room-line b { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.participants { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.participant { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 4px 10px 4px 5px; border-radius: 9999px; background: var(--bg-pill); border: 1px solid var(--bd); animation: rise .35s ease; }
html[dir="rtl"] .participant { padding: 4px 5px 4px 10px; }
.participant .role { font-family: var(--mono); font-size: 10px; color: var(--tx-mute); }
.participant.waiting { border-style: dashed; color: var(--tx-mute); background: transparent; font-weight: 500; padding: 5px 12px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff; flex-shrink: 0; }

.search-bar { display: flex; align-items: center; gap: 8px; margin: 10px 14px 0; padding: 0 14px; height: 40px; border-radius: 9999px; background: var(--bg-page); border: 1px solid var(--bd-input); color: var(--tx-mute); }
.search-bar input { flex: 1; border: none; outline: none; background: transparent; font-size: 13.5px; }

/* session banner */
.session-banner { display: flex; align-items: center; gap: 12px; margin: 12px 14px 0; padding: 10px 14px; border-radius: 18px; border: 1px solid; }
.session-banner .sb-icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.session-banner .sb-text { flex: 1; display: flex; flex-direction: column; font-size: 12.5px; color: var(--tx-2); gap: 2px; font-weight: 500; min-width: 0; }
.session-banner .sb-text b { font-size: 13.5px; color: var(--tx); }
.state-idle { background: var(--bg-muted); border-color: var(--bd); }
.state-idle .sb-icon { background: var(--bg-card); color: var(--tx-2); }
.state-working { background: color-mix(in srgb, var(--c-key) 9%, var(--bg-card)); border-color: color-mix(in srgb, var(--c-key) 30%, transparent); }
.state-working .sb-icon { background: var(--bg-card); color: var(--c-key); }
.state-working .sb-icon .ic { animation: spin 2s linear infinite; }
.state-secure { background: color-mix(in srgb, var(--online) 9%, var(--bg-card)); border-color: color-mix(in srgb, var(--online) 32%, transparent); }
.state-secure .sb-icon { background: var(--bg-card); color: var(--online); }

/* messages */
.messages { flex: 1; overflow-y: auto; padding: 14px 16px 6px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.date-pill { align-self: center; font-size: 12px; font-weight: 500; color: var(--tx-2); background: var(--bg-card); border: 1px solid var(--bd); border-radius: 9999px; padding: 4px 14px; }
.e2ee-card { align-self: center; max-width: 92%; text-align: center; padding: 12px 18px; border-radius: 18px; font-size: 13px; font-weight: 600; line-height: 1.7; color: var(--tx-2); background: var(--bg-muted); border: 1px solid var(--bd); }
.e2ee-card.secure { background: var(--bg-red); border-color: var(--bd-red); color: var(--accent); }
.share-hint { align-self: center; font-size: 11.5px; font-weight: 400; color: var(--tx-mute); text-align: center; }
.msg { display: flex; flex-direction: column; max-width: 78%; animation: msgIn .3s cubic-bezier(.2,.8,.2,1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.msg.mine { align-self: flex-start; align-items: flex-start; }
.msg.theirs { align-self: flex-end; align-items: flex-end; }
.msg.hide { display: none; }
.msg-meta { font-size: 11px; color: var(--tx-mute); margin: 0 6px 4px; display: flex; gap: 6px; align-items: center; font-weight: 500; }
.msg-meta .avatar { width: 20px; height: 20px; font-size: 10px; }
.bubble { padding: 10px 15px; border-radius: 18px; font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow); cursor: default; user-select: text; }
.msg.mine .bubble { background: var(--btn); color: var(--tx-on-btn); border-start-start-radius: 6px; }
.msg.theirs .bubble { background: var(--bg-card); color: var(--tx); border: 1px solid var(--bd); border-start-end-radius: 6px; }
.bubble.pressing { transform: scale(.97); }
.msg-foot { font-family: var(--mono); font-size: 10px; color: var(--tx-mute); margin: 4px 6px 0; display: flex; align-items: center; gap: 5px; direction: ltr; font-weight: 400; }
.msg-foot .ic { width: 11px; height: 11px; color: var(--online); }
.sys-msg { align-self: center; font-size: 12px; font-weight: 500; color: var(--tx-2); background: var(--bg-pill); border: 1px solid var(--bd); padding: 5px 14px; border-radius: 9999px; animation: msgIn .3s ease; text-align: center; }
.sys-msg.good { color: var(--online); background: color-mix(in srgb, var(--online) 9%, var(--bg-card)); border-color: color-mix(in srgb, var(--online) 28%, transparent); }
.sys-msg.warn { color: var(--c-ct); background: color-mix(in srgb, var(--c-ct) 9%, var(--bg-card)); border-color: color-mix(in srgb, var(--c-ct) 28%, transparent); }

.typing-indicator { height: 20px; padding: 0 18px; font-size: 12px; color: var(--tx-mute); font-weight: 400; }
.typing-indicator .dots span { display: inline-block; width: 5px; height: 5px; margin: 0 1px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.typing-indicator .dots span:nth-child(2) { animation-delay: .15s; }
.typing-indicator .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

.composer { display: flex; gap: 10px; align-items: center; padding: 8px 14px 6px; }
.composer textarea {
  flex: 1; resize: none; font-size: 14.5px; line-height: 1.5; height: 46px; max-height: 140px;
  background: var(--bg-card); border: 1px solid var(--bd-input); border-radius: 24px; padding: 11px 18px; outline: none;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
.composer textarea:disabled { opacity: .55; background: var(--bg-muted); }
.composer textarea::placeholder { color: var(--tx-mute); }
.protect-line { display: flex; align-items: center; gap: 7px; justify-content: center; font-family: var(--mono); font-size: 11px; color: var(--tx-mute); padding: 4px 14px 12px; flex-wrap: wrap; font-weight: 500; }
.protect-line.on { color: var(--online); }

/* ═════════ inspector ═════════ */
.tabs { display: flex; gap: 6px; padding: 10px 12px 0; border-bottom: 1px solid var(--bd); overflow-x: auto; }
.tab { font-size: 13.5px; font-weight: 700; color: var(--tx-2); background: transparent; border: 1px solid transparent; border-bottom: none; padding: 10px 14px; border-radius: 14px 14px 0 0; cursor: pointer; display: flex; align-items: center; gap: 7px; white-space: nowrap; position: relative; top: 1px; }
.tab:hover { color: var(--tx); }
.tab.active { color: var(--accent); background: var(--bg-red); border-color: var(--bd-red); border-bottom: 1px solid var(--bg-red); }
.badge { font-family: var(--mono); font-size: 10.5px; font-weight: 700; min-width: 20px; padding: 1px 6px; border-radius: 9999px; background: var(--bg-pill); color: var(--tx-2); text-align: center; }
.tab.active .badge { background: var(--bg-card); color: var(--accent); }
.badge-red { background: var(--des-bg); color: var(--des-tx); }
.badge.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.35); } }

.pane { display: none; flex: 1; overflow-y: auto; padding: 16px 16px 22px; flex-direction: column; gap: 16px; }
.pane.active { display: flex; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.pane-intro { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.pane-intro h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.pane-intro p { font-size: 12.5px; color: var(--tx-2); line-height: 1.85; max-width: 520px; font-weight: 400; }
.empty-pane { text-align: center; color: var(--tx-mute); font-size: 13px; padding: 28px 10px; border: 1px dashed var(--bd-input); border-radius: 18px; font-weight: 400; }

/* handshake diagram */
.hs-diagram { display: grid; grid-template-columns: 120px 1fr 120px; align-items: center; gap: 8px; padding: 18px 14px; border-radius: 20px; background: var(--bg-page); border: 1px solid var(--bd); direction: ltr; }
.node { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.node-ring { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-family: var(--mono); font-weight: 800; font-size: 20px; border: 2px solid; background: var(--bg-card); transition: box-shadow .3s; }
.node-a .node-ring { color: var(--c-pk); border-color: var(--c-pk); }
.node-b .node-ring { color: var(--c-key); border-color: var(--c-key); }
.node.active .node-ring { animation: nodePulse 1s ease-in-out infinite; }
@keyframes nodePulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, currentColor 14%, transparent); } }
.node-name { font-size: 12.5px; font-weight: 700; direction: ltr; unicode-bidi: plaintext; }
.node-holds { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; min-height: 20px; }
.hold { font-family: var(--mono); font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 7px; animation: rise .35s ease; }
.hold.pk { background: color-mix(in srgb, var(--c-pk) 14%, transparent); color: var(--c-pk); }
.hold.sk { background: color-mix(in srgb, var(--c-sk) 14%, transparent); color: var(--c-sk); }
.hold.ct { background: color-mix(in srgb, var(--c-ct) 14%, transparent); color: var(--c-ct); }
.hold.ss { background: color-mix(in srgb, var(--c-ss) 14%, transparent); color: var(--c-ss); }
.wire { position: relative; height: 90px; }
.wire-line { position: absolute; top: 45px; left: 0; right: 0; height: 2px; background: repeating-linear-gradient(90deg, var(--bd-input) 0 8px, transparent 8px 14px); animation: dash 1s linear infinite; }
@keyframes dash { to { background-position: 14px 0; } }
.wire-label { position: absolute; top: 12px; width: 100%; text-align: center; font-size: 11.5px; color: var(--tx-mute); font-weight: 500; direction: ltr; unicode-bidi: plaintext; }
.eve-tag { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--des-tx); opacity: .8; }
.packet { position: absolute; top: 33px; left: 0; padding: 4px 9px; border-radius: 9px; font-family: var(--mono); font-size: 10.5px; font-weight: 700; opacity: 0; white-space: nowrap; }
.packet.go-right { animation: goRight .8s cubic-bezier(.5,0,.3,1) forwards; }
.packet.go-left { animation: goLeft .8s cubic-bezier(.5,0,.3,1) forwards; }
@keyframes goRight { 0% { left: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: calc(100% - 70px); opacity: 0; } }
@keyframes goLeft { 0% { left: calc(100% - 70px); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: 0; opacity: 0; } }
.packet.pk { background: var(--bg-card); color: var(--c-pk); border: 1px solid var(--c-pk); box-shadow: var(--shadow); }
.packet.ct { background: var(--bg-card); color: var(--c-ct); border: 1px solid var(--c-ct); box-shadow: var(--shadow); }

/* timeline */
.timeline { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.step { display: grid; grid-template-columns: 36px 1fr; gap: 12px; opacity: .45; transition: opacity .4s ease; }
.step.done, .step.active { opacity: 1; }
.step-num { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-family: var(--mono); font-weight: 800; font-size: 14px; background: var(--bg-pill); border: 1px solid var(--bd-input); color: var(--tx-mute); }
.step.active .step-num { background: var(--btn); color: var(--tx-on-btn); border-color: transparent; animation: softPulse 1.4s infinite; }
.step.done .step-num { background: color-mix(in srgb, var(--online) 14%, var(--bg-card)); color: var(--online); border-color: color-mix(in srgb, var(--online) 35%, transparent); }
.step-card { border-radius: 18px; padding: 12px 14px; background: var(--bg-page); border: 1px solid var(--bd); min-width: 0; }
.step-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.step-title h4 { font-size: 14px; font-weight: 700; }
.step-title h4 small { font-family: var(--mono); font-size: 10.5px; color: var(--tx-mute); font-weight: 500; margin-inline-start: 6px; direction: ltr; display: inline-block; }
.actors { display: flex; gap: 6px; flex-wrap: wrap; }
.step-actor { font-size: 11px; padding: 2px 10px; border-radius: 9999px; font-weight: 700; }
.step-actor.A { background: color-mix(in srgb, var(--c-pk) 13%, transparent); color: var(--c-pk); }
.step-actor.B { background: color-mix(in srgb, var(--c-key) 13%, transparent); color: var(--c-key); }
.step-actor.N { background: var(--des-bg); color: var(--des-tx); }
.step-desc { font-size: 12px; color: var(--tx-2); line-height: 1.85; margin-top: 4px; font-weight: 400; }
.step-body { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.kv { display: flex; flex-direction: column; gap: 4px; }
.kv-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--tx-2); gap: 8px; font-weight: 600; }
.kv-label .meta { font-family: var(--mono); font-size: 10.5px; color: var(--tx-mute); direction: ltr; font-weight: 400; }
.hex { font-family: var(--mono); font-size: 11px; line-height: 1.65; direction: ltr; text-align: left; background: var(--bg-card); border: 1px solid var(--bd); border-radius: 12px; padding: 7px 11px; word-break: break-all; max-height: 120px; overflow: auto; cursor: pointer; position: relative; font-weight: 500; }
.hex.collapsed { max-height: 54px; overflow: hidden; }
.hex.collapsed::after { content: "⤢"; position: absolute; bottom: 2px; inset-inline-end: 8px; font-size: 11px; color: var(--tx-mute); background: var(--bg-card); padding: 0 4px; }
.hex.pk { color: var(--c-pk); } .hex.sk { color: var(--c-sk); } .hex.ct { color: var(--c-ct); } .hex.ss { color: var(--c-ss); } .hex.key { color: var(--c-key); }
.hex.nonce { color: var(--c-nonce); } .hex.tag { color: var(--c-tag); }
.match-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.match-icon { width: 38px; height: 38px; border-radius: 14px; display: grid; place-items: center; font-size: 18px; background: color-mix(in srgb, var(--online) 15%, var(--bg-card)); color: var(--online); animation: rise .45s ease; }
.match-icon.bad { background: var(--des-bg); color: var(--des-tx); }
.fp { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--online); direction: ltr; text-align: center; padding: 6px; border-radius: 10px; background: color-mix(in srgb, var(--online) 8%, var(--bg-card)); border: 1px solid color-mix(in srgb, var(--online) 25%, transparent); }
.stat-row { display: flex; gap: 8px; flex-wrap: wrap; }
.stat { font-family: var(--mono); font-size: 10.5px; padding: 3px 9px; border-radius: 9px; background: var(--bg-pill); border: 1px solid var(--bd); color: var(--tx-2); direction: ltr; font-weight: 500; }
.stat b { color: var(--accent); font-weight: 700; }
.lwe-note { font-size: 11.5px; color: var(--tx-2); background: var(--bg-red); border: 1px solid var(--bd-red); border-radius: 12px; padding: 8px 11px; line-height: 1.9; font-weight: 400; }
.lwe-note code { font-family: var(--mono); color: var(--accent); direction: ltr; unicode-bidi: embed; font-weight: 600; }

.seg { display: flex; background: var(--bg-pill); border: 1px solid var(--bd-input); border-radius: 12px; padding: 3px; direction: ltr; }
.seg-btn { font-family: var(--mono); font-size: 11.5px; font-weight: 700; padding: 6px 12px; border: none; background: transparent; color: var(--tx-mute); border-radius: 9px; cursor: pointer; }
.seg-btn.active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow); }

/* packet log */
.packet-list { display: flex; flex-direction: column; gap: 12px; }
.pkt { border-radius: 18px; background: var(--bg-page); border: 1px solid var(--bd); padding: 12px 14px; animation: rise .4s cubic-bezier(.2,.8,.2,1); }
.pkt.fresh { border-color: var(--bd-red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent); }
.pkt-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.pkt-route { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.pkt-route .arrow { color: var(--tx-mute); }
.pkt-id { font-family: var(--mono); font-size: 10.5px; color: var(--tx-mute); direction: ltr; font-weight: 400; }
.flow { display: flex; flex-direction: column; gap: 6px; }
.flow-step { display: grid; grid-template-columns: 112px 1fr; gap: 10px; align-items: start; }
.flow-label { font-size: 11.5px; font-weight: 700; padding-top: 6px; display: flex; flex-direction: column; gap: 1px; }
.flow-label small { font-family: var(--mono); font-size: 9.5px; color: var(--tx-mute); font-weight: 400; }
.flow-label.plain { color: var(--c-pk); } .flow-label.nonce { color: var(--c-nonce); } .flow-label.cipher { color: var(--c-sk); } .flow-label.tag { color: var(--c-tag); } .flow-label.dec { color: var(--c-ss); } .flow-label.aad { color: var(--tx-2); }
.flow-arrow { color: var(--tx-mute); font-size: 11px; margin: -1px 0; padding-inline-start: 6px; font-family: var(--mono); direction: ltr; text-align: start; }
.plain-box { font-size: 13.5px; padding: 6px 11px; border-radius: 12px; background: color-mix(in srgb, var(--c-pk) 8%, var(--bg-card)); border: 1px solid color-mix(in srgb, var(--c-pk) 25%, transparent); white-space: pre-wrap; word-break: break-word; }
.plain-box.dec { background: color-mix(in srgb, var(--c-ss) 8%, var(--bg-card)); border-color: color-mix(in srgb, var(--c-ss) 28%, transparent); }
.pkt-foot { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.hex.plainhex { color: var(--tx-2); cursor: default; }

/* attacker */
.attacker-hero { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 20px; background: var(--bg-red); border: 1px solid var(--bd-red); }
.ah-icon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--btn); color: var(--tx-on-btn); flex-shrink: 0; }
.ah-icon .ic { width: 26px; height: 26px; }
.attacker-hero h3 { font-size: 15px; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.attacker-hero p { font-size: 12.5px; color: var(--tx-2); line-height: 1.85; font-weight: 400; }
.att-section { display: flex; flex-direction: column; gap: 10px; }
.att-head { display: flex; justify-content: space-between; align-items: center; }
.att-head h4 { font-size: 14.5px; font-weight: 700; }
.harvest-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.hv { border-radius: 16px; border: 1px solid var(--bd); background: var(--bg-page); padding: 10px 12px; animation: rise .35s ease; }
.hv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; font-weight: 600; }
.hv-type { font-family: var(--mono); font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 7px; }
.hv-type.public_key { background: color-mix(in srgb, var(--c-pk) 14%, transparent); color: var(--c-pk); }
.hv-type.capsule { background: color-mix(in srgb, var(--c-ct) 14%, transparent); color: var(--c-ct); }
.hv-type.message { background: var(--des-bg); color: var(--des-tx); }
.hv-route { color: var(--tx-2); }
.hv-meta { margin-inline-start: auto; font-family: var(--mono); font-size: 10px; color: var(--tx-mute); direction: ltr; font-weight: 400; }
.hv .hex { margin-top: 7px; color: var(--c-sk); max-height: 46px; overflow: hidden; cursor: default; }
.hv-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.attack-result { margin-top: 8px; border-radius: 14px; padding: 10px 12px; background: var(--bg-card); border: 1px solid color-mix(in srgb, var(--online) 30%, transparent); font-size: 12px; line-height: 1.9; color: var(--tx-2); animation: rise .35s ease; font-weight: 400; }
.attack-result .ok { color: var(--online); font-weight: 700; }
.attack-result .fail { color: var(--des-tx); font-weight: 700; }
.attack-result code { font-family: var(--mono); font-size: 10.5px; color: var(--c-sk); direction: ltr; unicode-bidi: embed; word-break: break-all; font-weight: 500; }

.shor-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shor-output { display: flex; flex-direction: column; gap: 12px; }
.terminal { font-family: var(--mono); font-size: 11.5px; line-height: 1.75; text-align: left; background: var(--term-bg); border: 1px solid var(--bd); border-radius: 16px; padding: 12px 14px; max-height: 300px; overflow-y: auto; color: var(--term-tx); white-space: pre-wrap; word-break: break-word; }
.terminal .t-line { animation: fadeIn .2s ease; }
.terminal .t-ok { color: #6FE0A0; } .terminal .t-bad { color: #FF6B6B; } .terminal .t-warn { color: #F2B35A; }
.terminal .t-q { color: #B99AF0; } .terminal .t-dim { color: #8C8576; } .terminal .t-cy { color: #7DB4F0; }
.terminal .t-ar { direction: rtl; text-align: right; font-family: var(--font); }
.terminal .cursor { display: inline-block; width: 7px; height: 13px; background: #6FE0A0; vertical-align: middle; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.period-chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding: 10px; border-radius: 16px; background: var(--bg-page); border: 1px solid var(--bd); direction: ltr; }
.period-chart .bar { flex: 1; min-width: 3px; border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--accent) 55%, transparent); animation: grow .5s ease backwards; }
.period-chart .bar.one { background: var(--online); }
@keyframes grow { from { transform: scaleY(0); transform-origin: bottom; } }
.chart-caption { font-size: 11.5px; color: var(--tx-2); text-align: center; line-height: 1.9; font-weight: 400; margin-top: 8px; }
.chart-caption code { font-family: var(--mono); color: var(--online); font-weight: 600; }

.lwe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lwe-box { border-radius: 16px; padding: 11px 12px; border: 1px solid; font-size: 12px; line-height: 1.8; font-weight: 400; }
.lwe-box h6 { font-size: 12.5px; font-weight: 700; margin-bottom: 6px; }
.lwe-box.clean { border-color: var(--des-bd); background: var(--des-bg); }
.lwe-box.noisy { border-color: color-mix(in srgb, var(--online) 32%, transparent); background: color-mix(in srgb, var(--online) 8%, var(--bg-card)); }
.vec { font-family: var(--mono); font-size: 11px; direction: ltr; text-align: left; padding: 4px 8px; border-radius: 9px; background: var(--bg-card); border: 1px solid var(--bd); margin: 3px 0; word-break: break-all; font-weight: 500; }
.vec .k { color: var(--tx-mute); }
.vec.good { color: var(--online); } .vec.bad { color: var(--des-tx); } .vec.noise { color: var(--c-ct); }
.big-num { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.big-num div { text-align: center; padding: 10px 6px; border-radius: 14px; background: var(--bg-card); border: 1px solid var(--bd); }
.big-num b { display: block; font-family: var(--mono); font-size: 19px; font-weight: 800; color: var(--accent); direction: ltr; }
.big-num span { font-size: 10.5px; color: var(--tx-2); font-weight: 500; }
#shor-visual { display: flex; flex-direction: column; }

.why-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.why-card { border-radius: 18px; padding: 13px; border: 1px solid; display: flex; flex-direction: column; gap: 7px; }
.why-card h5 { font-size: 13px; font-weight: 700; }
.why-card p { font-size: 12px; color: var(--tx-2); line-height: 1.85; flex: 1; font-weight: 400; }
.why-card code { font-family: var(--mono); font-size: 10px; font-weight: 600; padding: 6px 8px; border-radius: 10px; background: var(--bg-card); text-align: left; }
.why-card.bad { border-color: var(--des-bd); background: var(--des-bg); } .why-card.bad h5, .why-card.bad code { color: var(--des-tx); }
.why-card.good { border-color: color-mix(in srgb, var(--online) 32%, transparent); background: color-mix(in srgb, var(--online) 7%, var(--bg-card)); } .why-card.good h5, .why-card.good code { color: var(--online); }
.why-card.info { border-color: var(--bd); background: var(--bg-muted); } .why-card.info h5, .why-card.info code { color: var(--c-pk); }

/* ═════════ settings drawer ═════════ */
.drawer-overlay { position: fixed; inset: 0; background: rgba(20, 15, 8, .38); backdrop-filter: blur(2px); z-index: 40; animation: fadeIn .2s ease; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(400px, 94vw); z-index: 41;
  background: var(--bg-page); border-inline-start: 1px solid var(--bd); box-shadow: var(--shadow);
  display: flex; flex-direction: column; transform: translateX(110%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
html[dir="rtl"] .drawer { transform: translateX(-110%); }
.drawer.open { transform: none !important; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; height: 68px; background: var(--bg-bar); border-bottom: 1px solid var(--bd); flex-shrink: 0; }
.drawer-head h2 { font-size: 18px; font-weight: 700; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.settings-group h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt-btn { height: 50px; border-radius: 14px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--sec-bg); color: var(--tx); border: 1px solid var(--sec-bd); }
.opt-btn:hover { background: var(--sec-hover); }
.opt-btn.active { background: var(--btn); color: var(--tx-on-btn); border-color: transparent; font-weight: 700; }
.promo-card { background: var(--bg-promo); border: 1px solid var(--bd-promo); border-radius: 22px; padding: 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.promo-card h3 { font-size: 20px; font-weight: 800; }
.promo-card p { font-size: 12.5px; color: var(--tx-2); line-height: 1.8; font-weight: 400; margin-top: -6px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-box { background: var(--bg-card); border: 1px solid var(--bd); border-radius: 14px; padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; position: relative; }
.stat-box .ic { color: var(--accent); width: 20px; height: 20px; margin-bottom: 2px; }
.stat-box b { font-family: var(--mono); font-size: 11.5px; font-weight: 800; }
.stat-box span { font-size: 10.5px; color: var(--tx-2); font-weight: 500; }
.stat-box .pro { font-style: normal; font-size: 9px; font-weight: 700; font-family: var(--mono); color: var(--accent); }

/* toasts */
.toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { min-width: 240px; max-width: 360px; padding: 12px 16px; border-radius: 16px; font-size: 13px; font-weight: 600; background: var(--bg-card); border: 1px solid var(--bd); box-shadow: var(--shadow); animation: toastIn .3s cubic-bezier(.2,.8,.2,1); }
.toast.good { border-color: color-mix(in srgb, var(--online) 45%, transparent); }
.toast.bad { border-color: var(--bd-red); color: var(--des-tx); }
.toast.info { border-color: var(--bd-input); }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px); } }

/* ═════════ responsive ═════════ */
@media (max-width: 1280px) { .security-badge .sb-sub { display: none; } }
@media (max-width: 1180px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .chat-panel { height: 78vh; }
  .inspector-panel { min-height: 80vh; }
  .why-grid { grid-template-columns: 1fr; }
  .security-badge { order: 3; width: 100%; }
}
@media (max-width: 720px) {
  .top-actions { flex-wrap: wrap; }
  .pane-intro { flex-direction: column; align-items: stretch; }
  .shor-buttons, .lwe-grid { grid-template-columns: 1fr; }
  .flow-step { grid-template-columns: 1fr; gap: 3px; }
  .hs-diagram { grid-template-columns: 80px 1fr 80px; }
  .device-text { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ═════════ attachments + message menu ═════════ */
.bubble { cursor: pointer; }
.bubble-text + .att-img, .att-img + .bubble-text, .att-file + .bubble-text { margin-top: 8px; }
.att-img { display: block; line-height: 0; }
.att-img img { max-width: min(260px, 100%); max-height: 260px; border-radius: 12px; display: block; object-fit: cover; }
.att-file { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 2px 0; }
.att-ic { font-size: 22px; }
.att-info { display: flex; flex-direction: column; min-width: 0; }
.att-info b { font-weight: 600; font-size: 13.5px; word-break: break-all; }
.att-info small { opacity: .75; font-size: 11px; }
.msg-menu { position: fixed; z-index: 1000; display: flex; gap: 2px; padding: 4px; background: var(--bg-card); border: 1px solid var(--bd); border-radius: 12px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.35); animation: msgIn .15s ease-out; }
.msg-menu button { border: 0; background: transparent; color: var(--tx); font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.msg-menu button:hover { background: var(--bd); }
.msg-menu button.danger { color: var(--accent); }
.logo .kasra { color: var(--accent); }
.bubble.deleted { cursor: default; font-style: italic; opacity: .7; background: transparent !important; color: var(--tx-mute) !important; border: 1px dashed var(--bd) !important; box-shadow: none; }

/* ═════════ PWA: iPhone notch / home-indicator safe areas (env() = 0 elsewhere) ═════════ */
.app { padding-top: env(safe-area-inset-top); padding-bottom: calc(16px + env(safe-area-inset-bottom));
       padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.login-screen { padding-top: calc(24px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.login-tools { top: calc(16px + env(safe-area-inset-top)); }
.drawer { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.toasts { bottom: calc(20px + env(safe-area-inset-bottom)); }
@media (display-mode: standalone) { body { -webkit-user-select: none; user-select: none; } .bubble, input, textarea, .hex { -webkit-user-select: text; user-select: text; } }
