:root {
  --color-bg:       #0a0e1a;
  --color-surface:  #111827;
  --color-surface-raised: #1a2235;
  --color-border:   #1e293b;
  --color-border-light: #2d3a4f;
  --color-text:     #e2e8f0;
  --color-text-sub: #8892a8;
  --color-text-dim: #4a5568;
  --color-accent:   #f0c040;
  --color-accent-light: #fbd96a;
  --color-active:   #34d399;
  --color-idle:     #f0c040;
  --color-waiting:  #60a5fa;
  --color-ai-from:  #1a1f2e;
  --color-ai-to:    #0f1a2a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

a,
button,
input,
textarea,
select,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

a:focus,
a:focus-visible,
button:focus,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus,
[role="button"]:focus-visible {
  outline: none;
}

body {
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

main#app,
.tab-bar {
  position: relative;
  z-index: 1;
}

body.room-mode {
  overflow: hidden;
}

/* ── Header ── */
/* ── Main layout ── */
main#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100%;
  padding: 16px 16px;
  padding-top: max(16px, env(safe-area-inset-top));
}

/* ── Room Overlay: fixed full-screen, flex-column ── */
/* All room UI lives in this div appended to body — completely isolated from app layout */
.room-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Message list: fills remaining space, scrolls */
.room-overlay .message-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: calc(max(16px, env(safe-area-inset-top)) + 52px) 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Form area: fixed height at bottom */
.room-overlay .room-form-area {
  flex: 0 0 auto;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: 8px 16px max(12px, env(safe-area-inset-bottom));
  margin-top: 0;
}

/* Left notice inside overlay */
.room-overlay .room-left-notice {
  flex: 0 0 auto;
  margin: 4px 16px 0;
  border-radius: 4px;
}

/* ── Lane Tabs (Parallel Rooms) ── */
.lane-tabs {
  display: flex;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0 16px;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  margin-top: calc(max(16px, env(safe-area-inset-top)) + 44px);
}
.lane-tab {
  flex: 1;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--color-text-dim);
  cursor: pointer;
  text-align: center;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  position: relative;
  font-family: inherit;
}
.lane-tab:hover { color: var(--color-text-sub); }
.lane-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}
.lane-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 36px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  display: none;
  animation: pulse-badge 1.5s infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.lane-readonly-notice {
  text-align: center;
  font-size: 11px;
  color: var(--color-text-dim);
  padding: 6px 16px;
  flex-shrink: 0;
}
.lane-message-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 16px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lane-message-list.hidden { display: none; }
.room-overlay.parallel-room > .message-list { display: none; }

.lane-direct-btn-wrap {
  text-align: center;
  padding: 8px 16px 0;
  flex-shrink: 0;
}
.lane-direct-btn {
  background: transparent;
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
}
.lane-direct-btn:hover {
  background: var(--color-accent);
  color: var(--color-bg);
}

/* ── Banner ── */
.banner {
  background: #1a2235;
  border: 1px solid #2d3a4f;
  border-radius: 6px;
  padding: 10px 16px;
  margin-bottom: 20px;
  color: #60a5fa;
  font-size: 13px;
}

/* ── Landing Page ── */
.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 400px;
  margin: 0 auto;
  padding: 20px 0;
}

.landing-hero {
  text-align: center;
  margin-bottom: 32px;
}

.landing-freq {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--color-accent);
  letter-spacing: 0.2em;
  margin-bottom: 8px;
  opacity: 0.7;
}

.landing-title {
  font-size: 48px;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: 0.1em;
  font-family: 'Inter', sans-serif;
}

.landing-divider {
  width: 48px;
  height: 1px;
  background: var(--color-accent);
  opacity: 0.3;
  margin: 12px auto;
}

.landing-subtitle {
  color: var(--color-text-sub);
  font-size: 13px;
  margin-top: 0;
  font-family: 'Inter', sans-serif;
}

.landing-tabs {
  display: flex;
  width: 100%;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 24px;
}

.landing-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.landing-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.landing-form-area {
  width: 100%;
}

.landing-form-area .form-group {
  margin-bottom: 16px;
}

.landing-form-area label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-text);
}

.landing-form-area label small {
  font-weight: 400;
  color: var(--color-text-sub);
}

.landing-form-area input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--color-surface);
}

.landing-form-area input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(240, 192, 64, 0.15);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--color-accent);
  color: #0a0e1a;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.password-strength {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* ── CQ Random Chat MVP ── */
.cq-page {
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 88px;
}

/* ── Top bar (Talk list / Search) ── */
.cq-top-bar {
  display: flex;
  align-items: center;
  padding: 12px 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.cq-top-bar-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.cq-start-panel,
.cq-chat-panel {
  border: none;
  background: transparent;
  border-radius: 0;
}

.cq-start-panel {
  padding: 18px;
}

.cq-start-panel h2,
.cq-chat-header h2 {
  font-size: 18px;
  line-height: 1.25;
  margin-bottom: 4px;
}

.cq-status {
  margin-top: 14px;
  min-height: 22px;
  color: var(--color-accent-light);
  font-size: 13px;
}

.cq-start-button {
  margin-top: 14px;
}

.cq-chat-panel {
  position: relative;
  min-height: min(680px, calc(100vh - 116px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cq-chat-panel[hidden],
.cq-start-panel[hidden],
.cq-home-panel[hidden] {
  display: none;
}

/* --- LINE型: トーク中の全画面表示 --- */
.cq-chat-panel.cq-chat-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 200;
  max-width: none;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0a0e1a;
}

.cq-chat-fullscreen .cq-chat-header {
  flex: 0 0 auto;
  padding-top: max(14px, env(safe-area-inset-top));
}

.cq-chat-fullscreen .cq-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cq-chat-fullscreen .cq-message-form {
  flex: 0 0 auto;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* --- DM home: search + thread list --- */
/* ── Search Page ── */
.cq-search-page .cq-search-input {
  flex: 1 1 auto;
  padding: 12px 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #1a1a2e;
  color: #fff;
  border-radius: 24px;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.cq-search-page .cq-search-input::placeholder {
  color: #666;
}

.cq-search-page .cq-search-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: #333;
  color: #fff;
  border-radius: 50%;
  font: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cq-search-results {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cq-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.cq-search-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2a2a3e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.cq-search-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cq-search-name {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}

.cq-search-id {
  color: #888;
  font-size: 12px;
}

.cq-search-empty {
  color: #666;
  font-size: 13px;
  padding: 16px 4px;
  text-align: center;
}

.cq-threads {
  margin-top: 0;
}

.cq-threads-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cq-thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 4px;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.cq-thread-item:active {
  background: rgba(255,255,255,0.04);
}

.cq-thread-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2a2a3e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.cq-thread-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cq-thread-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cq-thread-name {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}

.cq-thread-time {
  color: #666;
  font-size: 11px;
  flex-shrink: 0;
}

.cq-thread-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.cq-thread-preview {
  color: #888;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.cq-thread-item-unread .cq-thread-name {
  font-weight: 700;
}

.cq-thread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #555;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.cq-tab-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  z-index: 10;
}

.cq-threads-empty {
  color: var(--color-text-sub);
  font-size: 13px;
  padding: 4px 2px;
}

.cq-back-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cq-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2a2a3e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.cq-chat-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: #0a0e1a;
}

.cq-chat-title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cq-chat-title-text {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.cq-chat-state {
  color: #666;
  font-size: 11px;
}

.cq-chat-menu-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cq-chat-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 4px;
  min-width: 140px;
}

.cq-dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  color: #fff;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.cq-dropdown-item:hover {
  background: rgba(255,255,255,0.06);
}

.cq-dropdown-danger {
  color: #e55;
}

.cq-send-button {
  width: 40px;
  height: 40px;
  border: none;
  background: #333;
  color: #fff;
  border-radius: 50%;
  font: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cq-messages {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overscroll-behavior-y: contain;
}

.cq-message {
  position: relative;
  z-index: 1;
  max-width: min(82%, 420px);
}

.cq-message {
  position: relative;
  max-width: min(82%, 420px);
}

.cq-message-mine {
  align-self: flex-end;
}

.cq-message-partner {
  align-self: flex-start;
}

.cq-message-body {
  border-radius: 16px;
  padding: 10px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.5;
}

.cq-message-mine .cq-message-body {
  background: #333;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cq-message-partner .cq-message-body {
  background: #1a1a2e;
  color: #ddd;
  border-bottom-left-radius: 4px;
}

.cq-message-meta {
  color: #666;
  font-size: 10px;
  margin-top: 4px;
  text-align: right;
}

.cq-message-blocked .cq-message-body {
  background: #1a1a2e;
  color: #666;
  border: 1px dashed rgba(255,255,255,0.1);
}

/* ── Pending message bubble ── */
.cq-message-pending .cq-message-pending-body {
  background: #2a2a3e;
  color: #888;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 14px;
  border-bottom-right-radius: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.cq-message-pending-meta {
  color: #555;
  font-size: 10px;
  margin-top: 4px;
  text-align: right;
}

.cq-pending-dots span {
  animation: cq-pending-dot 1.4s infinite;
  opacity: 0;
}

.cq-pending-dots span:nth-child(1) { animation-delay: 0s; }
.cq-pending-dots span:nth-child(2) { animation-delay: 0.2s; }
.cq-pending-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cq-pending-dot {
  0%, 60%, 100% { opacity: 0; }
  30% { opacity: 1; }
}

/* ── Delivered pulse animation ── */
.cq-message-delivered-pulse {
  animation: cq-delivered-pulse 420ms ease-out;
}

@keyframes cq-delivered-pulse {
  0% { transform: scale(0.985); filter: brightness(1.12); }
  100% { transform: scale(1); filter: brightness(1); }
}

.cq-message-original-toggle {
  display: block;
  border: none;
  background: none;
  color: #666;
  font-size: 10px;
  margin-top: 4px;
  cursor: pointer;
  padding: 0;
}

.cq-message-original {
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 8px;
  background: #0a0e1a;
  font-size: 12px;
  color: #888;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cq-warning {
  margin: 0 14px 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: #211a0c;
  color: #f7d37a;
  font-size: 13px;
}

.cq-message-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.06);
  background: #0a0e1a;
}

.cq-message-form textarea {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  background: #1a1a2e;
  color: #fff;
  font: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 100px;
}

.cq-message-form textarea::placeholder {
  color: #666;
}

.cq-message-form textarea:focus {
  border-color: rgba(255,255,255,0.3);
}

.cq-send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── CQ Board ── */
.cq-board-page {
  position: fixed;
  inset: 0 0 88px;
  z-index: 80;
  max-width: none;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

.cq-board-top-bar {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  justify-content: space-between;
  gap: 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-inline: 4px;
}

.cq-board-refresh {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--color-text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cq-board-refresh:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cq-board-posts {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}

.cq-board-post {
  max-width: min(82%, 420px);
}

.cq-board-post-mine {
  align-self: flex-end;
}

.cq-board-post-meta {
  margin-top: 4px;
  padding-inline: 4px;
}

.cq-message-partner .cq-board-post-meta {
  text-align: left;
}

.cq-board-post-author {
  max-width: 100%;
  margin: 0 0 4px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-sub);
  font-size: 11px;
  line-height: 1.2;
}

.cq-board-original-toggle {
  margin-left: auto;
  text-align: right;
}

.cq-board-original {
  background: rgba(0,0,0,0.16);
}

.cq-board-notice-area {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
}

.cq-board-error,
.cq-board-empty {
  color: var(--color-text-sub);
  font-size: 13px;
  padding: 14px 4px;
  text-align: center;
}

.cq-board-empty {
  align-self: center;
  margin: auto 0;
}

.cq-board-error {
  color: #fca5a5;
}

.cq-board-warning {
  margin: 0 12px 8px;
}

.cq-board-form {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: var(--color-bg);
}

.cq-board-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  background: #1a1a2e;
  color: #fff;
  font: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
}

.cq-board-form textarea::placeholder {
  color: #666;
}

.cq-board-form textarea:focus {
  border-color: rgba(255,255,255,0.3);
}

@media (max-width: 520px) {
  .cq-board-page {
    bottom: 88px;
  }

  .cq-board-post {
    max-width: min(86%, 420px);
  }
}

/* ── CQ Admin Review ── */
.cq-admin-page {
  max-width: 1180px;
  margin: 0 auto;
  padding-bottom: 48px;
}

.cq-admin-header {
  padding: 24px 0 14px;
}

.cq-admin-header h1 {
  font-size: 34px;
  line-height: 1.1;
  margin-bottom: 8px;
}

.cq-admin-header p:last-child {
  color: var(--color-text-sub);
}

.cq-admin-auth {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.cq-admin-auth label {
  grid-column: 1 / -1;
  color: var(--color-text-sub);
  font-size: 12px;
}

.cq-admin-auth input {
  min-width: 0;
  border: 1px solid var(--color-border-light);
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
}

.cq-admin-auth button,
.cq-admin-refresh {
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: #0a0e1a;
  border-radius: 6px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.cq-admin-error {
  grid-column: 1 / -1;
  color: #fca5a5;
  font-size: 13px;
}

.cq-admin-dashboard[hidden] {
  display: none;
}

.cq-admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.cq-admin-filters label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--color-text-sub);
  font-size: 13px;
  cursor: pointer;
}

.cq-admin-filters input[type="checkbox"] {
  inline-size: 24px;
  block-size: 24px;
  accent-color: var(--color-accent);
}

.cq-admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 14px;
  margin-bottom: 14px;
}

.cq-admin-grid-secondary {
  grid-template-columns: 1fr 1fr;
}

.cq-admin-panel {
  min-width: 0;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 8px;
  padding: 12px;
}

.cq-admin-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.cq-admin-panel h2 {
  font-size: 16px;
  margin-bottom: 10px;
}

.cq-admin-refresh {
  padding: 7px 10px;
  font-size: 12px;
}

.cq-admin-rooms,
.cq-admin-messages,
.cq-admin-reports,
.cq-admin-failures {
  max-height: 560px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cq-admin-room-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) auto auto auto minmax(110px, auto);
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.cq-admin-room-row:hover {
  border-color: var(--color-border-light);
}

.cq-admin-room-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
}

.cq-admin-message,
.cq-admin-simple-row {
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 6px;
  padding: 10px;
}

.cq-admin-message header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.cq-admin-message header span {
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--color-text-sub);
  font-size: 11px;
}

.cq-admin-message dl,
.cq-admin-simple-row dl {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 6px 10px;
}

.cq-admin-message dt,
.cq-admin-simple-row dt {
  color: var(--color-text-dim);
  font-size: 12px;
}

.cq-admin-message dd,
.cq-admin-simple-row dd {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.cq-admin-empty {
  color: var(--color-text-sub);
  font-size: 13px;
}

@media (max-width: 820px) {
  .cq-admin-grid,
  .cq-admin-grid-secondary {
    grid-template-columns: 1fr;
  }

  .cq-admin-room-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .cq-admin-auth {
    grid-template-columns: 1fr;
  }
}

.strength-bar {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}

.strength-label {
  font-size: 11px;
  color: var(--color-text-sub);
  min-width: 28px;
}

.header-logout {
  display: none;
}

.header-logout:hover {
  opacity: 1;
  color: #ef4444;
}

/* ── Setting tab user info ── */
.setting-user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
}
.setting-username {
  font-family: 'JetBrains Mono', monospace;
  color: var(--color-accent);
  font-size: 13px;
  letter-spacing: 0.05em;
}
/* ── Settings Page ── */
.settings-page {
  padding: 0 16px 24px;
}

.settings-top-bar {
  display: flex;
  align-items: center;
  padding: 12px 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.settings-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.settings-empty {
  color: #666;
  font-size: 13px;
  padding: 16px 4px;
  text-align: center;
}

.settings-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.settings-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2a2a3e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  flex-shrink: 0;
}

.settings-profile-main {
  flex: 1;
  min-width: 0;
}

.settings-display-name {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.settings-username {
  font-size: 13px;
  color: #888;
  margin-top: 2px;
}

.settings-section {
  padding: 4px 0;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 16px 4px 6px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.settings-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.settings-row-label {
  font-size: 15px;
  color: #fff;
}

.settings-row-value {
  font-size: 13px;
  color: #888;
}

.settings-row-action {
  padding: 6px 14px;
  border: none;
  border-radius: 16px;
  background: #333;
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.settings-row-action:hover {
  background: #444;
}

.settings-row-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.settings-inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
}

.settings-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: #1a1a2e;
  color: #fff;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.settings-input:focus {
  border-color: rgba(255,255,255,0.3);
}

.settings-button {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: #333;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.settings-button:hover {
  background: #444;
}

.settings-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.settings-button-secondary {
  background: transparent;
  color: #888;
}

.settings-button-secondary:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.settings-error {
  color: #e55;
  font-size: 12px;
  padding: 2px 4px 6px;
}

.settings-danger {
  display: block;
  width: 100%;
  padding: 14px 4px;
  border: none;
  background: none;
  color: #e55;
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.2s;
}

.settings-danger:hover {
  background: rgba(255,255,255,0.04);
}

/* ── Onboarding Wizard ── */
.onboard-container {
  max-width: 480px;
  margin: 0 auto;
}

.onboard-progress {
  margin-bottom: 24px;
}

.progress-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), #e8a820);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.onboard-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.onboard-subtitle {
  color: var(--color-text-sub);
  font-size: 13px;
  margin-bottom: 20px;
}

.onboard-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin: 20px 0 8px;
}

.onboard-tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.onboard-tag {
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.onboard-tag:hover {
  border-color: var(--color-accent);
}

.onboard-tag.selected {
  background: var(--color-accent);
  color: #0a0e1a;
  border-color: var(--color-accent);
  font-weight: 600;
}

.onboard-custom-tag {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.onboard-custom-tag input {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

.onboard-custom-tag input:focus {
  border-color: var(--color-accent);
}

.onboard-custom-tag button {
  padding: 6px 14px;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.onboard-count {
  display: block;
  font-size: 12px;
  color: var(--color-text-sub);
  margin-top: 4px;
}

.onboard-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.onboard-textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(240, 192, 64, 0.15);
}

.onboard-starter-group {
  margin-bottom: 12px;
}

.onboard-starter-prompt {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: 4px;
}

.onboard-starter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.onboard-starter-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(240, 192, 64, 0.15);
}

.onboard-complete {
  text-align: center;
  padding: 20px 0;
}

.onboard-complete-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.onboard-score-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 20px;
  margin: 20px 0;
  box-shadow: var(--shadow-md);
}

.onboard-score-title {
  font-size: 13px;
  color: var(--color-text-sub);
  margin-bottom: 6px;
}

.onboard-score-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 10px;
}

.onboard-score-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.onboard-score-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--color-accent), #e8a820);
  border-radius: 3px;
  transition: width 0.3s;
}

.onboard-score-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--color-active);
  text-align: left;
}

.btn-match-big {
  font-size: 18px;
  padding: 16px;
  margin-top: 20px;
  background: linear-gradient(135deg, var(--color-accent), #e8a820, var(--color-accent));
  color: #0a0e1a;
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

.onboard-later {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: var(--color-text-sub);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}

.onboard-later:hover {
  color: var(--color-accent);
}

/* ── Tab Bar ── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 16px 24px;
  background: var(--color-bg);
  border-top: 1px solid rgba(255,255,255,0.05);
}

.tab-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 4px 12px;
  color: var(--color-text-dim);
  opacity: 0.5;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-item.active {
  color: var(--color-accent);
  opacity: 1;
}

.tab-icon-mat {
  font-size: 22px;
}

.tab-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

main#app.has-tabbar {
  padding-bottom: 80px;
}

.main-surface-shell {
  position: relative;
  min-height: calc(100dvh - 80px);
}

.main-surface-content {
  min-height: calc(100dvh - 80px);
}

.surface-toggle {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(8, 8, 8, 0.58);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}

.surface-toggle-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255,255,255,0.64);
  min-width: 78px;
  height: 34px;
  padding: 0 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
}

.surface-toggle-btn:hover {
  color: rgba(255,255,255,0.92);
}

.surface-toggle-btn.active {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
}

/* ── Snap Container (horizontal slide navigation) ── */
.snap-container {
  position: relative;
  width: 100%;
  height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.snap-track {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.snap-track::-webkit-scrollbar { display: none; }

.snap-track > * {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  height: 100%;
}


.room-slide {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: transparent;
  border-radius: 0;
  border: none;
  overflow: hidden;
}

.room-slide-messages {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: calc(max(16px, env(safe-area-inset-top)) + 52px) 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.swipe-hint {
  display: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--color-text-dim);
  text-transform: uppercase;
  text-align: center;
  padding: 6px 0;
  opacity: 0.5;
  flex-shrink: 0;
}

.swipe-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50vh;
  color: var(--color-text-sub);
}

/* ── Cards ── */
.card {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  background: var(--color-surface);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-meta {
  font-size: 12px;
  color: var(--color-text-sub);
  margin-top: 4px;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
}

.badge-active   { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.badge-idle     { background: rgba(240, 192, 64, 0.15); color: #f0c040; }
.badge-waiting  { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.badge-archived { background: rgba(30, 41, 59, 0.5); color: #8892a8; }

/* ── Room view ── */
.room-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-bg);
}

.room-header-content {
  flex: 1;
  min-width: 0;
}

.room-back-btn {
  background: none;
  border: none;
  color: var(--color-accent);
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  transition: opacity 0.15s;
}
.room-back-btn:hover { opacity: 0.7; }

.room-header h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--color-text-sub);
}

.room-summary-block {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-light);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  font-size: 14px;
}

.room-summary-block h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 8px;
}

/* ── Messages ── */
.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
  padding-bottom: 8px;
}

.msg {
  display: inline-block;
  max-width: min(82vw, 420px);
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}

.msg-ai {
  max-width: 100%;
  background: linear-gradient(135deg, var(--color-ai-from), var(--color-ai-to));
  font-style: italic;
  color: var(--color-text-sub);
  text-align: center;
  border-radius: 16px;
  white-space: pre-wrap;
  position: relative;
  overflow: hidden;
}

.msg-ai.msg-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  animation: shimmer 1.5s ease-out forwards;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.msg-enter {
  animation: msg-fade-in 0.45s ease-out;
}

.msg-enter-mine {
  animation: msg-slide-right 0.35s ease-out;
}

.msg-enter-other {
  animation: msg-slide-left 0.35s ease-out;
}

.msg-enter-ai {
  animation: msg-pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.msg-mine {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-light));
  color: #0a0e1a;
  border-bottom-right-radius: 4px;
}

.msg-other {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}

.msg-summary {
  align-self: stretch;
  max-width: 100%;
  background: rgba(240, 192, 64, 0.1);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: var(--color-text);
}

/* ── Message Row Layout ── */
.msg-row {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.msg-row-left {
  align-items: flex-start;
}
.msg-row-right {
  align-items: flex-end;
}
.msg-row-center {
  align-self: center;
  max-width: 90%;
  align-items: center;
}

.msg-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--color-text-dim);
  margin-bottom: 3px;
  padding-left: 4px;
}
.msg-label-btn {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  text-align: inherit;
}
.msg-label-btn:hover {
  color: var(--color-text-sub);
}
.msg-label-right {
  text-align: right;
  padding-left: 0;
  padding-right: 4px;
}
.msg-label-ai {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-accent);
  opacity: 0.7;
  text-align: center;
  padding: 0;
}

.msg-label-ai-icon {
  font-size: 15px;
  line-height: 1;
}

.msg-time {
  font-size: 10px;
  color: var(--color-text-sub);
  margin-top: 4px;
  padding: 0 6px;
}

.msg-time-left {
  text-align: left;
}

.msg-time-right {
  text-align: right;
}

.user-profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.user-profile-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.user-profile-sheet {
  position: relative;
  width: min(100%, 560px);
  margin: 0 12px max(12px, env(safe-area-inset-bottom));
  padding: 22px 18px 18px;
  border-radius: 24px;
  background: rgba(12, 12, 12, 0.96);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow-md);
}

.user-profile-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--color-text);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-profile-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.user-profile-head h3 {
  font-size: 20px;
  font-weight: 700;
}

.user-profile-eyebrow,
.user-profile-section-title {
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-sub);
  margin-bottom: 8px;
}

.user-profile-section-title {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: normal;
  text-transform: none;
}

.user-profile-bio,
.user-profile-empty {
  color: var(--color-text);
  line-height: 1.7;
}

.user-profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Thinking indicator ── */
.msg-thinking {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--color-ai-from), var(--color-ai-to));
  border-radius: 18px;
  font-size: 13px;
  color: var(--color-text-sub);
  animation: thinking-pulse 2s ease-in-out infinite;
}
.thinking-signal {
  display: flex;
  gap: 4px;
  align-items: end;
  min-width: 22px;
}
.thinking-signal-line {
  width: 2px;
  height: 8px;
  border-radius: 999px;
  background: var(--color-accent);
  opacity: 0.8;
  transform-origin: center bottom;
  animation: thinking-signal-wave 1.15s infinite ease-in-out;
}
.thinking-signal-line:nth-child(2) {
  animation-delay: 0.18s;
}
.thinking-signal-line:nth-child(3) {
  animation-delay: 0.36s;
}
.thinking-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.thinking-en {
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
}
.thinking-jp {
  font-size: 11px;
  color: var(--color-text-dim);
}
.thinking-code {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid rgba(240, 192, 64, 0.18);
  border-radius: 999px;
  background: rgba(240, 192, 64, 0.08);
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.24s ease, transform 0.24s ease;
  white-space: nowrap;
}
.thinking-code.visible {
  opacity: 1;
  transform: translateY(0);
}
@keyframes thinking-signal-wave {
  0%, 100% { transform: scaleY(0.65); opacity: 0.46; }
  50% { transform: scaleY(1.5); opacity: 1; }
}
@keyframes thinking-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(240,192,64,0); }
  50% { opacity: 0.85; box-shadow: 0 0 0 6px rgba(240,192,64,0.08); }
}

/* ── Typing indicator ── */
.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--color-text-sub);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  height: 24px;
}
.typing-indicator.visible { opacity: 1; }
.typing-name {
  font-style: italic;
}

/* Public surface: typing indicator sits outside the form area, so lift it above the tab bar. */
.room-slide > .typing-indicator {
  flex-shrink: 0;
  min-height: calc(24px + max(10px, env(safe-area-inset-bottom)) + 72px);
  padding-bottom: calc(max(10px, env(safe-area-inset-bottom)) + 72px);
}

.signal-cue {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: grid;
  justify-items: center;
  align-content: start;
  padding: calc(max(24px, env(safe-area-inset-top)) + 8px) 18px max(24px, env(safe-area-inset-bottom));
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
  overflow: hidden;
}
.signal-cue.visible {
  opacity: 1;
}
.signal-cue-contained {
  position: absolute;
  inset: 0;
  z-index: 0;
  padding: 16px 14px;
  align-content: center;
}
.signal-cue-contained .signal-cue-wallpaper {
  width: 100%;
}
.signal-cue-wallpaper {
  width: min(100vw, 760px);
  display: grid;
  gap: 12px;
  justify-items: center;
  opacity: 0.16;
  transform: scale(0.985);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.signal-cue.burst .signal-cue-wallpaper {
  opacity: 0.24;
  transform: scale(1);
}
.signal-cue-row {
  width: 118%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.18em;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(18px, 5.3vw, 42px);
  line-height: 1.05;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  word-break: break-word;
  text-align: center;
  opacity: 0.26;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.signal-cue.burst .signal-cue-row {
  animation: signal-scan 1400ms cubic-bezier(0.22, 1, 0.36, 1) infinite;
  animation-delay: var(--row-delay, 0ms);
}
.signal-cue-user .signal-cue-row {
  color: rgba(246, 236, 208, 0.72);
}
.signal-cue-reply .signal-cue-row {
  color: rgba(240, 192, 64, 0.8);
}
@keyframes signal-scan {
  0% {
    opacity: 0.08;
    transform: translateY(10px);
  }
  35% {
    opacity: 0.88;
    transform: translateY(0);
  }
  100% {
    opacity: 0.26;
    transform: translateY(0);
  }
}
.typing-dots {
  display: flex;
  align-items: center;
  gap: 3px;
}
.typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-text-sub);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Typewriter cursor ── */
.typewriter-active::after {
  content: '▎';
  animation: blink-cursor 0.7s step-end infinite;
  color: var(--color-accent);
  font-style: normal;
}
@keyframes blink-cursor {
  50% { opacity: 0; }
}

@keyframes msg-fade-in {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes msg-slide-right {
  0% {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes msg-slide-left {
  0% {
    opacity: 0;
    transform: translateX(-30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes msg-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Message form area (sticky bottom in room view) ── */
.room-form-area {
  background: var(--color-bg);
  padding: 8px 0 12px;
  z-index: 10;
  border-top: 1px solid var(--color-border);
  margin-top: 8px;
}

/* ── Message form ── */
.message-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 0;
}

.message-form textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  border-radius: 20px;
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow-y: auto;
  overscroll-behavior: contain;
  appearance: none;
  -webkit-appearance: none;
  scrollbar-width: none;
}

.message-form textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.message-form textarea::-webkit-scrollbar-button {
  display: none;
}

.message-form textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(240,192,64,0.1);
}

.message-form .send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: #0a0e1a;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
  font-size: 18px;
}

.message-form .send-btn:hover {
  transform: scale(1.08);
  background: var(--color-accent-light);
}

.message-form .send-btn:active {
  transform: scale(0.95);
}

.message-form .send-btn:disabled {
  opacity: 0.5;
  transform: none;
}

/* ── Global dark input styling ── */
input, textarea, select {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-dim);
}

/* ── Forms ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
  border-color: var(--color-accent);
}

textarea {
  resize: vertical;
  min-height: 60px;
  appearance: none;
  -webkit-appearance: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
  background: transparent;
}

textarea::-webkit-scrollbar-button {
  display: none;
}

textarea::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-track {
  background: transparent;
}

button {
  padding: 8px 16px;
  background: none;
  color: var(--color-text);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

button:hover {
  opacity: 0.85;
}

button.secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

button.secondary:hover {
  background: var(--color-border);
  opacity: 1;
}

button.danger {
  background: #ef4444;
  color: #fff;
}

/* ── Tags ── */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
}

.tag-remove {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  color: #60a5fa;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  opacity: 0.6;
}

.tag-remove:hover {
  opacity: 1;
  background: none;
}

.tag-add-form {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.tag-add-form input {
  flex: 1;
}

/* ── Utility ── */
.error {
  color: #ef4444;
  font-size: 13px;
  margin-top: 8px;
}

.loading {
  width: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 14px;
  color: var(--color-text-sub);
  text-align: center;
  align-content: center;
}

.loading-radar {
  position: relative;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
}

.loading-ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.loading-ring-2 {
  inset: 12px;
  border-color: rgba(255, 255, 255, 0.08);
}

.loading-core {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.loading-sweep {
  position: absolute;
  width: 1px;
  height: 34px;
  left: 50%;
  top: 50%;
  margin-left: -0.5px;
  margin-top: -34px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.88));
  transform-origin: bottom center;
  animation: loading-sweep 1.2s linear infinite;
}

.loading-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-sub);
  opacity: 0.9;
}

@keyframes loading-sweep {
  0% {
    transform: rotate(-135deg);
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: rotate(225deg);
    opacity: 0.3;
  }
}

.view-home > .loading,
.view-chats > .loading,
.view-radio > .loading,
.main-surface-content > .loading {
  min-height: calc(100dvh - 80px);
}

.room-slide-messages > .loading,
.qso-slide-messages > .loading {
  position: absolute;
  inset: 0;
  padding: calc(max(16px, env(safe-area-inset-top)) + 52px) 16px 16px;
}

.room-overlay > .loading {
  flex: 1 1 auto;
  min-height: 0;
}

.user-profile-body > .loading {
  min-height: 240px;
}

.section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text-sub);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  cursor: pointer;
}

a:hover {
  text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  main#app {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
}

/* ── Matchmaking ── */
.match-box {
  text-align: center;
  padding: 20px 0;
  margin-bottom: 16px;
}

.btn-match {
  background: none;
  border: none;
  color: var(--color-accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  letter-spacing: 0.15em;
  cursor: pointer;
  padding: 8px 0;
}
.btn-match:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-cancel {
  font-size: 12px;
  padding: 4px 14px;
  background: transparent;
  color: var(--color-text-sub);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  cursor: pointer;
  margin-left: 12px;
}
.btn-cancel:hover { background: var(--color-surface); }

.match-requested {
  text-align: center;
  padding: 24px 0;
}

.cq-status-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--color-accent);
  text-transform: uppercase;
  margin-bottom: 8px;
  animation: morse-pulse 2s ease-in-out infinite;
}

.cq-status-main {
  font-size: 16px;
  color: var(--color-text);
  margin-bottom: 4px;
}

.cq-status-sub {
  font-size: 12px;
  color: var(--color-text-dim);
}

.match-requested-text strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--color-accent);
}

.match-requested-text p {
  font-size: 12px;
  color: var(--color-text-sub);
  line-height: 1.5;
  margin: 0;
}

/* ── Morse pulse animation ── */
@keyframes morse-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.btn-cancel-small {
  background: none;
  border: none;
  color: var(--color-text-dim);
  font-size: 11px;
  cursor: pointer;
}

.btn-cancel-small:hover {
  color: var(--color-text-sub);
}

.match-waiting {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-sub);
}

.match-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Particles Background ── */
.room-overlay .room-left-notice,
.room-overlay .message-list,
.room-overlay .room-form-area {
  position: relative;
  z-index: 1;
}

/* ── Scroll-to-bottom Button ── */
.scroll-bottom-btn {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-accent);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.18s ease;
  animation: bounce-gentle 2s infinite;
}

.room-overlay .room-back-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(10, 14, 26, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
}
.scroll-bottom-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
@keyframes bounce-gentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ── Send Button Ripple ── */
.send-btn {
  position: relative;
  overflow: hidden;
}
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: ripple-anim 0.5s ease-out;
  pointer-events: none;
}
@keyframes ripple-anim {
  to { transform: scale(4); opacity: 0; }
}

/* ── AI Message Glow ── */
.msg-ai.msg-glow {
  animation: ai-glow 2s ease-in-out;
}
@keyframes ai-glow {
  0% { box-shadow: 0 0 0 0 rgba(240, 192, 64, 0); }
  30% { box-shadow: 0 0 16px 4px rgba(240, 192, 64, 0.2); }
  100% { box-shadow: 0 0 0 0 rgba(240, 192, 64, 0); }
}

/* ── Message hover timestamp ── */
.msg:hover .msg-time {
  opacity: 1;
}
.msg .msg-time {
  transition: opacity 0.2s;
}

/* ── Enhanced message list ── */
.message-list {
  position: relative;
  z-index: 1;
}

/* ── CQ Text Button ── */
.btn-cq-text {
  background: none;
  border: none;
  color: var(--color-accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  letter-spacing: 0.15em;
  cursor: pointer;
  padding: 8px 0;
  transition: opacity 0.2s;
}

.btn-cq-text:hover {
  opacity: 0.7;
}

.btn-cq-text:active {
  transform: scale(0.97);
}

.btn-cq-cancel {
  background: none;
  border: none;
  color: var(--color-text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px 0;
  margin-top: 16px;
  transition: color 0.2s;
}

.btn-cq-cancel:hover {
  color: var(--color-text-sub);
}

.cq-hint {
  color: var(--color-text-dim);
  font-size: 11px;
  margin-top: 4px;
  text-align: center;
}

.cq-empty {
  color: var(--color-text-dim);
  font-size: 13px;
  text-align: center;
  padding: 32px 0;
}

/* ── QSO Slide Styles ── */
.qso-slide {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: hidden;
  position: relative;
}

.qso-leave-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 14;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--color-text);
  font-size: 18px;
  line-height: 1;
}

.qso-slide-messages {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: calc(max(16px, env(safe-area-inset-top)) + 52px) 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qso-slide-messages::-webkit-scrollbar,
.room-overlay .message-list::-webkit-scrollbar {
  width: 0;
  height: 0;
  background: transparent;
}

.qso-slide-messages::-webkit-scrollbar-button,
.room-overlay .message-list::-webkit-scrollbar-button {
  display: none;
}

.qso-slide-messages::-webkit-scrollbar-thumb,
.qso-slide-messages::-webkit-scrollbar-track,
.room-overlay .message-list::-webkit-scrollbar-thumb,
.room-overlay .message-list::-webkit-scrollbar-track {
  background: transparent;
}

.qso-slide-form {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: 8px 16px max(12px, env(safe-area-inset-bottom));
}

.radio-board {
  height: calc(100dvh - 80px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.radio-board-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: max(16px, env(safe-area-inset-top)) 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-board-messages::-webkit-scrollbar {
  width: 0;
  height: 0;
  background: transparent;
}

.radio-board-form {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: 8px 16px max(12px, env(safe-area-inset-bottom));
}

.radio-board-form .message-form {
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.radio-board-intro {
  align-self: center;
  width: min(100%, 560px);
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--color-text-sub);
}

.radio-board-eyebrow {
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--color-accent);
}

.qso-slide-form .message-form {
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.btn-room-leave-inline {
  display: inline;
  margin: 0;
  font-size: 10px;
  padding: 2px 8px;
}

/* ── Onboarding Complete Title ── */
.onboard-complete-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  letter-spacing: 0.1em;
  color: var(--color-text);
  margin-bottom: 8px;
}

/* ── Room Leave Button ── */
.btn-room-leave {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--color-text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  padding: 6px 12px;
  transition: color 0.2s;
}
.btn-room-leave:hover {
  color: var(--color-text-sub);
}

/* ── Room Left Notice ── */
.room-left-notice {
  text-align: center;
  padding: 8px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-bottom: 12px;
}

/* ── Room Count Display ── */
.cq-room-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--color-text-dim);
  text-align: center;
  margin-bottom: 8px;
}

/* ── CQ FAB (Floating Action Button) ── */
.cq-fab {
  position: fixed;
  bottom: 172px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #0a0e1a;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(240,192,64,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.cq-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(240,192,64,0.4);
}
.cq-fab:active {
  transform: scale(0.95);
}
.cq-fab .material-symbols-outlined {
  font-size: 26px;
  font-weight: 700;
}
.cq-fab-waiting {
  animation: fab-pulse 2s ease-in-out infinite;
}
@keyframes fab-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(240,192,64,0.3); }
  50% { box-shadow: 0 4px 24px rgba(240,192,64,0.6); }
}

/* ── CQ Overlay ── */
.cq-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cq-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(8px);
}
.cq-overlay-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.cq-overlay-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--color-accent);
  text-transform: uppercase;
  min-height: 16px;
}
.cq-overlay-transmitting {
  animation: morse-pulse 2s ease-in-out infinite;
}
.cq-big-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--color-accent);
  color: var(--color-accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.cq-big-btn:hover {
  background: rgba(240, 192, 64, 0.08);
  transform: scale(1.03);
}
.cq-fab:focus,
.cq-fab:focus-visible,
.cq-big-btn:focus,
.cq-big-btn:focus-visible {
  outline: none;
  box-shadow: inherit;
}
.cq-big-btn:active {
  transform: scale(0.96);
  background: rgba(240, 192, 64, 0.15);
}
.cq-big-btn-sending {
  opacity: 0.6;
  pointer-events: none;
}
.cq-big-btn-cancel {
  border-color: var(--color-text-dim);
  color: var(--color-text-dim);
  font-size: 28px;
}
.cq-big-btn-cancel:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--color-text-sub);
  color: var(--color-text-sub);
}
.cq-big-btn-confirm {
  background: rgba(52, 211, 153, 0.12);
  border-color: var(--color-success);
  color: var(--color-success);
  font-size: 28px;
}
.cq-big-btn-confirm:hover {
  background: rgba(52, 211, 153, 0.2);
  border-color: var(--color-success);
  color: var(--color-success);
}
.cq-overlay-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  text-align: center;
  line-height: 1.7;
}

.match-effect-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  display: grid;
  place-items: center;
}

.match-effect-pulse {
  position: relative;
  width: 160px;
  height: 160px;
  display: grid;
  place-items: center;
}

.match-effect-core {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.5);
  animation: match-core-fade 1.1s ease-out forwards;
}

.match-effect-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  animation: match-ring-expand 1.1s ease-out forwards;
}

.match-effect-ring:nth-child(2) {
  animation-delay: 0.18s;
}

.match-effect-beacon {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(6, 6, 6, 0.82);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.06);
  animation: match-beacon-fade 1.1s ease-out forwards;
}

.match-effect-led {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  animation: match-led-blink 0.72s ease-in-out forwards;
}

.match-effect-led:nth-child(2) {
  animation-delay: 0.12s;
}

.match-effect-led:nth-child(3) {
  animation-delay: 0.24s;
}

.match-effect-label {
  color: rgba(255, 255, 255, 0.88);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
}

@keyframes match-ring-expand {
  0% {
    opacity: 0.75;
    transform: scale(0.22);
  }
  100% {
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes match-core-fade {
  0% {
    opacity: 0.95;
    transform: scale(0.8);
  }
  100% {
    opacity: 0;
    transform: scale(1.3);
  }
}

@keyframes match-beacon-fade {
  0% {
    opacity: 0;
    transform: translateY(4px);
  }
  18% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(0);
  }
}

@keyframes match-led-blink {
  0%, 100% {
    opacity: 0.2;
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }
  35%, 70% {
    opacity: 1;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.55);
  }
}

/* ── 2026-04 Morse monochrome redesign ─────────────────────────────── */
:root {
  --color-bg: #060606;
  --color-surface: #111111;
  --color-surface-raised: #181818;
  --color-border: #2a2a2a;
  --color-border-light: #363636;
  --color-text: #f5f5f5;
  --color-text-sub: #b9b9b9;
  --color-text-dim: #707070;
  --color-accent: #ffffff;
  --color-accent-light: #d8d8d8;
  --color-active: #ffffff;
  --color-idle: #d0d0d0;
  --color-waiting: #f2f2f2;
  --color-ai-from: rgba(255, 255, 255, 0.03);
  --color-ai-to: rgba(255, 255, 255, 0.07);
  --color-success: #ffffff;
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 22px 60px rgba(0, 0, 0, 0.36);
}

body {
  position: relative;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.06), transparent 26%),
    linear-gradient(180deg, #0a0a0a 0%, #050505 55%, #080808 100%);
  color: var(--color-text);
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  white-space: pre-wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 2;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.075);
  z-index: 0;
}

body::before {
  content:
    "-.-. --.-   -.-. --.-   -.. .   -. .- -- ..   -.-\A"
    ".-.. .. ... - . -.   -.-. --- -. -. . -.-. -   .-. . .--. .-.. -.--\A"
    "... --- ...   ..-. .. -. -..   - .... .   --- - .... . .-.\A"
    "-- --- .-. ... .   .. ...   .-   .-- .- -.--   - ---   .-. . .- -.-. ....\A"
    "-.- . . .--.   - .... .   -.-. .... .- -. -. . .-..   --- .--. . -.\A"
    ".- .-.. .-- .- -.-- ...   .-   ... .. --. -. .- .-..   .. -.   - .... .   -.. .- .-. -.-\A"
    "-.-. --.-   -.-. --.-   -.. .   -. .- -- ..   -.-";
  transform: rotate(-13deg) scale(1.1);
  display: grid;
  place-items: center;
}

body::after {
  content:
    ".-- .   .- .-. .   .- .-.. .-- .- -.-- ...   .-.. .. ... - . -. .. -. --.\A"
    "... .. --. -. .- .-..   .. -.   -. --- .. ... .\A"
    "- .... .   -. .. --. .... -   -.- . . .--. ...   - .... .   -... .- -. -..   --- .--. . -.\A"
    "-.-. --.-   -.-. --.-   -.-. --.-";
  transform: rotate(11deg) scale(1.08);
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.05);
}

main#app {
  position: relative;
  z-index: 1;
  max-width: 860px;
  padding-left: 18px;
  padding-right: 18px;
}

main#app.has-tabbar {
  padding-bottom: 98px;
}

.landing-container,
.onboard-container {
  max-width: 460px;
}

.landing-hero {
  margin-bottom: 36px;
}

.landing-freq,
.tab-label,
.badge,
.room-left-notice,
.cq-overlay-status,
.cq-overlay-hint,
.msg-label,
.setting-username,
.onboard-complete-title {
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.landing-freq {
  color: var(--color-text-sub);
  opacity: 0.78;
}

.landing-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 54px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.landing-divider {
  width: 72px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
  opacity: 1;
}

.landing-subtitle,
.onboard-subtitle,
.card-meta,
.cq-empty {
  color: var(--color-text-sub);
}

.landing-tabs,
.setting-user-info,
.room-header,
.room-form-area,
.qso-slide-form {
  border-color: rgba(255,255,255,0.08);
}

.landing-form-area input,
.onboard-custom-tag input,
.onboard-textarea,
.onboard-starter-input,
input[type="text"],
input[type="email"],
textarea,
select,
.message-form textarea {
  background: rgba(255,255,255,0.035);
  border-color: rgba(255,255,255,0.11);
  border-radius: 18px;
  color: var(--color-text);
}

.landing-form-area input:focus,
.onboard-custom-tag input:focus,
.onboard-textarea:focus,
.onboard-starter-input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
.message-form textarea:focus {
  border-color: rgba(255,255,255,0.45);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}

.btn-primary,
.btn-match-big,
.message-form .send-btn {
  background: #f5f5f5;
  color: #060606;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.75);
  box-shadow: none;
}

.btn-primary:hover,
.btn-match-big:hover,
.message-form .send-btn:hover {
  background: #ffffff;
}

.tab-bar {
  background: rgba(8, 8, 8, 0.78);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.tab-item {
  position: relative;
  color: var(--color-text-dim);
  opacity: 0.75;
}

.tab-item.active {
  color: var(--color-text);
}

.tab-item.active .tab-icon-mat {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.card,
.onboard-score-card,
.room-summary-block,
.cq-overlay-content {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.card,
.onboard-score-card,
.room-summary-block {
  border-radius: 22px;
}

.room-summary-block h3,
.onboard-score-value,
.onboard-starter-prompt,
.room-back-btn,
.btn-cq-text {
  color: var(--color-text);
}

.badge {
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
}

.badge-active,
.badge-idle,
.badge-waiting,
.badge-archived {
  color: var(--color-text-sub);
  background: rgba(255,255,255,0.04);
}

.room-slide-messages,
.qso-slide-messages,
.room-overlay .message-list {
  gap: 14px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.msg {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  box-shadow: none;
}

.msg-mine {
  background: #f4f4f4;
  color: #060606;
  border-color: rgba(255,255,255,0.65);
}

.msg-other {
  background: rgba(255,255,255,0.045);
  border-color: rgba(255,255,255,0.1);
}

.msg-ai {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px dashed rgba(255,255,255,0.14);
  color: var(--color-text-sub);
}

.msg-summary {
  background: rgba(255,255,255,0.04);
  border-left: 3px solid rgba(255,255,255,0.65);
  border-radius: 0 14px 14px 0;
}

.msg-label,
.msg-time,
.msg-label-ai,
.typing-indicator,
.cq-hint {
  color: var(--color-text-dim);
}

.msg-label-ai-icon {
  color: rgba(255,255,255,0.88);
}

.msg-mine .msg-time {
  color: rgba(6, 6, 6, 0.55);
}

.msg-thinking {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--color-text-sub);
}

.thinking-signal-line,
.typing-dots span {
  background: rgba(255,255,255,0.82);
}

@keyframes thinking-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,255,255,0); }
  50% { opacity: 0.9; box-shadow: 0 0 0 6px rgba(255,255,255,0.05); }
}

@keyframes ai-glow {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
  30% { box-shadow: 0 0 18px 4px rgba(255, 255, 255, 0.08); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.typewriter-active::after {
  color: rgba(255,255,255,0.9);
}

.room-form-area,
.qso-slide-form {
  background:
    linear-gradient(180deg, rgba(6,6,6,0.2), rgba(6,6,6,0.88) 24%, rgba(6,6,6,0.95)),
    #060606;
  backdrop-filter: blur(12px);
}

.scroll-bottom-btn,
.btn-room-leave,
.btn-cancel,
.btn-cancel-small,
.btn-room-leave-inline {
  color: var(--color-text-sub);
}

.scroll-bottom-btn {
  background: rgba(255,255,255,0.06);
  color: var(--color-text);
  border-color: rgba(255,255,255,0.14);
}

.cq-fab {
  background: #f4f4f4;
  color: #060606;
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 12px 32px rgba(0,0,0,0.42);
}

.cq-fab-label {
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: translateX(1px);
}

.cq-fab:hover {
  box-shadow: 0 16px 36px rgba(0,0,0,0.5);
}

.cq-fab-scroll-dimmed {
  opacity: 0.38;
}

@keyframes fab-pulse {
  0%, 100% { box-shadow: 0 12px 32px rgba(0,0,0,0.42), 0 0 0 0 rgba(255,255,255,0.1); }
  50% { box-shadow: 0 12px 32px rgba(0,0,0,0.42), 0 0 0 12px rgba(255,255,255,0.06); }
}

.cq-overlay-backdrop {
  background: rgba(0,0,0,0.86);
  backdrop-filter: blur(14px);
}

.cq-overlay-content {
  gap: 18px;
  padding: 28px 24px;
  border-radius: 28px;
}

.cq-overlay-status,
.cq-overlay-hint {
  color: var(--color-text-sub);
}

.cq-big-btn {
  border-color: rgba(255,255,255,0.82);
  color: var(--color-text);
}

.cq-big-btn:hover {
  background: rgba(255,255,255,0.08);
}

.cq-big-btn:active {
  background: rgba(255,255,255,0.14);
}

.cq-big-btn-confirm {
  background: #f4f4f4;
  color: #060606;
  border-color: rgba(255,255,255,0.82);
}

.cq-big-btn-confirm:hover {
  background: #ffffff;
  color: #060606;
  border-color: rgba(255,255,255,0.82);
}

.desktop-slide-nav {
  display: none;
}

.ai-profile-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 18px 0 22px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow-md);
}

.ai-profile-title {
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text);
}

.ai-profile-subtitle,
.ai-profile-settings-note {
  font-size: 13px;
  color: var(--color-text-sub);
  line-height: 1.6;
}

.ai-profile-transcript {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px 2px;
}

.ai-profile-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.55;
}

.ai-profile-msg-assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.ai-profile-msg-user {
  align-self: flex-end;
  background: #f4f4f4;
  color: #060606;
}

.ai-profile-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-profile-input {
  flex: 1;
  resize: vertical;
  min-height: 52px;
  max-height: 140px;
}

.ai-profile-send {
  width: auto;
  min-width: 74px;
  padding: 12px 16px;
}

.ai-profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.ai-profile-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.ai-profile-preview-block {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
}

.ai-profile-preview-block p {
  color: var(--color-text);
  line-height: 1.7;
}

.ai-profile-preview-label {
  margin-bottom: 8px;
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-sub);
}

.ai-profile-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-profile-chip,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--color-text-sub);
  font-size: 12px;
}

.ai-profile-starters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 18px;
}

.ai-profile-starters li {
  color: var(--color-text-sub);
}

.ai-profile-starters strong {
  display: block;
  margin-bottom: 4px;
  color: var(--color-text);
  font-size: 12px;
}

.ai-profile-starters span {
  display: block;
  font-size: 13px;
}

.ai-profile-settings-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 8px;
}

.profile-ai-fab {
  position: fixed;
  right: 18px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 140;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  background: #f4f4f4;
  color: #060606;
  border: 1px solid rgba(255,255,255,0.85);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.profile-ai-fab:hover {
  background: #ffffff;
  opacity: 1;
}

.profile-ai-fab.hidden-while-open {
  opacity: 0;
  pointer-events: none;
}

.onboard-test-fab {
  position: fixed;
  right: 18px;
  bottom: calc(146px + env(safe-area-inset-bottom));
  z-index: 139;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  color: var(--color-text);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(14px);
  z-index: 180;
  min-width: 180px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(15,15,15,0.92);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--color-text);
  text-align: center;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(12px);
}

.app-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 900px) {
  .room-form-area,
  .qso-slide-form,
  .radio-board-form {
    position: sticky;
    bottom: 0;
    z-index: 12;
    overscroll-behavior: none;
  }

  .message-form,
  .message-form textarea {
    overscroll-behavior: contain;
  }

  .profile-ai-fab {
    right: calc((100vw - min(860px, 100vw - 36px)) / 2 + 18px);
  }

  .onboard-test-fab {
    right: calc((100vw - min(860px, 100vw - 36px)) / 2 + 18px);
  }

  .desktop-slide-nav {
    display: contents;
  }

  .desktop-slide-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    width: 44px;
    height: 72px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(8,8,8,0.64);
    color: var(--color-text);
    backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s, opacity 0.2s;
  }

  .desktop-slide-arrow:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.24);
    transform: translateY(-50%) scale(1.02);
  }

  .desktop-slide-arrow:disabled {
    opacity: 0.28;
    cursor: default;
  }

  .desktop-slide-arrow:disabled:hover {
    background: rgba(8,8,8,0.64);
    border-color: rgba(255,255,255,0.12);
    transform: translateY(-50%);
  }

  .desktop-slide-arrow-left {
    left: 14px;
  }

  .desktop-slide-arrow-right {
    right: 14px;
  }

  .desktop-slide-arrow .material-symbols-outlined {
    font-size: 30px;
  }

  .snap-track {
    scroll-behavior: smooth;
  }

  .room-slide-messages,
  .qso-slide-messages,
  .radio-board-messages {
    padding-left: 74px;
    padding-right: 74px;
  }
}

/* ══════════════════════════════════════════════════════════════════
   Room + Visit UI — New styles for Room+AI pivot
   ══════════════════════════════════════════════════════════════════ */

/* ── Page Headers ── */
.page-header {
  padding: 24px 16px 12px;
}
.page-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text);
}
.page-subtitle {
  font-size: 13px;
  color: var(--color-text-sub);
  margin-top: 4px;
}

/* ── Discover Page ── */
.discover-page {
  padding-bottom: 80px;
}
.room-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;
}
.room-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--color-surface);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
}
.room-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.room-card:active {
  transform: scale(0.98);
}
.room-card-signal {
  flex-shrink: 0;
}
.signal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-text-sub);
}
.signal-dot.signal-active {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
  animation: signal-pulse 2s ease-in-out infinite;
}
.signal-dot.signal-idle {
  background: var(--color-text-sub);
  opacity: 0.5;
}
@keyframes signal-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}
.room-card-body {
  flex: 1;
  min-width: 0;
}
.room-card-owner {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.room-card-title {
  font-size: 12px;
  color: var(--color-text-sub);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-card-bio {
  font-size: 11px;
  color: var(--color-text-sub);
  opacity: 0.7;
  margin: 4px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-card-action {
  flex-shrink: 0;
  color: var(--color-text-sub);
}
.room-card-action .material-symbols-outlined {
  font-size: 20px;
}

/* ── My Room Page ── */
.my-room-page {
  padding: 0 16px 80px;
}
.my-room-info,
.my-room-agent {
  margin-bottom: 16px;
}
.my-room-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.my-room-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.my-room-desc {
  font-size: 13px;
  color: var(--color-text-sub);
  margin-bottom: 12px;
}
.agent-persona {
  font-size: 13px;
  color: var(--color-text-sub);
  margin: 4px 0 12px;
}
.my-room-visits h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-top: 8px;
}
.visit-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--color-surface);
}
.visit-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.visit-guest {
  font-size: 14px;
  font-weight: 600;
}
.visit-time {
  font-size: 11px;
  color: var(--color-text-sub);
}
.visit-summary {
  font-size: 12px;
  color: var(--color-text-sub);
  margin-top: 6px;
}

/* ── Visit Page (Chat with Beacon) ── */
.visit-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
}
.visit-page.visit-page-scroll {
  height: auto;
  max-height: none;
  min-height: 100%;
}
.visit-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
  z-index: 10;
}
.visit-back {
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
}
.visit-back:hover {
  background: var(--color-surface);
}
.visit-header-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.visit-agent-name {
  font-size: 11px;
  color: var(--color-text-sub);
}
.visit-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.visit-messages > * {
  flex: 0 0 auto;
}
.visit-page.visit-page-scroll .visit-messages {
  flex: 0 0 auto;
  min-height: 42dvh;
  overflow-y: visible;
}
.visit-form-wrap {
  flex-shrink: 0;
  padding: 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.visit-page.visit-page-scroll .visit-form-wrap {
  position: sticky;
  bottom: 0;
  z-index: 5;
}

/* ── Visit Message Bubbles ── */
.msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.msg-bubble.msg-user {
  align-self: flex-end;
  background: #f4f4f4;
  color: #060606;
  border: 1px solid rgba(255,255,255,0.65);
  border-bottom-right-radius: 4px;
}
.msg-bubble.msg-ai {
  align-self: flex-start;
  background: var(--color-surface);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--color-border);
}
.msg-bubble.msg-system {
  align-self: center;
  background: transparent;
  color: var(--color-text-sub);
  font-size: 12px;
  text-align: center;
  max-width: 90%;
}
.msg-sender {
  font-size: 11px;
  color: var(--color-text-sub);
  margin-bottom: 4px;
  font-weight: 600;
}
.msg-body {
  white-space: pre-wrap;
}
.msg-thinking .thinking-dots span {
  animation: thinking-blink 1.2s ease-in-out infinite;
}
@keyframes thinking-blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ── Message Form ── */
.msg-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.msg-input {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--color-text);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  font-family: inherit;
}
.msg-input:focus {
  border-color: rgba(255,255,255,0.45);
}
.msg-input::placeholder {
  color: var(--color-text-sub);
}
.msg-send-btn {
  background: #f5f5f5;
  border: 1px solid rgba(255,255,255,0.75);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #060606;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.msg-send-btn:hover {
  transform: scale(1.05);
}
.msg-send-btn:active {
  transform: scale(0.95);
}
.msg-send-btn .material-symbols-outlined {
  font-size: 20px;
}

/* ── Buttons ── */
.btn-secondary {
  display: inline-block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.btn-secondary:hover {
  background: var(--color-border);
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  color: var(--color-text-sub);
  font-size: 13px;
  padding: 24px 0;
}

/* ── Agent Settings in Profile ── */
.agent-settings-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}
.agent-settings-section h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.agent-field {
  margin-bottom: 12px;
}
.agent-field label {
  display: block;
  font-size: 12px;
  color: var(--color-text-sub);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.agent-field input,
.agent-field textarea {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--color-text);
  font-family: inherit;
  outline: none;
}
.agent-field input:focus,
.agent-field textarea:focus {
  border-color: rgba(255,255,255,0.45);
}
