/* ─────────────────────────────────────────────
   Design tokens — Light theme
───────────────────────────────────────────── */
:root {
  --bg          : #f5f5ff;
  --surface     : #ffffff;
  --surface-2   : #f8f8ff;
  --surface-3   : #f0f0fa;
  --border      : #e4e4f0;
  --border-hover: #c8c8e8;
  --border-focus: #7c3aed;

  --text-primary  : #111128;
  --text-secondary: #6b6b8d;
  --text-muted    : #9999bb;

  --accent      : #7c3aed;
  --accent-dark : #5b21b6;
  --accent-2    : #4f46e5;
  --accent-light: #ede9fe;
  --accent-grad : linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);

  --success       : #059669;
  --success-bg    : #ecfdf5;
  --success-border: #a7f3d0;

  --danger        : #dc2626;
  --danger-bg     : #fef2f2;
  --danger-border : #fecaca;

  --warning-bg    : #fffbeb;
  --warning-border: #fde68a;
  --warning-text  : #92400e;

  --nav-h    : 60px;
  --radius   : 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.05);
  --ease     : cubic-bezier(0.4, 0, 0.2, 1);
  --speed    : 0.2s;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background : var(--bg);
  color      : var(--text-primary);
  min-height : 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─────────────────────────────────────────────
   PASSKEY GATE
───────────────────────────────────────────── */
.gate {
  min-height: 100vh;
  display   : flex;
  align-items: center;
  justify-content: center;
  padding   : 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(124,58,237,0.08) 0%, transparent 60%),
    var(--bg);
}

.gate-card {
  background   : var(--surface);
  border       : 1px solid var(--border);
  border-radius: 24px;
  padding      : 48px 44px;
  width        : 100%;
  max-width    : 420px;
  box-shadow   : var(--shadow-lg);
  text-align   : center;
}

.gate-logo {
  display      : flex;
  align-items  : center;
  justify-content: center;
  gap          : 8px;
  font-size    : 15px;
  font-weight  : 700;
  color        : var(--text-secondary);
  margin-bottom: 32px;
  letter-spacing: 0.01em;
}

.gate-logo-icon {
  width        : 32px;
  height       : 32px;
  background   : var(--accent-grad);
  border-radius: 8px;
  display      : flex;
  align-items  : center;
  justify-content: center;
  color        : white;
  font-size    : 16px;
}

.gate-title {
  font-size    : 26px;
  font-weight  : 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color        : var(--text-primary);
}

.gate-sub {
  font-size    : 14.5px;
  color        : var(--text-secondary);
  margin-bottom: 28px;
  line-height  : 1.6;
}

.gate-field {
  display    : flex;
  gap        : 10px;
  margin-bottom: 12px;
}

.gate-input {
  flex         : 1;
  background   : var(--surface-2);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding      : 12px 16px;
  font-size    : 15px;
  font-family  : inherit;
  color        : var(--text-primary);
  outline      : none;
  transition   : border-color var(--speed) var(--ease);
}
.gate-input::placeholder { color: var(--text-muted); }
.gate-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(124,58,237,0.1); }
.gate-input.error { border-color: var(--danger); }

.gate-btn {
  background   : var(--accent-grad);
  color        : white;
  border       : none;
  border-radius: var(--radius-sm);
  width        : 46px;
  height       : 46px;
  display      : flex;
  align-items  : center;
  justify-content: center;
  cursor       : pointer;
  flex-shrink  : 0;
  transition   : all var(--speed) var(--ease);
  box-shadow   : 0 2px 8px rgba(124,58,237,0.3);
}
.gate-btn:hover  { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(124,58,237,0.4); }
.gate-btn:active { transform: translateY(0); }
.gate-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.gate-error {
  background   : var(--danger-bg);
  border       : 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding      : 10px 14px;
  font-size    : 13.5px;
  color        : var(--danger);
  text-align   : left;
  line-height  : 1.5;
}

.gate-lockout {
  background   : var(--warning-bg);
  border       : 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding      : 14px;
  display      : flex;
  align-items  : center;
  gap          : 12px;
  text-align   : left;
  color        : var(--warning-text);
}
.lockout-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.lockout-timer { font-size: 13px; font-variant-numeric: tabular-nums; }

/* ─────────────────────────────────────────────
   App shell
───────────────────────────────────────────── */
#app { min-height: 100vh; padding-top: var(--nav-h); }

/* ─────────────────────────────────────────────
   Top navigation
───────────────────────────────────────────── */
.top-nav {
  position  : fixed;
  top       : 0; left: 0; right: 0;
  height    : var(--nav-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index   : 50;
}

.nav-inner {
  max-width      : 1100px;
  margin         : 0 auto;
  height         : 100%;
  padding        : 0 24px;
  display        : flex;
  align-items    : center;
  gap            : 16px;
}

.nav-logo {
  display    : flex;
  align-items: center;
  gap        : 8px;
  font-size  : 15px;
  font-weight: 700;
  color      : var(--text-primary);
  background : none;
  border     : none;
  cursor     : pointer;
  font-family: inherit;
  padding    : 0;
  letter-spacing: 0.01em;
  margin-right: 8px;
}

.nav-logo-icon {
  width        : 28px;
  height       : 28px;
  background   : var(--accent-grad);
  border-radius: 7px;
  display      : flex;
  align-items  : center;
  justify-content: center;
  color        : white;
  font-size    : 14px;
  flex-shrink  : 0;
}

.nav-links { display: flex; align-items: center; gap: 2px; flex: 1; }

.nav-link {
  background   : none;
  border       : none;
  color        : var(--text-secondary);
  font-size    : 14px;
  font-weight  : 500;
  font-family  : inherit;
  cursor       : pointer;
  padding      : 6px 12px;
  border-radius: var(--radius-sm);
  transition   : all var(--speed) var(--ease);
  display      : flex;
  align-items  : center;
  gap          : 6px;
}
.nav-link:hover  { color: var(--text-primary); background: var(--surface-3); }
.nav-link.active { color: var(--accent); background: var(--accent-light); font-weight: 600; }

.nav-badge {
  background   : var(--accent);
  color        : white;
  font-size    : 11px;
  font-weight  : 700;
  border-radius: 100px;
  padding      : 1px 6px;
  min-width    : 18px;
  text-align   : center;
}

.nav-signout {
  display    : flex;
  align-items: center;
  gap        : 6px;
  background : none;
  border     : 1px solid var(--border);
  border-radius: var(--radius-sm);
  color      : var(--text-secondary);
  font-size  : 13px;
  font-weight: 500;
  font-family: inherit;
  cursor     : pointer;
  padding    : 6px 12px;
  transition : all var(--speed) var(--ease);
  margin-left: auto;
}
.nav-signout:hover { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }

/* ─────────────────────────────────────────────
   Stage system
───────────────────────────────────────────── */
.stage {
  display   : none;
  min-height: calc(100vh - var(--nav-h));
  padding   : 60px 20px 80px;
  opacity   : 0;
  transform : translateY(14px);
  transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.stage.active {
  display        : flex;
  flex-direction : column;
  align-items    : center;
  justify-content: center;
}
.stage.stage-top.active { justify-content: flex-start; }
.stage.active.visible   { opacity: 1; transform: translateY(0); }

.container      { width: 100%; max-width: 640px; margin: 0 auto; }
.container-wide { width: 100%; max-width: 980px; margin: 0 auto; }

/* ─────────────────────────────────────────────
   STAGE 1 — Hero
───────────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 40px; }

.hero-badge {
  display      : inline-flex;
  align-items  : center;
  background   : var(--accent-light);
  color        : var(--accent);
  border       : 1px solid rgba(124,58,237,0.2);
  border-radius: 100px;
  padding      : 5px 14px;
  font-size    : 12.5px;
  font-weight  : 600;
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}

.hero h1 {
  font-size    : clamp(32px, 6vw, 52px);
  font-weight  : 800;
  line-height  : 1.1;
  letter-spacing: -0.03em;
  color        : var(--text-primary);
  margin-bottom: 16px;
}

.gradient-text {
  background             : var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip        : text;
}

.subtitle {
  font-size  : 16px;
  color      : var(--text-secondary);
  max-width  : 420px;
  margin     : 0 auto;
  line-height: 1.7;
}

/* Input card */
.input-card {
  background   : var(--surface);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius);
  padding      : 20px;
  display      : flex;
  flex-direction: column;
  gap          : 14px;
  box-shadow   : var(--shadow-md);
  transition   : border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.input-card:focus-within {
  border-color: var(--accent);
  box-shadow  : var(--shadow-md), 0 0 0 3px rgba(124,58,237,0.1);
}

.input-label {
  font-size  : 13px;
  font-weight: 600;
  color      : var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

textarea {
  background : transparent;
  border     : none;
  outline    : none;
  color      : var(--text-primary);
  font-size  : 15.5px;
  font-family: inherit;
  line-height: 1.65;
  resize     : none;
  width      : 100%;
  min-height : 110px;
}
textarea::placeholder { color: var(--text-muted); }

.input-footer {
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  gap            : 16px;
  padding-top    : 4px;
  border-top     : 1px solid var(--border);
  flex-wrap      : wrap;
}

.input-controls {
  display  : flex;
  align-items: center;
  gap      : 16px;
  flex-wrap: wrap;
  flex     : 1;
}

.input-hint { font-size: 12px; color: var(--text-muted); }

.effort-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.effort-dropdown {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
}

.effort-dropdown:hover {
  border-color: var(--border-hover);
}

.effort-dropdown:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

/* Effort info button */
.effort-info-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.25);
  background: transparent;
  color: rgba(0,0,0,0.45);
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--speed) var(--ease), color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.effort-info-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124,58,237,0.06);
}

/* Effort popup */
.effort-popup {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.effort-popup.hidden { display: none; }

.effort-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}

.effort-popup-box {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px 20px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}

.effort-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.effort-popup-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.effort-popup-close {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--speed) var(--ease), color var(--speed) var(--ease);
}
.effort-popup-close:hover {
  border-color: var(--danger-border, #f87171);
  color: var(--danger, #ef4444);
}

.effort-popup-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.effort-popup-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.effort-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}
.effort-tag--low    { background: rgba(59,130,246,0.1); color: #2563eb; }
.effort-tag--medium { background: rgba(124,58,237,0.1); color: var(--accent); }
.effort-tag--high   { background: rgba(16,185,129,0.1); color: #059669; }

.effort-desc {
  font-size: 13px;
  color: var(--text-secondary, rgba(0,0,0,0.6));
  line-height: 1.5;
}

.effort-words {
  font-weight: 600;
  color: var(--text-primary);
}

/* Examples */
.examples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 20px; }
.examples-label { font-size: 13px; color: var(--text-muted); }

.example-chip {
  background   : var(--surface);
  border       : 1.5px solid var(--border);
  border-radius: 100px;
  padding      : 6px 14px;
  font-size    : 13px;
  color        : var(--text-secondary);
  cursor       : pointer;
  font-family  : inherit;
  font-weight  : 500;
  transition   : all var(--speed) var(--ease);
  box-shadow   : var(--shadow-sm);
}
.example-chip:hover {
  border-color: var(--accent);
  color       : var(--accent);
  background  : var(--accent-light);
}

/* ─────────────────────────────────────────────
   Buttons
───────────────────────────────────────────── */
.btn-primary {
  background   : var(--accent-grad);
  color        : white;
  border       : none;
  border-radius: var(--radius-sm);
  padding      : 11px 20px;
  font-size    : 14.5px;
  font-weight  : 600;
  font-family  : inherit;
  cursor       : pointer;
  display      : flex;
  align-items  : center;
  gap          : 7px;
  justify-content: center;
  width        : 100%;
  box-shadow   : 0 2px 10px rgba(124,58,237,0.3);
  transition   : all var(--speed) var(--ease);
  letter-spacing: -0.01em;
}
.btn-primary.btn-inline { width: auto; flex-shrink: 0; }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(124,58,237,0.4); }
.btn-primary:active:not(:disabled){ transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background   : var(--surface);
  color        : var(--text-primary);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding      : 10px 20px;
  font-size    : 14.5px;
  font-weight  : 500;
  font-family  : inherit;
  cursor       : pointer;
  flex         : 1;
  transition   : all var(--speed) var(--ease);
  box-shadow   : var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-2); }

.btn-outline-accent {
  background   : transparent;
  color        : var(--accent);
  border       : 1.5px solid rgba(124,58,237,0.3);
  border-radius: var(--radius-sm);
  padding      : 10px 20px;
  font-size    : 14.5px;
  font-weight  : 600;
  font-family  : inherit;
  cursor       : pointer;
  transition   : all var(--speed) var(--ease);
}
.btn-outline-accent:hover { background: var(--accent-light); border-color: var(--accent); }

.btn-ghost {
  background   : transparent;
  color        : var(--text-secondary);
  border       : none;
  padding      : 7px 10px;
  font-size    : 14px;
  font-weight  : 500;
  font-family  : inherit;
  cursor       : pointer;
  display      : flex;
  align-items  : center;
  gap          : 5px;
  border-radius: var(--radius-sm);
  transition   : all var(--speed) var(--ease);
  flex-shrink  : 0;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-3); }

.btn-danger-ghost {
  background   : transparent;
  color        : var(--danger);
  border       : 1.5px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding      : 9px 18px;
  font-size    : 14px;
  font-weight  : 600;
  font-family  : inherit;
  cursor       : pointer;
  transition   : all var(--speed) var(--ease);
}
.btn-danger-ghost:hover { background: var(--danger-bg); }

.btn-copy {
  background   : white;
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding      : 6px 12px;
  font-size    : 13px;
  font-weight  : 600;
  color        : var(--text-secondary);
  cursor       : pointer;
  display      : flex;
  align-items  : center;
  gap          : 6px;
  font-family  : inherit;
  transition   : all var(--speed) var(--ease);
  box-shadow   : var(--shadow-sm);
}
.btn-copy:hover  { border-color: var(--accent); color: var(--accent); }
.btn-copy.copied { border-color: var(--success-border); color: var(--success); background: var(--success-bg); }

/* ─────────────────────────────────────────────
   Shared: stage header row
───────────────────────────────────────────── */
.stage-header { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }

.progress-bar { flex: 1; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-fill {
  height: 100%; background: var(--accent-grad); border-radius: 3px;
  width: 0%; transition: width 0.45s var(--ease);
}
.progress-label { font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

.badge-success {
  display    : flex;
  align-items: center;
  gap        : 5px;
  background : var(--success-bg);
  color      : var(--success);
  border     : 1px solid var(--success-border);
  border-radius: 100px;
  padding    : 4px 11px;
  font-size  : 12.5px;
  font-weight: 600;
  margin-left: auto;
}

/* ─────────────────────────────────────────────
   STAGE 2 — Survey
───────────────────────────────────────────── */
.survey-header { margin-bottom: 24px; }
.survey-header h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 5px; }
.survey-header p  { color: var(--text-secondary); font-size: 15px; }

.survey-form { display: flex; flex-direction: column; gap: 16px; opacity: 1; }

.question-card {
  background   : var(--surface);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius);
  padding      : 20px 22px;
  box-shadow   : var(--shadow-sm);
  transition   : border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.question-card.answered {
  border-color: rgba(124,58,237,0.35);
  box-shadow  : var(--shadow-sm), 0 0 0 3px rgba(124,58,237,0.07);
}

.question-number {
  font-size    : 11px;
  font-weight  : 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color        : var(--accent);
  margin-bottom: 7px;
}
.question-text {
  font-size    : 15px;
  font-weight  : 600;
  color        : var(--text-primary);
  margin-bottom: 16px;
  line-height  : 1.5;
}

/* Multiple choice */
.options-grid { display: flex; flex-direction: column; gap: 7px; }
.option-card {
  background   : var(--surface-2);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding      : 10px 14px;
  cursor       : pointer;
  font-size    : 14.5px;
  color        : var(--text-secondary);
  font-family  : inherit;
  font-weight  : 500;
  display      : flex;
  align-items  : center;
  gap          : 11px;
  text-align   : left;
  transition   : all var(--speed) var(--ease);
}
.option-card::before {
  content      : '';
  width        : 17px; height: 17px;
  border-radius: 50%;
  border       : 2px solid var(--border-hover);
  flex-shrink  : 0;
  transition   : all var(--speed) var(--ease);
}
.option-card.multi::before { border-radius: 5px; }
.option-card:hover   { border-color: var(--accent); color: var(--text-primary); background: var(--accent-light); }
.option-card.selected {
  border-color: var(--accent);
  background  : var(--accent-light);
  color       : var(--accent-dark);
  font-weight : 600;
}
.option-card.selected::before { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px white; }
.option-card.multi.selected::before { box-shadow: none; }

/* Scale */
.scale-container { display: flex; flex-direction: column; gap: 10px; }
.scale-buttons   { display: flex; gap: 6px; }
.scale-btn {
  flex         : 1;
  aspect-ratio : 1;
  background   : var(--surface-2);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size    : 13.5px;
  font-weight  : 600;
  color        : var(--text-secondary);
  cursor       : pointer;
  font-family  : inherit;
  transition   : all var(--speed) var(--ease);
}
.scale-btn:hover   { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.scale-btn.selected { background: var(--accent); border-color: var(--accent); color: white; }
.scale-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* Open-ended */
.open-input {
  width        : 100%;
  background   : var(--surface-2);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding      : 11px 14px;
  font-size    : 14.5px;
  color        : var(--text-primary);
  font-family  : inherit;
  outline      : none;
  transition   : border-color var(--speed) var(--ease);
}
.open-input::placeholder { color: var(--text-muted); }
.open-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,0.1); }

/* Yes/No */
.yesno-buttons { display: flex; gap: 10px; }
.yesno-btn {
  flex         : 1;
  padding      : 14px 12px;
  background   : var(--surface-2);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size    : 15px;
  font-weight  : 600;
  color        : var(--text-secondary);
  cursor       : pointer;
  font-family  : inherit;
  transition   : all var(--speed) var(--ease);
}
.yesno-btn:hover   { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.yesno-btn.selected { background: var(--accent); border-color: var(--accent); color: white; }

/* Layer dots navigation */
.layer-dots {
  flex    : 1;
  display : flex;
  align-items: center;
  justify-content: center;
  gap     : 8px;
}
.layer-dot {
  width        : 10px;
  height       : 10px;
  border-radius: 50%;
  background   : var(--border-hover);
  transition   : all var(--speed) var(--ease);
  position     : relative;
}
.layer-dot.active {
  background: var(--accent);
  transform : scale(1.2);
}
.layer-dot.done {
  background: var(--success);
}
.layer-dot.skipped {
  background: var(--border-hover);
  opacity   : 0.5;
}
.layer-dot-label {
  position : absolute;
  top      : 14px;
  left     : 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color    : var(--text-muted);
  white-space: nowrap;
}

/* Layer badge */
.layer-badge {
  display      : inline-flex;
  align-items  : center;
  border-radius: 100px;
  padding      : 4px 12px;
  font-size    : 12px;
  font-weight  : 700;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}
.layer-badge.mandatory {
  background: var(--accent-light);
  color     : var(--accent);
  border    : 1px solid rgba(124,58,237,0.2);
}
.layer-badge.optional {
  background: #f0fdf4;
  color     : var(--success);
  border    : 1px solid var(--success-border);
}

/* Survey footer with skip + next side by side */
.survey-footer {
  display    : flex;
  align-items: center;
  justify-content: space-between;
  margin-top : 20px;
  gap        : 12px;
  flex-wrap  : wrap;
}
.answer-count {
  font-size  : 13px;
  color      : var(--text-muted);
  font-weight: 500;
}
.footer-btns { display: flex; align-items: center; gap: 10px; }

.btn-skip {
  background   : transparent;
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding      : 9px 16px;
  font-size    : 13.5px;
  font-weight  : 500;
  color        : var(--text-secondary);
  cursor       : pointer;
  font-family  : inherit;
  transition   : all var(--speed) var(--ease);
}
.btn-skip:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* Layer slide transition */
.survey-form.layer-in {
  animation: layerIn 0.28s var(--ease) both;
}
@keyframes layerIn {
  from { opacity: 0; transform: translateX(28px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─────────────────────────────────────────────
   STAGE 3 — Result
───────────────────────────────────────────── */
.result-meta-row { margin-bottom: 18px; }
.result-h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 10px; }

.result-card {
  background   : var(--surface);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow     : hidden;
  box-shadow   : var(--shadow-md);
}
.result-toolbar {
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  padding        : 12px 18px;
  border-bottom  : 1px solid var(--border);
  background     : var(--surface-2);
}
.result-label {
  font-size    : 11px;
  font-weight  : 700;
  color        : var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.result-text {
  padding    : 22px;
  font-size  : 14.5px;
  line-height: 1.8;
  color      : var(--text-primary);
  white-space: pre-wrap;
  max-height : 420px;
  overflow-y : auto;
}
.result-text::-webkit-scrollbar       { width: 5px; }
.result-text::-webkit-scrollbar-track { background: transparent; }
.result-text::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

.result-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }

/* ─────────────────────────────────────────────
   Tag pills (shared)
───────────────────────────────────────────── */
.tags-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pill {
  display      : inline-flex;
  align-items  : center;
  border-radius: 100px;
  padding      : 3px 10px;
  font-size    : 12px;
  font-weight  : 600;
  border       : 1px solid;
  white-space  : nowrap;
}

/* ─────────────────────────────────────────────
   STAGE 4 — Library
───────────────────────────────────────────── */
.library-header {
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  gap            : 16px;
  margin-bottom  : 24px;
  flex-wrap      : wrap;
}
.library-header h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 3px; }
.library-header p  { color: var(--text-secondary); font-size: 15px; }

.library-controls { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 14px; color: var(--text-muted); pointer-events: none; }
.library-search {
  width        : 100%;
  background   : var(--surface);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding      : 11px 16px 11px 42px;
  font-size    : 14.5px;
  color        : var(--text-primary);
  font-family  : inherit;
  outline      : none;
  box-shadow   : var(--shadow-sm);
  transition   : border-color var(--speed) var(--ease);
}
.library-search::placeholder { color: var(--text-muted); }
.library-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,0.1); }

.tag-filters      { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.tag-filter-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.tag-filter-pill {
  background   : var(--surface);
  border       : 1.5px solid var(--border);
  border-radius: 100px;
  padding      : 4px 12px;
  font-size    : 13px;
  font-weight  : 500;
  color        : var(--text-secondary);
  cursor       : pointer;
  font-family  : inherit;
  transition   : all var(--speed) var(--ease);
  box-shadow   : var(--shadow-sm);
}
.tag-filter-pill:hover { border-color: var(--accent); color: var(--accent); }
.tag-filter-pill.active { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }

/* Prompt grid */
.prompt-grid {
  display              : grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap                  : 14px;
}

.prompt-card {
  background   : var(--surface);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius);
  padding      : 18px 20px;
  cursor       : pointer;
  display      : flex;
  flex-direction: column;
  gap          : 10px;
  box-shadow   : var(--shadow-sm);
  transition   : all var(--speed) var(--ease);
}
.prompt-card:hover {
  border-color: var(--accent);
  transform   : translateY(-2px);
  box-shadow  : var(--shadow-md), 0 0 0 3px rgba(124,58,237,0.07);
}

.card-title  { font-size: 14.5px; font-weight: 700; color: var(--text-primary); line-height: 1.4; }
.card-tags   { display: flex; flex-wrap: wrap; gap: 5px; }
.card-snippet {
  font-size : 13px; color: var(--text-secondary); line-height: 1.6; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-date { font-size: 12px; color: var(--text-muted); }

.lib-empty {
  grid-column: 1 / -1; text-align: center; padding: 72px 20px;
  color: var(--text-muted); display: flex; flex-direction: column;
  align-items: center; gap: 14px;
}
.lib-empty p { font-size: 15px; }

/* ─────────────────────────────────────────────
   Prompt modal
───────────────────────────────────────────── */
.prompt-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  transition: opacity var(--speed) var(--ease);
}
.prompt-modal.hidden { opacity: 0; pointer-events: none; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(17,17,40,0.45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.modal-box {
  position    : relative; z-index: 1;
  background  : var(--surface);
  border      : 1.5px solid var(--border);
  border-radius: var(--radius);
  width       : 100%; max-width: 660px; max-height: 90vh;
  display     : flex; flex-direction: column;
  box-shadow  : var(--shadow-lg);
  transform   : scale(0.97);
  transition  : transform var(--speed) var(--ease);
}
.prompt-modal:not(.hidden) .modal-box { transform: scale(1); }

.modal-header {
  display        : flex;
  align-items    : flex-start;
  justify-content: space-between;
  gap            : 16px;
  padding        : 22px 22px 0;
}
.modal-title { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 10px; }
.modal-close {
  background   : var(--surface-2);
  border       : 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  width        : 34px; height: 34px;
  display      : flex; align-items: center; justify-content: center;
  cursor       : pointer; color: var(--text-secondary); flex-shrink: 0;
  transition   : all var(--speed) var(--ease);
}
.modal-close:hover { border-color: var(--danger-border); color: var(--danger); background: var(--danger-bg); }

.modal-meta { padding: 10px 22px 0; font-size: 12px; color: var(--text-muted); }

.modal-body {
  padding    : 16px 22px 0;
  overflow-y : auto;
  flex       : 1;
  font-size  : 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  color      : var(--text-primary);
}
.modal-body::-webkit-scrollbar       { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

.modal-footer {
  padding   : 16px 22px 20px;
  display   : flex;
  gap       : 10px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

/* ─────────────────────────────────────────────
   Loading overlay
───────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(245,245,255,0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; transition: opacity var(--speed) var(--ease);
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.loading-content { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.spinner {
  width        : 38px; height: 38px;
  border       : 3px solid rgba(124,58,237,0.15);
  border-top   : 3px solid var(--accent);
  border-radius: 50%;
  animation    : spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-content p { font-size: 14.5px; color: var(--text-secondary); font-weight: 500; }

/* ═══════════════════════════════════════════════════════════════
   Premium Prompt Generation Loading Component
   ═══════════════════════════════════════════════════════════════ */

.prompt-generation-loading {
  width: 100%; max-width: 520px; padding: 0 24px;
}

.pgl-container {
  display: flex;
  flex-direction: column;
  gap: 32px;
  animation: pglFadeIn 0.6s var(--ease) forwards;
}

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

/* Headline Section */
.pgl-headline-section {
  text-align: center;
}

.pgl-headline {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px 0;
  line-height: 1.3;
}

.pgl-subtext {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* Status Sentence (Rotating) */
.pgl-status-section {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pgl-status-sentence {
  font-size: 15px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
  line-height: 1.5;
  animation: pglFadeInOut 0.8s var(--ease) forwards;
  font-weight: 500;
}

@keyframes pglFadeInOut {
  0% {
    opacity: 0;
    transform: translateY(-4px);
  }
  10% {
    opacity: 1;
    transform: translateY(0);
  }
  85% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* Stage Progress Indicator */
.pgl-stage-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pgl-stages {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.pgl-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pgl-stage-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid transparent;
  transition: all 0.4s var(--ease);
  position: relative;
}

.pgl-stage-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  opacity: 0;
  animation: none;
}

.pgl-stage-active .pgl-stage-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.4);
}

.pgl-stage-active .pgl-stage-dot::after {
  animation: pglPulse 1.5s ease-out infinite;
}

@keyframes pglPulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

.pgl-stage-completed .pgl-stage-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.pgl-stage-completed .pgl-stage-dot::before {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.pgl-stage-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  transition: color 0.4s var(--ease);
}

.pgl-stage-active .pgl-stage-label {
  color: var(--accent);
}

.pgl-stage-completed .pgl-stage-label {
  color: var(--accent);
}

/* Progress Bar */
.pgl-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

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

/* Reassurance Text */
.pgl-reassurance {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
  line-height: 1.4;
  font-style: italic;
}

/* Subtle Spinner */
.pgl-spinner-container {
  display: flex;
  justify-content: center;
}

.pgl-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(124, 58, 237, 0.12);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: pglSpin 1s linear infinite;
}

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

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .pgl-container {
    gap: 28px;
  }

  .pgl-headline {
    font-size: 20px;
  }

  .pgl-subtext {
    font-size: 13px;
  }

  .pgl-status-section {
    min-height: 50px;
  }

  .pgl-status-sentence {
    font-size: 14px;
  }

  .pgl-stages {
    gap: 4px;
  }

  .pgl-stage-dot {
    width: 20px;
    height: 20px;
  }

  .pgl-stage-label {
    font-size: 10px;
    letter-spacing: 0.3px;
  }

  .pgl-reassurance {
    font-size: 11px;
  }

  .pgl-spinner {
    width: 28px;
    height: 28px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Analyze-Request Loading Overlay
   ═══════════════════════════════════════════════════════════════ */

.arl-overlay {
  position: fixed; inset: 0;
  background: rgba(245,245,255,0.88);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  transition: opacity 0.25s var(--ease);
}
.arl-overlay.hidden { opacity: 0; pointer-events: none; }

.arl-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 24px;
  width: 100%; max-width: 460px; padding: 0 28px;
  animation: arlFadeUp 0.5s var(--ease) forwards;
}
@keyframes arlFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Pulsing icon */
.arl-icon-wrap {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 72px; height: 72px;
}
.arl-icon-pulse {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: var(--accent-light);
  animation: arlPulse 1.8s ease-in-out infinite;
}
@keyframes arlPulse {
  0%, 100% { transform: scale(1);   opacity: 0.7; }
  50%       { transform: scale(1.18); opacity: 0.3; }
}
.arl-icon {
  position: relative;
  font-size: 32px; color: var(--accent);
  animation: arlSpin 3s linear infinite;
  display: inline-block;
}
@keyframes arlSpin {
  0%   { transform: rotate(0deg)   scale(1); }
  50%  { transform: rotate(180deg) scale(1.12); }
  100% { transform: rotate(360deg) scale(1); }
}

/* Headline */
.arl-headline {
  font-size: 22px; font-weight: 700;
  color: var(--text-primary);
  text-align: center; margin: 0;
}

/* Rotating sentence */
.arl-sentence {
  font-size: 14.5px; color: var(--text-secondary);
  text-align: center; margin: 0; line-height: 1.55;
  min-height: 44px;
  transition: opacity 0.35s ease;
}
.arl-sentence.fade { opacity: 0; }

/* Progress bar section */
.arl-progress-wrap {
  width: 100%; display: flex; flex-direction: column; gap: 10px;
}
.arl-progress-bar {
  width: 100%; height: 6px;
  background: rgba(124,58,237,0.12);
  border-radius: 99px; overflow: hidden;
}
.arl-progress-fill {
  height: 100%;
  background: var(--accent-grad);
  border-radius: 99px;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.arl-step-label {
  font-size: 12.5px; color: var(--text-muted);
  font-weight: 500; text-align: center;
  letter-spacing: 0.01em;
}

@media (max-width: 500px) {
  .arl-headline { font-size: 19px; }
  .arl-sentence { font-size: 13.5px; }
}

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

@media (max-width: 500px) {
  .gate-card    { padding: 36px 24px; }
  .scale-buttons{ gap: 4px; }
  .scale-btn    { font-size: 12px; }
  .yesno-buttons{ flex-direction: column; }
  .hero h1      { font-size: 28px; }
  .result-actions { flex-direction: column; }
  .prompt-grid  { grid-template-columns: 1fr; }
  .effort-options { flex-direction: column; }
}

