/* Lock — Dark theme with black header. */
:root {
  --bg: #0f0f10;
  --surface: #1a1a1c;
  --soft: #17171a;
  --fg: #e8e8e8;
  --muted: #8a8a8c;
  --line: #2a2a2d;
  --chat-fs: 15px;
  --bubble-mine: #2c2c30;
  --bubble-mine-text: var(--fg);
  --bubble-other: #1c1c1e;
  --black: #000000;
  --white: #ffffff;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(0,0,0,0.4);
  --radius: 12px;
  --header-h: 56px;
  --input-min-h: 56px;
  --max-w: 760px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto,
               Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* Chat font-size scale (set per-device via menu, persisted in localStorage). */
html.fs-small  { --chat-fs: 13px; }
html.fs-normal { --chat-fs: 15px; }
html.fs-large  { --chat-fs: 17px; }
html.fs-xl     { --chat-fs: 20px; }
body {
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; cursor: pointer; }

/* ---------- Auth screens ---------- */
.auth-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  background: var(--soft);
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.auth-logo img { width: 80px; height: 80px; border-radius: 12px; }
.auth-card h1 { font-size: 20px; margin: 0 0 8px; }
.auth-sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; line-height: 1.45; }

.auth-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-card input[type="text"],
.auth-card input[type="password"] {
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  outline: none;
  transition: border-color .15s;
}
.auth-card input:focus { border-color: var(--white); }

.btn-primary {
  background: var(--white);
  color: #111;
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
}
.btn-primary:hover { opacity: .9; }

.auth-error {
  background: rgba(220, 53, 69, 0.18);
  color: #ff8a93;
  border: 1px solid rgba(220, 53, 69, 0.35);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.unread-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 138, 147, 0.15);
  color: #ff8a93;
  border: 1px solid rgba(255, 138, 147, 0.4);
  padding: 8px 14px;
  border-radius: 999px;
  margin: 0 0 18px;
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.3px;
}
.auth-sub-muted { margin-bottom: 18px; }

.auth-foot {
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.auth-foot a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pulse-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--black);
  margin: 24px auto 4px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.7; }
  50%      { transform: scale(1.15); opacity: 1; }
}

/* ---------- App header (chat + admin) ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--black);
  color: var(--bg);
}
.app-header .logo-wrap { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.app-header .logo-wrap img { border-radius: 6px; }
.btn-ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); }

.btn-lock {
  background: rgba(255, 138, 147, 0.15);
  color: #ff8a93;
  border: 1px solid rgba(255, 138, 147, 0.45);
  padding: 6px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  flex: 1 1 0;
  max-width: 50%;
  margin: 0 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-lock:hover {
  background: rgba(255, 138, 147, 0.25);
  border-color: rgba(255, 138, 147, 0.7);
}
.btn-lock:active { background: rgba(255, 138, 147, 0.35); }

/* ---------- Admin ---------- */
.admin-wrap {
  max-width: 1080px; margin: 0 auto; padding: 24px 16px 80px;
  display: flex; flex-direction: column; gap: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; }

table.devices { width: 100%; border-collapse: collapse; font-size: 14px; }
table.devices th, table.devices td {
  padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.devices th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; }
table.devices td.ua { font-family: monospace; font-size: 11px; color: var(--muted); }
table.devices td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-suspicious { background: rgba(255, 180, 50, 0.08); }
.flag { font-size: 11px; color: #f5a524; margin-left: 6px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-pending  { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge-approved { background: rgba(34, 197, 94, 0.18);  color: #4ade80; }
.badge-revoked  { background: rgba(239, 68, 68, 0.18);  color: #f87171; }

.btn-mini {
  padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--soft); color: var(--fg); font-size: 12px;
}
.btn-mini:hover { background: var(--bg); }
.btn-ok   { border-color: rgba(34, 197, 94, 0.45); color: #4ade80; }
.btn-warn { border-color: rgba(245, 158, 11, 0.45); color: #fbbf24; }
.btn-danger {
  background: var(--danger); color: var(--white);
  border: 1px solid var(--danger); padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
}
.btn-danger:hover { opacity: .92; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 form { display: flex; flex-direction: column; gap: 10px; }
.grid-2 label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.grid-2 input {
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
  color: var(--fg); font-size: 15px;
}
.grid-2 input:focus { border-color: var(--white); outline: none; }

.pin-form {
  display: flex; flex-direction: column; gap: 10px;
  max-width: 360px;
}
.pin-form label { display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--muted); }
.pin-form input {
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
  color: var(--fg); font-size: 15px;
}
.pin-form input:focus { border-color: var(--white); outline: none; }
.card code {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
}

.danger-zone { border-color: rgba(192, 57, 43, 0.45); }
.panic-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.panic-row:last-child { border-bottom: none; }
.panic-row strong { font-size: 15px; }
.panic-row p { margin: 4px 0 0; }

@media (max-width: 720px) {
  .admin-wrap { padding: 16px 12px 80px; gap: 14px; }
  .card { padding: 16px 14px; }
  .card h2 { font-size: 16px; }

  .grid-2 { grid-template-columns: 1fr; }

  /* Tables → card list on mobile */
  table.devices,
  table.devices thead,
  table.devices tbody,
  table.devices tr,
  table.devices td {
    display: block; width: 100%;
  }
  table.devices thead { display: none; }
  table.devices tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--bg);
  }
  table.devices tr:last-child { margin-bottom: 0; }
  table.devices td {
    border: none;
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
  }
  table.devices td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
    font-weight: 600;
    flex-shrink: 0;
  }
  table.devices td.cell-primary {
    font-size: 16px; font-weight: 600;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
  }
  table.devices td.cell-primary::before { display: none; }
  table.devices td.actions {
    flex-wrap: wrap; gap: 6px;
    padding-top: 10px; margin-top: 4px;
    border-top: 1px solid var(--line);
    justify-content: flex-start;
  }
  table.devices td.actions::before {
    width: 100%;
    margin-bottom: 4px;
  }
  table.devices td.actions form { display: inline; }
  table.devices td.actions .btn-mini {
    padding: 8px 12px; font-size: 13px;
  }
  /* UA row stays but small */
  table.devices td.ua {
    font-family: monospace; font-size: 11px; color: var(--muted);
    word-break: break-all;
    align-items: flex-start;
  }
  table.devices td.ua::before { padding-top: 1px; }

  /* Panic rows stack vertically */
  .panic-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .panic-row .btn-danger { width: 100%; padding: 12px; }
  .panic-row p { font-size: 13px; }
}

@media (max-width: 480px) {
  .admin-wrap { padding: 12px 8px 80px; }
  .card { border-radius: 10px; }
  table.devices td.ua { display: none; }
}

/* ---------- Chat layout ---------- */
.chat-page { display: flex; flex-direction: column; min-height: 100dvh; background: var(--soft); }
.chat-header { position: sticky; top: 0; z-index: 50; }
.presence { font-size: 13px; color: rgba(255,255,255,0.75); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: #ffffff; color: #111;
  border: 1px solid #d4d4d4; border-radius: 10px;
  min-width: 200px; padding: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  display: flex; flex-direction: column;
}
.menu button, .menu .menu-link {
  background: transparent; border: none; padding: 10px 12px;
  border-radius: 6px; text-align: left; font-size: 14px;
  text-decoration: none; color: #111; cursor: pointer;
}
.menu button:hover, .menu .menu-link:hover { background: #f0f0f0; }
.menu-info {
  padding: 8px 12px 6px;
  font-size: 12px; color: #666;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 4px;
}
.menu-sep {
  height: 1px; background: #e0e0e0;
  margin: 6px 0;
}
.menu-danger {
  color: #c0392b !important;
  font-weight: 600;
}
.menu-danger:hover { background: #fde8e8 !important; }

.menu-section-title {
  padding: 6px 12px 4px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
}
.menu-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
}
.menu-toggle:hover { background: #f0f0f0; }
.menu-toggle input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: #111;
  cursor: pointer;
}
.menu-select-row select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #f3f3f5;
  color: #111;
  border: 1px solid #d4d4d4;
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='%23555' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: background-color .12s, border-color .12s;
}
.menu-select-row select:hover  { background-color: #e9e9ec; }
.menu-select-row select:focus  { border-color: #111; }
.menu-select-row { gap: 12px; }
.menu-users {
  list-style: none; margin: 0; padding: 0 4px 4px;
  max-height: 220px; overflow-y: auto;
}
.menu-user {
  display: flex; flex-direction: column;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.25;
}
.menu-user .mu-name { font-weight: 600; color: #111; }
.menu-user .mu-handle { font-size: 11px; color: #888; font-family: monospace; }
.menu-user.is-me { background: #f0f0f0; }
.menu-user.is-me .mu-name::after {
  content: ' (du)';
  color: #888; font-weight: 400; font-size: 11px;
}
.menu-user.empty { color: #888; font-style: italic; font-size: 12px; }

/* ---------- Centered modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadein .15s ease-out;
}
.modal {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 22px 18px;
  max-width: 380px; width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  animation: modalpop .18s ease-out;
}
@keyframes modalpop {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.modal h2 {
  margin: 0 0 12px;
  color: #ff8a93;
  font-size: 20px; font-weight: 800;
  letter-spacing: 0.5px; text-transform: uppercase;
}
.modal.modal-soft h2 {
  color: var(--fg);
  font-size: 17px; font-weight: 700;
  letter-spacing: 0; text-transform: none;
}
.modal p {
  margin: 0 0 8px;
  font-size: 15px; line-height: 1.4;
}
.modal .modal-sub {
  font-size: 13px; color: var(--muted);
  margin-bottom: 20px;
}
.modal-actions {
  display: flex; gap: 8px; justify-content: center;
  margin-top: 8px;
}
.btn-modal {
  padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg); color: var(--fg);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  min-width: 120px;
  transition: opacity .12s, background .12s;
}
.btn-modal:hover { background: var(--soft); }
.btn-modal:disabled { opacity: 0.5; cursor: wait; }
.btn-modal-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}
.btn-modal-danger:hover { background: #a93226; border-color: #a93226; }

.chat-main {
  flex: 1; overflow-y: auto;
  padding: 12px 12px 16px;
  display: flex; flex-direction: column;
}
.messages {
  width: 100%; max-width: var(--max-w); margin: 0 auto;
  display: flex; flex-direction: column; gap: 4px;
}

.msg-group { display: flex; flex-direction: column; margin-top: 10px; }
.msg-group.mine { align-items: flex-end; }
.msg-group.other { align-items: flex-start; }
.msg-author {
  font-size: 12px; font-weight: 600; margin: 0 8px 2px;
}
.bubble {
  max-width: 76%; padding: 8px 12px; border-radius: 14px;
  word-wrap: break-word; white-space: pre-wrap; line-height: 1.35;
  font-size: var(--chat-fs);
  animation: fadein .15s ease-out;
}
.bubble.mine  {
  background: var(--bubble-mine); color: var(--bubble-mine-text);
  border-top-right-radius: 4px;
  position: relative;
}
.bubble.other {
  background: var(--bubble-other); color: var(--fg);
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  position: relative;
}

.edited-mark {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.10);
  color: var(--muted);
  vertical-align: baseline;
  letter-spacing: 0.5px;
}

.bubble-edit-btn {
  position: absolute;
  top: -10px; right: -10px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 12px; line-height: 22px;
  padding: 0; cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: opacity .12s;
}
.bubble.mine:hover .bubble-edit-btn,
.bubble.mine:focus-within .bubble-edit-btn {
  opacity: 1; pointer-events: auto;
}
@media (pointer: coarse) {
  .bubble-edit-btn { opacity: 0.85; pointer-events: auto; }
}
.bubble-edit-btn:hover { background: var(--bg); }

/* Bubble in edit mode → full-width inline editor with surface contrast. */
.bubble.editing {
  width: 100%;
  max-width: 100%;
  min-width: 240px;
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  padding: 10px !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bubble.editing .bubble-edit-btn,
.bubble.editing .edited-mark { display: none; }

.bubble-edit-input {
  display: block;
  width: 100%; box-sizing: border-box;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: var(--chat-fs);
  line-height: 1.4;
  font-family: inherit;
  resize: none;
  outline: none;
  margin: 0;
  scrollbar-width: none;
}
.bubble-edit-input::-webkit-scrollbar { display: none; }
.bubble-edit-input:focus {
  border-color: var(--white);
  background: #0a0a0b;
}

.bubble-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  margin: 0;
}
.bubble-edit-actions button {
  flex: 0 0 auto;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  min-width: 80px;
  transition: background .12s, opacity .12s;
}
.bubble-edit-actions button:hover { background: var(--soft); }

.bubble-edit-actions .be-save {
  background: var(--white);
  color: #111;
  border-color: var(--white);
}
.bubble-edit-actions .be-save:hover { background: #d4d4d8; }

.bubble-edit-actions .be-delete {
  background: transparent;
  color: #ff8a93;
  border-color: rgba(255, 138, 147, 0.45);
}
.bubble-edit-actions .be-delete:hover {
  background: rgba(255, 138, 147, 0.12);
  border-color: rgba(255, 138, 147, 0.7);
}

.bubble.deleted {
  background: transparent !important;
  border: 1px dashed var(--line) !important;
  padding: 6px 10px !important;
  max-width: none;
}
.bubble.deleted .deleted-text {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}
.bubble-del-btn {
  font-size: 16px !important;
  line-height: 20px !important;
  color: #ff8a93 !important;
}
.bubble + .bubble { margin-top: 2px; }
.bubble.has-image { padding: 4px; background: transparent; border: none; max-width: 220px; }
.bubble.has-image img {
  max-width: 100%; border-radius: 12px; display: block; cursor: zoom-in;
}
.msg-time {
  font-size: 11px; color: var(--muted); margin: 2px 8px 0;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.typing {
  font-size: 12px; color: var(--muted);
  padding: 4px 16px;
  width: 100%; max-width: var(--max-w); margin: 0 auto;
}

.composer-area {
  flex-shrink: 0;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 10px;
}
.composer-btn {
  background: transparent; border: none; font-size: 22px;
  color: var(--fg);
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.composer-btn:hover { background: var(--soft); }
.composer-input {
  flex: 1; resize: none; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 18px;
  /* Always at least 16px on input to prevent iOS auto-zoom on focus */
  font-size: max(var(--chat-fs), 16px);
  font-family: inherit;
  max-height: calc(1.4em * 4 + 20px);
  line-height: 1.4; outline: none;
  background: var(--bg); color: var(--fg);
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE / alte Edge */
}
.composer-input::-webkit-scrollbar { display: none; }  /* Chrome / Safari */
.composer-input:focus { border-color: var(--white); }
.composer-input::placeholder { color: var(--muted); }
.composer-send {
  background: #d4d4d8;
  border: none; border-radius: 50%;
  width: 44px; height: 44px;
  padding: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, transform .08s;
}
.composer-send img {
  width: 86%; height: 86%;
  object-fit: contain;
  display: block;
}
.composer-send:disabled { opacity: 0.35; cursor: not-allowed; }
.composer-send:not(:disabled):hover { background: #c4c4c8; }
.composer-send:not(:disabled):active { transform: scale(0.94); }

@media (pointer: coarse) {
  .composer-send { width: 52px; height: 52px; }
}

.composer { position: relative; }
.emoji-pop {
  position: absolute;
  bottom: calc(100% + 6px); left: 8px; right: 8px;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  overflow: hidden;
  max-width: 360px;
}
@media (min-width: 480px) {
  .emoji-pop { right: auto; width: 340px; }
}

.lock-emoji { display: flex; flex-direction: column; }
.lock-emoji-tabs {
  display: flex; gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.lock-emoji-tabs::-webkit-scrollbar { display: none; }
.lock-emoji-tab {
  flex: 0 0 auto;
  background: transparent; border: none;
  width: 36px; height: 36px;
  font-size: 20px; line-height: 1;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: inherit; cursor: pointer;
  opacity: 0.7;
  transition: background .12s, opacity .12s;
}
.lock-emoji-tab:hover { background: var(--soft); opacity: 1; }
.lock-emoji-tab.active {
  background: var(--soft); opacity: 1;
  box-shadow: inset 0 -2px 0 var(--white);
}

.lock-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.lock-emoji-cell {
  background: transparent; border: none;
  font-size: 22px; line-height: 1;
  padding: 6px 0;
  border-radius: 6px;
  color: inherit; cursor: pointer;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  display: inline-flex; align-items: center; justify-content: center;
}
.lock-emoji-cell img.lock-tw-emoji {
  width: 24px; height: 24px;
  margin: 0;
}
.lock-emoji-tab img.lock-tw-emoji {
  width: 18px; height: 18px;
}

/* Twemoji inline in chat bubbles */
img.lock-tw-emoji {
  height: 1.2em;
  width: 1.2em;
  margin: 0 0.05em;
  vertical-align: -0.2em;
  display: inline-block;
}
.lock-emoji-cell:hover { background: var(--soft); }
.lock-emoji-cell:active { background: var(--bg); }
.lock-emoji-empty {
  grid-column: 1 / -1;
  text-align: center; padding: 24px 12px;
  color: var(--muted); font-size: 13px;
}

.image-preview {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--soft); border-bottom: 1px solid var(--line);
}
.image-preview img { max-width: 80px; max-height: 80px; border-radius: 8px; }
.image-preview-actions { display: flex; flex-direction: column; gap: 4px; }
.image-preview .btn-ghost { color: var(--fg); border-color: var(--line); }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox button {
  position: absolute; top: 16px; right: 20px;
  background: transparent; color: var(--white);
  border: none; font-size: 38px; line-height: 1;
}
.lightbox-countdown {
  position: absolute; top: 20px; left: 24px;
  font-size: 18px; font-weight: 700;
  color: #ff8a93;
  background: rgba(0,0,0,0.4);
  padding: 4px 10px; border-radius: 999px;
  letter-spacing: 0.5px;
}

.eph-bubble { padding: 0 !important; background: transparent !important; border: none !important; }
.eph-icon {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface);
  color: var(--fg);
  border: 1px dashed rgba(255, 138, 147, 0.55);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.eph-icon:hover {
  background: var(--bg);
  border-color: rgba(255, 138, 147, 0.8);
}
.eph-icon .eph-glyph {
  font-size: 20px; line-height: 1;
  display: inline-flex; align-items: center;
}
.eph-icon .eph-glyph img {
  width: 22px; height: 22px;
  object-fit: contain;
  display: block;
}
.eph-icon .eph-txt { letter-spacing: 0.2px; }
.eph-icon .eph-count {
  font-variant-numeric: tabular-nums;
  font-size: 12px; font-weight: 700;
  color: #ff8a93;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(255, 138, 147, 0.12);
}
.eph-icon .eph-badge {
  font-size: 11px; font-weight: 500;
  color: var(--muted);
  padding: 2px 6px; border-radius: 6px;
  background: rgba(255,255,255,0.05);
  letter-spacing: 0.2px;
}
.eph-icon.armed {
  border-color: rgba(255, 138, 147, 0.8);
  background: rgba(255, 138, 147, 0.08);
}
.eph-icon.expired {
  border-color: var(--line); cursor: not-allowed;
  opacity: 0.65;
}
.eph-icon.expired .eph-count,
.eph-icon.expired .eph-badge { display: none; }

.eph-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
}
.eph-label select {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 6px; font-size: 12px;
  cursor: pointer;
}

@media (min-width: 800px) {
  .chat-main { padding-left: 0; padding-right: 0; }
}
