:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #edf7f1;
  --muted: #8fa69a;
  --ground: #0a100d;
  --panel: #101915;
  --panel-2: #15211b;
  --line: rgba(213, 244, 225, .09);
  --accent: #a9f3c9;
  --accent-ink: #092116;
  --danger: #ff9c9c;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--ground); color: var(--ink); }
body { min-height: 100dvh; height: 100%; overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.welcome {
  min-height: 100dvh; max-width: 520px; margin: auto; padding: 48px 28px calc(40px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(circle at 50% 35%, rgba(89, 177, 126, .16), transparent 37%);
}
.brand-mark { width: 76px; height: 76px; display: grid; place-items: center; border: 1px solid #4b705d; border-radius: 26px; color: var(--accent); font: 500 36px/1 Georgia, serif; transform: rotate(-5deg); }
.welcome h1 { font: 500 48px/1.1 Georgia, serif; margin: 26px 0 12px; letter-spacing: -.03em; }
.welcome p { color: #b3c4ba; line-height: 1.55; max-width: 390px; margin: 0 0 30px; }
.welcome small { color: var(--muted); margin-top: 18px; }
.primary { border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); padding: 14px 20px; font-weight: 700; cursor: pointer; }
.primary:disabled { opacity: .55; cursor: wait; }
.primary.compact { padding: 8px 16px; font-size: 22px; }

.app { height: 100dvh; display: grid; grid-template-columns: minmax(280px, 360px) 1fr; }
.sidebar { min-width: 0; padding: calc(18px + env(safe-area-inset-top)) 18px 18px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.identity { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.profile-avatar { margin-right: 10px; cursor: pointer; }
.identity > div { flex: 1; }
.eyebrow { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .13em; margin-bottom: 5px; }
.alias { border: 0; padding: 0; background: none; font-size: 21px; font-weight: 700; cursor: pointer; }
.alias span:last-child { color: var(--muted); font-size: 15px; margin-left: 4px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.02); cursor: pointer; }
.connect-card { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-2); }
.connect-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 13px; margin-bottom: 8px; padding: 11px 13px; background: rgba(255,255,255,.025); color: #bfd0c6; font-size: 13px; font-weight: 650; cursor: pointer; }
.connect-toggle span:last-child { color: var(--accent); font-size: 12px; font-weight: 700; }
.connect-toggle:hover { border-color: rgba(169,243,201,.35); }
.connect-card label { display: block; color: #bfd0c6; font-size: 13px; margin-bottom: 9px; }
.connect-row { display: flex; gap: 8px; }
.connect-row input { width: 100%; min-width: 0; border: 1px solid #32463b; border-radius: 12px; background: #0c1510; color: var(--ink); padding: 10px 12px; outline: none; }
.connect-row input:focus { border-color: #75c497; box-shadow: 0 0 0 3px rgba(117,196,151,.1); }
.form-error { min-height: 0; color: var(--danger); font-size: 12px; margin: 8px 2px 0; }
.form-error:empty { margin: 0; }
.requests-section { margin-top: 18px; }
.request-list { display: grid; gap: 8px; }
.request-card { display: grid; grid-template-columns: 38px 1fr; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(169,243,201,.045); }
.request-card .avatar { width: 38px; height: 38px; font-size: 17px; }
.request-copy { min-width: 0; display: grid; gap: 3px; font-size: 12px; line-height: 1.35; }
.request-copy strong { font-size: 14px; }
.request-copy span { color: var(--muted); }
.request-actions { grid-column: 2; display: flex; gap: 7px; }
.request-actions button { border-radius: 9px; padding: 7px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.request-accept { border: 0; background: var(--accent); color: var(--accent-ink); }
.request-reject { border: 1px solid var(--line); background: transparent; color: var(--muted); }
.request-actions button:disabled { opacity: .55; cursor: wait; }
.list-heading { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin: 24px 4px 10px; }
.link-button { margin-left: auto; border: 0; padding: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.link-button:hover { color: var(--accent); }
.chat-list { display: grid; gap: 5px; }
.chat-item { width: 100%; display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; align-items: center; text-align: left; padding: 10px; border: 0; border-radius: 13px; background: transparent; cursor: pointer; }
.chat-item:hover, .chat-item.active { background: rgba(169,243,201,.07); }
.avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: #243a2e; color: var(--accent); font-weight: 800; }
.avatar[data-avatar="luna"] { background: #282343; color: #d5d0ff; }
.avatar[data-avatar="coral"] { background: #3d2929; color: #ffb0a5; }
.avatar[data-avatar="bosque"] { background: #1d392e; color: #9de7b5; }
.avatar[data-avatar="brisa"] { background: #203743; color: #a9e7f8; }
.chat-name { display: block; font-weight: 650; }
.chat-preview { display: block; max-width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 12px; margin-top: 4px; }
.chat-time { color: var(--muted); font-size: 10px; }
.empty-list { color: var(--muted); text-align: center; font-size: 13px; line-height: 1.5; padding: 35px 22px; }

.conversation { min-width: 0; background: radial-gradient(circle at 45% 45%, #111c16 0, #0a100d 65%); }
.conversation.empty { display: grid; place-items: center; }
.empty-chat { text-align: center; max-width: 360px; padding: 30px; color: var(--muted); }
.empty-chat h2 { color: var(--ink); font: 400 28px/1.2 Georgia, serif; }
.empty-chat p { line-height: 1.55; }
.empty-orbit { margin: auto; width: 82px; height: 82px; display: grid; place-items: center; border: 1px solid #31503f; border-radius: 50%; color: var(--accent); font-size: 28px; box-shadow: 0 0 0 14px rgba(72,115,90,.08); }
.chat-view { height: 100%; display: grid; grid-template-rows: auto 1fr auto auto; }
.chat-header { min-height: calc(70px + env(safe-area-inset-top)); padding: calc(12px + env(safe-area-inset-top)) 18px 10px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: rgba(10,16,13,.82); backdrop-filter: blur(18px); }
.peer { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.peer span { color: var(--muted); font-size: 11px; }
.back { display: none; }
.messages { overflow-y: auto; padding: 24px max(22px, calc((100% - 760px) / 2)); display: flex; flex-direction: column; gap: 9px; }
.message { max-width: min(76%, 520px); align-self: flex-start; }
.message.mine { align-self: flex-end; }
.bubble { padding: 10px 13px; border-radius: 16px 16px 16px 4px; background: #1a2921; overflow-wrap: anywhere; line-height: 1.42; }
.mine .bubble { background: #b2edca; color: #0a2114; border-radius: 16px 16px 4px 16px; }
.bubble img { display: block; max-width: 100%; max-height: 420px; border-radius: 10px; }
.bubble audio { display: block; width: min(300px, 65vw); height: 42px; }
.message-meta { color: var(--muted); font-size: 9px; margin: 4px 5px 0; }
.message-status { color: var(--accent); }
.mine .message-meta { text-align: right; }
.system-message { align-self: center; color: var(--muted); font-size: 11px; margin: 8px; }
.media-preview { width: min(820px, calc(100% - 36px)); margin: 4px auto 0; display: grid; grid-template-columns: 60px 1fr auto auto; align-items: center; gap: 10px; padding: 8px; border: 1px solid #355044; border-radius: 15px; background: #132019; }
.media-preview img { width: 60px; height: 60px; object-fit: cover; border-radius: 10px; background: #0a100d; }
.media-preview-copy { min-width: 0; display: grid; gap: 3px; }
.media-preview-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.media-preview-copy span { color: var(--muted); font-size: 11px; }
.image-mode-label { color: var(--muted); font-size: 11px; }
.image-mode-label select { margin-left: 3px; border: 1px solid var(--line); border-radius: 7px; background: #0c1510; color: var(--ink); padding: 3px 5px; font-size: 11px; }
.upload-track { height: 3px; overflow: hidden; border-radius: 99px; background: rgba(169,243,201,.14); }
.upload-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .15s linear; }
.preview-action, .preview-send { border: 0; cursor: pointer; }
.preview-action { width: 28px; height: 28px; border-radius: 50%; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.preview-send { border-radius: 10px; padding: 9px 11px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 750; white-space: nowrap; }
.preview-send:disabled, .preview-action:disabled { opacity: .55; cursor: wait; }
.reveal-image { min-width: 170px; border: 1px solid rgba(169,243,201,.35); border-radius: 12px; padding: 18px 15px; background: rgba(169,243,201,.08); color: var(--accent); font-weight: 700; cursor: pointer; }
.composer { margin: 0 auto; width: min(820px, 100%); padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; max-height: 120px; resize: none; border: 1px solid #30443a; border-radius: 18px; background: var(--panel-2); color: var(--ink); padding: 11px 14px; outline: none; }
.attach-button, .record-button, .send-button { flex: 0 0 auto; width: 43px; height: 43px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.attach-button { border: 1px solid var(--line); color: var(--accent); font-size: 25px; }
.record-button { border: 1px solid var(--line); background: transparent; color: #e3a1a1; }
.record-button.recording { color: #ff6969; border-color: #ff6969; }
.send-button { border: 0; background: var(--accent); color: var(--accent-ink); font-size: 20px; }
.recording-bar { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); padding: 9px 14px; border-radius: 20px; background: #432225; font-size: 12px; }
.recording-bar button { margin-left: 12px; border: 0; background: none; text-decoration: underline; cursor: pointer; }
.pulse { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #ff6f75; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

dialog { width: min(360px, calc(100% - 32px)); border: 1px solid #33483d; border-radius: 18px; padding: 8px; background: #142019; color: var(--ink); }
.info-dialog h2 { margin: 8px 12px 12px; font-size: 20px; }
.info-expiry { margin: 0 12px 8px; color: var(--accent); line-height: 1.45; }
.info-note { margin: 0 12px 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.qr-panel { display: grid; place-items: center; text-align: center; }
.qr-image { width: min(250px, 72vw); aspect-ratio: 1; margin: 10px 0; padding: 10px; border-radius: 14px; background: #fff; }
.qr-panel strong { font-size: 21px; }
.qr-panel p { margin: 10px 8px 4px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.qr-connect-person { display: flex; align-items: center; gap: 12px; margin: 8px 4px 2px; }
.qr-connect-person .avatar { flex: 0 0 auto; }
.qr-connect-person div { display: grid; gap: 3px; }
.qr-connect-person span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.qr-request { color: var(--accent-ink); background: var(--accent); font-weight: 750; }
dialog::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(3px); }
.dialog-action { width: 100%; border: 0; border-radius: 12px; padding: 13px; background: transparent; text-align: left; cursor: pointer; }
.dialog-action:hover { background: rgba(255,255,255,.05); }
.dialog-action.danger { color: var(--danger); }
.avatar-panel { padding: 12px 12px 8px; }
.avatar-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.avatar-option { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 50%; background: #243a2e; color: var(--accent); font-size: 20px; cursor: pointer; }
.avatar-option.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar-option[data-avatar="luna"] { background: #282343; color: #d5d0ff; }
.avatar-option[data-avatar="coral"] { background: #3d2929; color: #ffb0a5; }
.avatar-option[data-avatar="bosque"] { background: #1d392e; color: #9de7b5; }
.avatar-option[data-avatar="brisa"] { background: #203743; color: #a9e7f8; }
.toast { position: fixed; z-index: 5; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0; pointer-events: none; border: 1px solid var(--line); border-radius: 99px; padding: 10px 16px; background: #1a2921; font-size: 12px; transition: .2s ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 700px) {
  html, body { background: #0a100d; }
  .app { display: block; min-height: 100dvh; height: 100dvh; }
  .sidebar { height: 100%; border: 0; }
  .conversation { display: none; position: fixed; inset: 0; z-index: 2; width: 100%; height: 100dvh; min-height: 100dvh; }
  .conversation.mobile-open { display: block; }
  .conversation.empty { display: none; }
  .conversation.mobile-open .chat-view { position: fixed; inset: 0; height: 100dvh; min-height: 100dvh; }
  .back { display: grid; }
  .chat-header { padding-left: 10px; }
  .messages { padding: 18px 13px; }
  .message { max-width: 84%; }
  .composer { padding-left: 10px; padding-right: 10px; }
  .media-preview { width: calc(100% - 20px); grid-template-columns: 52px 1fr auto; }
  .media-preview img { width: 52px; height: 52px; }
  .preview-send { grid-column: 2 / 4; }
}
