/* ============================================================
   UrielChat — layout schermate (mobile-first, stile UrielSec)
   ============================================================ */

.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100dvh; height: 100%; }

/* ---------- app bar & chat bar ---------- */

.app-bar, .chat-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--sat)) max(12px, calc((100% - 720px) / 2)) 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 8, 15, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.app-bar-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.03em;
  color: #fff;
  flex: 1;
}
.app-bar-spacer { width: 40px; }
.app-bar-logo {
  border-radius: 22%;
  filter: drop-shadow(0 0 6px rgba(127, 163, 217, 0.45));
}

.chat-bar { padding-top: calc(8px + var(--sat)); }
.chat-peer { flex: 1; min-width: 0; }
.chat-peer-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.chat-peer-status {
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  display: flex;
  align-items: center;
}
.shield { position: relative; }
.shield.verified { color: var(--ok); }

/* ---------- onboarding & card centrale ---------- */

.center-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 20px calc(32px + var(--sab));
  text-align: center;
  gap: 14px;
  overflow-y: auto;
}
.center-card > * { flex-shrink: 0; }
.logo-big {
  border-radius: 24%;
  object-fit: contain;
  max-height: 100px;
  filter: drop-shadow(0 0 18px rgba(127, 163, 217, 0.38));
}
.wordmark {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #fff;
}
.wordmark.cyber { color: #fff; }
.wordmark span { color: var(--steel-bright); }
.center-card form { width: 100%; max-width: 360px; }
.trust-list {
  list-style: none;
  padding: 12px 16px;
  margin: 12px 0 0;
  width: 100%;
  max-width: 360px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.trust-list li {
  position: relative;
  padding: 4px 0 4px 16px;
}
.trust-list li::before {
  content: "//";
  position: absolute;
  left: 0;
  color: var(--steel-deep);
  font-family: var(--mono);
  font-size: 11px;
}
.trust-item-accent {
  color: var(--ok);
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.trust-item-accent::before { color: var(--ok) !important; }

/* ---------- home ---------- */

.home-body {
  flex: 1;
  padding: 18px 16px calc(24px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}
.identity-line {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-faint);
  margin: 0;
  word-break: break-all;
}
.home-identity-card {
  background: var(--bg-elev);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-top: 2px solid var(--steel-deep);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.home-alias {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  margin-bottom: 6px;
}
.home-actions { display: flex; flex-direction: column; gap: 10px; }
.action-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 2px;
  text-align: left;
  min-height: 70px;
  padding: 14px 16px;
  background: var(--bg-elev);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.action-card::after {
  content: "›";
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  font-size: 20px;
  color: var(--text-faint);
  padding-left: 4px;
}
.action-card:hover { border-color: var(--line-strong); background: var(--bg-elev2); }
.action-card:active { transform: translateY(1px); background: var(--bg-elev2); border-color: var(--steel); }
.action-icon {
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(127, 163, 217, 0.08);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--steel-bright);
}
.action-title { grid-column: 2; font-family: var(--display); font-weight: 600; font-size: 16px; color: #fff; }
.action-desc { grid-column: 2; color: var(--text-dim); font-size: 13px; line-height: 1.35; }

/* ---------- mode pill / host / QR ---------- */

.mode-pill {
  align-self: center;
  margin-top: auto;
  padding: 8px 16px;
  background: rgba(127, 163, 217, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--steel-bright);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.mode-pill:active { background: rgba(127, 163, 217, 0.14); }

.explain {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 360px;
  margin: 0;
}
.qr-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(127, 163, 217, 0.06);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#qr-host {
  width: 200px;
  height: 200px;
  max-width: 62vw;
  max-height: 62vw;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.qr-progress { color: var(--steel-bright); font-size: 13px; font-family: var(--mono); }
.host-actions { display: flex; gap: 10px; width: 100%; max-width: 360px; flex-wrap: wrap; }
.host-actions .btn { flex: 1 1 130px; }
.host-answer {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}
.host-answer[hidden] { display: none !important; }
.host-code-details {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
}
.host-code-details summary {
  color: var(--steel-bright);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.host-code-details textarea {
  margin-top: 8px;
  background: rgba(5, 8, 15, 0.9);
}
.status-line {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  min-height: 18px;
  margin: 0;
}
.paste-area { width: 100%; }

/* ---------- join / fotocamera ---------- */

.join-body {
  flex: 1;
  padding: 14px 16px calc(24px + var(--sab));
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.join-step { text-align: center; }
.step-title { font-family: var(--display); font-size: 19px; color: #fff; margin-bottom: 4px; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 19, 34, 0.5);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab {
  flex: 1;
  padding: 12px 0;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.tab.active {
  color: var(--steel-bright);
  box-shadow: inset 0 -2px 0 var(--steel);
}
.tab-pane { display: none; flex-direction: column; gap: 10px; }
.tab-pane.active { display: flex; }
.camera-frame {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  overflow: hidden;
  background: #000;
  aspect-ratio: 1;
  max-width: 280px;
  max-height: 280px;
  width: 100%;
  margin: 0 auto;
}
.camera-frame video { width: 100%; height: 100%; object-fit: cover; }
.camera-reticle {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 62%;
  height: 62%;
  border: 2px solid rgba(179, 202, 239, 0.85);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(5, 8, 15, 0.35);
  pointer-events: none;
}

/* ---------- chat ---------- */

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px max(12px, calc((100% - 720px) / 2)) 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg {
  max-width: min(80%, 520px);
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.42;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.in {
  align-self: flex-start;
  background: var(--bg-elev2);
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 3px;
}
.msg.out {
  align-self: flex-end;
  background: linear-gradient(135deg, #2d5188, #1d365e);
  border: 1px solid rgba(127, 163, 217, 0.38);
  color: #eef4fc;
  border-bottom-right-radius: 3px;
}
.msg .meta {
  display: block;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.85;
  margin-top: 4px;
}
.msg.out .meta { color: #c7d9f2; text-align: right; }
.msg.system {
  align-self: center;
  background: rgba(127, 163, 217, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  text-align: center;
  max-width: 92%;
}
.composer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px max(12px, calc((100% - 720px) / 2)) calc(12px + var(--sab));
  border-top: 1px solid var(--line);
  background: rgba(5, 8, 15, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.composer input {
  flex: 1;
  min-width: 0;
  background: rgba(12, 19, 34, 0.9);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 11px 16px;
  outline: none;
}
.composer input:focus { border-color: var(--steel); }
.send-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a76b6, #2d4f84);
  color: #ffffff;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(45, 79, 132, 0.4);
  transition: filter .15s ease, transform .1s ease;
}
.send-btn:active { transform: scale(0.96); filter: brightness(1.12); }

/* ---------- verifica & impostazioni ---------- */

.safety-number {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  letter-spacing: 2px;
  word-break: break-all;
  color: var(--steel-bright);
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
  max-width: 360px;
}
.verify-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}

.settings-body {
  flex: 1;
  padding: 16px 16px calc(30px + var(--sab));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
}
.settings-group {
  background: var(--bg-elev);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-group h2 {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--steel);
  margin-bottom: 4px;
}
.settings-alias {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}
.settings-group .field { margin-bottom: 0; }
.danger-zone { border-color: rgba(224, 96, 107, 0.32); background: rgba(224, 96, 107, 0.04); }
.danger-zone h2 { color: var(--danger); }
.explain-small {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 6px;
}
.warn-box {
  border-left: 3px solid var(--amber);
  background: rgba(230, 181, 83, 0.06);
  padding: 8px 10px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
}

/* ---------- contatti salvati ---------- */

.trust-faint { color: var(--text-faint); font-size: 13px; }
.btn-back { align-self: flex-start; }
.contacts-body {
  flex: 1;
  padding: 16px 16px calc(30px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}
.contacts-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.contact-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg-elev);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.contact-item .name { font-family: var(--display); font-size: 17px; font-weight: 600; color: #fff; overflow-wrap: anywhere; }
.contact-item .fp { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-faint); word-break: break-all; }
.contact-item .contact-actions { display: flex; gap: 8px; margin-top: 8px; }
.contact-item .contact-actions button { flex: 1; font-size: 12px; padding: 8px 10px; min-height: 40px; }

/* ---------- chiamata (contatto fidato, senza QR) ---------- */

.call-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 8px auto 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(127, 163, 217, 0.25), transparent 64%),
    var(--bg-elev);
  border: 1px solid var(--steel);
  box-shadow: 0 0 22px rgba(127, 163, 217, 0.24);
  position: relative;
  flex-shrink: 0;
}
.call-avatar::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px dashed rgba(179, 202, 239, 0.45);
  animation: call-spin 6s linear infinite;
}
@keyframes call-spin { to { transform: rotate(360deg); } }
.call-peer-name {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.03em;
  color: #fff;
  text-align: center;
  word-break: break-word;
}

.chat-warn {
  margin: 6px max(12px, calc((100% - 720px) / 2)) 8px;
  padding: 10px 14px;
  border: 1px solid rgba(230, 181, 83, 0.28);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  background: rgba(230, 181, 83, 0.08);
  color: var(--text);
  font-size: 13px;
}

/* ---------- installazione PWA + banner di chiamata ---------- */

.install-card { border-color: var(--line-strong); }
.install-card .action-icon { color: var(--ok); border-color: rgba(95, 212, 154, 0.3); background: rgba(95, 212, 154, 0.08); }

.call-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(10px + var(--sat));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: min(560px, calc(100vw - 20px));
  padding: 12px 16px;
  background: rgba(12, 19, 34, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .6), 0 0 18px var(--accent-glow);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.call-banner[hidden] { display: none !important; }
.call-banner-text {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
  min-width: 0;
}
.call-banner-actions { display: flex; gap: 8px; }
.call-banner-actions .btn { padding: 8px 14px; min-height: 38px; font-size: 12px; }

.composer input:disabled, .composer button:disabled { opacity: .5; cursor: not-allowed; }
.composer .attach-btn {
  border: 1px solid var(--line-strong);
  background: rgba(127, 163, 217, 0.06);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  flex: none;
}

.msg-file-img { max-width: 100%; border-radius: 8px; display: block; margin-top: 6px; }
.msg-file-link { color: var(--steel-bright); text-decoration: underline; display: inline-block; margin-top: 4px; word-break: break-all; }

/* modale custom accessibile */
.uc-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(3, 6, 12, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.uc-modal-card {
  width: 100%;
  max-width: 390px;
  background: rgba(12, 19, 34, 0.96);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .65);
  display: flex;
  flex-direction: column;
  gap: 12px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.uc-modal-card h3 { font-family: var(--display); font-size: 18px; color: var(--steel-bright); }
.uc-modal-card p { margin: 0; font-size: 14px; color: var(--text); white-space: pre-line; }
.uc-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.settings-select {
  width: 100%;
  background: rgba(7, 12, 22, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 4px;
}
