@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --border: #E5E3DE;
  --border-strong: #C9C5BC;
  --accent: #FFE073;
  --accent-hover: #FFD740;
  --accent-light: #FFFBEB;
  --accent-text: #1C1917;
  --text-primary: #1C1917;
  --text-secondary: #78716C;
  --text-muted: #A8A29E;
  --selected: #FFE073;
  --selected-bg: #FFFBEB;
  --success: #059669;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 15px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: var(--text-primary);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--bg); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text-primary); }
.btn:disabled {
  cursor: not-allowed;
  pointer-events: none;
}
.btn-primary:disabled {
  background: var(--border);
  color: var(--text-muted);
}
.btn-secondary:disabled {
  opacity: 0.4;
}
.btn-lg {
  padding: 13px 28px;
  font-size: 1rem;
  border-radius: 10px;
}

/* ── Level buttons ── */
.level-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 20px 24px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}
.level-btn:hover {
  border-color: var(--accent);
  background: var(--selected-bg);
}
.level-btn-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.level-btn-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Cards ── */
.analogy-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  user-select: none;
}
.analogy-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.analogy-card.selected {
  border-color: var(--accent);
  background: var(--selected-bg);
  box-shadow: 0 0 0 4px rgba(255,224,115,0.25);
}
.analogy-card.selected::after {
  content: '✓';
  position: absolute;
  top: 14px;
  right: 16px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: var(--text-primary);
  border-radius: 50%;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.card-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-right: 30px;
}
.card-body {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Stack panel ── */
.stack-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}
.stack-item-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stack-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.stack-item-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  font-size: 12px;
}
.stack-item.open .stack-item-chevron { transform: rotate(180deg); }
.stack-item-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}
.stack-item.open .stack-item-body { display: block; }
.stack-item-body p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-top: 12px;
}
.stack-item-roles { padding-top: 12px; }
.stack-item-roles li {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-left: 16px;
  margin-bottom: 4px;
}
.stack-item-roles li strong { color: var(--text-primary); }
.stack-item-delete {
  margin-top: 12px;
  width: 100%;
  padding: 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.stack-item-delete:hover {
  background: #FEE2E2;
  border-color: #FCA5A5;
  color: #B91C1C;
}

/* ── Inputs ── */
textarea, input[type="text"], input[type="number"] {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.15s;
  outline: none;
  resize: none;
}
textarea:focus, input:focus { border-color: var(--accent); }
textarea { min-height: 80px; }

/* ── Roles card ── */
.roles-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.role-item {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.role-name {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.role-desc {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.5;
}

/* ── Synthesis ── */
.synthesis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.synthesis-card-header {
  padding: 16px 20px;
  background: var(--accent-light);
  border-bottom: 1px solid var(--border);
}
.synthesis-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.synthesis-card-body { padding: 16px 20px; }
.synthesis-card-body p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
}
.synthesis-questions { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.synthesis-questions li {
  font-size: 0.875rem;
  color: var(--text-primary);
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  line-height: 1.5;
}

/* ── Loader ── */
.loader {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.loader-dots {
  display: flex;
  gap: 4px;
}
.loader-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.2s infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Loader overlay ── */
.loader-overlay {
  position: absolute;
  inset: 0;
  background: rgba(247, 246, 243, 0.92);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  z-index: 10;
}
.loader-overlay .loader-dots span {
  width: 10px;
  height: 10px;
}

/* ── Flying card animation ── */
.card-flying {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Layout page standard ── */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 32px 48px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  gap: 24px;
}

/* ── Utility ── */
.hidden { display: none !important; }
.text-muted { color: var(--text-secondary); font-size: 0.85rem; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
