/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --iv-bg:           #0f0f1a;
  --iv-surface:      #1a1a2e;
  --iv-surface2:     #16213e;
  --iv-border:       #2a2a4a;
  --iv-accent:       #7c3aed;
  --iv-accent2:      #6366f1;
  --iv-accent-muted: rgba(124, 58, 237, 0.15);
  --iv-text:         #e2e8f0;
  --iv-text-muted:   #8b8fa8;
  --iv-text-dim:     #555870;
  --iv-user-bg:      #7c3aed;
  --iv-success:      #10b981;
  --iv-warning:      #f59e0b;
  --iv-danger:       #ef4444;
  --iv-gold:         #fbbf24;
  --iv-header-h:     56px;
  --iv-progress-h:   3px;
  --iv-radius:       16px;
  --iv-radius-sm:    8px;
}

[data-theme="light"] {
  --iv-bg:           #f4f4f9;
  --iv-surface:      #ffffff;
  --iv-surface2:     #eaeaf2;
  --iv-border:       #d0d0e0;
  --iv-text:         #16162a;
  --iv-text-muted:   #52527a;
  --iv-text-dim:     #9090b0;
}

[data-theme="light"] .app-header {
  background: rgba(244, 244, 249, 0.92);
}

/* ── Theme toggle button ─────────────────────────────────────────────────── */
.btn-theme-toggle {
  background: none;
  border: 1px solid var(--iv-border);
  width: 34px; height: 34px;
  border-radius: var(--iv-radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.btn-theme-toggle:hover {
  border-color: var(--iv-accent);
  background: var(--iv-accent-muted);
}

.theme-icon-dark,
.theme-icon-light { display: none; }

:root .theme-icon-dark                  { display: inline; }
[data-theme="light"] .theme-icon-light  { display: inline; }
[data-theme="light"] .theme-icon-dark   { display: none; }

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

html, body {
  height: 100%;
  background: var(--iv-bg);
  color: var(--iv-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── App shell ───────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--iv-header-h);
  padding: 0 16px;
  background: rgba(15, 15, 26, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--iv-border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-home {
  text-decoration: none;
}

.brand-icon-sm {
  background: linear-gradient(135deg, var(--iv-accent), var(--iv-accent2));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.5px;
}

.brand-sep {
  width: 1px;
  height: 20px;
  background: var(--iv-border);
}

.brand-logo { font-size: 1.1rem; }

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #a78bfa, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.q-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--iv-text-muted);
  letter-spacing: 0.5px;
}

.btn-end {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--iv-danger);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 99px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-end:hover { background: rgba(239, 68, 68, 0.22); }

/* Plan badge */
.plan-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--iv-accent-muted);
  color: var(--iv-accent2);
  border: 1px solid rgba(99,102,241,0.25);
}
.plan-badge.pro {
  background: rgba(16,185,129,0.12);
  color: var(--iv-success);
  border-color: rgba(16,185,129,0.3);
}

.btn-upgrade-sm {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 14px;
  background: var(--iv-accent);
  color: #fff;
  border: none;
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-upgrade-sm:hover { background: #6d28d9; }

.btn-signin-iv {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 14px;
  background: transparent;
  color: var(--iv-accent2);
  border: 1px solid rgba(99,102,241,0.4);
  border-radius: 99px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn-signin-iv:hover { background: var(--iv-accent-muted); border-color: var(--iv-accent2); }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-track {
  height: var(--iv-progress-h);
  background: var(--iv-border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--iv-accent), var(--iv-accent2));
  border-radius: 0 2px 2px 0;
  transition: width 0.4s ease;
  width: 0%;
}

/* ── Chat ────────────────────────────────────────────────────────────────── */
.chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.chat::-webkit-scrollbar { width: 4px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: var(--iv-border); border-radius: 4px; }

/* ── Message rows ────────────────────────────────────────────────────────── */
.msg {
  display: flex;
  flex-direction: column;
  animation: msgIn 0.22s ease-out;
}
.msg.ai  { align-items: flex-start; }
.msg.user { align-items: flex-end; }

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

/* ── AI avatar ───────────────────────────────────────────────────────────── */
.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--iv-accent), var(--iv-accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  margin-bottom: 4px;
  flex-shrink: 0;
}

/* ── Bubbles ─────────────────────────────────────────────────────────────── */
.bubble {
  max-width: min(86vw, 420px);
  padding: 11px 15px;
  word-break: break-word;
}

.ai .bubble {
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-radius: 4px var(--iv-radius) var(--iv-radius) var(--iv-radius);
  color: var(--iv-text);
}

.user .bubble {
  background: var(--iv-user-bg);
  border-radius: var(--iv-radius) 4px var(--iv-radius) var(--iv-radius);
  color: #fff;
}

.bubble-text {
  font-size: 0.93rem;
  white-space: pre-wrap;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-radius: 4px var(--iv-radius) var(--iv-radius) var(--iv-radius);
  width: fit-content;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--iv-text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0);  opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Question card ───────────────────────────────────────────────────────── */
.question-card {
  max-width: min(92vw, 480px);
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-left: 3px solid var(--iv-accent);
  border-radius: 4px var(--iv-radius-sm) var(--iv-radius-sm) 4px;
  padding: 14px 16px;
  animation: msgIn 0.22s ease-out;
}

.topic-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--iv-accent2);
  background: var(--iv-accent-muted);
  border-radius: 99px;
  padding: 2px 9px;
  margin-bottom: 10px;
}

.q-number {
  float: right;
  font-size: 0.72rem;
  color: var(--iv-text-dim);
  margin-top: 2px;
}

.question-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--iv-text);
  line-height: 1.5;
}

/* ── Evaluation card ─────────────────────────────────────────────────────── */
.eval-card {
  max-width: min(92vw, 480px);
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-left: 3px solid var(--iv-success);
  border-radius: 4px var(--iv-radius-sm) var(--iv-radius-sm) 4px;
  padding: 14px 16px;
  animation: msgIn 0.22s ease-out;
}
.eval-card.score-low  { border-left-color: var(--iv-danger); }
.eval-card.score-mid  { border-left-color: var(--iv-warning); }
.eval-card.score-high { border-left-color: var(--iv-success); }

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.score-stars {
  color: var(--iv-gold);
  font-size: 1rem;
  letter-spacing: 2px;
  animation: starsIn 0.4s ease-out;
}
@keyframes starsIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.score-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}
.score-badge.high { color: var(--iv-success); background: rgba(16,185,129,0.12); }
.score-badge.mid  { color: var(--iv-warning); background: rgba(245,158,11,0.12); }
.score-badge.low  { color: var(--iv-danger);  background: rgba(239,68,68,0.12); }

.eval-feedback {
  font-size: 0.88rem;
  color: var(--iv-text);
  line-height: 1.55;
}

.eval-tip {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(99,102,241,0.1);
  border-radius: var(--iv-radius-sm);
  font-size: 0.82rem;
  color: var(--iv-accent2);
}
.eval-tip::before { content: '💡 '; }

/* ── JD result card ──────────────────────────────────────────────────────── */
.jd-result-card {
  max-width: min(92vw, 480px);
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-left: 3px solid var(--iv-accent2);
  border-radius: 4px var(--iv-radius-sm) var(--iv-radius-sm) 4px;
  padding: 14px 16px;
  animation: msgIn 0.22s ease-out;
}
.jd-position {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.jd-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}
.skill-chip {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--iv-accent-muted);
  color: var(--iv-accent2);
  border-radius: 99px;
  padding: 3px 9px;
}
.jd-qcount {
  font-size: 0.85rem;
  color: var(--iv-text-muted);
  margin-bottom: 14px;
}
.jd-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.topic-pill {
  font-size: 0.75rem;
  color: var(--iv-text-muted);
  background: var(--iv-surface2);
  border: 1px solid var(--iv-border);
  border-radius: 99px;
  padding: 3px 10px;
}

/* ── Inline action button ────────────────────────────────────────────────── */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 9px 18px;
  background: var(--iv-accent);
  color: #fff;
  border: none;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-action:hover  { background: #6d28d9; }
.btn-action:active { transform: scale(0.97); }
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Input footer ────────────────────────────────────────────────────────── */
.input-footer {
  position: sticky;
  bottom: 0;
  z-index: 100;
  background: rgba(15, 15, 26, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--iv-border);
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-radius: 22px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: var(--iv-accent); }

.user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--iv-text);
  font-size: 0.93rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px 0;
}
.user-input::placeholder { color: var(--iv-text-dim); }
.user-input::-webkit-scrollbar { width: 3px; }
.user-input::-webkit-scrollbar-thumb { background: var(--iv-border); border-radius: 3px; }
.user-input:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--iv-accent);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-send:hover:not(:disabled) { background: #6d28d9; }
.btn-send:active:not(:disabled) { transform: scale(0.92); }
.btn-send:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Report Modal ────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 88dvh;
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius) var(--iv-radius) 0 0;
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.3s ease-out;
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--iv-border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  color: var(--iv-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-score-row {
  padding: 14px 20px;
  background: var(--iv-surface2);
  border-bottom: 1px solid var(--iv-border);
  flex-shrink: 0;
}
.score-summary { display: flex; align-items: center; gap: 12px; }
.score-big { font-size: 2rem; font-weight: 800; color: var(--iv-gold); }
.score-of  { font-size: 0.8rem; color: var(--iv-text-muted); margin-top: 2px; }
.score-stars-big { font-size: 1.3rem; color: var(--iv-gold); letter-spacing: 3px; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 0.9rem;
  line-height: 1.6;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--iv-border); border-radius: 4px; }

.md h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--iv-accent2);
  margin: 16px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--iv-border);
}
.md h3:first-child { margin-top: 0; }
.md p { margin-bottom: 10px; }
.md ul { padding-left: 18px; margin-bottom: 10px; }
.md li { margin-bottom: 4px; }
.md strong { font-weight: 700; color: var(--iv-text); }
.md .rec-proceed    { color: var(--iv-success); font-weight: 700; }
.md .rec-conditional { color: var(--iv-warning); font-weight: 700; }
.md .rec-decline    { color: var(--iv-danger);  font-weight: 700; }

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--iv-border);
  flex-shrink: 0;
}

.btn-primary {
  flex: 1;
  padding: 12px;
  background: var(--iv-accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #6d28d9; }

.btn-secondary {
  flex: 1;
  padding: 12px;
  background: transparent;
  color: var(--iv-text-muted);
  border: 1px solid var(--iv-border);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--iv-accent); color: var(--iv-text); }

/* ── System message ──────────────────────────────────────────────────────── */
.msg-system {
  text-align: center;
  font-size: 0.78rem;
  color: var(--iv-text-dim);
  padding: 4px 0;
  animation: msgIn 0.2s ease-out;
}

/* ── Auth Gate ───────────────────────────────────────────────────────────── */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(10, 10, 20, 0.97);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-gate[hidden] { display: none; }

.auth-gate-card {
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-gate-logo { font-size: 2.5rem; margin-bottom: 10px; }
.auth-gate-title {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, #a78bfa, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.auth-gate-sub {
  font-size: 0.85rem;
  color: var(--iv-text-muted);
  margin-bottom: 24px;
  line-height: 1.4;
}

.auth-tabs {
  display: flex;
  background: var(--iv-surface2);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  padding: 7px;
  background: transparent;
  border: none;
  color: var(--iv-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: var(--iv-accent);
  color: #fff;
}

.auth-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: var(--iv-surface2);
  border: 1px solid var(--iv-border);
  border-radius: 10px;
  color: var(--iv-text);
  font-size: 0.9rem;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.auth-input:focus {
  outline: none;
  border-color: var(--iv-accent);
}
.auth-input::placeholder { color: var(--iv-text-dim); }

.auth-error {
  font-size: 0.82rem;
  color: var(--iv-danger);
  background: rgba(239,68,68,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  text-align: left;
}
.auth-error.hidden { display: none; }

.auth-submit {
  width: 100%;
  padding: 11px;
  background: var(--iv-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 14px;
}
.auth-submit:hover { background: #6d28d9; }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-gate-divider {
  font-size: 0.78rem;
  color: var(--iv-text-dim);
  margin: 6px 0 12px;
  position: relative;
}
.auth-gate-divider::before,
.auth-gate-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--iv-border);
}
.auth-gate-divider::before { left: 0; }
.auth-gate-divider::after  { right: 0; }

.google-btn-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  min-height: 44px;
}

.auth-gate-free-note {
  font-size: 0.75rem;
  color: var(--iv-text-dim);
  margin-top: 4px;
}

/* ── Plans Section ───────────────────────────────────────────────────────── */
.iv-plans-section {
  padding: 64px 20px 80px;
  background: var(--iv-surface2);
  border-top: 1px solid var(--iv-border);
}
.iv-plans-inner {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}
.iv-plans-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--iv-accent);
  margin-bottom: 14px;
}
.iv-plans-title {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--iv-text);
  margin-bottom: 10px;
}
.iv-plans-sub {
  font-size: .9rem;
  color: var(--iv-text-muted);
  margin-bottom: 40px;
}
.iv-plans-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 560px) { .iv-plans-grid { grid-template-columns: 1fr; } }
.iv-plan-card {
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  text-align: left;
}
.iv-plan-card.iv-plan-featured {
  border-color: var(--iv-accent);
  box-shadow: 0 0 0 1px var(--iv-accent), 0 8px 32px rgba(124,58,237,.2);
}
.iv-plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--iv-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  white-space: nowrap;
}
.iv-plan-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--iv-text);
  margin-bottom: 12px;
}
.iv-plan-price { display: flex; align-items: baseline; gap: 4px; }
.iv-price-amount {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--iv-text);
}
.iv-plan-period {
  font-size: .8rem;
  color: var(--iv-text-muted);
  margin-bottom: 20px;
}
.iv-plan-features {
  list-style: none;
  flex: 1;
  margin-bottom: 24px;
}
.iv-plan-features li {
  font-size: .85rem;
  color: var(--iv-text-muted);
  padding: 5px 0;
  padding-left: 18px;
  position: relative;
}
.iv-plan-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--iv-success);
  font-weight: 700;
}
.iv-plan-btn {
  display: block;
  text-align: center;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}
.iv-plan-btn:hover { opacity: .85; }
.iv-plan-btn-ghost {
  border: 1px solid var(--iv-border);
  color: var(--iv-text);
  background: transparent;
}
.iv-plan-btn-primary {
  background: var(--iv-accent);
  color: #fff;
}

/* ── Upgrade Modal ───────────────────────────────────────────────────────── */
.upgrade-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.upgrade-overlay[hidden] { display: none; }

.upgrade-card {
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  position: relative;
}

.upgrade-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--iv-text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
}

.upgrade-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upgrade-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 8px; }
.upgrade-sub { font-size: 0.85rem; color: var(--iv-text-muted); margin-bottom: 18px; line-height: 1.45; }

.upgrade-features {
  list-style: none;
  text-align: left;
  margin-bottom: 20px;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upgrade-price {
  margin-bottom: 16px;
}
.price-amount {
  font-size: 2rem;
  font-weight: 800;
  color: var(--iv-accent2);
}
.price-period {
  font-size: 0.85rem;
  color: var(--iv-text-muted);
}

.upgrade-btn {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--iv-accent);
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  transition: background 0.15s;
}
.upgrade-btn:hover { background: #6d28d9; }

.upgrade-dismiss {
  background: none;
  border: none;
  color: var(--iv-text-dim);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 6px;
}
.upgrade-dismiss:hover { color: var(--iv-text-muted); }

/* ── Desktop adjustments ─────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .chat { padding: 24px 20%; }
  .modal-card {
    max-width: 520px;
    margin: auto;
    border-radius: var(--iv-radius);
    max-height: 80dvh;
    align-self: center;
  }
  .modal { align-items: center; }
  @keyframes sheetUp {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
  }
}

@media (min-width: 1024px) {
  .chat { padding: 24px 28%; }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
