/* ============================================================
   UrielChat — layout schermate
   ============================================================ */

.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100dvh; height: 100%; }

/* ---------- app bar ---------- */

.app-bar, .chat-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(10px + var(--sat)) 12px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg);
}
.app-bar-title {
  font-weight: 600;
  font-size: 17px;
  flex: 1;
}
.app-bar-spacer { width: 40px; }
.app-bar-logo { opacity: .9; }

.chat-bar { padding-top: calc(8px + var(--sat)); }
.chat-peer { flex: 1; min-width: 0; }
.chat-peer-name { font-weight: 600; }
.chat-peer-status {
  font-size: 12px;
  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: 18px 22px calc(30px + 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: 104px; }
.wordmark {
  font-size: 34px;
  letter-spacing: .05em;
  font-family: ui-monospace, 'Courier New', Courier, monospace;
}
.wordmark.cyber { color: var(--accent-bright); }
.wordmark span { color: var(--accent); }
/* .motto rimosso: onboarding più pulito */
.center-card form { width: 100%; max-width: 340px; }
.trust-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  color: var(--text-faint);
  font-size: 13px;
}
.trust-list li { margin: 4px 0; }
.trust-item-accent { color: var(--accent-bright); font-weight: 700; text-align: center; margin-top: 6px; }

/* ---------- home ---------- */

.home-body {
  flex: 1;
  padding: 16px 18px calc(24px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}
.identity-line {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  margin: 0;
  word-break: break-all;
}
.home-identity-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.home-alias {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.home-actions { display: flex; flex-direction: column; gap: 12px; }
.action-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  text-align: left;
  padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.action-card:active { background: var(--bg-elev2); }
.action-icon {
  grid-row: span 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
}
.action-title { font-weight: 600; font-size: 16px; }
.action-desc { color: var(--text-dim); font-size: 13px; }

/* ---------- mode pill / host / QR ---------- */

.mode-pill {
  align-self: center;
  margin-top: auto;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-faint);
  font-size: 13px;
  cursor: pointer;
}

.explain {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 340px;
  margin: 0;
}
.qr-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#qr-host {
  width: 200px;
  height: 200px;
  max-width: 62vw;
  max-height: 62vw;
  border-radius: 12px;
  background: #fff;
}
.qr-progress { color: var(--accent); font-size: 13px; font-family: var(--mono); }
.host-actions { display: flex; gap: 10px; width: 100%; max-width: 340px; }
.host-actions .btn { flex: 1; }
.host-answer {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}
/* display:flex batterebbe l'attributo hidden: lo ribattiamo esplicitamente */
.host-answer[hidden] { display: none !important; }
.host-code-details {
  width: 100%;
  max-width: 340px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.host-code-details summary {
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.host-code-details textarea {
  margin-top: 8px;
  background: var(--bg);
}
.status-line {
  color: var(--text-faint);
  font-size: 13px;
  min-height: 18px;
  margin: 0;
}
.paste-area { width: 100%; }

/* ---------- join / fotocamera ---------- */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line-soft);
}
.tab {
  flex: 1;
  padding: 12px 0;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 14px;
  cursor: pointer;
}
.tab.active {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.tab-pane { display: none; flex-direction: column; gap: 10px; }
.tab-pane.active { display: flex; }
.camera-frame {
  position: relative;
  border-radius: var(--radius);
  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(0, 255, 157, .8);
  border-radius: 16px;
  pointer-events: none;
}

/* ---------- chat ---------- */

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 16px;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.in {
  align-self: flex-start;
  background: var(--bg-elev2);
  border-bottom-left-radius: 4px;
}
.msg.out {
  align-self: flex-end;
  background: linear-gradient(160deg, #0a2a1c, #071f14);
  border: 1px solid #10402b;
  border-bottom-right-radius: 4px;
}
.msg .meta {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 3px;
}
.msg.system {
  align-self: center;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--text-faint);
  font-size: 12px;
  max-width: 92%;
}
.composer {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(12px + var(--sab));
  border-top: 1px solid var(--line-soft);
  background: var(--bg);
}
.composer input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  outline: none;
}
.send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--accent-bright), var(--accent));
  color: #1a1206;
  font-size: 18px;
  cursor: pointer;
}

/* ---------- verifica & impostazioni ---------- */

.safety-number {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 2px;
  word-break: break-all;
  color: var(--accent-bright);
}
.verify-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 340px;
}

.settings-body {
  flex: 1;
  padding: 16px 18px calc(30px + var(--sab));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}
.settings-group {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.settings-group h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 10px;
}
.settings-alias {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.settings-group .field { margin-bottom: 0; }
.danger-zone { border-color: #3a1d1f; }
.danger-zone h2 { color: var(--danger); }
.explain-small {
  color: var(--text-faint);
  font-size: 13px;
  margin: 0 0 10px;
}

/* ---------- contatti salvati ---------- */

.trust-faint { color: var(--text-faint); font-size: 13px; }
.btn-back { align-self: flex-start; }
.contacts-body {
  flex: 1;
  padding: 16px 18px calc(30px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}
.contacts-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.contact-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}
.contact-item .name { font-weight: 600; color: var(--text); }
.contact-item .fp { font-family: var(--mono); font-size: 11px; color: var(--text-faint); word-break: break-all; }
.contact-item .contact-actions { display: flex; gap: 6px; margin-top: 6px; }
.contact-item .contact-actions button { flex: 1; font-size: 12px; padding: 6px 8px; }

/* ---------- chiamata (contatto fidato, senza QR) ---------- */

.call-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 4px auto 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(0, 229, 255, 0.22), transparent 62%),
    var(--bg-elev);
  border: 1px solid var(--accent);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.18);
  position: relative;
  flex-shrink: 0;
}
.call-avatar::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px dashed rgba(0, 229, 255, 0.35);
  animation: call-spin 6s linear infinite;
}
@keyframes call-spin { to { transform: rotate(360deg); } }
.call-peer-name {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--text);
  text-align: center;
  word-break: break-word;
}

/* avviso identità: contatto nuovo, non ancora verificato di persona */
.chat-warn {
  margin: 0 12px 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius);
  background: rgba(0, 212, 255, 0.07);
  color: var(--text-dim);
  font-size: 13px;
}
/* ---------- installazione PWA + banner di chiamata ---------- */

.install-card { border-color: var(--accent-dim); }
.install-card .action-icon { color: var(--accent); }

.call-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(10px + var(--sat));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: min(560px, calc(100vw - 20px));
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 0 18px var(--accent-glow);
}
.call-banner[hidden] { display: none !important; }
.call-banner-text {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.call-banner-actions { display: flex; gap: 8px; }
.call-banner-actions .btn { padding: 8px 14px; font-size: 13px; }
