/* features.css: edit/delete, attachments, pickers, profiles (v2.5) */

a.btn { text-decoration: none; text-align: center; justify-content: center; }

/* ---------- names you can click ---------- */
button.msg-who { background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 800; text-align: left; cursor: pointer; color: hsl(var(--h, 90) 72% var(--name-l)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
button.msg-who:hover { text-decoration: underline; text-underline-offset: 3px; }
button.msg-who:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- edited + actions ---------- */
.msg.is-edited .msg-body::after { content: ' (edited)'; font-family: var(--font-mono); font-size: 0.68rem; color: var(--dim); white-space: nowrap; }
.msg.is-edited .msg-body.is-empty::after { content: none; }
.msg-body.is-empty { display: none; }
.msg-act {
  position: absolute; top: -0.85rem; right: 0.6rem; z-index: 2; display: none; gap: 0;
  background: var(--panel); border: 2px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.msg-act button { background: none; border: 0; padding: 0.15rem 0.55rem; font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.msg-act button + button { border-left: 2px solid var(--line); }
.msg-act button:hover, .msg-act button:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.msg-act button.is-danger:hover, .msg-act button.is-danger:focus-visible { background: var(--hot); color: #fff; }
.msg.has-actions:hover .msg-act, .msg.has-actions:focus-within .msg-act, .msg.is-picked .msg-act { display: flex; }
@media (hover: none) { .msg.has-actions:hover .msg-act { display: none; } .msg.is-picked .msg-act { display: flex; } }

.msg.is-editing { background: var(--wash); box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- attachments ---------- */
.msg-att { grid-column: 3; margin-top: 0.25rem; min-width: 0; }
.att-media {
  position: relative; width: 20rem; max-width: 100%; width: min(20rem, var(--w, 20rem), 100%); max-height: 20rem; aspect-ratio: var(--ar, 4 / 3);
  border: 2px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--wash); cursor: zoom-in;
}
.att-media.no-size { aspect-ratio: auto; min-height: 6rem; }
.att-media.is-gif { width: min(16rem, var(--w, 16rem), 100%); }
.att-img { display: block; width: 100%; height: 100%; max-height: 20rem; object-fit: contain; }
.att-media.no-size .att-img { height: auto; }
.att-media.is-loading::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: linear-gradient(90deg, transparent, var(--wash), transparent); background-size: 200% 100%; animation: slide 1.2s linear infinite; }
.att-media.is-gone { display: grid; place-items: center; aspect-ratio: auto; min-height: 3rem; padding: 0.6rem; cursor: default; font-family: var(--font-mono); font-size: 0.75rem; color: var(--dim); }
.att-media:hover { border-color: var(--accent); }

.att-file { display: flex; align-items: center; gap: 0.7rem; width: min(22rem, 100%); padding: 0.5rem 0.6rem; border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); }
.att-file-ico { flex: none; width: 2.4rem; height: 2.4rem; display: grid; place-content: center; background: var(--accent); color: var(--accent-ink); font-family: var(--font-mono); font-size: 0.62rem; font-weight: 800; border-radius: var(--radius); }
.att-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.att-file-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file-size { font-family: var(--font-mono); font-size: 0.68rem; color: var(--dim); }
.btn-sm-plain { min-height: 1.9rem; padding: 0.2rem 0.65rem; font-size: 0.75rem; flex: none; }

@media (max-width: 820px) {
  .msg-att { grid-column: 1; order: 2; }
  .msg-act { top: -0.6rem; }
}

/* ---------- composer tools ---------- */
.composer-wrap { position: relative; }
.composer { align-items: stretch; }
.tools { display: flex; align-items: center; gap: 0.25rem; flex: none; }
.tool {
  display: grid; place-content: center; width: 2.35rem; height: 100%; min-height: 2.35rem; padding: 0;
  background: transparent; color: var(--dim); border: 2px solid transparent; border-radius: var(--radius); cursor: pointer;
}
.tool:hover, .tool[aria-expanded='true'] { color: var(--ink); border-color: var(--line-strong); background: var(--wash); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tool:disabled { opacity: 0.4; pointer-events: none; }
.tool-txt { width: auto; padding: 0 0.45rem; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; }

.edit-bar {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 1.1rem;
  border-top: 2px solid var(--line-strong); border-left: 4px solid var(--accent); background: var(--wash);
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink);
}
.edit-bar .pulse { color: var(--accent); }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkish:hover { color: var(--ink); }

.stage.is-drop .stream-wrap { outline: 3px dashed var(--accent); outline-offset: -10px; }

/* ---------- pickers ---------- */
.pop {
  position: absolute; bottom: 100%; left: 0.75rem; z-index: 40; margin-bottom: 0.4rem;
  width: 21rem; max-width: calc(100vw - 1.5rem); max-height: min(24rem, 60vh); display: flex; flex-direction: column;
  background: var(--panel); border: 2px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow);
}
.emoji-tabs { display: flex; gap: 0.2rem; padding: 0.4rem; overflow-x: auto; border-bottom: 2px solid var(--line); flex: none; scrollbar-width: thin; }
.emoji-tabs button { flex: none; background: none; border: 2px solid transparent; padding: 0.15rem 0.45rem; font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700; color: var(--dim); border-radius: var(--radius); cursor: pointer; }
.emoji-tabs button:hover { color: var(--ink); }
.emoji-tabs button.is-active { color: var(--accent-ink); background: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.1rem; padding: 0.4rem; overflow-y: auto; }
.emoji { background: none; border: 0; padding: 0.25rem 0; font-size: 1.35rem; line-height: 1.2; border-radius: var(--radius); cursor: pointer; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.emoji:hover, .emoji:focus-visible { background: var(--wash); outline: none; transform: scale(1.15); }
.emoji-none, .gif-note { grid-column: 1 / -1; padding: 1rem 0.5rem; text-align: center; font-family: var(--font-mono); font-size: 0.75rem; color: var(--dim); }

.pop-gif { width: 24rem; }
.gif-search { margin: 0.5rem; width: auto; flex: none; }
.gif-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; padding: 0 0.5rem 0.5rem; overflow-y: auto; align-content: start; }
.gif-pick { position: relative; padding: 0; border: 2px solid transparent; background: var(--wash); border-radius: var(--radius); overflow: hidden; aspect-ratio: var(--ar, 1 / 1); cursor: pointer; }
.gif-pick img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gif-pick:hover, .gif-pick:focus-visible { border-color: var(--accent); outline: none; }
.pop-foot { flex: none; padding: 0.35rem 0.6rem; border-top: 2px solid var(--line); font-family: var(--font-mono); font-size: 0.62rem; color: var(--dim); }

@media (max-width: 820px) {
  .pop { left: 0.5rem; right: 0.5rem; width: auto; max-width: none; }
  .tool { width: 2.1rem; }
  .edit-bar { padding: 0.35rem 0.75rem; }
}

/* ---------- picture viewer ---------- */
.modal-media { padding: 1rem; }
.media-card { display: grid; gap: 0.8rem; justify-items: center; max-width: 100%; max-height: 100%; animation: pop-in 0.22s var(--ease); }
.media-card img { max-width: min(92vw, 70rem); max-height: 78vh; object-fit: contain; border: 2px solid var(--line-strong); background: var(--panel); }
.media-card .btn-row { justify-content: center; }
@media (max-width: 820px) { .modal-media { align-items: center; padding: 0.75rem; } }

/* ---------- avatars with pictures ---------- */
.avatar.has-img { padding: 0; overflow: hidden; background: var(--panel); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-foot .me { cursor: pointer; border-radius: var(--radius); }
.rail-foot .me:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- someone's profile (popup) ---------- */
.pf-card {
  --pf-bg: var(--panel); --pf-accent: var(--accent); --pf-ink: var(--ink); --pf-accent-ink: var(--accent-ink);
  position: relative; padding: 0; overflow: hidden; background: var(--pf-bg); color: var(--pf-ink); border-color: var(--pf-accent);
}
.pf-banner { height: 7.5rem; background: var(--pf-accent); background: linear-gradient(135deg, var(--pf-accent), color-mix(in srgb, var(--pf-accent) 35%, var(--pf-bg))); border-bottom: 2px solid var(--pf-accent); }
.pf-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-x { position: absolute; top: 0.55rem; right: 0.55rem; background: var(--pf-bg); color: var(--pf-ink); border-color: var(--pf-accent); }
.pf-top { display: flex; align-items: flex-end; gap: 0.9rem; padding: 0 1.2rem; margin-top: -2.4rem; }
.pf-avatar {
  flex: none; width: 5rem; height: 5rem; display: grid; place-content: center; overflow: hidden;
  border: 3px solid var(--pf-accent); border-radius: 50%; background: var(--pf-accent); color: var(--pf-accent-ink);
  font-size: 2rem; font-weight: 800; text-transform: uppercase; box-shadow: 0 0 0 4px var(--pf-bg);
}
.pf-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pf-names { min-width: 0; padding-bottom: 0.2rem; }
.pf-names h3 { font-size: 1.35rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.pf-handle { font-family: var(--font-mono); font-size: 0.76rem; opacity: 0.7; white-space: pre-wrap; }
.pf-status { margin: 0.9rem 1.2rem 0; display: inline-block; padding: 0.2rem 0.6rem; border: 2px solid var(--pf-accent); border-radius: 99px; font-size: 0.82rem; font-weight: 600; }
.pf-bio { margin: 0.8rem 1.2rem 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: 0.93rem; }
.pf-bio:empty { display: none; }
.pf-links { display: grid; gap: 0.45rem; margin: 1rem 1.2rem 0; }
.pf-links:empty { display: none; }
.pf-link {
  display: block; padding: 0.55rem 0.8rem; border: 2px solid var(--pf-accent); border-radius: var(--radius);
  color: var(--pf-ink); text-decoration: none; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: transform 0.12s var(--ease), box-shadow 0.12s;
}
.pf-link:hover, .pf-link:focus-visible { background: var(--pf-accent); color: var(--pf-accent-ink); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 0 var(--pf-ink); outline: none; }
.pf-meta { margin: 0.9rem 1.2rem 0; font-family: var(--font-mono); font-size: 0.7rem; opacity: 0.65; }
.pf-meta:empty { display: none; }
.pf-card > .btn { margin: 1rem 1.2rem 1.2rem; width: calc(100% - 2.4rem); color: var(--pf-ink); border-color: var(--pf-accent); background: transparent; }
.pf-card.is-guest .pf-banner { background: var(--line); }
.pf-card.is-guest .pf-bio { font-family: var(--font-mono); font-size: 0.8rem; opacity: 0.8; padding-bottom: 1.2rem; }

/* ---------- my profile editor ---------- */
.prof-pics { position: relative; margin-bottom: 1.8rem; }
.prof-banner {
  --pf-bg: var(--panel); --pf-accent: var(--accent);
  height: 5.5rem; border: 2px solid var(--line-strong); border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, var(--pf-accent), var(--pf-bg));
}
.prof-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prof-avatar {
  position: absolute; left: 0.8rem; bottom: -1.5rem; width: 3.6rem; height: 3.6rem; display: grid; place-content: center; overflow: hidden;
  border: 3px solid var(--accent); border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 1.4rem; font-weight: 800; text-transform: uppercase;
  box-shadow: 0 0 0 3px var(--panel);
}
.prof-avatar img { width: 100%; height: 100%; object-fit: cover; }
.prof-rm { gap: 1.2rem; font-size: 0.78rem; }
.prof-rm > .linkish { flex: none; }
.prof-links { display: grid; gap: 0.45rem; }
.prof-link { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr) auto; gap: 0.4rem; align-items: center; }
#prof-form textarea { resize: vertical; min-height: 5rem; font-family: var(--font-ui); line-height: 1.45; }

@supports not (aspect-ratio: 1 / 1) {
  .att-media { height: 14rem; }
  .gif-pick { height: 8rem; }
  .tools > * + * { margin-left: 0.25rem; }
}
