:root {
  color-scheme: dark;
  --bg: #050505;
  --bg-soft: #0a0a0a;
  --panel: rgba(15, 15, 15, 0.95);
  --panel-strong: #121212;
  --border: rgba(212, 175, 55, 0.2);
  --text: #ffffff;
  --muted: #a0a0a0;
  --muted-strong: #cccccc;
  --accent: #d4af37;
  --accent-strong: #b5952f;
  --danger: #e74c3c;
  --warning: #f1c40f;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  --radius: 8px;
  --radius-sm: 4px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: 'Playfair Display', ui-serif, Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}

/* Logo Styles */
.title-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.kxn-logo-img {
  height: clamp(6rem, 15vw, 10rem);
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.4));
  transition: transform 0.3s ease;
}

.kxn-logo-img:hover {
  transform: scale(1.05);
}

.gold-key {
  font-size: 0.85em;
  filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.5));
}

h1, h2, h3 {
  font-family: var(--serif);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.72rem 1.25rem;
  background: linear-gradient(180deg, #eccb63 0%, var(--accent) 48%, var(--accent-strong) 100%);
  color: #1a1205;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.005em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 8px 20px rgba(212, 175, 55, 0.22);
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), 0 12px 28px rgba(212, 175, 55, 0.34);
}

button:active:not(:disabled) {
  transform: translateY(0);
  filter: brightness(0.97);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 12px rgba(212, 175, 55, 0.2);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  filter: saturate(0.65);
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  outline: none;
  padding: 0.9rem 1rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 54px;
  max-height: 170px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #64748b;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: rgba(212, 175, 55, 0.85);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.18);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.075em;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  letter-spacing: -0.04em;
}

h3 {
  margin-bottom: 0.65rem;
  font-size: 1rem;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.split-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  height: min(78vh, 820px);
  min-height: 540px;
}

.sidebar-contacts {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.25rem;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.main-chat {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
}

.hero {
  max-width: 820px;
  margin: 0 auto 28px;
  text-align: center;
}

.hero p {
  margin: 0 auto;
  max-width: 660px;
  color: var(--muted-strong);
  font-size: 1.08rem;
}

.hero-badge,
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(23, 29, 42, 0.96), rgba(14, 18, 27, 0.94));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.join-panel {
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(1.35rem, 4vw, 2.1rem);
}

.panel-heading {
  margin-bottom: 1.2rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.42rem;
  color: var(--muted-strong);
  font-weight: 700;
}

.field small,
.muted,
.status {
  color: var(--muted);
}

.field small {
  font-weight: 500;
}

.status {
  min-height: 1.5rem;
  margin: 0.2rem 0 0;
}

.status.ok {
  color: var(--accent);
}

.status.warn {
  color: var(--warning);
}

.status.error {
  color: var(--danger);
}

.security-callout,
.security-note {
  margin-top: 1.25rem;
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(212, 175, 55, 0.06);
  color: var(--muted-strong);
  padding: 1rem;
}

.security-note {
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.07);
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.2rem;
}

.topbar h2 {
  margin-bottom: 0.1rem;
}

.topbar-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.secondary-button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 600;
  box-shadow: none;
}
.secondary-button:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.12);
  border-color: rgba(212, 175, 55, 0.5);
  color: var(--accent);
  filter: none;
  box-shadow: none;
}

.danger-button {
  border: 1px solid rgba(251, 113, 133, 0.38);
  background: rgba(251, 113, 133, 0.1);
  color: #fecdd3;
  box-shadow: none;
}
.danger-button:hover:not(:disabled) {
  background: rgba(251, 113, 133, 0.2);
  border-color: rgba(251, 113, 133, 0.6);
  filter: none;
  box-shadow: none;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.sidebar,
.chat-panel {
  padding: 1rem;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.fingerprint {
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.22);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.8;
  padding: 0.85rem;
}

.peer-list {
  display: grid;
  gap: 0.75rem;
}

.peer-card {
  display: grid;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  padding: 0.85rem;
}

.peer-card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
}

.peer-name {
  margin: 0;
  font-weight: 850;
  word-break: break-word;
}

.peer-meta {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--mono);
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 800;
}

.badge.verified {
  border-color: rgba(212, 175, 55, 0.34);
  background: rgba(212, 175, 55, 0.09);
  color: var(--accent);
}

.badge.unverified {
  border-color: rgba(251, 191, 36, 0.36);
  background: rgba(251, 191, 36, 0.1);
  color: #fde68a;
}

.peer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.peer-actions button,
.button-row button {
  min-height: 36px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
}

.messages {
  display: flex;
  flex: 1 1 auto;     /* Fills remaining space in main-chat flex column */
  min-height: 0;       /* Critical: lets the messages box actually shrink */
  overflow-y: auto;
  overflow-x: hidden;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.25rem 1.25rem;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.message-row {
  display: flex;
  width: 100%;
  margin-top: 0.15rem;
}

.message-row.new-burst {
  margin-top: 1rem; /* Clear burst grouping between different users/times */
}

.message-row.consecutive {
  margin-top: 0.15rem;
}

.message-row.own {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(72%, 760px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.75rem 1rem;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, background 0.2s ease;
  position: relative;
}

/* Matrix "decode" reveal overlay (added briefly to new message bubbles). */
.matrix-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.25;
  letter-spacing: 2px;
  word-break: break-all;
  white-space: pre-wrap;
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.85);
  background: rgba(5, 4, 3, 0.9);
  border-radius: inherit;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.22s ease;
}
.matrix-overlay.fade { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .matrix-overlay { display: none; } }

.message-row.own .message-bubble {
  border-color: rgba(212, 175, 55, 0.22);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(181, 149, 47, 0.12));
  border-bottom-right-radius: 4px; /* Signal style speech bubble corners */
}

.message-row:not(.own) .message-bubble {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.045);
  border-bottom-left-radius: 4px;
}

.message-row.consecutive.own .message-bubble {
  border-bottom-right-radius: 16px; /* Smooth secondary bubbles */
}

.message-row.consecutive:not(.own) .message-bubble {
  border-bottom-left-radius: 16px;
}

.message-meta {
  margin-bottom: 0.35rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.45;
}

.micro-time {
  font-size: 0.65rem;
  opacity: 0.55;
  margin-left: 10px;
  font-family: var(--mono);
  float: right;
  margin-top: 5px;
}

/* Animations */
@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.animate-pop-in {
  animation: popIn 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.system-message {
  align-self: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted-strong);
  padding: 0.55rem 0.9rem;
  text-align: center;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.noscript {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: #190a0f;
  color: #fecdd3;
  padding: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Contact Styling in Sidebar */
.contact-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.08);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
  position: relative;
}

.contact-item:hover {
  background: rgba(212, 175, 55, 0.03);
}

.contact-item.active {
  background: rgba(212, 175, 55, 0.08);
  border-left: 3px solid var(--accent);
}

.contact-avatar-wrapper {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(181, 149, 47, 0.15));
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  border: 1px solid rgba(212, 175, 55, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-soft);
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 2;
}

.status-indicator.online {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-indicator.offline {
  background: #64748b;
}

.contact-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-id-text {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-badge {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  position: absolute;
  right: 1rem;
  top: 0.85rem;
}

/* Chat bubble enhancements */
.message-bubble {
  max-width: min(72%, 760px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.72rem 0.85rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.message-row.own .message-bubble {
  border-color: rgba(212, 175, 55, 0.25);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(181, 149, 47, 0.12));
}

.mobile-only-btn {
  display: none;
}

@media (max-width: 820px) {
  .shell {
    width: 100%;
    padding: 12px;
    transition: padding 0.3s ease;
  }

  body:has(#chat-view:not(.hidden)) {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  body:has(#chat-view:not(.hidden)) .shell {
    height: 100vh;
    overflow: hidden; /* Prevent horizontal scrollbars during slides */
    padding: 12px 12px 0 12px;
  }

  body:has(#chat-view:not(.hidden)) .hero {
    display: none; /* Hide hero header on mobile to maximize chat area */
  }

  /* Make branding more compact on mobile login screen */
  .kxn-logo-img {
    height: 4.5rem;
  }
  h1 {
    font-size: 1.6rem;
  }
  .hero p {
    font-size: 0.9rem;
    padding: 0 10px;
  }

  .split-layout {
    display: flex !important;
    flex-direction: row;
    grid-template-columns: none !important;
    width: 200%; /* Side by side on double width */
    height: calc(100vh - 24px) !important;
    gap: 0;
    transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .split-layout.chat-open {
    transform: translateX(-50%); /* Slide to the chat pane */
  }

  .sidebar-contacts {
    display: flex !important;
    width: 50% !important;
    height: 100%;
    flex-shrink: 0;
    border-right: none;
  }

  .main-chat {
    display: flex !important;
    width: 50% !important;
    height: 100%;
    flex-shrink: 0;
    border-left: none;
  }

  .mobile-only-btn {
    display: inline-block !important;
  }

  .messages {
    min-height: auto;
    flex: 1;
    max-height: calc(100vh - 180px);
  }

  .message-bubble {
    max-width: 85%;
  }
}

/* Tab Buttons */
.tab-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  font-weight: 600;
  transition: color 180ms ease, background 180ms ease;
  cursor: pointer;
}
.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.tab-btn.active {
  background: rgba(212, 175, 55, 0.12) !important;
  color: var(--accent) !important;
  border: 1px solid var(--border) !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   KXN BRAND REFINEMENT v1.2  — applied after base rules so they win.
   Goal: heavier KXN logo presence, gold focus everywhere, subtle motion.
   ──────────────────────────────────────────────────────────────────────── */

/* Ambient KXN watermark behind everything — fixed, never scrolls. */
.kxn-watermark {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(1100px 700px at 75% -10%, rgba(212, 175, 55, 0.10), transparent 60%),
    radial-gradient(900px  650px at -10% 110%, rgba(212, 175, 55, 0.06), transparent 60%),
    url('kxn-logo.png') center / clamp(420px, 55vw, 760px) no-repeat;
  background-blend-mode: screen, screen, normal;
  opacity: 0.045;
  filter: grayscale(0.2) blur(0.4px);
}

/* Star-field-ish noise to break up the flat black */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255,255,255,0.05), transparent 40%),
    radial-gradient(1px 1px at 78% 64%, rgba(212,175,55,0.06), transparent 40%),
    radial-gradient(1px 1px at 32% 88%, rgba(255,255,255,0.04), transparent 40%),
    radial-gradient(1px 1px at 90% 12%, rgba(212,175,55,0.05), transparent 40%);
}

/* Logo frame: layered gold glow ring around the KXN mark */
.kxn-logo-frame {
  position: relative;
  display: inline-grid;
  place-items: center;
  padding: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(212,175,55,0.18), rgba(212,175,55,0.04) 55%, transparent 70%);
  isolation: isolate;
}

.kxn-logo-frame::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    rgba(212,175,55,0.0) 0deg,
    rgba(212,175,55,0.45) 90deg,
    rgba(255,235,160,0.55) 180deg,
    rgba(212,175,55,0.45) 270deg,
    rgba(212,175,55,0.0) 360deg);
  -webkit-mask: radial-gradient(circle, transparent 65%, #000 66%);
          mask: radial-gradient(circle, transparent 65%, #000 66%);
  animation: kxnHaloSpin 22s linear infinite;
  z-index: -1;
}

@media (prefers-reduced-motion: reduce) {
  .kxn-logo-frame::before { animation: none; }
}

@keyframes kxnHaloSpin {
  to { transform: rotate(360deg); }
}

.kxn-logo-img {
  height: clamp(5.5rem, 13vw, 9rem);
  width: auto;
  object-fit: contain;
  filter:
    drop-shadow(0 0 18px rgba(212, 175, 55, 0.45))
    drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), filter 0.3s ease;
}

.kxn-logo-img:hover {
  transform: scale(1.04);
  filter:
    drop-shadow(0 0 24px rgba(212, 175, 55, 0.65))
    drop-shadow(0 4px 14px rgba(0, 0, 0, 0.6));
}

/* Hero: bigger headline, tighter rhythm, gold tracery */
.hero-title {
  margin: 0.4rem 0 0.7rem;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2.1rem, 5.2vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(180deg, #ffffff 0%, #e9d28a 60%, #d4af37 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  text-shadow: 0 1px 30px rgba(212, 175, 55, 0.15);
}

.hero-strap {
  margin: 0 auto;
  max-width: 640px;
  color: var(--muted-strong);
  font-size: 1.06rem;
  line-height: 1.55;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.05);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.8);
  animation: kxnPulse 2.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .badge-dot { animation: none; }
}

@keyframes kxnPulse {
  0%, 100% { opacity: 0.55; transform: scale(0.95); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

/* Panels: subtle gold inner ring + cleaner gradient */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(20, 20, 20, 0.96), rgba(10, 10, 10, 0.94));
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.025),
    inset 0 0 0 1px rgba(212, 175, 55, 0.04);
  backdrop-filter: blur(22px);
}

.join-panel {
  position: relative;
  overflow: hidden;
}

.join-panel::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}

/* Buttons: glossier gold + subtle inner highlight */
button {
  background: linear-gradient(180deg, #e7c659 0%, var(--accent) 50%, var(--accent-strong) 100%);
  color: #0a0a0a;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 -1px 0 rgba(0, 0, 0, 0.25) inset,
    0 6px 14px rgba(212, 175, 55, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

button:hover:not(:disabled) {
  filter: brightness(1.08) saturate(1.05);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 -1px 0 rgba(0, 0, 0, 0.25) inset,
    0 8px 18px rgba(212, 175, 55, 0.28),
    0 2px 6px rgba(0, 0, 0, 0.35);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.035) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}

.secondary-button:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.08) !important;
  border-color: rgba(212, 175, 55, 0.35) !important;
}

/* Inputs: slightly warmer background, gold underline on focus */
input,
textarea {
  background: rgba(15, 15, 15, 0.7);
  border-color: rgba(212, 175, 55, 0.18);
}

/* Custom scrollbar — subtle gold thumb */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.32);
  background-clip: padding-box;
  border: 2px solid transparent;
}
* {
  scrollbar-color: rgba(212, 175, 55, 0.25) transparent;
  scrollbar-width: thin;
}

/* Selection highlight in brand colour */
::selection {
  background: rgba(212, 175, 55, 0.32);
  color: #fff;
}

/* Avatar placeholder polish */
#my-avatar-placeholder,
#edit-avatar-placeholder {
  background: linear-gradient(135deg, #e9d28a, var(--accent) 55%, var(--accent-strong));
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Contact rows: smoother active state */
.contact-item.active {
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.10), rgba(212, 175, 55, 0.02));
  border-left: 3px solid var(--accent);
}

/* Message bubbles: subtle entry animation */
.message-row {
  animation: kxnBubbleIn 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  .message-row { animation: none; }
}

@keyframes kxnBubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mobile: the hero badge sits cleanly under a smaller logo */
@media (max-width: 820px) {
  .hero-title { font-size: 1.85rem; }
  .kxn-logo-frame { padding: 12px; }
  .kxn-logo-img { height: 4.2rem; }
  .hero-strap { font-size: 0.92rem; }
}

/* ─────────────────────────────────────────────────────────────────────────
   v1.3  — sexier buttons + mobile-smooth touch handling
   ──────────────────────────────────────────────────────────────────────── */

/* Kill the default blue tap-highlight rectangle on iOS/Android */
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Anything interactive: no 300ms double-tap delay, no callout menu */
button,
a,
input,
textarea,
.tab-btn,
.contact-item {
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

/* Safe-area awareness for notched phones */
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Sexy buttons: liquid-gold gradient, layered depth, animated shine sweep */
button:not(.secondary-button):not(.tab-btn) {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(255, 215, 120, 0.55);
  background:
    linear-gradient(180deg,
      #f4dd8a 0%,
      #e7c659 22%,
      #d4af37 55%,
      #b5952f 88%,
      #8f7423 100%);
  color: #1a1300;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.45);
  box-shadow:
    /* top inner highlight */
    inset 0 1px 0 rgba(255, 245, 200, 0.7),
    /* bottom inner shadow for depth */
    inset 0 -2px 4px rgba(80, 50, 0, 0.35),
    /* hairline edge */
    inset 0 0 0 1px rgba(255, 230, 160, 0.15),
    /* drop shadow */
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 6px 16px rgba(212, 175, 55, 0.18),
    0 12px 30px rgba(0, 0, 0, 0.35);
  transition:
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 180ms ease,
    filter 180ms ease;
}

/* Animated shine that sweeps across on hover/focus */
button:not(.secondary-button):not(.tab-btn)::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.0) 38%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0.0) 62%,
    transparent 70%);
  transform: translateX(-110%);
  transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: 1;
}

button:not(.secondary-button):not(.tab-btn):hover:not(:disabled)::before,
button:not(.secondary-button):not(.tab-btn):focus-visible:not(:disabled)::before {
  transform: translateX(110%);
}

/* Subtle gold halo on hover */
button:not(.secondary-button):not(.tab-btn):hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05) saturate(1.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 220, 0.85),
    inset 0 -2px 4px rgba(80, 50, 0, 0.35),
    inset 0 0 0 1px rgba(255, 230, 160, 0.25),
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 10px 24px rgba(212, 175, 55, 0.35),
    0 16px 36px rgba(0, 0, 0, 0.4),
    0 0 0 4px rgba(212, 175, 55, 0.12);
}

/* Press feel — collapse the shadow stack a bit */
button:not(.secondary-button):not(.tab-btn):active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
  filter: brightness(0.97);
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 200, 0.4),
    inset 0 2px 5px rgba(80, 50, 0, 0.4),
    inset 0 0 0 1px rgba(255, 230, 160, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 3px 8px rgba(212, 175, 55, 0.18);
}

/* Disabled — desaturated, no shine */
button:not(.secondary-button):not(.tab-btn):disabled {
  filter: grayscale(0.65) brightness(0.7);
  cursor: not-allowed;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 2px rgba(0, 0, 0, 0.2);
}

button:not(.secondary-button):not(.tab-btn):disabled::before {
  display: none;
}

/* Secondary buttons get their own touch: subtle gold ring on hover */
.secondary-button {
  border: 1px solid var(--border) !important;
  background: rgba(255, 255, 255, 0.035) !important;
  color: var(--text) !important;
  transition: background 180ms ease, border-color 180ms ease, transform 160ms ease;
}
.secondary-button:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.10) !important;
  border-color: rgba(212, 175, 55, 0.45) !important;
  transform: translateY(-1px);
}
.secondary-button:active:not(:disabled) {
  transform: translateY(0);
  background: rgba(212, 175, 55, 0.06) !important;
}

/* Composer textarea: rounded + a hair more height for thumb typing */
.composer {
  padding: 0.85rem 1rem 1rem;
  gap: 0.6rem;
}
#message-input {
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font-size: 16px; /* iOS won't zoom on focus when >= 16px */
}
#send-button {
  border-radius: 14px;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Reduce blur cost on small screens — backdrop-filter is expensive on GPUs */
@media (max-width: 820px) {
  .panel {
    backdrop-filter: blur(10px);
  }
  /* Mobile-only: bigger, thumbier buttons */
  button {
    min-height: 48px;
    border-radius: 999px;
  }
  #send-button {
    min-height: 48px;
  }
  /* Inputs at exactly 16px to defeat iOS auto-zoom */
  input, textarea {
    font-size: 16px;
  }
  .composer {
    padding: 0.7rem 0.75rem calc(0.7rem + env(safe-area-inset-bottom));
  }
  /* Prevent the chat scroll from rubber-banding the whole page on iOS */
  .messages, .sidebar-contacts, .contacts-list {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/* On true touch devices (no hover), don't leave hover states "stuck" */
@media (hover: none) {
  button:not(.secondary-button):not(.tab-btn):hover:not(:disabled) {
    transform: none;
    filter: none;
  }
  .secondary-button:hover:not(:disabled) {
    transform: none;
  }
  /* Disable the shine sweep on touch — it adds GPU load without payoff */
  button:not(.secondary-button):not(.tab-btn)::before {
    display: none;
  }
}

/* Respect "reduce motion" globally for all of the above */
@media (prefers-reduced-motion: reduce) {
  button:not(.secondary-button):not(.tab-btn)::before {
    display: none;
  }
  button, .secondary-button, .message-row, .contact-item {
    transition: none !important;
    animation: none !important;
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   v1.4  — 2026 REDESIGN
   Anthropic-style softness × KXN gold. Heavy glass, big radii, fluid motion.
   Fixes the chat layout (no more cornery boxes / overflowing message panel).
   ═════════════════════════════════════════════════════════════════════════ */

:root {
  /* Warmer dark palette — pure black was the "old ass" tell */
  --bg:           #0b0907;
  --bg-soft:      #110e0a;
  --ink:          #f4ecdb;          /* warm off-white text */
  --ink-mute:     #b4a994;
  --ink-dim:      #7a715e;
  --gold:         #d4af37;
  --gold-bright:  #f4dd8a;
  --gold-deep:    #8f7423;
  --amber:        #e7a76a;          /* warm secondary accent */
  --danger:       #f4736c;
  --glass:        rgba(28, 22, 16, 0.55);
  --glass-strong: rgba(34, 27, 19, 0.78);
  --hairline:     rgba(255, 220, 160, 0.08);
  --hairline-2:   rgba(255, 220, 160, 0.14);

  --radius-lg:    28px;
  --radius-md:    18px;
  --radius-sm:    12px;
  --radius-xs:    8px;

  --shadow-soft:  0 1px 2px rgba(0,0,0,0.4),
                  0 12px 28px rgba(0,0,0,0.35),
                  0 30px 60px rgba(0,0,0,0.25);
  --shadow-pop:   0 1px 2px rgba(0,0,0,0.4),
                  0 18px 44px rgba(0,0,0,0.45),
                  0 40px 90px rgba(212,175,55,0.06);

  --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);
}

html, body {
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: var(--sans);
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
}

/* Replace the harsh black canvas with a slow gold sunrise */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(60vw 60vw at 12% -10%,  rgba(231, 167, 106, 0.10),  transparent 60%),
    radial-gradient(70vw 60vw at 95% 110%,  rgba(212, 175, 55, 0.10),  transparent 60%),
    radial-gradient(40vw 40vw at 50% 50%,   rgba(212, 175, 55, 0.04),  transparent 60%),
    linear-gradient(180deg, #0b0907 0%, #0a0805 100%);
}

/* Wider, breathier shell */
.shell {
  width: min(1240px, calc(100% - 40px));
  padding: 56px 0 40px;
  gap: 28px;
}

/* Hero — lighter, more confident headline */
.hero { margin-bottom: 14px; }
.hero-title {
  font-weight: 600;
  letter-spacing: -0.045em;
  background: linear-gradient(180deg, #ffffff 0%, #f1d795 55%, #d4af37 100%);
  -webkit-background-clip: text;
          background-clip: text;
}
.hero-badge {
  border-color: var(--hairline-2);
  background: rgba(255, 220, 160, 0.04);
  backdrop-filter: blur(20px);
  padding: 0.45rem 1rem;
  border-radius: 999px;
}
.hero-strap {
  color: var(--ink-mute);
  font-size: 1.05rem;
}

/* ─── PANELS: heavy glass, soft hairline, bigger radius ─── */
.panel {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(34, 27, 19, 0.72), rgba(20, 16, 11, 0.72));
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 rgba(255, 230, 170, 0.04),
    inset 0 0 80px rgba(212, 175, 55, 0.025);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
}

.join-panel {
  border-radius: var(--radius-lg);
  padding: clamp(1.75rem, 4vw, 2.6rem);
}

/* ─── INPUTS: airy, focus glows soft gold ─── */
input, textarea {
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  padding: 0.95rem 1.05rem;
  transition: border-color 200ms var(--ease-out),
              background 200ms var(--ease-out),
              box-shadow 200ms var(--ease-out);
}
input::placeholder, textarea::placeholder {
  color: var(--ink-dim);
}
input:focus, textarea:focus, button:focus-visible {
  border-color: rgba(212, 175, 55, 0.65);
  background: rgba(255, 240, 200, 0.04);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.14),
              0 0 32px -8px rgba(212, 175, 55, 0.3);
}

/* ─── BUTTONS: pill, softer gold (less brassy), spring transitions ─── */
button {
  border-radius: 999px;
  padding: 0.85rem 1.4rem;
  min-height: 48px;
  font-weight: 600;
  letter-spacing: 0.005em;
  transition: transform 220ms var(--ease-spring),
              filter 220ms var(--ease-out),
              box-shadow 220ms var(--ease-out),
              background 220ms var(--ease-out);
}

button:not(.secondary-button):not(.tab-btn) {
  background: linear-gradient(180deg,
    #fbe9a8 0%,
    #f4dd8a 18%,
    #e7c659 42%,
    #d4af37 78%,
    #b5952f 100%);
  color: #1a1300;
  border: 1px solid rgba(255, 235, 170, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 220, 0.75),
    inset 0 -1px 0 rgba(80, 50, 0, 0.25),
    0 1px 1px rgba(0,0,0,0.25),
    0 8px 20px rgba(212, 175, 55, 0.18),
    0 16px 36px rgba(0,0,0,0.35);
}

.secondary-button {
  border: 1px solid var(--hairline-2) !important;
  border-radius: 999px !important;
  background: rgba(255, 240, 200, 0.04) !important;
  color: var(--ink) !important;
  box-shadow: none !important;
}
.secondary-button:hover:not(:disabled) {
  background: rgba(255, 240, 200, 0.08) !important;
  border-color: rgba(212, 175, 55, 0.4) !important;
}

/* ─── CHAT LAYOUT — proper flex, no more magic numbers ─── */
.main-chat {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-left: 0;             /* the gap handles visual separation */
  border-radius: var(--radius-lg);
  min-height: 0;              /* allows internal flex to shrink */
}

.sidebar-contacts {
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  min-height: 0;
}

.topbar {
  flex: 0 0 auto;
  padding: 1.1rem 1.4rem;
  margin: 0;
  border-bottom: 1px solid var(--hairline);
  background: rgba(28, 22, 16, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.topbar h2 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.topbar .eyebrow {
  color: var(--ink-dim);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

/* The messages box already had its layout fixed above; here we polish look */
.messages {
  background:
    radial-gradient(50vw 30vw at 50% -10%, rgba(212, 175, 55, 0.05), transparent 60%);
}

.system-message {
  align-self: center;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(255, 240, 200, 0.04);
  color: var(--ink-mute);
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
}

/* ─── MESSAGE BUBBLES — softer, no more sharp Signal-style corners ─── */
.message-bubble {
  max-width: min(74%, 720px);
  border: 1px solid var(--hairline);
  border-radius: 22px;
  padding: 0.85rem 1.1rem;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.25),
    0 8px 22px rgba(0,0,0,0.22);
  backdrop-filter: blur(8px);
}
.message-row.own .message-bubble {
  border-color: rgba(212, 175, 55, 0.28);
  background: linear-gradient(165deg,
    rgba(244, 221, 138, 0.18),
    rgba(212, 175, 55, 0.10) 55%,
    rgba(143, 116, 35, 0.08));
  border-bottom-right-radius: 8px;     /* gentle tail, not pointy */
  color: #fff7e0;
}
.message-row:not(.own) .message-bubble {
  background: rgba(255, 240, 200, 0.045);
  border-bottom-left-radius: 8px;
}
.message-row.consecutive.own .message-bubble {
  border-bottom-right-radius: 22px;
}
.message-row.consecutive:not(.own) .message-bubble {
  border-bottom-left-radius: 22px;
}
.message-meta {
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}
.message-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: inherit;
}
.micro-time { color: var(--ink-dim); }

/* ─── COMPOSER — floating pill at the bottom of the chat ─── */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: end;
  gap: 0.7rem;
  padding: 0.9rem 1.1rem calc(1rem + env(safe-area-inset-bottom));
  margin: 0;
  border-top: 1px solid var(--hairline);
  background: rgba(28, 22, 16, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
#message-input {
  flex: 1 1 auto;
  min-height: 48px;
  max-height: 160px;
  border-radius: 22px;
  background: rgba(255, 240, 200, 0.035);
  border: 1px solid var(--hairline-2);
  padding: 0.85rem 1.1rem;
  resize: none;
  font-size: 16px;            /* keeps iOS from auto-zooming */
}
#message-input:focus {
  background: rgba(255, 240, 200, 0.06);
}
#send-button {
  flex: 0 0 auto;
  min-width: 90px;
  border-radius: 999px;
  padding: 0.85rem 1.3rem;
}

/* ─── CONTACT LIST ─── */
.contact-item {
  border-bottom: 0;
  border-radius: var(--radius-md);
  padding: 0.85rem 0.95rem;
  margin-bottom: 4px;
}
.contact-item:hover {
  background: rgba(255, 240, 200, 0.04);
}
.contact-item.active {
  background: linear-gradient(95deg, rgba(212,175,55,0.14), rgba(231,167,106,0.06));
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-left: 3px solid var(--gold);
}
.contact-avatar {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold) 55%, var(--gold-deep));
  color: #1a1300;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3),
              inset 0 1px 0 rgba(255,255,255,0.4);
}

/* ─── FIELD LABELS ─── */
.field {
  gap: 0.5rem;
  color: var(--ink-mute);
  font-weight: 600;
  font-size: 0.88rem;
}
.field span { letter-spacing: 0.005em; }

/* ─── TAB BUTTONS ─── */
.tab-btn {
  border-radius: 12px !important;
  font-weight: 600;
  padding: 0.6rem 0.85rem !important;
  font-size: 0.88rem !important;
  transition: color 200ms, background 200ms, border-color 200ms;
}
.tab-btn.active {
  background: linear-gradient(180deg, rgba(212,175,55,0.18), rgba(212,175,55,0.08)) !important;
  color: var(--gold-bright) !important;
  border: 1px solid rgba(212, 175, 55, 0.35) !important;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.1);
}

/* ─── FINGERPRINT / SAFETY CODE ─── */
.fingerprint {
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-sm);
  background: rgba(255, 240, 200, 0.04);
  color: var(--gold-bright);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  line-height: 1.7;
  padding: 0.75rem 0.9rem;
}

/* ─── MOBILE LAYOUT FIX: full dynamic viewport, no overflow ─── */
@media (max-width: 820px) {
  .shell {
    width: 100%;
    padding: 12px;
    gap: 14px;
  }

  /* When chat is open on mobile, the shell becomes a full-screen flex column */
  body:has(#chat-view:not(.hidden)) {
    overflow: hidden;
    position: fixed;
    inset: 0;
  }
  body:has(#chat-view:not(.hidden)) .shell {
    width: 100%;
    height: 100dvh;            /* dynamic viewport — accounts for iOS chrome */
    padding: 8px 8px 0 8px;
    overflow: hidden;
  }
  body:has(#chat-view:not(.hidden)) .hero { display: none; }
  body:has(#chat-view:not(.hidden)) #chat-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
  }

  .split-layout {
    width: 200%;
    height: 100%;
    grid-template-columns: none !important;
    display: flex !important;
    gap: 0;
    transition: transform 380ms var(--ease-spring);
  }
  .split-layout.chat-open { transform: translateX(-50%); }

  .sidebar-contacts,
  .main-chat {
    width: 50% !important;
    flex-shrink: 0;
    height: 100%;
    border-radius: var(--radius-md);
  }

  /* On mobile, the topbar + composer remain pinned, messages fills */
  .main-chat { display: flex; flex-direction: column; }
  .topbar { border-radius: var(--radius-md) var(--radius-md) 0 0; padding: 0.85rem 1rem; }
  .composer { border-radius: 0 0 var(--radius-md) var(--radius-md); padding: 0.7rem 0.75rem calc(0.7rem + env(safe-area-inset-bottom)); }
  .messages { padding: 0.85rem 0.85rem 1rem; }
  .message-bubble { max-width: 86%; border-radius: 18px; }

  .panel { backdrop-filter: blur(14px); }
}

/* iOS standalone PWA: extra top padding for the status bar */
@media (display-mode: standalone) {
  body { padding-top: max(env(safe-area-inset-top), 16px); }
}

/* ─── SUBTLE ENTRY FOR NEW MESSAGES ─── */
@keyframes kxnBubbleIn2026 {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.message-row {
  animation: kxnBubbleIn2026 320ms var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .message-row { animation: none; }
}

/* ═════════════════════════════════════════════════════════════════════════
   v1.5  — Phase 1 chat features styling
   ═════════════════════════════════════════════════════════════════════════ */

/* ─── Folder tabs (sidebar) ─── */
.folder-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 0.9rem;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 240, 200, 0.03);
  border: 1px solid var(--hairline);
}
.folder-tab {
  flex: 1 1 auto;
  min-height: 32px;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-mute);
  font-size: 0.82rem;
  font-weight: 600;
  border: 0;
  box-shadow: none;
  transition: background 180ms var(--ease-out), color 180ms var(--ease-out);
}
.folder-tab:hover { color: var(--ink); background: rgba(255, 240, 200, 0.05); }
.folder-tab.active {
  color: #1a1300;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

#contact-search-input {
  border-radius: 999px;
}

/* Contact row extras */
.contact-mute, .contact-archive {
  font-size: 0.78rem;
  opacity: 0.75;
  margin-right: 4px;
}
.contact-unread-pill {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1300;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.35);
  min-width: 22px;
  text-align: center;
}
.contact-item { position: relative; }

/* Per-contact color accent: a subtle left rail when contact has a custom color */
.contact-item[style*="--contact-color"]::before {
  content: '';
  position: absolute;
  left: 0; top: 18%; bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--contact-color, transparent);
  opacity: 0.7;
}

/* ─── Pinned bar above messages ─── */
.pinned-bar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--hairline);
  background: rgba(212, 175, 55, 0.04);
  max-height: 30%;
  overflow-y: auto;
}
.pinned-bar.hidden { display: none; }
.pinned-bar-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pin-icon { font-size: 0.85rem; }
.pinned-bar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.45rem 0.65rem;
  border-radius: 12px;
  background: rgba(255, 240, 200, 0.035);
  border: 1px solid var(--hairline);
  cursor: pointer;
  transition: background 180ms;
}
.pinned-bar-item:hover { background: rgba(255, 240, 200, 0.06); }
.pinned-bar-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pinned-bar-unpin {
  padding: 2px 8px !important;
  min-height: 24px !important;
  font-size: 0.75rem !important;
  border-radius: 999px !important;
}

/* ─── Composer strip (reply / edit preview) ─── */
.composer-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--hairline);
  background: rgba(28, 22, 16, 0.7);
  backdrop-filter: blur(16px);
  border-left: 3px solid var(--gold);
}
.composer-strip.hidden { display: none; }
.composer-strip.edit { border-left-color: var(--amber); }
.composer-strip .strip-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
}
.composer-strip.edit .strip-label { color: var(--amber); }
.composer-strip .strip-snippet {
  flex: 1;
  color: var(--ink-mute);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-strip .strip-close {
  padding: 2px 8px !important;
  min-height: 28px !important;
  font-size: 0.78rem !important;
  border-radius: 999px !important;
}

/* ─── Reply quote inside message bubble ─── */
.reply-quote {
  border-left: 3px solid rgba(212, 175, 55, 0.55);
  background: rgba(255, 240, 200, 0.06);
  padding: 0.4rem 0.7rem;
  margin-bottom: 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms;
}
.reply-quote:hover { background: rgba(255, 240, 200, 0.1); }
.reply-quote-sender {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}
.reply-quote-text {
  font-size: 0.85rem;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Inline message formatting ─── */
.message-text strong { font-weight: 700; color: #fff8e0; }
.message-text em     { font-style: italic; }
.message-text s      { opacity: 0.65; }
.message-text code   {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.1em 0.4em;
  border-radius: 6px;
  background: rgba(255, 240, 200, 0.08);
  border: 1px solid var(--hairline);
}
.message-text a {
  color: var(--gold-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── Edited / deleted markers ─── */
.edited-tag {
  font-size: 0.7rem;
  color: var(--ink-dim);
  font-style: italic;
  margin-left: 6px;
}
.message-row.deleted .message-bubble {
  opacity: 0.55;
  background: rgba(255, 240, 200, 0.02);
}

/* ─── TTL countdown badge ─── */
.ttl-badge {
  margin-left: 6px;
  font-size: 0.75rem;
  color: var(--gold);
}
.disappearing-out {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 350ms ease, transform 350ms ease;
}

/* ─── Hover/long-press message action menu ─── */
.message-bubble { position: relative; }
.msg-actions {
  position: absolute;
  top: -34px;
  right: 0;
  display: none;
  gap: 4px;
  padding: 4px;
  background: rgba(20, 16, 11, 0.92);
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 5;
  backdrop-filter: blur(20px);
}
.message-row.own .msg-actions { right: auto; left: 0; }
.message-bubble:hover .msg-actions { display: inline-flex; }
.msg-action-btn {
  min-width: 30px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  border: 0;
  box-shadow: none;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 160ms;
}
.msg-action-btn:hover { background: rgba(212, 175, 55, 0.18); }
@media (hover: none) {
  /* On touch, show the menu when bubble has .menu-open (long-press) */
  .message-bubble.menu-open .msg-actions { display: inline-flex; }
}

/* ─── Chat settings drawer ─── */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: flex-end;
}
.drawer.hidden { display: none; }
.drawer-card {
  width: min(420px, 92%);
  height: 100%;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  border-right: 0;
  display: flex;
  flex-direction: column;
  animation: drawerIn 320ms var(--ease-spring);
}
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--hairline);
}
.drawer-body { flex: 1; padding: 1rem 1.4rem 1.5rem; overflow-y: auto; }

.cs-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--hairline);
}
.cs-section:last-child { border-bottom: 0; }
.cs-section h3 { margin: 0 0 4px; font-family: var(--sans); font-weight: 600; font-size: 1.05rem; }
.cs-section h4 { margin: 0 0 0.6rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-dim); font-family: var(--sans); }
.cs-fingerprint { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-dim); margin: 0; word-break: break-all; }
.cs-sub { font-size: 0.78rem; color: var(--ink-dim); margin: 0 0 0.7rem; }

.cs-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cs-swatch {
  width: 36px; height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 160ms, border-color 160ms;
}
.cs-swatch.selected { border-color: #fff; transform: scale(1.1); }
.cs-swatch-default {
  background: repeating-linear-gradient(45deg,
    rgba(255, 220, 160, 0.2),
    rgba(255, 220, 160, 0.2) 4px,
    rgba(255, 220, 160, 0.05) 4px,
    rgba(255, 220, 160, 0.05) 8px);
}

.cs-pillrow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cs-pill {
  min-height: 34px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 240, 200, 0.04) !important;
  color: var(--ink) !important;
  border: 1px solid var(--hairline) !important;
  font-size: 0.82rem;
  box-shadow: none !important;
}
.cs-pill.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold)) !important;
  color: #1a1300 !important;
  border-color: rgba(255, 235, 170, 0.6) !important;
}

/* Per-chat color: a chosen chat color recolors your own message bubbles.
   Falls back to the default gold when no color is set for the conversation. */
.message-row.own .message-bubble {
  border-color: var(--chat-accent, rgba(212, 175, 55, 0.5));
  background:
    var(--chat-accent-bg,
      linear-gradient(165deg, rgba(244, 221, 138, 0.18), rgba(212, 175, 55, 0.10) 55%, rgba(143, 116, 35, 0.08)));
}

.cs-toggles { display: flex; flex-direction: column; gap: 8px; }
.cs-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  cursor: pointer;
  user-select: none;
  font-size: 0.92rem;
}
.cs-toggle input[type="checkbox"] { display: none; }
.cs-switch {
  position: relative;
  width: 40px; height: 22px;
  background: rgba(255, 240, 200, 0.1);
  border-radius: 999px;
  transition: background 200ms;
  flex-shrink: 0;
}
.cs-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 200ms var(--ease-spring);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.cs-toggle input:checked + .cs-switch {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
}
.cs-toggle input:checked + .cs-switch::after { transform: translateX(18px); }

.cs-danger { padding-top: 0.5rem; }

/* ─── Screen lock overlay ─── */
.lock-overlay {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 9, 7, 0.94);
  backdrop-filter: blur(30px) saturate(140%);
}
.lock-overlay.hidden { display: none; }
.lock-card {
  width: min(380px, 90%);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.7rem;
}
.lock-logo {
  width: 88px; height: 88px;
  filter: drop-shadow(0 0 24px rgba(212, 175, 55, 0.5));
}
.lock-card h2 {
  font-family: var(--serif);
  background: linear-gradient(180deg, #fff, var(--gold-bright), var(--gold));
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}
.lock-card input {
  font-size: 1.2rem;
  letter-spacing: 0.4em;
  text-align: center;
  margin-top: 0.6rem;
}
.lock-card button { width: 100%; }
body.locked { overflow: hidden; }

/* ─── Schedule modal ─── */
.modal {
  position: fixed; inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
}
.modal.hidden { display: none; }
.modal-card {
  width: min(380px, 90%);
  padding: 1.8rem;
}

/* ─── Mobile: drawer becomes bottom sheet ─── */
@media (max-width: 820px) {
  .drawer { justify-content: stretch; align-items: flex-end; }
  .drawer-card {
    width: 100%;
    height: 88vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: drawerInMobile 320ms var(--ease-spring);
  }
  @keyframes drawerInMobile { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

  /* Show the message action menu permanently on mobile (no hover) */
  .msg-actions { display: inline-flex !important; position: static; margin-top: 6px; }
  .message-row.own .msg-actions { justify-content: flex-end; }
  .msg-action-btn { min-width: 38px; min-height: 38px; }

  .folder-tabs { padding: 3px; gap: 4px; }
  .folder-tab { font-size: 0.78rem; padding: 0.35rem 0.4rem; min-height: 30px; }
}

/* ═════════════════════════════════════════════════════════════════════════
   v1.5.1  — Quick-edit profile: click your avatar/name in the sidebar
   ═════════════════════════════════════════════════════════════════════════ */

.my-identity-clickable {
  position: relative;
  padding: 6px 8px;
  margin: -6px -8px 0.4rem -8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background 220ms var(--ease-out),
    border-color 220ms var(--ease-out),
    transform 220ms var(--ease-spring);
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

.my-identity-clickable:hover {
  background: rgba(212, 175, 55, 0.07);
  border-color: var(--hairline-2);
  transform: translateY(-1px);
}

.my-identity-clickable:active {
  transform: translateY(0);
  background: rgba(212, 175, 55, 0.04);
}

.my-identity-clickable:focus-visible {
  outline: 0;
  background: rgba(212, 175, 55, 0.06);
  border-color: rgba(212, 175, 55, 0.4);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

/* Avatar gets a pencil overlay on hover */
.my-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: visible;
}

.my-avatar-edit-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(11, 9, 7, 0.55);
  color: var(--gold-bright);
  font-size: 1.15rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.35);
}

.my-identity-clickable:hover .my-avatar-edit-hint,
.my-identity-clickable:focus-visible .my-avatar-edit-hint {
  opacity: 1;
}

/* Tiny chevron at the right edge — soft, only fully visible on hover */
.my-identity-chev {
  flex-shrink: 0;
  color: var(--ink-dim);
  font-size: 1.4rem;
  font-weight: 300;
  line-height: 1;
  padding: 0 4px 0 0;
  opacity: 0.35;
  transform: translateX(0);
  transition: opacity 220ms, transform 220ms var(--ease-spring), color 220ms;
}

.my-identity-clickable:hover .my-identity-chev,
.my-identity-clickable:focus-visible .my-identity-chev {
  opacity: 1;
  transform: translateX(3px);
  color: var(--gold);
}

/* Touch devices: keep the hint visible at low opacity so it's discoverable */
@media (hover: none) {
  .my-avatar-edit-hint {
    opacity: 0;            /* still hidden by default */
  }
  .my-identity-clickable:active .my-avatar-edit-hint {
    opacity: 1;
  }
  .my-identity-chev { opacity: 0.5; }
}

/* KXN OFFICIAL PREMIUM THEME */
:root { --gold: #D4AF37; --bg: #080808; }
body { background: var(--bg); color: #fff; font-family: 'Inter', sans-serif; }
.hero h1 { color: var(--gold); text-shadow: 0 0 20px rgba(212,175,55,0.4); }


/* KocaExpress Holding Company - Metallic Theme Integration */
:root { 
  --gold-metallic: #c5a059; /* Brushed gold from KX logo */
  --silver-metallic: #b8b8b8; /* Chrome silver from KX logo */
  --bg-dark: #0a0c10; 
}

/* Match the Brand Name to the Metallic Gold */
.brand-name, .hero h1, h1, .kxn-text {
  background: linear-gradient(to bottom, #f1d3a1 0%, #c5a059 50%, #947a39 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  letter-spacing: 1px;
}

/* Match Buttons to the Holding Company Aesthetic */
button, .btn, .primary-button {
  background: linear-gradient(135deg, #c5a059 0%, #947a39 100%) !important;
  color: #000 !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  font-weight: bold !important;
  text-transform: uppercase !important;
  box-shadow: 0 4px 15px rgba(197, 160, 89, 0.3) !important;
  transition: all 0.3s ease !important;
}

button:hover, .btn:hover {
  background: linear-gradient(135deg, #f1d3a1 0%, #c5a059 100%) !important;
  box-shadow: 0 6px 20px rgba(197, 160, 89, 0.5) !important;
  transform: translateY(-1px);
}


/* Precision Color Correction - Holding Company Metallic */
:root { 
  --kx-gold-high: #E8C191; /* Bright metallic highlight */
  --kx-gold-mid: #B68E56;  /* True brushed gold from KX logo */
  --kx-gold-deep: #7D6335; /* Shadow gold */
  --signal-blue: #5599ff;  /* Signal-inspired trust blue */
}

/* Match Logo Gold exactly using a 3-stop metallic gradient */
.brand-name, .hero h1, h1, .kxn-text {
  background: linear-gradient(135deg, var(--kx-gold-high) 0%, var(--kx-gold-mid) 50%, var(--kx-gold-deep) 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  text-shadow: none !important;
}

/* Signal Blue for Technical/Trust taglines */
.trust-text, .tagline, .hero p, .sub-info {
  color: var(--signal-blue) !important;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ── Modern button system (authoritative) ──────────────────────────────────
   PRIMARY buttons get a metallic gold gradient with real depth; secondary and
   danger keep a clear, distinct, lighter treatment so there's visual hierarchy
   (the old rule flattened EVERY button to one muted gold — that read as dated).
   Round icon buttons (send/burn) and pills are excluded and keep their own. */
/* PRIMARY — premium metallic gold, modern rounded-rect (not pill), real depth. */
button:not(.secondary-button):not(.danger-button):not(.danger-act):not(.send-btn):not(.burn-btn):not(.cs-pill):not(.burn-opt):not(.folder-tab):not(.tab-btn) {
  background: linear-gradient(180deg, #fbe9a8 0%, #f4dd8a 18%, #e7c659 42%, #d4af37 78%, #b5952f 100%) !important;
  color: #1a1300 !important;
  border: 1px solid rgba(255, 235, 170, 0.55) !important;
  border-radius: 12px !important;
  box-shadow: inset 0 1px 0 rgba(255, 250, 220, 0.7), 0 1px 1px rgba(0, 0, 0, 0.25), 0 8px 22px rgba(212, 175, 55, 0.22), 0 14px 30px rgba(0, 0, 0, 0.3) !important;
}
button:not(.secondary-button):not(.danger-button):not(.send-btn):not(.burn-btn):not(.cs-pill):not(.burn-opt):hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 250, 220, 0.8), 0 2px 2px rgba(0, 0, 0, 0.25), 0 14px 34px rgba(212, 175, 55, 0.34), 0 18px 40px rgba(0, 0, 0, 0.4) !important;
}

/* SECONDARY — clear, lighter, distinct (restores hierarchy). */
.secondary-button {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--text) !important;
  border: 1px solid var(--hairline-2, rgba(212, 175, 55, 0.22)) !important;
  border-radius: 12px !important;
  box-shadow: none !important;
}
.secondary-button:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.12) !important;
  border-color: rgba(212, 175, 55, 0.5) !important;
  color: var(--accent) !important;
  transform: translateY(-1px);
}

/* DANGER — red, unmistakable. */
.danger-button, button.danger-act {
  background: rgba(231, 76, 60, 0.12) !important;
  color: #ffb4ab !important;
  border: 1px solid rgba(231, 76, 60, 0.42) !important;
  border-radius: 12px !important;
  box-shadow: none !important;
}
.danger-button:hover:not(:disabled), button.danger-act:hover:not(:disabled) {
  background: rgba(231, 76, 60, 0.22) !important;
  border-color: rgba(231, 76, 60, 0.6) !important;
}

/* =====================================================================
   RESPONSIVE — authoritative single-pane layout for phones & tablets.
   (Supersedes the older, duplicated/conflicting mobile rules above.)
   On <=820px the contacts list and the conversation each take the full
   screen, one at a time; opening a chat adds .chat-open (set in ui.js),
   and the in-chat Back button removes it.
   ===================================================================== */
@media (max-width: 820px) {
  .split-layout {
    width: 100% !important;
    max-width: 100% !important;
    flex-direction: row !important;
    transform: none !important;
    overflow: hidden !important;
  }
  .split-layout > .sidebar-contacts,
  .split-layout > .main-chat {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border-radius: 0 !important;
  }
  /* Contacts visible by default; conversation hidden until one is opened. */
  .split-layout > .main-chat { display: none !important; }
  .split-layout.chat-open > .sidebar-contacts { display: none !important; }
  .split-layout.chat-open > .main-chat { display: flex !important; }
  /* Chat header: title row on top, action buttons on their own full-width row
     (kept to one tidy line, scrollable if ever needed) instead of wrapping ragged. */
  .topbar { flex-wrap: wrap !important; row-gap: 0.5rem !important; }
  .topbar-actions { flex-wrap: nowrap !important; width: 100% !important; overflow-x: auto !important; justify-content: flex-start !important; }
  .mobile-only-btn { display: inline-flex !important; }
}
@media (min-width: 821px) {
  .mobile-only-btn { display: none !important; }
}

/* Taglines: gold to match the brand, not the clashing blue. */
.trust-text, .tagline, .hero p, .sub-info { color: var(--kx-gold-high, #e8c191) !important; }

/* ===================================================================
   COMPOSER — flex row: input grows, a compact disappearing-timer pill,
   and a round gold send arrow. (Replaces the broken 2-col grid.)
   =================================================================== */
.composer {
  display: flex !important;
  align-items: flex-end;
  gap: 0.5rem !important;
  position: relative;
}
.composer #message-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 120px;
}
.send-btn {
  flex: 0 0 auto;
  width: 48px !important; height: 48px !important;
  min-width: 48px !important; max-width: 48px !important; min-height: 48px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; line-height: 1;
  text-transform: none !important; letter-spacing: 0 !important;
  background: linear-gradient(135deg, var(--kx-gold-high, #e8c191), var(--kx-gold-mid, #b68e56)) !important;
  color: #1a1300 !important; border: none !important;
}
.send-btn:disabled { opacity: 0.4; }
.burn-btn {
  flex: 0 0 auto;
  height: 48px !important; min-height: 48px !important; min-width: 48px !important; width: auto !important;
  padding: 0 14px !important;
  border-radius: 999px !important;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700;
  text-transform: none !important; letter-spacing: 0 !important;
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--ink, #e9e3d2) !important;
  border: 1px solid var(--border, rgba(212, 175, 55, 0.25)) !important;
  box-shadow: none !important;
}
.burn-btn.active {
  background: rgba(212, 175, 55, 0.18) !important;
  border-color: var(--gold, #d4af37) !important;
  color: var(--kx-gold-high, #f0cf6a) !important;
}
.burn-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 8px;
  z-index: 60;
  background: #14110a;
  border: 1px solid var(--border, rgba(212, 175, 55, 0.3));
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 170px;
}
.burn-menu.hidden { display: none; }
.burn-menu-title {
  margin: 5px 10px 6px;
  font-size: 0.68rem; letter-spacing: 0.6px;
  color: var(--ink-dim, #b3ac9a); text-transform: uppercase;
}
.burn-opt {
  text-align: left;
  background: transparent !important;
  color: var(--ink, #e9e3d2) !important;
  border: none !important;
  border-radius: 9px;
  padding: 10px 12px !important;
  font-size: 0.92rem; font-weight: 500 !important;
  min-height: auto !important;
  box-shadow: none !important;
  text-transform: none !important;
}
.burn-opt:hover { background: rgba(212, 175, 55, 0.14) !important; color: var(--kx-gold-high, #f0cf6a) !important; }

/* Mobile: pin the chat pane to the viewport so ONLY the message list scrolls. */
@media (max-width: 820px) {
  .split-layout { height: 100dvh !important; }
  .split-layout > .sidebar-contacts,
  .split-layout > .main-chat { height: 100dvh !important; }
  .main-chat { display: flex !important; flex-direction: column !important; }
  .messages { flex: 1 1 auto !important; min-height: 0 !important; max-height: none !important; overflow-y: auto !important; }
  .composer { flex: 0 0 auto !important; }
}

/* ─── "Nice try" gorilla overlay (wrong password) ─── */
.gorilla-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 40%, #1a0606 0%, #000 75%);
  animation: gorilla-in 0.18s ease-out;
}
.gorilla-overlay.hidden { display: none; }
@keyframes gorilla-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.gorilla-art {
  position: relative; line-height: 1;
  animation: gorilla-shake 0.5s ease-in-out 1;
}
.gorilla-face { font-size: clamp(96px, 30vw, 240px); display: block; filter: drop-shadow(0 10px 30px rgba(0,0,0,0.6)); }
.gorilla-finger {
  position: absolute; right: -6%; bottom: 4%;
  font-size: clamp(48px, 14vw, 120px);
  transform: rotate(-12deg);
}
@keyframes gorilla-shake {
  0%,100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-8px) rotate(-2deg); }
  40% { transform: translateX(8px) rotate(2deg); }
  60% { transform: translateX(-6px) rotate(-1deg); }
  80% { transform: translateX(6px) rotate(1deg); }
}
.gorilla-text {
  margin: 0; font-weight: 900; letter-spacing: 2px;
  font-size: clamp(1.4rem, 6vw, 2.6rem); color: #ff3b3b;
  text-shadow: 0 0 18px rgba(255, 59, 59, 0.5);
}
.gorilla-sub { margin: 0; color: #e9e3d2; font-size: clamp(0.95rem, 3.4vw, 1.15rem); max-width: 30ch; }
.gorilla-close {
  margin-top: 10px; padding: 10px 22px; border-radius: 999px;
  background: rgba(255,255,255,0.1); color: #fff;
  border: 1px solid rgba(255,255,255,0.25); cursor: pointer; font-size: 0.95rem;
}
.gorilla-close:hover { background: rgba(255,255,255,0.18); }

/* ─── View-once ("1× bekijken") message bubble ─── */
.vo-placeholder {
  display: inline-flex; align-items: center; gap: 6px;
  font-style: italic; color: var(--kx-gold-high, #f0cf6a);
  cursor: pointer; user-select: none;
}
.message-row.view-once .message-bubble { border: 1px dashed rgba(212, 175, 55, 0.5); }
.message-row.vo-burned .vo-placeholder { color: var(--ink-dim, #8a8472); cursor: default; font-style: italic; }
.vo-badge { color: var(--kx-gold-high, #f0cf6a); font-size: 0.78em; }

