/* Notachat — estilos (claro / oscuro), inspirado en WhatsApp, más minimalista */
:root {
  --accent: #00a884;
  --accent-strong: #008069;
  --bg: #eef0f3;
  --panel: #ffffff;
  --panel-2: #f5f6f8;
  --head: #f7f8fa;
  --line: #e7e9ec;
  --text: #111b21;
  --text-2: #54656f;
  --text-3: #8696a0;
  --hover: #f3f4f6;
  --active: #ebeef1;
  --chat-bg: #efeae2;
  --bubble: #d9fdd3;
  --bubble-text: #111b21;
  --bubble-meta: #667781;
  --card: rgba(0,0,0,.045);
  --danger: #e5484d;
  --star: #f5b100;
  --shadow: 0 6px 28px rgba(11,20,26,.14), 0 1px 3px rgba(11,20,26,.08);
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1014;
  --panel: #111b21;
  --panel-2: #1b262d;
  --head: #18232a;
  --line: #222e35;
  --text: #e9edef;
  --text-2: #aebac1;
  --text-3: #8696a0;
  --hover: #1d2a31;
  --active: #233138;
  --chat-bg: #0b141a;
  --bubble: #005c4b;
  --bubble-text: #e9edef;
  --bubble-meta: #99beb7;
  --card: rgba(255,255,255,.06);
  --shadow: 0 8px 30px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; display: block; flex-shrink: 0; }
a { color: #027eb5; }
:root[data-theme="dark"] a { color: #53bdeb; }

.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); transition: background .15s, color .15s; flex-shrink: 0; }
.icon-btn:hover { background: var(--hover); }
.icon-btn.active { color: var(--accent); }
.icon-btn.danger { color: var(--danger); }
.btn-primary { background: var(--accent); color: #fff; border-radius: 24px; padding: 11px 22px; font-weight: 600; transition: filter .15s; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { color: var(--accent-strong); padding: 10px 16px; border-radius: 24px; font-weight: 600; }
:root[data-theme="dark"] .btn-ghost { color: var(--accent); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { color: var(--danger); }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login-card { background: var(--panel); padding: 36px 30px; border-radius: 22px; width: min(360px, 100%); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-logo { width: 72px; height: 72px; margin: 0 auto 4px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0 0 10px; color: var(--text-2); }
.login-card input { padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); outline: none; }
.login-card input:focus { border-color: var(--accent); }
.login-error { color: var(--danger); min-height: 20px; font-size: 14px; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100dvh; max-width: 1600px; margin: 0 auto; background: var(--panel); }
@media (min-width: 1640px) { .app { height: calc(100dvh - 38px); margin-top: 19px; box-shadow: var(--shadow); border-radius: 6px; overflow: hidden; } }
.sidebar { width: 30%; min-width: 320px; max-width: 440px; display: flex; flex-direction: column; border-right: 1px solid var(--line); position: relative; background: var(--panel); }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--chat-bg); }

.side-head, .chat-head { height: 60px; padding: 0 10px 0 16px; display: flex; align-items: center; gap: 6px; flex-shrink: 0; padding-top: var(--safe-t); box-sizing: content-box; }
.side-head { background: var(--panel); }
.brand { font-size: 21px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -.2px; }
.head-actions { display: flex; gap: 2px; margin-left: auto; }

.search-wrap { padding: 4px 12px 10px; }
.search { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 10px; padding: 0 12px; height: 38px; }
.search-ic { color: var(--text-3); }
.search-ic svg { width: 18px; height: 18px; }
.search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; font-size: 14.5px; }

.chat-list, .search-results { flex: 1; overflow-y: auto; padding-bottom: 90px; }
.chat-item { display: flex; align-items: center; gap: 13px; padding: 0 14px; height: 72px; cursor: pointer; position: relative; user-select: none; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item .meta { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--line); gap: 3px; }
.chat-item:last-child .meta { border-bottom: 0; }
.row1, .row2 { display: flex; align-items: center; gap: 8px; }
.chat-name { font-size: 16px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 12px; color: var(--text-3); }
.chat-last { font-size: 14px; color: var(--text-2); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.chat-last svg { width: 16px; height: 16px; color: var(--text-3); display: inline-block; vertical-align: -3px; margin-right: 2px; }
.pin-ic { color: var(--text-3); }
.pin-ic svg { width: 16px; height: 16px; }
.list-label { padding: 14px 16px 6px; font-size: 13px; color: var(--accent-strong); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
:root[data-theme="dark"] .list-label { color: var(--accent); }
.list-empty { padding: 40px 30px; text-align: center; color: var(--text-3); line-height: 1.5; }

.avatar { width: 49px; height: 49px; border-radius: 50%; display: grid; place-items: center; font-size: 25px; flex-shrink: 0; overflow: hidden; background: var(--panel-2); color: #fff; font-weight: 600; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 40px; height: 40px; font-size: 21px; }
.avatar.xl { width: 110px; height: 110px; font-size: 56px; }

.fab { position: absolute; right: 20px; bottom: calc(22px + var(--safe-b)); width: 56px; height: 56px; border-radius: 17px; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,168,132,.35); transition: transform .15s; }
.fab:hover { transform: translateY(-2px); }
.fab svg { width: 26px; height: 26px; }

.result-item { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--line); }
.result-item:hover { background: var(--hover); }
.result-item .r-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-3); margin-bottom: 3px; gap: 8px; }
.result-item .r-chat { color: var(--accent-strong); font-weight: 600; }
:root[data-theme="dark"] .result-item .r-chat { color: var(--accent); }
.result-item .r-text { font-size: 14px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
mark { background: rgba(0,168,132,.25); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Vacío ---------- */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; background: var(--head); border-bottom: 6px solid var(--accent); }
.empty-state img { width: 96px; height: 96px; opacity: .9; }
.empty-state h2 { font-weight: 300; font-size: 30px; margin: 20px 0 8px; }
.empty-state p { color: var(--text-2); max-width: 440px; line-height: 1.6; margin: 0; }

/* ---------- Conversación ---------- */
.chat-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { background: var(--head); border-bottom: 1px solid var(--line); padding-left: 10px; }
.chat-head .back { display: none; }
.chat-head-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; padding: 6px; border-radius: 10px; }
.chat-head-info .avatar { width: 42px; height: 42px; font-size: 22px; }
.chat-head-text { min-width: 0; }
.chat-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12.5px; color: var(--text-3); }
.chat-search { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; background: var(--head); border-bottom: 1px solid var(--line); }
.chat-search .search { flex: 1; background: var(--panel); }

.pinned-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--head); border-bottom: 1px solid var(--line); cursor: pointer; min-height: 52px; }
.pinned-bar .pb-ind { display: flex; flex-direction: column; gap: 2px; align-self: stretch; justify-content: center; }
.pinned-bar .pb-ind i { width: 3px; flex: 1; max-height: 14px; border-radius: 2px; background: var(--text-3); opacity: .35; }
.pinned-bar .pb-ind i.on { background: var(--accent); opacity: 1; }
.pinned-bar .pb-body { flex: 1; min-width: 0; }
.pinned-bar .pb-title { font-size: 13px; color: var(--accent-strong); font-weight: 600; display: flex; align-items: center; gap: 5px; }
:root[data-theme="dark"] .pinned-bar .pb-title { color: var(--accent); }
.pinned-bar .pb-title svg { width: 14px; height: 14px; }
.pinned-bar .pb-text { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-bar .pb-thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; }

.messages-wrap { flex: 1; position: relative; min-height: 0; }
.messages {
  position: absolute; inset: 0; overflow-y: auto; padding: 14px 6% 10px; display: flex; flex-direction: column;
  background-color: var(--chat-bg);
  background-image: radial-gradient(rgba(0,0,0,.045) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  overscroll-behavior: contain;
}
:root[data-theme="dark"] .messages { background-image: radial-gradient(rgba(255,255,255,.035) 1.2px, transparent 1.3px); }
.load-more { align-self: center; margin: 4px 0 10px; font-size: 13px; color: var(--text-2); background: var(--panel); padding: 6px 14px; border-radius: 16px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.day-sep { align-self: center; margin: 10px 0 8px; position: sticky; top: 4px; z-index: 2; background: var(--panel); color: var(--text-2); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11,20,26,.13); }
.chat-intro { align-self: center; text-align: center; max-width: 420px; margin: 6px 0 14px; background: #fff7d6; color: #54656f; font-size: 13px; padding: 8px 14px; border-radius: 8px; line-height: 1.45; }
:root[data-theme="dark"] .chat-intro { background: #182229; color: #ffd279; }

.msg { align-self: flex-end; max-width: min(68%, 560px); margin: 2px 0; position: relative; }
.msg.first { margin-top: 8px; }
.bubble { background: var(--bubble); color: var(--bubble-text); border-radius: 10px; padding: 6px 8px 8px 10px; box-shadow: 0 1px .5px rgba(11,20,26,.13); position: relative; overflow-wrap: anywhere; min-width: 92px; }
.msg.first .bubble { border-top-right-radius: 2px; }
.msg.first .bubble::after { content: ""; position: absolute; top: 0; right: -7px; width: 8px; height: 13px; background: var(--bubble); clip-path: polygon(0 0, 100% 0, 0 100%); }
.msg.highlight .bubble { animation: flash 1.6s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 1px .5px rgba(11,20,26,.13); } }
.msg-text { white-space: pre-wrap; line-height: 1.42; font-size: 14.6px; }
.msg-text code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--card); padding: 1px 4px; border-radius: 4px; }
.msg-text.big-emoji { font-size: 40px; line-height: 1.2; }
.msg-meta { float: right; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--bubble-meta); margin: 6px 0 -4px 10px; position: relative; top: 4px; white-space: nowrap; }
.msg-meta svg { width: 13px; height: 13px; }
.msg-meta .star { color: var(--star); }
.msg-meta-block { display: flex; justify-content: flex-end; }
.msg-meta-block .msg-meta { float: none; margin: 4px 0 -4px; top: 0; }
.msg-menu-btn { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bubble); color: var(--bubble-meta); opacity: 0; transition: opacity .12s; z-index: 2; box-shadow: -6px 0 8px var(--bubble); }
.msg-menu-btn svg { width: 18px; height: 18px; }
@media (hover: hover) { .msg:hover .msg-menu-btn { opacity: 1; } }
.msg.selected .bubble { filter: brightness(.93); }

/* Vista previa de enlace */
.link-card { display: block; text-decoration: none; color: inherit !important; background: var(--card); border-radius: 8px; overflow: hidden; margin: 0 -4px 6px -6px; }
.link-card .lc-img { position: relative; background: rgba(0,0,0,.08); }
.link-card .lc-img img { width: 100%; display: block; max-height: 300px; object-fit: cover; }
.link-card .lc-play { position: absolute; inset: 0; display: grid; place-items: center; }
.link-card .lc-play span { width: 54px; height: 54px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; color: #fff; backdrop-filter: blur(4px); }
.link-card .lc-play svg { width: 26px; height: 26px; margin-left: 3px; }
.link-card .lc-body { padding: 8px 10px 9px; }
.link-card .lc-site { font-size: 12px; color: var(--bubble-meta); display: flex; align-items: center; gap: 6px; text-transform: lowercase; }
.link-card .lc-site img { width: 14px; height: 14px; border-radius: 3px; }
.link-card .lc-title { font-size: 14px; font-weight: 600; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-card .lc-desc { font-size: 13px; color: var(--bubble-meta); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-card.loading .lc-body { color: var(--bubble-meta); font-size: 13px; }

/* Media */
.media-grid { display: grid; gap: 3px; margin: -2px -4px 4px -6px; border-radius: 8px; overflow: hidden; }
.media-grid.n1 { grid-template-columns: 1fr; }
.media-grid.n2, .media-grid.n3, .media-grid.n4 { grid-template-columns: 1fr 1fr; }
.media-grid.n3 .mitem:first-child { grid-column: span 2; }
.mitem { position: relative; cursor: pointer; background: rgba(0,0,0,.12); overflow: hidden; aspect-ratio: 1; }
.media-grid.n1 .mitem { aspect-ratio: auto; max-height: 420px; }
.media-grid.n3 .mitem:first-child { aspect-ratio: 2 / 1; }
.mitem img, .mitem video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid.n1 .mitem img, .media-grid.n1 .mitem video { height: auto; max-height: 420px; min-height: 120px; object-fit: cover; }
.mitem .more { position: absolute; inset: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 28px; display: grid; place-items: center; }
.mitem .play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.mitem .play span { width: 50px; height: 50px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; color: #fff; }
.mitem .play svg { margin-left: 3px; }
.drawing-img { display: block; width: 100%; border-radius: 8px; margin: -2px -4px 4px -6px; width: calc(100% + 10px); background: #fff; cursor: zoom-in; }

/* Archivo */
.file-card { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 8px; padding: 10px 12px; margin: 0 -4px 4px -6px; text-decoration: none; color: inherit !important; min-width: 230px; }
.file-card .f-ic { width: 40px; height: 46px; border-radius: 6px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; text-transform: uppercase; flex-shrink: 0; }
.file-card .f-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .f-size { font-size: 12px; color: var(--bubble-meta); }
.file-card .f-dl { margin-left: auto; color: var(--bubble-meta); }

/* Audio */
.audio { display: flex; align-items: center; gap: 10px; min-width: 250px; padding: 4px 2px 0 0; }
.audio .a-play { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.audio .a-play svg { width: 20px; height: 20px; }
.audio .a-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.audio .a-wave { height: 28px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.audio .a-wave i { flex: 1; background: var(--bubble-meta); opacity: .45; border-radius: 2px; min-height: 3px; }
.audio .a-wave i.on { background: var(--accent); opacity: 1; }
.audio .a-info { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--bubble-meta); }
.audio .a-speed { font-size: 12px; font-weight: 700; background: var(--card); border-radius: 10px; padding: 3px 7px; color: var(--bubble-meta); }

/* Checklist */
.checklist { min-width: 240px; }
.checklist .cl-title { font-weight: 600; font-size: 15px; margin: 2px 0 6px; display: flex; align-items: center; gap: 8px; }
.checklist .cl-title svg { width: 18px; height: 18px; color: var(--accent); }
.checklist .cl-progress { height: 4px; background: var(--card); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.checklist .cl-progress i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.cl-item { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; cursor: pointer; user-select: none; }
.cl-box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--bubble-meta); flex-shrink: 0; display: grid; place-items: center; margin-top: 1px; transition: all .15s; }
.cl-box svg { width: 14px; height: 14px; color: #fff; opacity: 0; }
.cl-item.done .cl-box { background: var(--accent); border-color: var(--accent); }
.cl-item.done .cl-box svg { opacity: 1; }
.cl-item.done .cl-text { text-decoration: line-through; color: var(--bubble-meta); }
.cl-text { font-size: 14.5px; line-height: 1.35; }
.cl-count { font-size: 12px; color: var(--bubble-meta); margin-top: 4px; }

.caption { margin-top: 2px; }

/* Botón bajar */
.scroll-down { position: absolute; right: 18px; bottom: 14px; width: 42px; height: 42px; border-radius: 50%; background: var(--panel); color: var(--text-2); box-shadow: var(--shadow); display: grid; place-items: center; z-index: 3; }
.drop-overlay { position: absolute; inset: 10px; border: 3px dashed var(--accent); border-radius: 16px; background: rgba(0,168,132,.08); display: grid; place-items: center; font-size: 18px; color: var(--accent-strong); font-weight: 600; z-index: 5; pointer-events: none; backdrop-filter: blur(2px); }

.chat-search-results { position: absolute; inset: 0; background: var(--panel); overflow-y: auto; z-index: 4; }

/* Composer */
.upload-progress { position: relative; height: 26px; background: var(--head); font-size: 12px; color: var(--text-2); display: flex; align-items: center; padding: 0 16px; }
.upload-progress .bar { position: absolute; left: 0; top: 0; height: 3px; background: var(--accent); width: 0; transition: width .2s; }
.link-draft, .edit-banner { background: var(--head); padding: 8px 14px 0; }
.link-draft .ld, .edit-banner .eb { display: flex; gap: 10px; align-items: center; background: var(--panel); border-radius: 10px; padding: 8px; border-left: 4px solid var(--accent); }
.link-draft img { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; }
.link-draft .ld-body, .edit-banner .eb-body { flex: 1; min-width: 0; }
.link-draft .ld-title, .edit-banner .eb-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-draft .ld-sub, .edit-banner .eb-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-banner .eb-title { color: var(--accent-strong); }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); background: var(--head); position: relative; flex-shrink: 0; }
.composer-box { flex: 1; display: flex; align-items: flex-end; background: var(--panel); border-radius: 24px; min-height: 46px; padding: 3px 4px; box-shadow: 0 1px .5px rgba(11,20,26,.08); }
.composer textarea { flex: 1; border: 0; outline: none; resize: none; background: none; padding: 10px 4px; max-height: 160px; min-height: 40px; line-height: 1.4; font-size: 15px; min-width: 0; overflow-y: hidden; }
.composer-box .icon-btn { width: 40px; height: 40px; }
.dictate.listening { color: #fff; background: var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.5); } 100% { box-shadow: 0 0 0 12px rgba(229,72,77,0); } }
.send-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0; transition: transform .12s; }
.send-btn:active { transform: scale(.94); }

.recorder { position: absolute; inset: 0; background: var(--head); display: flex; align-items: center; gap: 12px; padding: 8px 10px calc(8px + var(--safe-b)) 10px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 16px; min-width: 44px; }
.rec-wave { flex: 1; height: 40px; min-width: 0; }

.attach-menu { position: absolute; left: 12px; bottom: calc(70px + var(--safe-b)); background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; display: flex; flex-direction: column; min-width: 220px; z-index: 20; animation: pop .14s ease; transform-origin: bottom left; }
@keyframes pop { from { opacity: 0; transform: scale(.92) translateY(6px); } }
.attach-menu button { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 10px; text-align: left; font-size: 15px; }
.attach-menu button:hover { background: var(--hover); }
.attach-menu .am-ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.attach-menu .am-ic svg { width: 19px; height: 19px; }

/* ---------- Menús contextuales ---------- */
.ctx-menu { position: fixed; z-index: 1000; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 210px; animation: pop .12s ease; }
.ctx-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 8px; text-align: left; font-size: 14.5px; color: var(--text); }
.ctx-menu button svg { width: 19px; height: 19px; color: var(--text-2); }
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.danger, .ctx-menu button.danger svg { color: var(--danger); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.ctx-backdrop { position: fixed; inset: 0; z-index: 999; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,.35); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.ctx-menu.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; border-radius: 20px 20px 0 0; padding: 10px 10px calc(14px + var(--safe-b)); animation: up .18s ease; }
.ctx-menu.sheet::before { content: ""; display: block; width: 40px; height: 4px; background: var(--line); border-radius: 2px; margin: 0 auto 8px; }
.ctx-menu.sheet button { padding: 13px 14px; font-size: 15.5px; }
@keyframes up { from { transform: translateY(100%); } }

/* ---------- Modales ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,20,26,.5); z-index: 500; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border-radius: 20px; width: min(460px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .16s ease; overflow: hidden; }
.modal.wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px 20px; }
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 16px; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.input { padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); outline: none; width: 100%; }
.input:focus { border-color: var(--accent); }

.avatar-edit { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0 16px; }
.avatar-edit .ae-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { padding: 7px 13px; border-radius: 18px; background: var(--panel-2); font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { background: var(--active); }
.chip svg { width: 16px; height: 16px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; max-height: 190px; overflow-y: auto; padding: 2px; }
.emoji-grid button { font-size: 24px; height: 40px; border-radius: 10px; }
.emoji-grid button:hover, .emoji-grid button.on { background: var(--active); }
.emoji-grid button.on { box-shadow: inset 0 0 0 2px var(--accent); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-row button { width: 30px; height: 30px; border-radius: 50%; }
.color-row button.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text-2); }

.pick-list { display: flex; flex-direction: column; }
.pick-list .chat-item { height: 60px; padding: 0 8px; border-radius: 10px; }
.pick-list .chat-item .meta { border: 0; }

/* Lista de chequeo (editor) */
.cl-edit-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cl-edit-item .cl-box { cursor: pointer; }
.cl-edit-item input[type=text] { flex: 1; border: 0; border-bottom: 1px solid var(--line); background: none; outline: none; padding: 8px 2px; }
.cl-edit-item input[type=text]:focus { border-color: var(--accent); }
.cl-edit-item .icon-btn { width: 32px; height: 32px; }
.cl-edit-item .icon-btn svg { width: 18px; height: 18px; }
.cl-edit-item.done .cl-box { background: var(--accent); border-color: var(--accent); }
.cl-edit-item.done .cl-box svg { opacity: 1; }

/* Previsualización de adjuntos */
.attach-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.ap-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--panel-2); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 12px; padding: 4px; color: var(--text-2); }
.ap-item img, .ap-item video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ap-item .ap-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; z-index: 2; }
.ap-item .ap-x svg { width: 15px; height: 15px; }
.ap-item .ap-name { word-break: break-all; padding: 0 6px; }

/* ---------- Pizarra ---------- */
.draw { position: fixed; inset: 0; z-index: 600; background: var(--bg); display: flex; flex-direction: column; animation: fade .15s; }
.draw-top { display: flex; align-items: center; gap: 4px; padding: calc(8px + var(--safe-t)) 10px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.draw-top .title { font-weight: 600; font-size: 16px; flex: 1; padding-left: 6px; }
.draw-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; }
.draw-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.draw-tools { display: flex; align-items: center; gap: 10px; padding: 10px 12px calc(10px + var(--safe-b)); background: var(--panel); border-top: 1px solid var(--line); overflow-x: auto; }
.draw-tools .sep { width: 1px; height: 28px; background: var(--line); flex-shrink: 0; }
.swatch { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; border: 2px solid var(--line); }
.swatch.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.size-btn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.size-btn i { background: var(--text); border-radius: 50%; display: block; }
.size-btn.on { background: var(--active); }
.tool-btn.on { background: var(--active); color: var(--accent); }

/* ---------- Visor ---------- */
.viewer { position: fixed; inset: 0; z-index: 700; background: rgba(8,12,15,.96); display: flex; flex-direction: column; animation: fade .15s; color: #fff; }
.viewer-top { display: flex; align-items: center; gap: 6px; padding: calc(8px + var(--safe-t)) 10px 8px; }
.viewer-top .icon-btn { color: #fff; }
.viewer-top .icon-btn:hover { background: rgba(255,255,255,.12); }
.viewer-top .v-info { flex: 1; font-size: 14px; opacity: .8; padding-left: 8px; }
.viewer-stage { flex: 1; display: grid; place-items: center; position: relative; min-height: 0; padding: 10px; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; }
.viewer-nav.prev { left: 14px; } .viewer-nav.next { right: 14px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: #233138; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 2000; box-shadow: var(--shadow); max-width: calc(100vw - 32px); animation: pop .15s; }

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .sidebar { width: 100%; max-width: none; min-width: 0; border: 0; }
  .chat { position: fixed; inset: 0; transform: translateX(100%); transition: transform .22s ease; z-index: 50; }
  .app.in-chat .chat { transform: none; }
  .chat-head .back { display: grid; }
  .chat-head { padding-left: 4px; }
  .chat-head-info { padding: 4px; gap: 10px; }
  .messages { padding: 10px 10px 8px 12px; }
  .msg { max-width: 86%; }
  .empty-state { display: none; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 22px 22px 0 0; max-height: 92dvh; animation: up .2s ease; }
  .modal-foot { padding-bottom: calc(16px + var(--safe-b)); }
  .viewer-nav { display: none; }
}
@media (min-width: 761px) { .app.in-chat .empty-state { display: none; } }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: rgba(134,150,160,.35); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
