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

/* ── Beamible Brand Tokens ─────────────────────────────────────── */
:root {
  /* Brand colours */
  --navy:         #0D2E4D;
  --navy-light:   #1A4A73;
  --blue:         #3698F1;
  --blue-dark:    #1E78D9;
  --blue-bg:      #EEF6FF;
  --blue-border:  #B3D8FA;
  --yellow:       #FACD04;
  --yellow-text:  #3D2E00;
  --pink:         #F66470;

  /* Neutral surface */
  --text:         #0D2E4D;
  --text-2:       #3E6187;
  --text-3:       #7DA3C0;
  --border:       rgba(13,46,77,0.12);
  --border-2:     rgba(13,46,77,0.22);
  --bg:           #F4F9FF;
  --bg-2:         #EEF6FF;
  --bg-3:         #FFFFFF;

  /* Radii & shadows */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(13,46,77,0.08);
  --shadow-md: 0 4px 12px rgba(13,46,77,0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text:    #E8F2FF;
    --text-2:  #8AB4D4;
    --text-3:  #4A7A9E;
    --border:  rgba(200,230,255,0.1);
    --border-2:rgba(200,230,255,0.18);
    --bg:      #091C2E;
    --bg-2:    #0F2A42;
    --bg-3:    #132F47;
    --blue-bg: #0C2438;
    --blue-border: #1A4A73;
  }
}

/* ── Base ──────────────────────────────────────────────────────── */
body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}
h1, h2, h3, h4 { font-family: 'Poppins', sans-serif; font-weight: 700; }

/* ── Layout ────────────────────────────────────────────────────── */
.page-wrap { display: flex; flex-direction: column; min-height: 100vh; }

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; height: 56px;
  background: var(--navy); position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.logo {
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
}
.logo-mark {
  width: 26px; height: 26px; background: var(--blue); border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; letter-spacing: -0.5px;
  flex-shrink: 0;
}
.header-right { display: flex; align-items: center; gap: 10px; }

.main-content {
  flex: 1; max-width: 720px; margin: 0 auto; width: 100%; padding: 2.5rem 1.5rem;
}

/* ── Wizard progress ───────────────────────────────────────────── */
.wizard-meta { margin-bottom: 2rem; }
.step-label-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.65rem;
}
.step-label-row strong {
  font-size: 11px; color: var(--blue); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.step-label-row span { font-size: 12px; color: var(--text-2); }
.prog-bar { height: 3px; background: var(--border); border-radius: 2px; }
.prog-fill {
  height: 100%; background: var(--blue); border-radius: 2px;
  transition: width 0.4s cubic-bezier(.4,0,.2,1); width: 16.6%;
}

/* ── Steps ─────────────────────────────────────────────────────── */
.step { display: none; }
.step.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.step-title { font-size: 22px; font-weight: 700; margin-bottom: 0.4rem; line-height: 1.25; color: var(--navy); }
.step-sub { font-size: 13px; color: var(--text-2); margin-bottom: 2rem; line-height: 1.7; }

/* ── Form elements ─────────────────────────────────────────────── */
.field-wrap { margin-bottom: 1.25rem; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 0.4rem; display: block; text-transform: uppercase; letter-spacing: 0.04em; }
textarea, input[type=text] {
  width: 100%; border: 1.5px solid var(--border-2); border-radius: var(--radius-lg);
  padding: 0.8rem 1rem; font-size: 13px; font-family: 'Poppins', sans-serif;
  color: var(--text); background: var(--bg-3); resize: vertical; line-height: 1.6;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea { min-height: 90px; }
textarea:focus, input[type=text]:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(54,152,241,0.14);
}
.char-count { font-size: 11px; color: var(--text-3); text-align: right; margin-top: 4px; }
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; }

/* ── Function & Role grids ─────────────────────────────────────── */
.fn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 8px; }
.fn-card, .role-card {
  padding: 0.85rem 0.7rem; border-radius: var(--radius-md);
  border: 1.5px solid var(--border); cursor: pointer; transition: all 0.15s;
  background: var(--bg-3); text-align: center;
}
.fn-card:hover, .role-card:hover { border-color: var(--blue); background: var(--blue-bg); }
.fn-card.selected, .role-card.selected { border-color: var(--blue); background: var(--blue-bg); }
.fn-icon, .role-icon { font-size: 18px; margin-bottom: 0.35rem; color: var(--text-2); }
.fn-card.selected .fn-icon, .role-card.selected .role-icon { color: var(--blue); }
.fn-name, .role-name { font-size: 11px; font-weight: 500; line-height: 1.3; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 8px; }
.role-group { margin-bottom: 1.25rem; }
.role-group-head {
  font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;
}
.role-group-head span { flex: 1; height: 1px; background: var(--border); }

/* ── Hypotheses ────────────────────────────────────────────────── */
.hyp-list { display: flex; flex-direction: column; gap: 8px; }
.hyp-item {
  padding: 0.85rem 1rem; border-radius: var(--radius-md); border: 1.5px solid var(--border);
  font-size: 13px; cursor: pointer; transition: all 0.15s; line-height: 1.5; background: var(--bg-3);
}
.hyp-item:hover { border-color: var(--blue); background: var(--blue-bg); }
.hyp-item.selected { border-color: var(--blue); background: var(--blue-bg); }
.hyp-item strong { display: block; font-weight: 600; margin-bottom: 3px; }
.hyp-item span { color: var(--text-2); font-size: 12px; }
.hyp-item.selected span { color: var(--blue-dark); }

/* ── Tags ──────────────────────────────────────────────────────── */
.section-head {
  font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase;
  letter-spacing: 0.06em; margin: 1.5rem 0 0.75rem;
}
.tag-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0.5rem; }
.tag-chip {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px;
  border: 1.5px solid var(--border); font-size: 12px; cursor: pointer; transition: all 0.15s;
  background: var(--bg-3); color: var(--text); user-select: none;
}
.tag-chip:hover { border-color: var(--blue); color: var(--blue-dark); }
.tag-chip.selected { background: var(--blue-bg); border-color: var(--blue); color: var(--navy); font-weight: 600; }
.tag-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.35; flex-shrink: 0; }
.tag-chip.selected .dot { opacity: 1; background: var(--blue); }
.suggested-badge {
  font-size: 10px; background: var(--yellow); color: var(--yellow-text);
  border-radius: 10px; padding: 1px 6px; margin-left: 4px; font-weight: 600;
}

.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* ── Review ────────────────────────────────────────────────────── */
.review-card {
  background: var(--bg-2); border-radius: var(--radius-lg);
  padding: 1rem 1.2rem; margin-bottom: 0.85rem;
  border: 1px solid var(--border);
}
.review-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3); margin-bottom: 0.3rem; font-weight: 600;
}
.review-val { font-size: 13px; line-height: 1.6; }
.review-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.35rem; }
.rtag {
  font-size: 11px; padding: 3px 10px; border-radius: 12px;
  background: var(--blue-bg); color: var(--navy);
  border: 1px solid var(--blue-border);
}
.sel-count {
  font-size: 12px; color: var(--blue-dark); background: var(--blue-bg);
  border-radius: 10px; padding: 2px 8px; margin-left: 8px; vertical-align: middle;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  padding: 0.6rem 1.3rem; border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; font-family: 'Poppins', sans-serif;
  border: 1.5px solid var(--border-2); display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--text); text-decoration: none;
}
.btn:hover { background: var(--bg-2); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-light); border-color: var(--navy-light); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn-row { display: flex; gap: 10px; margin-top: 2rem; justify-content: space-between; align-items: center; }

/* ── Activities page ───────────────────────────────────────────── */
.activities-main { max-width: 860px; }
.act-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem;
}
.act-title { font-size: 20px; margin-bottom: 0.2rem; color: var(--navy); }
.act-meta { font-size: 12px; color: var(--text-2); }
.act-header-actions { flex-shrink: 0; }

.gen-banner {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--blue-bg); border: 1px solid var(--blue-border);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-bottom: 1.5rem;
}
.gen-icon { font-size: 20px; color: var(--blue); flex-shrink: 0; margin-top: 1px; }
.gen-banner strong { font-size: 13px; font-weight: 600; color: var(--navy); display: block; margin-bottom: 2px; }
.gen-banner p { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.loading-dots span { display: inline-block; animation: blink 1.2s infinite; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity:0; } 40% { opacity:1; } }

.tag-legend {
  display: flex; align-items: center; gap: 10px; margin-bottom: 1rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.legend-label { font-size: 11px; color: var(--text-2); font-weight: 600; flex-shrink: 0; }
.legend-chip {
  font-size: 11px; padding: 3px 9px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-2);
}

/* ── Activity category blocks ──────────────────────────────────── */
.cat-block {
  margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--bg-3);
}
.cat-header {
  display: flex; align-items: center; gap: 10px; padding: 0.75rem 1rem;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.cat-header.collapsed { border-bottom: none; }
.cat-name {
  flex: 1; font-size: 12px; font-weight: 700; font-family: 'Poppins', sans-serif;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy);
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  outline: none; padding: 2px 4px; min-width: 0;
}
.cat-name:focus { border-color: var(--blue); background: var(--bg-3); color: var(--text); }
.cat-count {
  font-size: 11px; color: var(--text-2); background: var(--bg-3);
  border: 1px solid var(--border); border-radius: 10px; padding: 2px 8px; white-space: nowrap;
}
.cat-toggle { font-size: 14px; color: var(--text-3); transition: transform 0.2s; flex-shrink: 0; }
.cat-header.collapsed .cat-toggle { transform: rotate(-90deg); }
.cat-body.collapsed { display: none; }

/* ── Activity rows ─────────────────────────────────────────────── */
.act-row {
  display: flex; align-items: flex-start; gap: 8px; padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.act-row:last-child { border-bottom: none; }
.act-row:hover { background: var(--bg-2); }
.drag-handle { color: var(--text-3); opacity: 0.3; cursor: grab; padding-top: 3px; flex-shrink: 0; font-size: 14px; }
.act-row:hover .drag-handle { opacity: 0.6; }

.act-name-wrap { flex: 1; min-width: 0; }
.act-name {
  font-size: 13px; line-height: 1.5; padding: 2px 4px; border-radius: 4px;
  border: 1px solid transparent; background: transparent; width: 100%;
  font-family: 'Poppins', sans-serif; color: var(--text); transition: border-color 0.15s;
}
.act-name:focus { outline: none; border-color: var(--blue); background: var(--bg-3); box-shadow: 0 0 0 2px rgba(54,152,241,0.12); }

.act-tags-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.act-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border);
  cursor: pointer; background: var(--bg-3); color: var(--text-2); transition: all 0.12s;
  user-select: none; font-family: 'Poppins', sans-serif;
}
.act-tag:hover { border-color: var(--blue); color: var(--blue-dark); }
.act-tag.on { background: var(--blue-bg); border-color: var(--blue); color: var(--navy); font-weight: 600; }

.act-del {
  color: var(--text-3); opacity: 0; cursor: pointer; padding-top: 3px; flex-shrink: 0;
  font-size: 14px; background: none; border: none; transition: opacity 0.15s, color 0.15s;
  display: flex; align-items: flex-start; padding: 3px 2px;
}
.act-row:hover .act-del { opacity: 0.45; }
.act-del:hover { opacity: 1 !important; color: var(--pink); }

.add-act-row {
  padding: 0.55rem 1rem; display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--border);
}
.add-act-icon { font-size: 13px; color: var(--text-3); opacity: 0.4; flex-shrink: 0; }
.add-act-input {
  flex: 1; font-size: 13px; border: none; background: transparent;
  color: var(--text-2); font-family: 'Poppins', sans-serif; outline: none;
}
.add-act-input::placeholder { color: var(--text-3); }
.add-act-input:focus { color: var(--text); }

/* ── Loading & states ──────────────────────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: 4rem 0; color: var(--text-2); font-size: 14px;
}
.loading-spinner {
  width: 28px; height: 28px; border: 2px solid var(--border);
  border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-cta {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  padding: 3rem 1rem; color: var(--text-2); font-size: 14px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--radius-lg);
}
.empty-cta i { font-size: 28px; opacity: 0.3; }
.link-btn {
  background: none; border: none; color: var(--blue); cursor: pointer;
  font-family: 'Poppins', sans-serif; font-size: inherit; text-decoration: underline; padding: 0;
}

/* ── Save indicator ────────────────────────────────────────────── */
.save-indicator { font-size: 12px; display: flex; align-items: center; gap: 5px; transition: color 0.3s; color: var(--text-3); }
.save-indicator.saving { color: var(--text-2); }
.save-indicator.saved { color: var(--blue); }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--navy); color: #fff;
  font-size: 13px; padding: 0.65rem 1.1rem; border-radius: var(--radius-md);
  opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 999;
}
.toast.show { opacity: 1; }

/* ── Animations ────────────────────────────────────────────────── */
.spin { animation: spin 1s linear infinite; }

/* ── Drag-and-drop ─────────────────────────────────────────────── */
.dnd-dragging { opacity: 0.35; pointer-events: none; }
.dnd-before   { border-top: 2px solid var(--blue) !important; }
.dnd-after    { border-bottom: 2px solid var(--blue) !important; }
.dnd-empty-target { background: var(--blue-bg) !important; }
.cat-block.dnd-before { border-top-color: var(--blue) !important; border-top-width: 2px; }
.cat-block.dnd-after  { border-bottom-color: var(--blue) !important; border-bottom-width: 2px; }

/* ── Custom hypothesis ─────────────────────────────────────────── */
.hyp-custom-row {
  display: flex; align-items: flex-start; gap: 8px;
}
.hyp-remove-btn {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  font-size: 14px; padding: 2px 4px; flex-shrink: 0; border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.hyp-remove-btn:hover { color: var(--pink); background: rgba(246,100,112,0.08); }

/* ── Review tag sub-sections ───────────────────────────────────── */
.review-tag-section { margin-top: 0.75rem; }
.review-tag-section:first-child { margin-top: 0.35rem; }
.review-tag-head {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3); margin-bottom: 0.35rem;
}
.rv-none { font-size: 12px; color: var(--text-3); font-style: italic; }

/* ── Generation error banner ───────────────────────────────────── */
.gen-error-banner {
  display: flex; align-items: flex-start; gap: 14px;
  background: #FFF5F5; border: 1px solid rgba(246,100,112,0.3);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-bottom: 1.5rem;
  color: var(--text);
}
.gen-error-banner > i { font-size: 18px; color: var(--pink); flex-shrink: 0; margin-top: 1px; }
.gen-error-banner strong { font-size: 13px; font-weight: 600; display: block; margin-bottom: 2px; }
.gen-error-banner p { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.gen-error-banner > button { margin-left: auto; flex-shrink: 0; }

@media (prefers-color-scheme: dark) {
  .gen-error-banner { background: rgba(246,100,112,0.08); border-color: rgba(246,100,112,0.2); }
}
