/* ── Modals ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  align-items: center; justify-content: center; z-index: 100;
  padding: 16px 0;        /* top/bottom padding */
  overflow-y: auto;       /* overlay scroll if popup taller than screen */
}
.modal-overlay.show { display: flex; }
.modal {
  background: #252526; border: 1px solid #555; border-radius: 6px;
  padding: 24px; width: 480px; max-width: 95vw; position: relative;
  max-height: calc(100dvh - 32px); /* stay within screen bounds */
  overflow-y: auto;                 /* scroll inside popup */
  flex-shrink: 0;                   /* no shrink in flex overlay */
}
.modal h3 { color: #9cdcfe; margin-top: 0; }
.modal label { color: #9cdcfe; display: block; margin: 10px 0 4px; font-size: 13px; }
.modal input:not([type="checkbox"]) {
  width: 100%; background: #2d2d2d; border: 1px solid #444; color: #d4d4d4;
  padding: 6px 8px; border-radius: 4px; font-family: monospace; font-size: 13px;
}
.modal textarea {
  width: 100%; height: 80px; resize: vertical;
  background: #2d2d2d; border: 1px solid #444; color: #d4d4d4;
  padding: 6px 8px; border-radius: 4px; font-family: monospace; font-size: 12px;
}
.modal input[readonly] { color: #888; border-color: #333; cursor: default; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.modal-actions button { margin-top: 0; }

.btn-cancel { background: #3a3a3a; }
.btn-cancel:hover { background: #444; }

/* Close button (always in DOM, visible only on mobile) */
.modal-close-btn {
  display: none;
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: #888;
  font-size: 22px; line-height: 1; cursor: pointer;
  padding: 4px 8px; border-radius: 4px; z-index: 1;
}
.modal-close-btn:hover { color: #d4d4d4; background: #333; }

#modal-addr-preview { font-size: 11px; color: #666; margin-top: 4px; min-height: 16px; }
#modal-contacts-list { max-height: 400px; overflow-y: auto; margin-top: 12px; }

.mc-section-title { font-size: 11px; color: #666; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: 1px; }
.mc-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; border-radius: 4px; margin-bottom: 3px;
  background: #2d2d2d; font-size: 13px;
}
.mc-item.blocked { background: #2a1a1a; color: #888; }

/* ── Specific modal widths ── */
.modal-wide   { width: 480px; }
.modal-narrow { width: 440px; }

/* ── Section inside modal ── */
.modal-section {
  margin-top: 16px;
}
.modal-section-label {
  font-size: 11px; color: #888; margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .5px;
}
.modal-hint  { font-size: 11px; color: #666; margin-top: 8px; }
.modal-error { font-size: 11px; color: #f44747; margin-top: 4px; min-height: 16px; }
.modal-ok    { font-size: 11px; color: #4ec9b0; margin-top: 4px; min-height: 16px; }

/* ── Contacts popup: top buttons ── */
.contacts-popup-actions {
  display: flex; gap: 8px; margin-bottom: 16px;
}

/* ── Contacts popup: contact row ── */
.contacts-popup-item {
  cursor: pointer; padding: 8px; border-radius: 4px;
  display: flex; align-items: center; gap: 8px;
}
.contacts-popup-item-name {
  flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.contacts-popup-item-actions {
  display: flex; gap: 4px; flex-shrink: 0;
}
.contacts-popup-item-actions button {
  font-size: 20px; padding: 3px 18px; margin: 0;
}
.btn-contact-msg {
  /* default style */
}
.btn-contact-edit {
  background: #1a2233; border-color: #569cd6; color: #569cd6;
}
.btn-contact-save {
  background: #1e3a1e; border-color: #4ec9b0; color: #4ec9b0;
}
.inline-rename-input {
  width: 100%; padding: 2px 6px; font-size: 13px;
  background: #1e1e2e; color: #cdd6f4; border: 1px solid #569cd6;
  border-radius: 4px; outline: none;
}
.btn-contact-retry {
  background: #1a2233; border-color: #569cd6; color: #569cd6;
}
.btn-contact-block {
  background: #2a1a1a; border-color: #f44747; color: #f44747;
}

/* ── Contacts popup: blocked section ── */
.contacts-blocked-sep {
  margin: 16px 0 8px; font-size: 11px; color: #888;
  text-transform: uppercase; letter-spacing: .5px;
}
.contacts-blocked-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 4px; opacity: 0.6;
}
.contacts-blocked-item img { filter: grayscale(1); }
.contacts-blocked-item-name {
  flex: 1; min-width: 0; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; font-size: 13px;
}
.contacts-blocked-item-actions {
  display: flex; gap: 4px; flex-shrink: 0;
}
.btn-contact-unblock {
  font-size: 11px; padding: 3px 8px; margin: 0;
  background: #1e3a1e; border-color: #4ec9b0; color: #4ec9b0;
}
.btn-contact-forget {
  font-size: 11px; padding: 3px 8px; margin: 0;
  background: #2a1a1a; border-color: #f44747; color: #f44747;
}

/* ── Group members: member row ── */
.group-member-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
}
.group-member-row-inner { flex: 1; }
.group-member-owner-badge {
  font-size: 10px; color: #888;
}
.btn-group-member-remove {
  font-size: 11px; padding: 2px 6px; margin: 0;
  background: #2a1a1a; border-color: #f44747; color: #f44747;
}

/* ── Add member to group ── */
.group-add-member-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  margin-bottom: 4px; padding: 6px 10px;
}

/* ── Create group: member checklist ── */
.create-group-member-label {
  display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer;
}

/* ── Settings: avatar block ── */
.settings-identity {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
}
.settings-identity img { border-radius: 10px; flex-shrink: 0; }
.settings-address-block { flex: 1; min-width: 0; }
.settings-address-label { font-size: 11px; color: #888; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
#settings-address {
  font-family: monospace; font-size: 13px; color: #4ec9b0;
  word-break: break-all; cursor: pointer;
}
#settings-copy-hint { font-size: 11px; color: #555; margin-top: 4px; }

/* ── Settings: section ── */
.settings-section { margin-bottom: 20px; }
.settings-section-label {
  font-size: 11px; color: #888; margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .5px;
}
.settings-hint { font-size: 11px; color: #555; margin-top: 4px; }
.settings-select {
  background: #2a2a2a; color: #ccc; border: 1px solid #444;
  border-radius: 6px; padding: 6px 10px; font-size: 14px;
}

/* ── Settings: QR + share ── */
.share-row {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
#qr-canvas-wrap { width: 100%; display: flex; justify-content: center; }
#qr-canvas-wrap canvas {
  border-radius: 6px; display: block;
  background: #ffffff; width: 100%; max-width: 280px; height: auto;
}
.share-actions {
  width: 100%; display: flex; flex-direction: column; gap: 8px;
}
.btn-secondary-settings {
  background: #2d2d2d; border: 1px solid #444; color: #d4d4d4;
  text-align: left; font-size: 13px; padding: 8px 12px; border-radius: 4px;
  cursor: pointer;
}
.btn-secondary-settings:hover { background: #333; }
#share-copy-hint { font-size: 11px; color: #4ec9b0; min-height: 14px; }
#settings-name-hint { font-size: 11px; color: #4ec9b0; margin-top: 4px; min-height: 16px; }
#push-status { font-size: 11px; color: #555; margin-top: 4px; }
#privacy-hint { font-size: 11px; color: #4ec9b0; margin-top: 8px; min-height: 16px; }

/* ── Settings: privacy checkboxes ── */
.privacy-option {
  display: flex !important;  /* override global label { display: block } */
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin: 0 0 12px;          /* global label gives margin: 10px 0 4px, override */
  color: inherit;
}
.privacy-option input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.privacy-option-title { font-size: 13px; }
.privacy-option-desc  { font-size: 11px; color: #555; margin-top: 2px; }

/* ── Settings: PWA install ── */
#install-section, #install-ios-hint { margin-bottom: 20px; }
.ios-install-hint {
  font-size: 13px; color: #9cdcfe; background: #1a2233;
  border: 1px solid #264f78; border-radius: 4px;
  padding: 10px 12px; line-height: 1.6;
}
.btn-install-pwa {
  background: #1e3a2a; border: 1px solid #4ec9b0; color: #4ec9b0;
  width: 100%; text-align: left;
}
.btn-push-subscribe {
  background: #1a2a3a; border: 1px solid #569cd6; color: #569cd6;
  width: 100%; text-align: left;
}

/* ── Settings: data and danger zone ── */
.settings-danger { border-top: 1px solid #333; padding-top: 16px; }
.btn-data-action {
  background: #1a2a3a; border: 1px solid #569cd6; color: #569cd6; text-align: left;
}
.btn-reset-all {
  background: #2a1a1a; border: 1px solid #f44747; color: #f44747; width: 100%;
}

/* ── Welcome screen ── */
.welcome-desc { color: #aaa; font-size: 13px; margin: 0 0 20px; }
.welcome-name-hint { font-size: 11px; color: #555; margin-top: 6px; }
.welcome-lang-row { text-align: right; margin-bottom: 8px; }
.welcome-actions { flex-direction: column; gap: 8px; }
#welcome-name { margin-top: 6px; }
.btn-welcome-start { width: 100%; }

/* ── modal-actions alignment ── */
.modal-actions-split { justify-content: space-between; }

/* ── Settings: input + button row ── */
.settings-name-row {
  display: flex; gap: 8px; align-items: center;
}
.settings-name-row input  { flex: 1; margin: 0; }
.settings-name-row button { flex-shrink: 0; margin: 0; }

/* ── Settings: data — button list ── */
.settings-data-list {
  display: flex; flex-direction: column; gap: 8px;
}

/* ── Privacy: checkbox list ── */
.privacy-list {
  display: flex; flex-direction: column; gap: 10px;
}

/* ── modal-actions-split: inner button group ── */
.modal-actions-split-right {
  display: flex; gap: 10px;
}

/* ── Settings tabs ── */
.settings-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid #333;
  margin-bottom: 16px;
}
.settings-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: #888; font-size: 14px; padding: 6px 14px; cursor: pointer;
  margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.settings-tab:hover  { color: #ccc; }
.settings-tab.active { color: #7aa; border-bottom-color: #7aa; }

/* ── Logs block ── */
.logs-toolbar {
  display: flex; gap: 8px; margin-bottom: 8px;
}
.logs-toolbar button {
  background: #2a2a2a; border: 1px solid #444; border-radius: 6px;
  color: #ccc; font-size: 12px; padding: 4px 10px; cursor: pointer;
}
.logs-toolbar button:hover { background: #333; }

#app-log-output {
  font-family: monospace; font-size: 11px; line-height: 1.5;
  background: #111; border: 1px solid #333; border-radius: 6px;
  padding: 8px; height: 360px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}
#app-log-output .log-info  { color: #ccc; }
#app-log-output .log-warn  { color: #e8a93a; }
#app-log-output .log-error { color: #f44747; }
