/* ═══════════════════════════════════════════════════════════════
   9bugs — Design System
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────── */
:root {
  /* Dark theme (default) */
  --bg:           #0A0A0F;
  --bg-raised:    #111118;
  --bg-elevated:  #17171F;
  --surface:      #1E1E28;
  --surface-hi:   #25252F;
  --border:       rgba(255,255,255,0.07);
  --border-hi:    rgba(255,255,255,0.13);

  --text:         #E8E6F0;
  --text-muted:   #7A788A;
  --text-faint:   #45434F;

  --glow:         #6B8CFF;
  --glow-rgb:     107,140,255;
  --glow-warm:    #FFB088;
  --glow-warm-rgb: 255,176,136;
  --glow-violet:  #B088FF;
  --glow-mint:    #88FFD4;
  --glow-amber:   #FFD488;

  --nav-w:        56px;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    16px;

  --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  /* Safe area insets (notch phones) */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

[data-theme="light"] {
  --bg:           #F5F3EF;
  --bg-raised:    #EDEAE4;
  --bg-elevated:  #E6E3DC;
  --surface:      #DEDAD2;
  --surface-hi:   #D4D0C8;
  --border:       rgba(0,0,0,0.08);
  --border-hi:    rgba(0,0,0,0.14);

  --text:         #1A1A25;
  --text-muted:   #6B6878;
  --text-faint:   #A8A6B2;

  --glow:         #4B6AE0;
  --glow-rgb:     75,106,224;
  --glow-warm:    #D4854A;
  --glow-warm-rgb: 212,133,74;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg:           #F5F3EF;
    --bg-raised:    #EDEAE4;
    --bg-elevated:  #E6E3DC;
    --surface:      #DEDAD2;
    --surface-hi:   #D4D0C8;
    --border:       rgba(0,0,0,0.08);
    --border-hi:    rgba(0,0,0,0.14);
    --text:         #1A1A25;
    --text-muted:   #6B6878;
    --text-faint:   #A8A6B2;
    --glow:         #4B6AE0;
    --glow-rgb:     75,106,224;
    --glow-warm:    #D4854A;
    --glow-warm-rgb: 212,133,74;
  }
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  height: 100%;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Intro Screen ────────────────────────────────────────────── */
.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.8s var(--ease-out), visibility 0.8s;
}

.intro-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-lines {
  text-align: center;
}

.intro-logo {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  object-fit: contain;
  opacity: 0.8;
}

.intro-line {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.5vw, 2.2rem);
  color: var(--text);
  opacity: 0;
  transform: translateY(12px);
  animation: introReveal 0.9s var(--ease-out) forwards;
}

.intro-line:nth-child(2) {
  animation-delay: 0.5s;
  color: var(--text-muted);
  font-style: italic;
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  margin-top: 0.35em;
}

@keyframes introReveal {
  to { opacity: 1; transform: none; }
}

/* ── App Shell ───────────────────────────────────────────────── */
.app {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  transition: opacity 0.6s var(--ease-out);
}

/* ── Side Navigation ─────────────────────────────────────────── */
.side-nav {
  position: relative;
  z-index: 20;
  width: var(--nav-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 16px;
  gap: 0;
  background: var(--bg-raised);
}

.nav-logo {
  width: 36px;
  height: 36px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.nav-logo-fallback {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text-muted);
  display: none;
}
.nav-logo-img[style*="display:none"] + .nav-logo-fallback { display: block; }

.nav-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 0 6px;
}

.nav-item {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  outline: none;
}

.nav-item:hover {
  color: var(--text-muted);
  background: var(--surface);
}

.nav-item.active {
  color: var(--glow);
  background: rgba(var(--glow-rgb), 0.12);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 2px;
  border-radius: 1px;
  background: var(--glow);
  box-shadow: 0 0 8px rgba(var(--glow-rgb), 0.4);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--glow-warm);
  display: none;
  font-size: 9px;
  color: #000;
  line-height: 1;
  padding: 0 2px;
}

.nav-badge.visible { display: flex; align-items: center; justify-content: center; }

/* ── Content Area ─────────────────────────────────────────────── */
.app-content {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.section {
  position: absolute;
  inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}

.section.active {
  display: flex;
  opacity: 1;
}

/* ── Scrollable sections ──────────────────────────────────────── */
.section-scroll {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-scroll::-webkit-scrollbar { width: 4px; }
.section-scroll::-webkit-scrollbar-track { background: transparent; }
.section-scroll::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

.section-head { padding-bottom: 4px; }

.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.2;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.card-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--glow);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  align-self: flex-start;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  align-self: flex-start;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hi); background: var(--surface); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border: 1px solid rgba(255, 80, 80, 0.25);
  border-radius: var(--radius-sm);
  background: rgba(255, 80, 80, 0.08);
  color: #FF6464;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  align-self: flex-start;
}
.btn-danger:hover { background: rgba(255, 80, 80, 0.15); border-color: rgba(255, 80, 80, 0.4); }

/* ═══════════════════════════════════════════════════════════════
   CHAT SECTION
   ═══════════════════════════════════════════════════════════════ */
#sectionChat {
  flex-direction: row;
}

/* ── Chat Sidebar ─────────────────────────────────────────────── */
.chat-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  overflow: hidden;
  transition: width 0.22s var(--ease-out);
}

.chat-sidebar.collapsed { width: 56px; }

.sidebar-header {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}
.chat-sidebar.collapsed .sidebar-header { justify-content: center; }

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.sidebar-toggle:hover { color: var(--text); background: var(--surface); }
.sidebar-toggle svg { transition: transform 0.22s var(--ease-out); }
.chat-sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conv-list::-webkit-scrollbar { width: 3px; }
.conv-list::-webkit-scrollbar-track { background: transparent; }
.conv-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-sidebar.collapsed .conv-new-btn { display: none; }
.chat-sidebar.collapsed .conv-name,
.chat-sidebar.collapsed .conv-preview { display: none; }
.chat-sidebar.collapsed .conv-item-actions { display: none; }
.chat-sidebar.collapsed .conv-item {
  justify-content: center;
  padding: 8px;
}
.chat-sidebar.collapsed .conv-item::before {
  content: attr(data-initial);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chat-sidebar.collapsed .conv-item.active::before {
  background: rgba(var(--glow-rgb), 0.18);
  color: var(--glow);
}

.conv-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  border: 1px solid transparent;
  position: relative;
}

.conv-item:hover { background: var(--surface); }
.conv-item.active {
  background: rgba(var(--glow-rgb), 0.1);
  border-color: rgba(var(--glow-rgb), 0.18);
}

.conv-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}

.conv-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action buttons (rename / delete) */
.conv-item-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.15s;
}
.conv-item:hover .conv-item-actions { opacity: 1; }

.conv-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.conv-action-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.conv-delete-btn:hover { color: #FF6464; background: rgba(255,100,100,0.08); }
.conv-delete-yes { color: #FF6464; }

.conv-delete-msg {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-right: 2px;
}

/* Inline rename */
.conv-rename-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-hi);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 1px 0 2px;
  outline: none;
  min-width: 0;
}
.conv-rename-save {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--glow);
  padding: 2px 4px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.conv-new-btn {
  margin: 8px;
  padding: 8px 12px;
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  text-align: left;
  flex-shrink: 0;
}
.conv-new-btn:hover { color: var(--glow); border-color: rgba(var(--glow-rgb), 0.4); }

/* ── Chat Main ────────────────────────────────────────────────── */
.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  flex-shrink: 0;
}

.back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s;
}
.back-btn:hover { background: var(--surface); }

.chat-header-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  position: relative;
}

.messages-container::-webkit-scrollbar { width: 4px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.messages-inner {
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 100%;
  justify-content: flex-end;
}

/* ── Messages ─────────────────────────────────────────────────── */
.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 72%;
  opacity: 0;
  animation: messageAppear 0.4s var(--ease-out) forwards;
}

@keyframes messageAppear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.message.user-message { align-self: flex-end; flex-direction: row-reverse; }
.message.ai-message   { align-self: flex-start; }

.message-bubble {
  position: relative;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  word-break: break-word;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15),
              inset 0 1px 0 rgba(255,255,255,0.06),
              inset 0 -1px 0 rgba(0,0,0,0.05);
  transition: background 0.2s, border-color 0.3s, box-shadow 0.3s;
  animation: messageGlow 1.2s ease-out forwards;
}

/* Star-light glow pseudo-element */
.message-bubble::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    ellipse at calc(50% + var(--star-glow-x, 0px)) calc(50% + var(--star-glow-y, 0px)),
    rgba(200, 215, 255, var(--star-glow-opacity, 0)),
    transparent 60%
  );
  opacity: var(--star-glow-opacity, 0);
  transition: opacity 0.5s ease;
  z-index: 0;
}

@keyframes messageGlow {
  0%   { border-color: rgba(var(--glow-rgb), 0.3); box-shadow: 0 0 16px rgba(var(--glow-rgb), 0.12); }
  100% { border-color: rgba(255,255,255,0.06); box-shadow: none; }
}

.user-message .message-bubble {
  background: rgba(var(--glow-rgb), 0.10);
  border-radius: 16px 16px 4px 16px;
  border-color: rgba(var(--glow-rgb), 0.12);
  box-shadow: 0 2px 12px rgba(var(--glow-rgb), 0.08),
              0 0 1px rgba(var(--glow-rgb), 0.2),
              inset 0 1px 0 rgba(255,255,255,0.05);
  animation: messageSend 0.35s var(--ease-spring), messageGlow 1.2s ease-out forwards;
}

@keyframes messageSend {
  0%  { transform: scale(0.94); }
  60% { transform: scale(1.02); }
  100%{ transform: scale(1); }
}

.ai-message .message-bubble {
  background: rgba(255,255,255,0.03);
  border-radius: 16px 16px 16px 4px;
  border-color: rgba(255,255,255,0.06);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12),
              inset 0 1px 0 rgba(255,255,255,0.04);
}

[data-theme="light"] .message-bubble {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(0,0,0,0.06);
}
[data-theme="light"] .user-message .message-bubble {
  background: rgba(var(--glow-rgb), 0.10);
  border-color: rgba(var(--glow-rgb), 0.12);
  box-shadow: 0 0 8px rgba(var(--glow-rgb), 0.06);
}
[data-theme="light"] .ai-message .message-bubble {
  background: rgba(0,0,0,0.03);
}

.message-word {
  display: inline;
  opacity: 0;
  animation: wordFade 0.25s var(--ease-out) forwards;
}

@keyframes wordFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ai-char {
  display: inline;
}

.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--glow);
  border-radius: 1px;
  margin-left: 2px;
  vertical-align: middle;
  animation: cursorBlink 0.8s steps(2) infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.message-time {
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
  padding-bottom: 2px;
}

/* ── Input Area ───────────────────────────────────────────────── */
.input-area {
  flex-shrink: 0;
  padding: 16px 20px 16px;
  border-top: 1px solid var(--border);
}

.stop-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 100, 100, 0.35);
  border-radius: 6px;
  background: rgba(255, 100, 100, 0.08);
  color: #FF6464;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.stop-btn:hover { background: rgba(255, 100, 100, 0.18); }

.input-container {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-field {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 11px 52px 11px 14px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  overflow-y: hidden;
}

.input-field::placeholder { color: var(--text-faint); }
.input-field:focus { border-color: rgba(var(--glow-rgb), 0.4); background: var(--bg-elevated); }

.input-hint {
  position: absolute;
  bottom: 11px;
  right: 12px;
  font-size: 11px;
  color: var(--text-faint);
  pointer-events: none;
  transition: opacity 0.2s;
}

.send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(107, 140, 255, 0.30);
  border-radius: 6px;
  background: rgba(107, 140, 255, 0.08);
  color: var(--glow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  opacity: 0.6;
}
.send-btn:hover { background: rgba(107, 140, 255, 0.18); opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   MATCHES SECTION
   ═══════════════════════════════════════════════════════════════ */
#sectionMatches { flex-direction: column; }
#sectionMatches .section-scroll { max-width: 640px; }

.mode-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-chip {
  padding: 6px 14px;
  border: 1px solid var(--border-hi);
  border-radius: 99px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-chip:hover { color: var(--text); border-color: rgba(var(--glow-rgb), 0.3); }
.mode-chip.active {
  background: rgba(var(--glow-rgb), 0.15);
  border-color: rgba(var(--glow-rgb), 0.5);
  color: var(--glow);
  font-weight: 500;
}

.intent-field {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
.intent-field::placeholder { color: var(--text-faint); }
.intent-field:focus { border-color: rgba(var(--glow-rgb), 0.4); }

.blind-status {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-muted);
}

.match-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.match-item:hover { border-color: rgba(var(--glow-rgb), 0.25); }

.match-item-mode {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--glow);
  font-weight: 500;
}

.match-item-id {
  font-size: 13px;
  color: var(--text-muted);
  font-family: monospace;
}

.empty-hint {
  font-size: 13px;
  color: var(--text-faint);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════
   CONNECTIONS SECTION
   ═══════════════════════════════════════════════════════════════ */
#sectionConnections { flex-direction: column; }

.connections-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  min-height: 300px;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  color: var(--text-faint);
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-muted);
}

.empty-desc {
  font-size: 13px;
  color: var(--text-faint);
  max-width: 300px;
  line-height: 1.65;
}

/* ═══════════════════════════════════════════════════════════════
   CONSTELLATION SECTION
   ═══════════════════════════════════════════════════════════════ */
#sectionConstellation { flex-direction: row; }

.constellation-section-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.constellation-canvas-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  background: transparent;
}

#constellationSvg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#constellationSvg:active { cursor: grabbing; }

/* ── Tooltip ─────────────────────────────────────────────────── */
.constellation-tooltip {
  position: absolute;
  top: 0; left: 0;
  padding: 10px 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  max-width: 270px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  backdrop-filter: blur(8px);
  z-index: 10;
}
.constellation-tooltip.visible { opacity: 1; }

.tip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.tip-type {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tip-time {
  font-size: 10px;
  color: var(--text-faint);
}
.tip-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 7px;
}
.tip-foot {
  display: flex;
  gap: 10px;
  font-size: 10.5px;
  color: var(--text-faint);
}

/* ── Constellation Detail Panel ──────────────────────────────── */
.c-detail-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 300px;
  background: rgba(10, 10, 16, 0.90);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255,255,255,0.06);
  transform: translateX(100%);
  transition: transform 0.28s var(--ease-out);
  overflow-y: auto;
  z-index: 20;
  padding: 52px 18px 24px;
}
.c-detail-panel.open { transform: translateX(0); }

.c-detail-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.c-detail-close:hover { background: rgba(255,255,255,0.12); }

.c-det-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.c-det-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.c-det-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.c-det-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}
.c-det-body {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 12px;
}
.c-det-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.c-det-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.c-det-obs {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.c-det-obs-row {
  padding: 9px 10px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.c-det-obs-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.c-det-obs-txt {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.c-det-group {
  margin-bottom: 14px;
}
.c-det-group-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.c-det-obs-meta {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 3px;
}

.c-det-weight-bar {
  height: 3px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  margin: 10px 0 8px;
  overflow: hidden;
}
.c-det-weight-fill {
  height: 100%;
  background: var(--glow);
  border-radius: 2px;
  opacity: 0.5;
}

/* ── Star Tooltip ────────────────────────────────────────────── */
.star-tooltip {
  position: fixed;
  max-width: 280px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 200;
  backdrop-filter: blur(12px);
}
.star-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.tooltip-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 5px;
}
.tooltip-text {
  color: var(--text);
  margin-bottom: 6px;
}
.tooltip-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Constellation SVG node styles ──────────────────────────── */
#constellationSvg .g-nodes g.node { cursor: pointer; }
#constellationSvg .g-nodes g.centroid { cursor: pointer; }
#constellationSvg .g-edges line.edge {
  transition: stroke-opacity 0.3s ease, stroke-width 0.3s ease;
}
#constellationSvg .g-edges line.edge-centroid {
  stroke: rgba(255,255,255,0.15);
  stroke-dasharray: 4 3;
}

/* ── Left legend ─────────────────────────────────────────────── */
.c-legend {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 5;
  opacity: 0.4;
  transition: opacity 0.3s;
}
.c-legend.faded { opacity: 0; pointer-events: none; }

.c-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 11px;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.c-legend-item:hover { opacity: 0.8; }
.c-legend-item.active { color: var(--text-muted); }

/* Shape icons in legend */
.c-legend-icon {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.c-icon-all {
  border-radius: 50%;
  background: var(--text-faint);
}
.c-icon-circle { border-radius: 50%; }
.c-icon-diamond {
  width: 8px; height: 8px;
  transform: rotate(45deg);
  border-radius: 1px;
}
.c-icon-triangle {
  width: 0; height: 0;
  background: transparent !important;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid;
  border-bottom-color: inherit;
}
.c-icon-ring {
  border-radius: 50%;
  border: 1.5px solid;
  background: transparent !important;
}
.c-icon-star {
  font-size: 11px;
  line-height: 1;
  width: auto;
}

/* ── Top-right mode filter ───────────────────────────────────── */
.c-mode-filter {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  max-width: 260px;
  z-index: 5;
}

.c-mode-chip {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: rgba(10,10,15,0.55);
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.18s;
  backdrop-filter: blur(6px);
}
.c-mode-chip:hover { color: var(--text-muted); border-color: var(--border-hi); }
.c-mode-chip.active {
  background: rgba(var(--glow-rgb), 0.14);
  border-color: rgba(var(--glow-rgb), 0.45);
  color: var(--glow);
}

/* ── Bottom time slider ──────────────────────────────────────── */
.c-timeslider {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 70%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.c-timeslider-track { position: relative; }

.c-time-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--border-hi);
  outline: none;
  cursor: pointer;
}
.c-time-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 8px rgba(var(--glow-rgb), 0.5);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.c-time-range:hover::-webkit-slider-thumb {
  box-shadow: 0 0 14px rgba(var(--glow-rgb), 0.7);
}
.c-timeslider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-faint);
  padding: 0 2px;
}


/* ═══════════════════════════════════════════════════════════════
   PROFILE SECTION
   ═══════════════════════════════════════════════════════════════ */
#sectionProfile { flex-direction: column; }
#sectionProfile .section-scroll { max-width: 560px; }

.profile-identity {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 16px !important;
}

.avatar-upload {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.avatar-img-wrap {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--border-hi);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  transition: border-color 0.2s;
}
.avatar-upload:hover .avatar-img-wrap { border-color: rgba(var(--glow-rgb), 0.5); }

.avatar-placeholder-icon {
  width: 32px;
  height: 32px;
  color: var(--text-faint);
}

.avatar-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-hint {
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
}

.profile-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.profile-input::placeholder { color: var(--text-faint); }
.profile-input:focus { border-color: rgba(var(--glow-rgb), 0.4); }

.profile-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
.profile-textarea::placeholder { color: var(--text-faint); }
.profile-textarea:focus { border-color: rgba(var(--glow-rgb), 0.4); }

/* ── Setting Rows ────────────────────────────────────────────── */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 36px;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.setting-name {
  font-size: 14px;
  color: var(--text);
}

.setting-desc {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.4;
}

/* ── Theme Toggle Group ──────────────────────────────────────── */
.theme-toggle-group {
  display: flex;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.theme-btn {
  padding: 6px 12px;
  border: none;
  border-right: 1px solid var(--border-hi);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.theme-btn:last-child { border-right: none; }
.theme-btn:hover { background: var(--surface); color: var(--text); }
.theme-btn.active { background: rgba(var(--glow-rgb), 0.15); color: var(--glow); }

/* ── Toggle Switch ───────────────────────────────────────────── */
.toggle-label { cursor: pointer; flex-shrink: 0; }
.toggle-input { display: none; }

.toggle-track {
  display: block;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  position: relative;
  transition: background 0.25s, border-color 0.25s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.25s var(--ease-spring), background 0.25s;
}

.toggle-input:checked + .toggle-track {
  background: rgba(var(--glow-rgb), 0.25);
  border-color: rgba(var(--glow-rgb), 0.5);
}
.toggle-input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: var(--glow);
}

/* ── Data Actions ────────────────────────────────────────────── */
.data-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-footer {
  border: none !important;
  background: transparent !important;
  padding-top: 4px !important;
  padding-bottom: 24px !important;
}

.profile-user-id {
  font-size: 11px;
  color: var(--text-faint);
  font-family: monospace;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: modalIn 0.2s var(--ease-out);
}

@keyframes modalIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 28px 24px 20px;
  max-width: 380px;
  width: calc(100% - 48px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: modalSlide 0.25s var(--ease-spring);
}

@keyframes modalSlide {
  from { transform: translateY(16px) scale(0.97); }
  to   { transform: none; }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text);
}

.modal-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.65;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE  (<= 680px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 680px) {
  .app { flex-direction: column; }

  .side-nav {
    width: 100%;
    height: var(--nav-w);
    flex-direction: row;
    padding: 0 8px;
    border-right: none;
    border-top: 1px solid var(--border);
    order: 2;
    justify-content: space-around;
  }

  .nav-logo { display: none; }

  .nav-items {
    flex-direction: row;
    padding: 0;
    justify-content: space-around;
    width: 100%;
  }

  .app-content { order: 1; }

  /* Chat: sidebar covers full width, slides in/out */
  .chat-sidebar {
    position: absolute;
    inset: 0;
    width: 100%;
    z-index: 5;
    transform: translateX(0);
    transition: transform 0.3s var(--ease-out);
  }

  .chat-sidebar.hidden-mobile {
    transform: translateX(-100%);
    pointer-events: none;
  }

  .back-btn { display: flex; }

  /* Constellation: stack vertically */
  .constellation-section-layout { flex-direction: column; }
  .constellation-canvas-wrap { min-height: 320px; }
  .c-legend { top: 12px; left: 8px; transform: none; flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .c-mode-filter {
    position: static;
    max-width: 100%;
    padding: 8px 10px;
    justify-content: flex-start;
    gap: 5px;
  }
  .c-mode-chip {
    font-size: 9.5px;
    padding: 3px 8px;
  }
  .c-timeslider { width: 80%; bottom: 10px; }

  #sectionMatches .section-scroll,
  #sectionProfile .section-scroll { max-width: 100%; }

  .profile-identity { flex-direction: column !important; align-items: center !important; }
  .profile-fields { width: 100%; }

  /* Safe areas */
  .side-nav { padding-bottom: var(--safe-bottom); }
  .input-area { padding-bottom: calc(16px + var(--safe-bottom)); }
  .chat-sidebar { padding-top: var(--safe-top); }

  /* Detail panel: full width on mobile */
  .c-detail-panel {
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.06);
  }

  /* Touch-friendly targets (44x44 min) */
  .c-detail-close,
  .send-btn,
  .stop-btn,
  .chat-match-btn {
    width: 44px;
    height: 44px;
  }
  .send-btn, .stop-btn {
    right: 6px;
    bottom: 6px;
  }

  /* Chat header sticky (visible when keyboard open) */
  .chat-header {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--bg);
  }

  /* Nav indicator: bottom bar instead of left bar */
  .nav-item.active::before {
    left: 25%;
    top: auto;
    bottom: 0;
    width: 50%;
    height: 2px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET  (681–1024px)
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 681px) and (max-width: 1024px) {
  .chat-sidebar { width: 200px; }
  .c-detail-panel { width: min(300px, 50vw); }
}

/* ═══════════════════════════════════════════════════════════════
   Utility
   ═══════════════════════════════════════════════════════════════ */
.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;
}

.hidden { display: none !important; }

/* Thinking indicator */
.thinking-dots {
  display: inline-flex;
  gap: 4px;
  padding: 2px 0;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: dotPulse 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   SIGNATURE ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. AI ink-settle: word-level glow fades out ─────────────── */
.ai-message .message-word {
  animation: wordFade 0.25s var(--ease-out) forwards,
             inkSettle 0.5s ease forwards;
}

@keyframes inkSettle {
  0%   { text-shadow: 0 0 10px currentColor; }
  100% { text-shadow: none; }
}


/* ── 3. Partner breath (blind conversations) ─────────────────── */
.partner-breath {
  width: 4px;
  height: 60px;
  border-radius: 2px;
  background: var(--glow);
  opacity: 0;
  flex-shrink: 0;
  animation: breath var(--breath-period, 3s) ease-in-out infinite;
}

.partner-breath--typing  { --breath-period: 1.2s; opacity: 0.6; }
.partner-breath--present { --breath-period: 3.5s; opacity: 0.2; }
.partner-breath--gone    { animation: none; opacity: 0; transition: opacity 1.5s ease; }

@keyframes breath {
  0%, 100% { opacity: var(--breath-min, 0.1); transform: scaleY(0.9); }
  50%       { opacity: var(--breath-max, 0.5); transform: scaleY(1.1); }
}

/* ── 4. Nav unread warmth glow ───────────────────────────────── */
.nav-item::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: radial-gradient(circle,
    hsla(30, 80%, 60%, calc(var(--unread-warmth, 0) * 0.45)),
    transparent 70%);
  pointer-events: none;
  transition: background 0.6s ease;
}

/* ── 5. Conversation fade-through ────────────────────────────── */
.messages-inner.fade-out {
  animation: convFadeOut 0.18s ease forwards;
}

.messages-inner.fade-in {
  opacity: 0;
  animation: convFadeIn 0.28s ease 0.12s forwards;
}

@keyframes convFadeOut { to   { opacity: 0; } }
@keyframes convFadeIn  { from { opacity: 0; } to { opacity: 1; } }

/* ── 9. Avatar fade-in ───────────────────────────────────────── */
.avatar-preview {
  opacity: 0;
  animation: avatarAppear 0.8s ease forwards;
}

@keyframes avatarAppear { to { opacity: 1; } }

/* ── 10. Logo pulse (once on startup) ────────────────────────── */
.nav-logo-img {
  animation: logoPulse 2.2s ease forwards;
}

@keyframes logoPulse {
  0%   { opacity: 0;    filter: brightness(1); }
  25%  { opacity: 1;    filter: brightness(1.5); }
  55%  { opacity: 0.9;  filter: brightness(1); }
  100% { opacity: 0.85; filter: brightness(1); }
}

/* ═══════════════════════════════════════════════════════════════
   ONBOARDING — innerhalb des #introScreen
   ═══════════════════════════════════════════════════════════════ */
.intro-onboard-name {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  margin-top: 32px;
  opacity: 0; transform: translateY(10px);
  animation: introReveal 0.7s var(--ease-out) 0.2s forwards;
}
.intro-onboard-row {
  display: flex; align-items: center; gap: 12px;
}

.intro-onboard-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1.5px dashed var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-faint); font-size: 16px;
  flex-shrink: 0; overflow: hidden;
  transition: border-color 0.2s, color 0.2s;
}
.intro-onboard-avatar:hover {
  border-color: rgba(var(--glow-rgb), 0.4);
  color: var(--text-muted);
}

.intro-onboard-input {
  background: transparent;
  border: none; border-bottom: 1px solid var(--border-hi);
  border-radius: 0; padding: 6px 2px 8px;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  color: var(--text); text-align: center;
  outline: none; width: min(200px, 70vw);
  transition: border-color 0.2s;
}
.intro-onboard-input::placeholder { color: var(--text-faint); font-style: italic; }
.intro-onboard-input:focus { border-color: rgba(var(--glow-rgb), 0.5); }

.intro-onboard-submit {
  margin-top: 28px;
  opacity: 0; transform: translateY(10px);
  animation: introReveal 0.7s var(--ease-out) 0.6s forwards;
}

/* ═══════════════════════════════════════════════════════════════
   CHAT MATCH SHEET
   ═══════════════════════════════════════════════════════════════ */
.chat-match-sheet {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.32s var(--ease-out), opacity 0.25s;
  pointer-events: none;
}
.chat-match-sheet.open {
  max-height: 340px;
  opacity: 1;
  pointer-events: all;
}
.chat-match-sheet-inner {
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.cms-header {
  display: flex; align-items: center; justify-content: space-between;
}
.cms-title {
  font-family: var(--font-display);
  font-size: 0.95rem; font-style: italic; color: var(--text-muted);
}
.cms-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); font-size: 13px;
  padding: 4px 8px; border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.cms-close:hover { color: var(--text); background: var(--surface); }

.cms-result { display: flex; flex-direction: column; gap: 8px; }

.cms-result-row {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.cms-result-top {
  display: flex; align-items: center; justify-content: space-between;
}
.cms-result-label { font-size: 13px; color: var(--text); }
.cms-result-pct { font-size: 13px; font-weight: 600; color: var(--glow); }
.cms-score-bar {
  height: 3px; border-radius: 2px; background: var(--border); overflow: hidden;
}
.cms-score-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--glow), var(--glow-violet));
  transition: width 0.6s var(--ease-out);
}
.cms-empty {
  font-size: 13px; color: var(--text-faint);
  font-style: italic; text-align: center; padding: 4px 0;
}

/* Chat match button — absolute left, mirrors send-btn on right */
.chat-match-btn {
  position: absolute;
  left: 10px; bottom: 10px;
  width: 28px; height: 28px;
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  background: transparent; color: var(--text-faint);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0.5;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}
.chat-match-btn:hover {
  background: var(--surface); color: var(--text-muted);
  opacity: 1; border-color: var(--border-hi);
}
.chat-match-btn.active {
  color: var(--glow); border-color: rgba(var(--glow-rgb), 0.35);
  background: rgba(var(--glow-rgb), 0.08); opacity: 1;
}

/* Adjust input padding to clear both left (match) and right (send) buttons */
#sectionChat .input-field { padding-left: 46px; }

/* ═══════════════════════════════════════════════════════════════
   SEARCH PROFILES (Matches Section)
   ═══════════════════════════════════════════════════════════════ */
.profiles-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 8px;
}

.profile-create-form {
  overflow: hidden;
  max-height: 0; opacity: 0; pointer-events: none;
  transition: max-height 0.38s var(--ease-out), opacity 0.3s, margin 0.3s;
  margin-bottom: 0;
}
.profile-create-form.open {
  max-height: 520px; opacity: 1; pointer-events: all;
  margin-bottom: 16px;
}
.profile-create-form-inner {
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.pcf-field { display: flex; flex-direction: column; gap: 6px; }
.pcf-mode-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pcf-actions { display: flex; gap: 8px; }

.profile-list { display: flex; flex-direction: column; gap: 10px; }

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.profile-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pc-color, var(--border));
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 0.2s, opacity 0.25s;
  animation: cardEnter 0.3s var(--ease-out) both;
}
.profile-card:hover { border-color: var(--border-hi); }
.profile-card.pc-inactive {
  opacity: 0.45;
  border-left-color: var(--border);
}

.pc-header { display: flex; align-items: center; gap: 8px; }
.pc-name {
  font-size: 14px; font-weight: 500; color: var(--text);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pc-mode-badge {
  font-size: 11px; font-weight: 500; padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--pc-color, var(--border));
  color: var(--pc-color, var(--text-muted));
  white-space: nowrap; flex-shrink: 0;
  opacity: 0.85;
}

/* Toggle switch */
.pc-toggle-label { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.pc-toggle-cb { display: none; }
.pc-toggle-track {
  width: 32px; height: 18px; border-radius: 9px;
  background: var(--surface-hi); position: relative;
  transition: background 0.22s;
}
.pc-toggle-cb:checked + .pc-toggle-track { background: var(--glow); }
.pc-toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: white; transition: transform 0.22s var(--ease-spring);
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.pc-toggle-cb:checked + .pc-toggle-track .pc-toggle-thumb { transform: translateX(14px); }

.pc-desc {
  font-size: 13px; color: var(--text-muted); margin: 0;
  line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

.pc-actions { display: flex; gap: 6px; align-items: center; }

.pc-delete-wrap { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pc-delete-btn {
  padding: 6px 12px; font-size: 12px;
  color: var(--text-faint); border-color: transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.pc-delete-btn:hover { color: #FF6464; border-color: rgba(255,100,100,0.25); background: rgba(255,100,100,0.07); }
.pc-delete-confirm { display: none; align-items: center; gap: 6px; }
.pc-delete-confirm.show { display: flex; }
.pc-delete-confirm span { font-size: 12px; color: var(--text-muted); }
.pc-delete-yes { padding: 4px 10px; font-size: 12px; color: #FF6464; border-color: rgba(255,100,100,0.3); }
.pc-delete-no  { padding: 4px 10px; font-size: 12px; }

/* Match results view */
.profile-match-results { display: flex; flex-direction: column; gap: 14px; }

.pmr-header { display: flex; align-items: center; gap: 10px; padding-bottom: 2px; }
.pmr-title { font-family: var(--font-display); font-size: 1.1rem; color: var(--text); flex: 1; }

.pmr-list { display: flex; flex-direction: column; gap: 10px; }

.pmr-item {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  animation: cardEnter 0.25s var(--ease-out) both;
}
.pmr-item-top {
  display: flex; align-items: baseline; justify-content: space-between;
}
.pmr-item-label { font-size: 14px; color: var(--text); }
.pmr-item-score { font-size: 15px; font-weight: 600; color: var(--glow); }
.pmr-score-bar { height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; }
.pmr-score-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--glow), var(--glow-violet));
  transition: width 0.7s var(--ease-out);
}
.pmr-item-meta { display: flex; align-items: center; gap: 8px; }
.pmr-via { font-size: 11px; color: var(--text-faint); }

/* ── 11. Live conversation preview breathes ──────────────────── */
.conv-item.live .conv-preview {
  animation: previewBreath 3s ease-in-out infinite;
}

@keyframes previewBreath {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 0.8; }
}

/* ── Profile Save Toast ───────────────────────────────────────── */
.profile-saved-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface);
  border: 1px solid var(--border-hi);
  color: var(--glow-mint);
  font-size: 13px;
  font-family: var(--font-body);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
  z-index: 100;
  white-space: nowrap;
}
.profile-saved-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
