/* ============================================
   ふたりで - Global Styles
   ============================================ */

html, body,
.app-header,
.app-nav,
.app-body,
.settings-card,
.message-bubble,
.compose,
.checkin-card {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

:root {
  --bg: #FFF8F0;
  --bg-card: #FFFFFF;
  --primary: #E8927C;
  --primary-dark: #D4785F;
  --primary-light: #FCEEE9;
  --secondary: #7CAFE8;
  --secondary-light: #E9F2FC;
  --text: #3D3535;
  --text-light: #5C504C;
  --text-muted: #9A8E8A;
  --border: #F0E6E0;
  --success: #7BC88F;
  --danger: #E87C7C;
  --shadow: 0 2px 16px rgba(61, 53, 53, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Yu Gothic', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100dvh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: 16px;
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 440px;
  width: calc(100% - 40px);
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastIn 0.3s ease-out;
  border-left: 4px solid var(--text-muted);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-info { border-left-color: var(--secondary); }

.toast.toast-out {
  animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-12px); }
}

/* ============================================
   Landing Page
   ============================================ */

.landing {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.landing-hero {
  text-align: center;
  padding: 48px 0 32px;
}

.landing-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.landing-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 2px;
}

.landing-subtitle {
  font-size: 15px;
  color: var(--text-light);
  margin-top: 8px;
}

.landing-features {
  margin: 32px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feature-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.feature-card h3 {
  font-size: 16px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.feature-card p {
  font-size: 14px;
  color: var(--text-light);
}

.landing-cta {
  margin-top: auto;
  padding: 24px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  width: auto;
}

.btn-ghost {
  background: none;
  color: var(--text-light);
  padding: 8px;
  width: 100%;
  text-align: center;
}

.btn-ghost:hover {
  color: var(--primary);
}

.btn-danger {
  background: none;
  color: var(--danger);
  font-size: 13px;
  padding: 4px 8px;
  width: auto;
}

/* ============================================
   Auth Forms
   ============================================ */

.auth-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.auth-header {
  text-align: center;
  padding: 32px 0 24px;
}

.auth-header h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.auth-header p {
  color: var(--text-light);
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-light);
  background: none;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
}

.form-group input {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
}

.auth-error {
  background: #FEF0F0;
  color: var(--danger);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: none;
}

.auth-back {
  text-align: center;
  margin-top: 16px;
}

/* ============================================
   App Layout
   ============================================ */

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.app-header {
  background: var(--bg-card);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
}

.app-header-status {
  font-size: 12px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-header-status:not(:empty)::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.app-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  padding-bottom: 100px;
}

/* ============================================
   View Transitions
   ============================================ */

.view {
  animation: viewFadeIn 0.25s ease-out;
}

.view.hidden {
  display: none !important;
}

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

/* ============================================
   Bottom Nav
   ============================================ */

.app-nav {
  background: var(--bg-card);
  padding: 8px 20px;
  display: flex;
  justify-content: space-around;
  box-shadow: 0 -1px 4px rgba(0,0,0,0.04);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 20px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  background: none;
  border-radius: 8px;
  transition: all 0.2s;
  position: relative;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 12px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   FAB (Floating Action Button)
   ============================================ */

.fab {
  position: fixed;
  bottom: 80px;
  right: calc(50% - 210px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(232, 146, 124, 0.4);
  transition: all 0.2s;
  z-index: 11;
}

.fab:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(232, 146, 124, 0.5);
}

.fab.hidden {
  display: none;
}

@media (max-width: 480px) {
  .fab {
    right: 20px;
  }
}

/* ============================================
   Pairing Screen
   ============================================ */

.pairing {
  text-align: center;
  padding: 16px 0;
}

.onboarding-intro {
  margin-bottom: 32px;
}

.onboarding-intro h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.onboarding-intro p {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.8;
}

.pairing-choice {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.pairing h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.pairing > p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.invite-code-display {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

.invite-code-display label {
  font-size: 13px;
  color: var(--text-light);
  display: block;
  margin-bottom: 8px;
}

.invite-code {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--primary);
}

.waiting-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-form {
  display: flex;
  gap: 8px;
}

.join-form input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 18px;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}

.join-form input:focus {
  border-color: var(--primary);
}

/* ============================================
   Messages
   ============================================ */

.messages-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
}

.message-date-separator {
  text-align: center;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  position: relative;
}

.message-date-separator span {
  background: var(--bg);
  padding: 0 12px;
  position: relative;
  z-index: 1;
}

.message-date-separator::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.message-bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.6;
  position: relative;
}

.message-sender-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.message-mine {
  align-self: flex-end;
  background: var(--primary-light);
  border-bottom-right-radius: 4px;
}

.message-theirs {
  align-self: flex-start;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 4px;
}

.message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
}

.message-original {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

.message-original-label {
  font-size: 11px;
  color: var(--text-muted);
  font-style: normal;
  display: block;
  margin-bottom: 2px;
}

.messages-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.messages-empty p {
  font-size: 14px;
  margin-top: 8px;
}

/* ============================================
   Compose
   ============================================ */

.compose {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.compose h2 {
  font-size: 18px;
}

.compose-hint {
  font-size: 13px;
  color: var(--text-light);
  background: var(--secondary-light);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  line-height: 1.6;
}

.compose textarea {
  width: 100%;
  min-height: 140px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  resize: vertical;
  outline: none;
  line-height: 1.7;
  transition: border-color 0.2s;
}

.compose textarea:focus {
  border-color: var(--primary);
}

.compose textarea::placeholder {
  color: var(--text-muted);
}

.compose-charcount {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  margin-top: -8px;
}

/* Transform loading */

.transform-loading {
  text-align: center;
  padding: 60px 20px;
}

.transform-loading-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.transform-loading-text {
  font-size: 15px;
  color: var(--text-light);
  animation: loadingPulse 2s ease-in-out infinite;
}

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

/* Preview */

.preview-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.preview-card h3 {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.preview-original {
  font-size: 14px;
  color: var(--text-light);
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  line-height: 1.6;
}

.preview-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 0;
}

.preview-transformed {
  font-size: 15px;
  padding: 14px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  line-height: 1.7;
}

.compose-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.compose-actions .btn {
  flex: 1;
}

/* Sent success */

.sent-success {
  text-align: center;
  padding: 48px 20px;
}

.sent-success-icon {
  font-size: 56px;
  animation: sentBounce 0.5s ease-out;
}

@keyframes sentBounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.sent-success-title {
  font-size: 18px;
  font-weight: 600;
  margin-top: 16px;
}

.sent-success-sub {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 6px;
}

/* ============================================
   Check-in
   ============================================ */

.checkin-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.checkin-question {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
  line-height: 1.6;
}

.checkin-card textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  outline: none;
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.checkin-card textarea:focus {
  border-color: var(--primary);
}

.checkin-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checkin-entry {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
}

.checkin-entry-q {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.checkin-entry-a {
  font-size: 15px;
}

.checkin-entry-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.checkin-entry.mine {
  border-left: 3px solid var(--primary);
}

.checkin-entry.theirs {
  border-left: 3px solid var(--secondary);
}

/* ============================================
   Settings
   ============================================ */

.settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.settings-card p {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.7;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.settings-item:last-child {
  border-bottom: none;
}

/* ============================================
   Loading & Spinner
   ============================================ */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 248, 240, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 100;
}

.loading-overlay .spinner {
  width: 32px;
  height: 32px;
}

.loading-text {
  font-size: 14px;
  color: var(--text-light);
}

/* ============================================
   Confirm Dialog
   ============================================ */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fadeIn 0.15s ease-out;
}

.confirm-dialog {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: calc(100% - 40px);
  text-align: center;
  animation: dialogIn 0.2s ease-out;
  max-height: 80vh;
  overflow-y: auto;
}

.confirm-dialog p {
  font-size: 15px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 8px;
}

.confirm-actions .btn {
  flex: 1;
  padding: 10px;
}

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

@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ============================================
   Utilities
   ============================================ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus ring (accessibility) */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Settings editable */
.settings-editable {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-editable .btn-ghost {
  width: auto;
  padding: 2px 6px;
  font-size: 16px;
}

/* Invite share buttons */
.invite-share-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

/* Prompt dialog (reusable) */
.prompt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fadeIn 0.15s ease-out;
}

.prompt-dialog {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 340px;
  width: calc(100% - 40px);
  animation: dialogIn 0.2s ease-out;
}

.prompt-dialog h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.prompt-dialog input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  margin-bottom: 16px;
  outline: none;
}

.prompt-dialog input:focus {
  border-color: var(--primary);
}

.prompt-actions {
  display: flex;
  gap: 8px;
}

.prompt-actions .btn {
  flex: 1;
  padding: 10px;
}

/* ============================================
   Responsive
   ============================================ */

@media (min-width: 481px) {
  .app, .landing, .auth-container {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ============================================
   Dark Mode
   ============================================ */

[data-theme="dark"] {
  --bg: #1A1A2E;
  --bg-card: #252540;
  --primary: #E8927C;
  --primary-dark: #D4785F;
  --primary-light: #3D2A2A;
  --secondary: #7CAFE8;
  --secondary-light: #1E2A3A;
  --text: #E8E0DC;
  --text-light: #B0A8A4;
  --text-muted: #787070;
  --border: #3A3A52;
  --success: #7BC88F;
  --danger: #E87C7C;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .loading-overlay {
  background: rgba(26, 26, 46, 0.9);
}

[data-theme="dark"] .message-date-separator span {
  background: var(--bg);
}

/* ============================================
   Reactions
   ============================================ */

.message-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.reaction-badge:hover,
.reaction-badge.mine {
  border-color: var(--primary);
  background: var(--primary-light);
}

.reaction-picker {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.reaction-picker button {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.reaction-picker button:hover {
  background: var(--primary-light);
  transform: scale(1.15);
}

.reaction-toggle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  transition: all 0.15s;
}

.reaction-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ============================================
   Message expand link
   ============================================ */

.message-expand {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  padding: 4px 0;
  cursor: pointer;
  font-weight: 600;
}

.message-expand:hover {
  text-decoration: underline;
}

/* ============================================
   Read Receipt
   ============================================ */

.message-read-status {
  font-size: 10px;
  color: var(--secondary);
  margin-left: 6px;
}

.message-edited {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
  font-style: italic;
}

/* ============================================
   Onboarding Overlay
   ============================================ */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 160;
  animation: fadeIn 0.3s ease-out;
}

.onboarding-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 360px;
  width: calc(100% - 40px);
  text-align: center;
  animation: dialogIn 0.3s ease-out;
}

.onboarding-card h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.onboarding-card p {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.7;
  margin-bottom: 8px;
}

.onboarding-steps {
  text-align: left;
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
}

.onboarding-step-num {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ============================================
   Tone Selector
   ============================================ */

.tone-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.tone-option {
  flex: 1;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-card);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.tone-option.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.tone-option:hover:not(.active) {
  border-color: var(--text-muted);
}

/* ============================================
   Plan Badge
   ============================================ */

.plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.plan-badge.free { background: var(--border); color: var(--text-light); }
.plan-badge.trial { background: var(--secondary-light); color: var(--secondary); }
.plan-badge.plus { background: var(--primary-light); color: var(--primary); }
.plan-badge.premium { background: #FFF3CD; color: #856404; }

.plan-info {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ============================================
   Theme Toggle
   ============================================ */

.theme-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.3s;
  border: none;
}

.theme-toggle.active {
  background: var(--primary);
}

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform 0.3s;
}

.theme-toggle.active::after {
  transform: translateX(22px);
}

/* ============================================
   Upgrade Banner
   ============================================ */

.upgrade-banner {
  background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.upgrade-banner p {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.usage-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}

.usage-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ============================================
   Search Bar
   ============================================ */

.search-bar {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
}

.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--primary);
}

.search-bar .btn-ghost {
  width: auto;
  font-size: 20px;
  padding: 4px 8px;
}

.search-results {
  margin-bottom: 12px;
}

.search-result-item {
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  box-shadow: var(--shadow);
  font-size: 14px;
  cursor: pointer;
}

.search-result-item:hover {
  border-left: 3px solid var(--primary);
}

.search-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================
   Typing Indicator
   ============================================ */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

/* ============================================
   Online Status Dot
   ============================================ */

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: onlinePulse 2s infinite;
}

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

/* ============================================
   Upgrade Modal
   ============================================ */

.upgrade-dialog {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 360px;
  width: calc(100% - 40px);
  text-align: center;
  animation: dialogIn 0.2s ease-out;
}

.upgrade-dialog h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.upgrade-dialog > p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.upgrade-plans {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.upgrade-plan {
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  border: 2px solid var(--border);
}

.upgrade-plan h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.upgrade-plan p {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}

/* ============================================
   Reaction Toggle
   ============================================ */

.reaction-toggle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  transition: all 0.15s;
}

.reaction-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ============================================
   Message Expand (long messages)
   ============================================ */

.message-expand {
  display: inline-block;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  margin-top: 4px;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.message-expand:hover {
  text-decoration: underline;
}

/* ============================================
   Email Verification Banner
   ============================================ */

.email-verify-banner {
  background: #FFF3CD;
  color: #856404;
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

[data-theme="dark"] .email-verify-banner {
  background: #3D3520;
  color: #FFD666;
}

.email-verify-banner button {
  white-space: nowrap;
}

.scroll-bottom-btn {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scroll-bottom-btn.hidden {
  display: none;
}

.search-result-item mark {
  background: var(--primary-light);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  z-index: 9999;
  transition: top 0.2s;
  text-decoration: none;
  font-size: 14px;
}
.skip-link:focus {
  top: 0;
}
