:root {
  --primary:        #E87878;
  --primary-light:  #FDEAEA;
  --secondary:      #9B8DD4;
  --secondary-light:#F0EDFA;
  --bg:             #FEF9F7;
  --card:           #FFFFFF;
  --text:           #2C2C2C;
  --muted:          #999999;
  --border:         #F0E6E6;
  --success:        #6CC88A;
  --shadow:         0 2px 16px rgba(232,120,120,0.10);
  --radius:         16px;
}

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

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

/* ── Shell ── */
.shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
}

/* ── Header ── */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.4s;
}
.header-username.status-online  { color: var(--success); }
.header-username.status-offline { color: #E55050; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
.btn-icon:hover { color: var(--text); }

/* ── Together bar ── */
.together-bar {
  text-align: center;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: linear-gradient(90deg, #FEF0EC, #FDE8F0, #FEF0EC);
  border-bottom: 1px solid #F5DDD8;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

/* ── Main scroll area ── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* ── Bottom nav ── */
.nav {
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  transition: color 0.2s;
}
.nav-btn.active { color: var(--primary); }
.nav-btn svg { flex-shrink: 0; }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

/* ── Date badge ── */
.date-badge {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

/* ── Question card ── */
.question-card {
  background: linear-gradient(135deg, var(--primary) 0%, #c85a5a 100%);
  color: white;
  margin-bottom: 20px;
}
.question-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
  margin-bottom: 10px;
}
.question-text {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.2px;
}

/* ── Category badge ── */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.22);
  color: white;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
}

/* ── Answer form ── */
.answer-form { display: flex; flex-direction: column; gap: 10px; }
textarea {
  width: 100%;
  min-height: 130px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  resize: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
textarea:focus { outline: none; border-color: var(--primary); }
textarea::placeholder { color: var(--muted); }

/* ── Buttons ── */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-primary:active  { transform: scale(0.98); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  width: 100%;
  padding: 14px;
  background: none;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary:hover { background: var(--primary-light); }

/* ── Answer cards ── */
.answer-card {
  border-left: 4px solid var(--user-color, var(--primary));
  background: color-mix(in srgb, var(--user-color, var(--primary)) 8%, white);
}
.answer-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--user-color, var(--primary));
  margin-bottom: 8px;
}
.answer-text {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}
.answer-time {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* ── Waiting card ── */
.waiting-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 20px;
  border: 2px dashed var(--border);
  box-shadow: none;
  background: transparent;
}
.waiting-text { color: var(--muted); font-size: 15px; }
.dots { display: flex; gap: 6px; }
.dots span {
  width: 8px; height: 8px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}

/* ── Partner already answered hint ── */
.partner-answered-hint {
  text-align: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, #F0EDFA, #FFF0F0);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: 12px;
}

/* ── More-question invite banner ── */
.more-invite {
  text-align: center;
  padding: 14px;
  background: linear-gradient(135deg, #F0EDFA, #FFF0F0);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: 12px;
}

/* ── Both answered banner ── */
.both-done {
  text-align: center;
  padding: 14px;
  background: linear-gradient(135deg, #FFF0F0, #F0EDFA);
  border-radius: 12px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Divider ── */
.divider {
  text-align: center;
  font-size: 20px;
  margin: 4px 0 12px;
}

/* ── History ── */
.history-item {
  margin-bottom: 16px;
}
.history-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  padding: 0 2px;
}
.history-question {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.4;
}
.unanswered-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 4px;
}


/* ── Auth screens ── */
.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  background: var(--bg);
}
.auth-logo { font-size: 52px; margin-bottom: 8px; }
.auth-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.auth-subtitle {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 32px;
  text-align: center;
}
.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
input[type=text], input[type=password] {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  -webkit-appearance: none;
  transition: border-color 0.2s;
}
input:focus { outline: none; border-color: var(--primary); }
.auth-link {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
  cursor: pointer;
}
.auth-link span { color: var(--primary); font-weight: 600; }
.auth-info {
  text-align: center;
  font-size: 13px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  padding: 10px 14px;
  line-height: 1.5;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #2C2C2C;
  color: white;
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  max-width: calc(100vw - 48px);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}
.toast.toast-error { background: #c0392b; }
.toast.toast-success { background: var(--success); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 48px 0;
  color: var(--muted);
  font-size: 15px;
}
.loading::after {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  margin: 16px auto 0;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-size: 15px; line-height: 1.6; }

/* ── Stat chip ── */
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}
