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

:root {
  --bg:           #0e0b0b;
  --surface:      #1c1515;
  --surface-r:    #261c1c;
  --accent:       #8b1a1a;
  --accent-bright:#b52a2a;
  --text:         #f0e8e8;
  --text-muted:   #9e8888;
  --border:       #3a2828;
  --danger:       #c0392b;
  --success:      #2e7d52;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: 'Georgia', serif;
}

/* ── Utility ── */
.hidden { display: none !important; }

.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }

/* ── Buttons ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--text);
}
.btn-primary:hover, .btn-primary:active {
  background: var(--accent-bright);
}

.btn-secondary {
  background: var(--surface-r);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover, .btn-secondary:active {
  background: var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover, .btn-danger:active {
  background: var(--danger);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 12px;
}
.btn-ghost:hover { color: var(--text); }

.btn-full { width: 100%; }

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

/* ── Inputs ── */
input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--surface-r);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  appearance: none;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
}
input::placeholder { color: var(--text-muted); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239e8888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ── Screen wrapper ── */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 20px;
}

/* ── Welcome Screen ── */
.welcome-logo {
  font-family: 'Georgia', serif;
  font-size: 32px;
  color: var(--accent-bright);
  text-align: center;
  letter-spacing: 1px;
  margin-top: 32px;
}
.welcome-tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  padding: 0 8px;
}
.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.welcome-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.65;
}
.welcome-how {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.66;
}
.welcome-how strong {
  display: block;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: normal;
  text-transform: uppercase;
  text-align: center;
}
.welcome-how ul {
  padding-left: 16px;
  list-style: disc;
}
.welcome-how ul li { margin-bottom: 4px; }

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--border);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin: 4px 0;
}
.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.or-divider span { color: var(--text-muted); }

/* ── Partner Code Screen ── */
.code-display-label {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.code-display {
  font-family: 'Georgia', serif;
  font-size: 52px;
  letter-spacing: 10px;
  color: var(--text);
  text-align: center;
  padding: 20px 0 12px;
  cursor: pointer;
  user-select: all;
}
.code-copy-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: -12px;
}
.code-copy-hint.copied { color: var(--success); }

.field-label {
  font-size: 14px;
  color: var(--text-muted);
  display: block;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inline-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 0;
}

/* ── Waiting Screen ── */
.waiting-screen {
  align-items: center;
  text-align: center;
  gap: 24px;
}
.waiting-screen h2 {
  font-size: 22px;
}
.waiting-pulse {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.3;
  animation: pulse 2s ease-in-out infinite;
  margin: 0 auto;
}
@keyframes pulse {
  0%, 100% { transform: scale(1);   opacity: 0.3; }
  50%       { transform: scale(1.2); opacity: 0.6; }
}
.waiting-timer {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Question Screen Top Bar ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 7px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-row1 {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-code-item {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.topbar-code-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.topbar-code-val {
  font-family: 'Georgia', serif;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 2px;
  flex-shrink: 0;
}
.badge-done {
  font-size: 10px;
  background: var(--success);
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  flex-shrink: 0;
}
.topbar-row2 {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar-select {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  font-size: 13px;
  padding: 4px 28px 4px 10px;
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  padding: 0;
}
.icon-btn:hover { color: var(--text); background: var(--surface-r); }
.icon-btn.delete-btn:hover { color: var(--danger); }
.icon-btn svg { width: 20px; height: 20px; }

.save-status {
  font-size: 11px;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.save-status.visible { opacity: 1; }

/* ── Question Body ── */
.question-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 80px;
}
.category-section {
  padding: 0;
}
.category-header {
  font-family: 'Georgia', serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 18px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.question-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.question-row:last-child { border-bottom: none; }
.question-text {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.4;
}
.answer-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.answer-btn {
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-r);
  color: var(--text-muted);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.answer-btn:hover { color: var(--text); border-color: var(--text-muted); }
.answer-btn.selected-yes {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.answer-btn.selected-no {
  background: var(--surface-r);
  border-color: var(--accent);
  color: var(--text);
}
.answer-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

/* ── Bottom bar ── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  z-index: 10;
}

/* ── Locked / results header ── */
.locked-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-muted);
}
.results-header {
  font-family: 'Georgia', serif;
  font-size: 20px;
  color: var(--text);
  padding: 20px 16px 4px;
}
.results-subheader {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 16px 16px;
}
.match-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.match-row:last-child { border-bottom: none; }
.match-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-top: 6px;
  flex-shrink: 0;
}
.match-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.4;
}
.match-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.no-matches {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 24px;
  font-size: 15px;
}

/* ── Deleted Screen ── */
.deleted-screen {
  align-items: center;
  text-align: center;
  gap: 24px;
  padding-top: 60px;
}
.deleted-screen h2 {
  font-family: 'Georgia', serif;
  font-size: 22px;
}
.deleted-detail {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── Restore / inline prompt ── */
.restore-prompt {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 11, 11, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 20px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-title {
  font-family: 'Georgia', serif;
  font-size: 18px;
  color: var(--text);
}
.modal-body {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions .btn { flex: 1; }

/* ── Input variants ── */
.input-code {
  font-size: 28px;
  letter-spacing: 8px;
  text-align: center;
  font-family: 'Georgia', serif;
}
.input-pin {
  font-size: 28px;
  letter-spacing: 8px;
  text-align: center;
  font-family: 'Georgia', serif;
  padding-left: 44px;
  padding-right: 44px;
}
.pin-wrap {
  position: relative;
  display: block;
}
.pin-wrap .pin-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

/* ── Consent checkboxes ── */
.consent-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.consent-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.consent-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--surface-r);
  cursor: pointer;
  margin-top: 1px;
  transition: background 0.15s, border-color 0.15s;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
}
.consent-item input[type="checkbox"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 8l3.5 3.5 6.5-7' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.consent-item label {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  cursor: pointer;
}
.consent-item label a {
  color: var(--accent-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Legal footer ── */
.legal-footer {
  text-align: center;
  padding: 16px 0 4px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.legal-footer a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 4px;
  transition: color 0.15s;
}
.legal-footer a:hover { color: var(--text); }
.legal-footer span { color: var(--border); }

/* ── Doc pages (terms / privacy) ── */
body.doc-page {
  height: auto;
  min-height: 100%;
}
.doc-container {
  max-width: 620px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.doc-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 28px;
  padding: 6px 0;
  transition: color 0.15s;
}
.doc-close:hover { color: var(--text); }
.doc-content h1 {
  font-family: 'Georgia', serif;
  font-size: 22px;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}
.doc-content h2 {
  font-family: 'Georgia', serif;
  font-size: 16px;
  color: var(--text);
  margin-top: 28px;
  margin-bottom: 8px;
}
.doc-content p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 12px;
}
.doc-content strong { color: var(--text); }
.doc-content ul {
  padding-left: 20px;
  margin-bottom: 12px;
}
.doc-content ul li {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 4px;
}
.doc-effective {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ── Save icon animation ── */
@keyframes save-bounce {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-4px); }
  70%  { transform: translateY(1px); }
  100% { transform: translateY(0); }
}
.saving .save-icon { animation: save-bounce 0.5s ease; }
