@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap");

.pain-section {
  --purple: #54498b;
  --lilac: #9582c3;
  --pink: #dc4ff5;
  --hot-pink: #f65ed8;
  --peach: #fbe8c8;
  --ink: #1a0a3a;
  --soft-pink: #fc90e4;
  --mist: #e0d9fa;
  --page: #1a0a3a;
  --text: #fffaff;
  --card: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.14);
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.36);
  isolation: isolate;
  overflow: hidden;
  position: relative;
  min-height: 720px;
  padding: clamp(3.25rem, 6vw, 5.5rem) clamp(1.25rem, 5.5vw, 5.5rem);
  margin-top: -1px;
  border-top: 0;
  color: var(--text);
  background: radial-gradient(circle at 84% 13%, rgba(220, 79, 245, 0.46), transparent 27%), var(--page);
  font-family: "DM Sans", Poppins, sans-serif;
  transition: background 0.35s ease, color 0.35s ease;
}

body.light-theme .pain-section {
  --page: #fff8fe;
  --text: #281747;
  --card: rgba(255, 255, 255, 0.65);
  --line: rgba(84, 73, 139, 0.14);
  --shadow: 0 26px 60px rgba(84, 39, 116, 0.18);
  border-top: 0;
  background: radial-gradient(circle at 87% 13%, rgba(220, 79, 245, 0.34), transparent 25%), radial-gradient(circle at 7% 86%, rgba(251, 232, 200, 0.9), transparent 30%), var(--page);
}

.pain-section::before, .pain-section::after { position: absolute; content: ""; pointer-events: none; z-index: -1; border: 1px solid var(--line); border-radius: 50%; }
.pain-section::before { width: 710px; height: 710px; right: -260px; top: 38px; }
.pain-section::after { width: 490px; height: 490px; right: -210px; top: 145px; }
.pain-section button { font: inherit; }
.pain-section-inner { max-width: 1280px; margin: auto; display: grid; grid-template-columns: minmax(280px, 0.84fr) minmax(510px, 1.16fr); gap: clamp(42px, 7vw, 110px); align-items: center; }
.pain-title { margin: 0 0 14px; max-width: 520px; color: inherit; font-family: "Plus Jakarta Sans", sans-serif; font-size: clamp(40px, 5vw, 68px); font-weight: 700; line-height: 1.02; letter-spacing: -0.06em; }
.pain-lead { margin: 0; max-width: 500px; color: inherit; font-size: clamp(16px, 1.3vw, 18px); line-height: 1.7; opacity: 0.82; }
.pain-highlight { display: inline-block; font-size: 1.13em; font-weight: 700; color: var(--pink); }
.pain-section.in-view .pain-highlight { animation: pain-focus 2.7s ease both; }
.pain-section.in-view .pain-highlight:nth-child(2) { animation-delay: 0.35s; }
.pain-section.in-view .pain-highlight:nth-child(3) { animation-delay: 0.7s; }
.pain-section.in-view .pain-highlight:nth-child(4) { animation-delay: 1.05s; }
@keyframes pain-focus { 0%, 18% { opacity: 0.58; transform: scale(1); } 38%, 57% { color: var(--hot-pink); opacity: 1; text-shadow: 0 3px 12px rgba(220, 79, 245, 0.28); transform: scale(1.07); } 100% { color: var(--pink); opacity: 1; transform: scale(1); } }

.pain-cta { display: inline-flex; align-items: center; justify-content: center; margin-top: 31px; padding: 15px 22px; border: 0; border-radius: 999px; cursor: pointer; color: white; font-weight: 700; text-decoration: none; background: linear-gradient(110deg, var(--purple), var(--pink)); box-shadow: 0 14px 30px rgba(180, 62, 190, 0.32); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.pain-cta:hover { transform: translateY(-3px); box-shadow: 0 18px 36px rgba(180, 62, 190, 0.42); }
.pain-cta:focus-visible, .pain-mobile-expand:focus-visible, .pain-modal-close:focus-visible { outline: 3px solid var(--peach); outline-offset: 3px; }

.pain-visual-stage { position: relative; min-height: 630px; opacity: 0; transform: translateY(30px); transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
.pain-visual-stage.in-view { opacity: 1; transform: none; }
.pain-visual-copy { position: absolute; top: 2px; left: 0; z-index: 4; font-family: "Plus Jakarta Sans", sans-serif; font-size: clamp(18px, 1.75vw, 25px); font-weight: 700; letter-spacing: -0.045em; white-space: nowrap; }
.pain-visual-copy span { color: var(--pink); }
.pain-phone { position: absolute; top: 105px; left: 24%; z-index: 3; width: 260px; height: 500px; padding: 8px; border: 4px solid rgba(20, 13, 27, 0.92); border-radius: 38px; outline: 1px solid rgba(239, 219, 255, 0.5); background: linear-gradient(120deg, rgba(255,255,255,0.38), rgba(34,25,48,0.78) 10%, rgba(8,5,17,0.96) 42%, rgba(108,85,127,0.38) 100%); box-shadow: inset 1px 1px 1px rgba(255,255,255,0.5), inset -1px -1px 2px rgba(255,255,255,0.12), 16px 22px 0 rgba(26,10,58,0.18), var(--shadow); transform: rotate(-5deg); transition: transform 0.5s ease; }
.pain-phone:hover { transform: rotate(-2deg) translateY(-4px); }
.pain-phone::before { content: ""; position: absolute; top: 7px; left: 50%; width: 76px; height: 18px; border: 1px solid rgba(255,255,255,0.06); border-radius: 20px; background: #10081e; box-shadow: inset 0 1px 2px rgba(255,255,255,0.06); transform: translateX(-50%); z-index: 7; }
.pain-phone::after { position: absolute; bottom: 4px; left: 50%; z-index: 10; width: 76px; height: 3px; border-radius: 99px; content: ""; background: rgba(255,255,255,0.9); box-shadow: 0 0 5px rgba(255,255,255,0.28); transform: translateX(-50%); }
.pain-phone-screen { position: relative; overflow: hidden; height: 100%; border: 1px solid rgba(255,255,255,0.18); border-radius: 29px; padding: 24px 12px 12px; color: white; background: linear-gradient(160deg, #3f2877 0%, #7654ac 55%, #ce58cc 125%); }

.pain-chaos-ui { position: absolute; inset: 0; overflow: hidden; color: #111b21; background: #fff; }
.pain-wa-status { display: flex; align-items: center; justify-content: space-between; height: 25px; padding: 0 12px; color: #12252a; background: #f6f8f7; font-size: 8px; font-weight: 800; }
.pain-wa-status-icons { display: flex; align-items: center; gap: 4px; font-size: 7px; }
.pain-wifi-icon { width: 13px; height: 10px; background: radial-gradient(circle at 50% 100%, #12252a 0 1px, transparent 1.3px), radial-gradient(circle at 50% 100%, transparent 0 3px, #12252a 3.2px 3.9px, transparent 4.1px), radial-gradient(circle at 50% 100%, transparent 0 5.5px, #12252a 5.7px 6.4px, transparent 6.6px); }
.pain-battery { display: inline-block; width: 13px; height: 7px; border: 1px solid #12252a; border-radius: 2px; }
.pain-battery::after { content: ""; display: block; width: 8px; height: 3px; margin: 1px; background: #12252a; }
.pain-wa-topbar { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 11px; color: #111b21; background: #fff; }
.pain-wa-home-title { flex: 1; font-size: 15px; font-weight: 800; }
.pain-wa-actions { color: #526268; font-size: 13px; letter-spacing: 2px; }
.pain-unread { color: #008069; font-size: 11px; font-weight: 800; line-height: 1; }
.pain-inbox-tabs { display: flex; gap: 17px; height: 26px; padding: 0 12px; border-bottom: 1px solid #edf0f1; color: #667781; font-size: 8px; font-weight: 700; }
.pain-inbox-tabs b { position: relative; color: #008069; }
.pain-inbox-tabs b::after { position: absolute; right: 0; bottom: -8px; left: 0; height: 2px; border-radius: 3px; content: ""; background: #00a884; }
.pain-inbox-list { position: absolute; top: 93px; right: 0; bottom: 31px; left: 0; overflow: hidden; padding: 2px 9px 0; }
.pain-inbox-feed { display: grid; }
.pain-visual-stage.in-view .pain-inbox-feed { animation: pain-inbox-feed 22s linear infinite 0.5s; }
.pain-visual-stage.organised .pain-inbox-feed { animation-play-state: paused; }
.pain-inbox-thread { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; column-gap: 7px; align-items: center; min-height: 54px; border-bottom: 1px solid #f0f2f3; opacity: 1; transition: opacity 0.35s ease, transform 0.4s cubic-bezier(0.2,0.8,0.2,1); }
.pain-visual-stage.in-view .pain-inbox-thread { animation: pain-inbox-arrive 0.42s backwards ease-out; }
.pain-inbox-thread:nth-child(2) { animation-delay: 0.1s; }
.pain-inbox-thread:nth-child(3) { animation-delay: 0.2s; }
.pain-inbox-thread:nth-child(4) { animation-delay: 0.3s; }
@keyframes pain-inbox-arrive { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes pain-inbox-feed { from { transform: translateY(0); } to { transform: translateY(-594px); } }
.pain-inbox-avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: white; background: linear-gradient(135deg, #fdad90, #e879ad); font-size: 10px; font-weight: 800; }
.pain-inbox-thread:nth-child(2n) .pain-inbox-avatar { background: linear-gradient(135deg, #7fb8e8, #6b72cf); }
.pain-inbox-thread:nth-child(3n) .pain-inbox-avatar { background: linear-gradient(135deg, #b291e3, #d864b1); }
.pain-inbox-thread:nth-child(5n) .pain-inbox-avatar { background: linear-gradient(135deg, #8fd5b1, #42a87b); }
.pain-thread-copy { min-width: 0; }
.pain-thread-copy b, .pain-thread-copy span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pain-thread-copy b { font-size: 9px; }
.pain-thread-copy span { margin-top: 3px; color: #667781; font-size: 8px; }
.pain-thread-meta { align-self: start; padding-top: 9px; color: #8696a0; font-size: 7px; text-align: right; }
.pain-thread-dot { display: inline-block; width: 6px; height: 6px; margin-top: 4px; border-radius: 50%; background: #25d366; animation: pain-incoming-pulse 2.4s ease-in-out infinite; }
@keyframes pain-incoming-pulse { 0%, 72%, 100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); transform: scale(1); } 84% { box-shadow: 0 0 0 4px rgba(37,211,102,0.25); transform: scale(1.18); } }
.pain-inbox-nav { position: absolute; right: 0; bottom: 0; left: 0; display: flex; justify-content: space-around; align-items: center; height: 31px; border-top: 1px solid #edf0f1; color: #68777c; background: #fff; font-size: 7px; }
.pain-nav-item { display: inline-flex; align-items: center; gap: 3px; }
.pain-inbox-nav b { color: #008069; }
.pain-story-icon { width: 12px; height: 12px; border-radius: 50%; background: conic-gradient(#63c7ac 0 30%, transparent 30% 35%, #63c7ac 35% 64%, transparent 64% 69%, #63c7ac 69% 100%); }
.pain-call-icon { font-style: normal; font-size: 10px; }
.pain-chat-icon { position: relative; width: 12px; height: 9px; border: 1.5px solid currentColor; border-radius: 4px; }
.pain-chat-icon::after { position: absolute; bottom: -4px; left: 2px; width: 4px; height: 4px; border-bottom: 1.5px solid currentColor; border-left: 1.5px solid currentColor; content: ""; transform: skewY(-35deg); }

.pain-process-list { position: absolute; z-index: 5; left: -28px; bottom: 30px; display: grid; gap: 7px; width: 160px; pointer-events: none; }
.pain-process { display: flex; align-items: center; gap: 7px; padding: 8px; border: 1px solid rgba(255,255,255,0.23); border-radius: 10px; color: white; background: rgba(43,20,81,0.75); box-shadow: 0 8px 20px rgba(27,7,51,0.2); font-size: 10px; font-weight: 700; opacity: 0; transform: translateX(25px); }
.pain-process em { color: #ead9ff; font-style: normal; font-weight: 500; }
.pain-outcomes { position: absolute; z-index: 4; top: 82px; right: 5px; width: 142px; display: grid; gap: 12px; }
.pain-outcome { padding-left: 10px; border-left: 2px solid var(--soft-pink); font-size: 11px; font-weight: 700; line-height: 1.2; opacity: 0.9; }
.pain-outcome span { display: block; margin-top: 3px; color: var(--pink); opacity: 0; transform: translateX(12px); transition: opacity 0.35s ease, transform 0.35s ease; }
.pain-outcome span::before { content: "↓ "; color: var(--lilac); }
.pain-visual-stage.organised .pain-outcome span { opacity: 1; transform: none; }
.pain-visual-stage.organised .pain-outcome:nth-child(1) span { transition-delay: 0.45s; }
.pain-visual-stage.organised .pain-outcome:nth-child(2) span { transition-delay: 0.85s; }
.pain-visual-stage.organised .pain-outcome:nth-child(3) span { transition-delay: 1.25s; }
.pain-visual-cta { position: absolute; z-index: 8; left: calc(24% + 220px); bottom: 8px; margin: 0; white-space: nowrap; font-size: 13px; }

.pain-dashboard { position: absolute; inset: 50px 12px 12px; z-index: 6; padding: 7px 0; opacity: 0; transform: translateY(15px); pointer-events: none; transition: opacity 0.28s ease, transform 0.28s ease; }
.pain-app-head { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.pain-rose-mark { display: grid; place-items: center; overflow: hidden; width: 22px; height: 22px; border-radius: 7px; background: #b976db; }
.pain-rose-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pain-dashboard h3 { margin: 11px 0 8px; font-size: 16px; }
.pain-dashboard-sub { margin: 0 0 10px; color: #e7dafd; font-size: 9px; }
.pain-dash-schedule { padding: 10px; border-radius: 13px; color: #3e275e; background: rgba(255,255,255,0.94); box-shadow: 0 6px 15px rgba(29,8,55,0.13); font-size: 9px; }
.pain-dash-row { display: flex; justify-content: space-between; gap: 4px; padding: 5px 0; border-bottom: 1px solid #ebe5f1; }
.pain-dash-row:last-child { border: 0; }
.pain-dash-row strong { color: #44306b; }
.pain-confirmed { color: #2eaf72; font-weight: 700; }
.pain-dash-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.pain-dash-stat { padding: 8px; border-radius: 11px; background: rgba(255,255,255,0.15); font-size: 9px; }
.pain-dash-stat b { display: block; margin-bottom: 3px; font-size: 18px; }
.pain-dash-stat:nth-child(2) b { color: #d7ff94; }
.pain-visual-stage.organised .pain-inbox-thread { opacity: 0; transform: translateX(-95px) scale(0.72); }
.pain-visual-stage.organised .pain-inbox-thread:nth-child(2) { transition-delay: 0.25s; }
.pain-visual-stage.organised .pain-inbox-thread:nth-child(3) { transition-delay: 0.5s; }
.pain-visual-stage.organised .pain-inbox-thread:nth-child(4) { transition-delay: 0.75s; }
.pain-visual-stage.organised .pain-process { opacity: 1; transform: none; }
.pain-visual-stage.organised .pain-process:nth-child(1) { transition-delay: 0.25s; }
.pain-visual-stage.organised .pain-process:nth-child(2) { transition-delay: 0.62s; }
.pain-visual-stage.organised .pain-process:nth-child(3) { transition-delay: 0.98s; }
.pain-visual-stage.organised .pain-process:nth-child(4) { transition-delay: 1.34s; }
.pain-visual-stage.done .pain-process-list, .pain-visual-stage.done .pain-chaos-ui { opacity: 0; transition: opacity 0.18s ease; }
.pain-visual-stage.done .pain-dashboard { opacity: 1; transform: none; pointer-events: auto; }

.pain-mobile-expand, .pain-modal { display: none; }
.pain-modal.open { display: grid; place-items: center; position: fixed; inset: 0; z-index: 99; padding: 20px; background: rgba(16,7,32,0.82); }
.pain-modal-card { position: relative; width: min(100%, 370px); min-height: 560px; padding: 20px; border-radius: 25px; color: white; background: linear-gradient(160deg, #3f2877, #ab52bd); box-shadow: 0 22px 70px #000; }
.pain-modal-card h3 { font-family: "Plus Jakarta Sans"; font-size: 24px; margin: 16px 0 7px; }
.pain-modal-card p { max-width: none; color: rgba(255,255,255,0.86); line-height: 1.55; }
.pain-modal-close { position: absolute; top: 12px; right: 12px; border: 0; border-radius: 50%; width: 34px; height: 34px; color: white; background: rgba(255,255,255,0.16); font-size: 21px; }
.pain-modal-card .pain-dash-schedule { margin-top: 21px; font-size: 12px; }
.pain-modal-card .pain-dash-row { padding: 10px 2px; }
.pain-modal-card .pain-dash-stats { margin-top: 16px; }
.pain-modal-card .pain-dash-stat { padding: 14px; }

@media (max-width: 860px) {
  .pain-section { min-height: auto; padding: 3.5rem 1.5rem; }
  .pain-section-inner { grid-template-columns: 1fr; gap: 2.5rem; }
  .pain-visual-stage { min-height: 630px; width: min(100%, 570px); margin: auto; }
  .pain-visual-copy { top: 0; }
  .pain-phone { left: max(6%, calc(50% - 133px)); }
  .pain-outcomes { right: 2%; }
  .pain-visual-cta { left: 55%; bottom: 8px; }
  .pain-mobile-expand { display: block; position: absolute; z-index: 8; bottom: 4px; right: 4%; border: 0; border-radius: 999px; padding: 8px 12px; color: var(--ink); background: rgba(255,255,255,0.8); font-size: 11px; font-weight: 700; }
}

@media (max-width: 510px) {
  .pain-section { padding: 3rem 1.25rem; }
  .pain-title { font-size: 43px; }
  .pain-lead { font-size: 16px; }
  .pain-visual-stage { min-height: 570px; }
  .pain-visual-copy { font-size: 18px; }
  .pain-phone { top: 92px; left: 7%; width: 224px; height: 431px; transform: rotate(-4deg) scale(0.92); transform-origin: top left; }
  .pain-outcomes { top: 98px; right: -4px; width: 116px; }
  .pain-outcome { font-size: 9px; }
  .pain-process-list { left: -5px; bottom: 10px; width: 140px; }
  .pain-visual-cta { left: auto; right: 0; bottom: 17px; padding: 11px 13px; font-size: 11px; }
  .pain-mobile-expand { bottom: -10px; }
}

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

/* Scroll-driven tangled-thread visual replaces the former phone demo. */
.pain-visual-stage, .pain-modal { display: none !important; }
.thread-stage { position: relative; min-height: 580px; overflow: hidden; border: 1px solid rgba(255,255,255,0.14); border-radius: 28px; background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(149,130,195,0.04)); box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 28px 70px rgba(6,1,20,0.24); }
.thread-stage::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 32% 50%, rgba(149,130,195,0.18), transparent 28%), radial-gradient(circle at 75% 48%, rgba(220,79,245,0.13), transparent 35%); pointer-events: none; }
.thread-stage-heading { position: absolute; z-index: 3; top: 28px; left: 30px; right: 30px; font-family: "Plus Jakarta Sans", sans-serif; font-size: clamp(20px, 2vw, 28px); font-weight: 700; letter-spacing: -0.045em; }
.thread-stage-heading span { color: var(--pink); }
.thread-source-list, .thread-results { position: absolute; z-index: 3; top: 118px; bottom: 92px; display: flex; flex-direction: column; justify-content: space-between; }
.thread-source-list { left: 20px; width: 94px; }
.thread-source-list span { width: fit-content; padding: 7px 10px; border: 1px solid rgba(255,255,255,0.14); border-radius: 999px; color: rgba(255,255,255,0.68); background: rgba(26,10,58,0.58); font-size: 9px; font-weight: 700; white-space: nowrap; }
.thread-results { right: 18px; width: 152px; }
.thread-result { position: relative; padding: 10px 11px 10px 14px; border: 1px solid rgba(252,144,228,0.2); border-radius: 12px; background: rgba(26,10,58,0.68); box-shadow: 0 12px 28px rgba(8,2,24,0.2); opacity: 0.5; transform: translateX(10px); transition: opacity 0.35s ease, transform 0.35s ease, border-color 0.35s ease; }
.thread-result::before { content: ""; position: absolute; left: -7px; top: 50%; width: 9px; height: 9px; border: 2px solid var(--pink); border-radius: 50%; background: var(--ink); transform: translateY(-50%); box-shadow: 0 0 0 4px rgba(220,79,245,0.12); }
.thread-result span, .thread-result strong { display: block; }
.thread-result span { color: rgba(255,255,255,0.7); font-size: 8px; line-height: 1.2; }
.thread-result strong { margin-top: 3px; color: var(--pink); font-size: 11px; }
.thread-stage.is-resolved .thread-result { opacity: 1; transform: none; border-color: rgba(252,144,228,0.45); }
.thread-stage.is-resolved .thread-result:nth-child(2) { transition-delay: 0.08s; }
.thread-stage.is-resolved .thread-result:nth-child(3) { transition-delay: 0.16s; }
.thread-canvas { position: absolute; z-index: 2; left: 92px; right: 164px; top: 86px; bottom: 70px; width: calc(100% - 256px); height: calc(100% - 156px); }
.thread-state-label { position: absolute; z-index: 3; bottom: 45px; font-size: 8px; font-weight: 800; letter-spacing: 0.18em; }
.thread-state-chaos { left: 96px; color: rgba(224,217,250,0.48); }
.thread-state-flow { right: 168px; color: var(--pink); }
.thread-progress { position: absolute; z-index: 3; right: 30px; bottom: 24px; left: 30px; height: 2px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,0.1); }
.thread-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #9582c3, #dc4ff5, #fc90e4); box-shadow: 0 0 12px rgba(220,79,245,0.6); }

body.light-theme .thread-stage { border-color: rgba(84,73,139,0.15); background: linear-gradient(145deg, rgba(255,255,255,0.72), rgba(224,217,250,0.36)); box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 28px 70px rgba(84,39,116,0.12); }
body.light-theme .thread-source-list span { border-color: rgba(84,73,139,0.2); color: rgba(26,10,58,0.68); background: rgba(255,255,255,0.38); box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), 0 8px 22px rgba(84,39,116,0.08); backdrop-filter: blur(14px) saturate(135%); -webkit-backdrop-filter: blur(14px) saturate(135%); }
body.light-theme .thread-result { border-color: rgba(84,73,139,0.18); background: rgba(255,255,255,0.42); box-shadow: inset 0 1px 0 rgba(255,255,255,0.72), 0 12px 28px rgba(84,39,116,0.1); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); }
body.light-theme .thread-result::before { background: #fff8fe; }
body.light-theme .thread-result span { color: rgba(26,10,58,0.62); }
body.light-theme .thread-result strong { color: var(--purple); }
body.light-theme .thread-state-chaos { color: rgba(84,73,139,0.48); }

@media (max-width: 860px) {
  .thread-stage { min-height: 540px; width: min(100%, 660px); margin: auto; }
}

@media (max-width: 560px) {
  .thread-stage { min-height: 500px; border-radius: 22px; }
  .thread-stage-heading { top: 22px; left: 20px; right: 20px; font-size: 20px; }
  .thread-source-list, .thread-results { top: 104px; bottom: 78px; }
  .thread-source-list { left: 10px; width: 70px; }
  .thread-source-list span { max-width: 70px; padding: 6px 7px; font-size: 7px; white-space: normal; }
  .thread-results { right: 8px; width: 118px; }
  .thread-result { padding: 8px 7px 8px 11px; border-radius: 10px; }
  .thread-result span { font-size: 6.5px; }
  .thread-result strong { font-size: 9px; }
  .thread-canvas { left: 64px; right: 122px; top: 78px; bottom: 58px; width: calc(100% - 186px); height: calc(100% - 136px); }
  .thread-state-label { bottom: 36px; font-size: 6px; }
  .thread-state-chaos { left: 66px; }
  .thread-state-flow { right: 126px; }
  .thread-progress { right: 18px; bottom: 18px; left: 18px; }
}

/* Open-background knot interaction. */
.pain-section::before, .pain-section::after { display: none; }
.thread-stage { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.thread-stage::before { display: none; }
body.light-theme .thread-stage { border: 0; background: transparent; box-shadow: none; }
.thread-state-label { bottom: 68px; }
.thread-trigger { position: absolute; z-index: 5; bottom: 22px; left: 50%; padding: 9px 14px; border: 1px solid rgba(252,144,228,0.35); border-radius: 999px; color: #fff; background: rgba(84,73,139,0.38); box-shadow: 0 10px 24px rgba(9,2,28,0.18); font-size: 10px; font-weight: 700; cursor: pointer; opacity: 0.65; transform: translateX(-50%); transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.25s ease, background 0.25s ease; }
.thread-stage.is-ready .thread-trigger { opacity: 1; animation: thread-invite 2.2s ease-in-out infinite; }
.thread-trigger:hover { border-color: rgba(252,144,228,0.75); background: rgba(220,79,245,0.22); transform: translateX(-50%) translateY(-2px); }
.thread-trigger:focus-visible { outline: 3px solid var(--peach); outline-offset: 3px; }
.thread-trigger:disabled { cursor: default; animation: none; opacity: 0.82; }
.thread-stage.is-resolved .thread-trigger { border-color: rgba(252,144,228,0.55); background: rgba(84,73,139,0.2); }
.thread-progress { bottom: 7px; }
@keyframes thread-invite { 0%, 100% { box-shadow: 0 10px 24px rgba(9,2,28,0.18), 0 0 0 0 rgba(220,79,245,0); } 50% { box-shadow: 0 10px 24px rgba(9,2,28,0.18), 0 0 0 6px rgba(220,79,245,0.1); } }

body.light-theme .thread-trigger { border-color: rgba(84,73,139,0.3); color: var(--ink); background: rgba(255,255,255,0.4); box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 10px 24px rgba(84,39,116,0.1); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); }
body.light-theme .thread-trigger:hover { border-color: rgba(84,73,139,0.58); background: rgba(255,255,255,0.58); }

@media (max-width: 560px) {
  .thread-state-label { bottom: 58px; }
  .thread-trigger { bottom: 18px; padding: 8px 11px; font-size: 8px; }
  .thread-progress { bottom: 4px; }
}

/* Strand-specific colour system. */
.thread-result:nth-child(1) { --thread-color: #FC90E4; }
.thread-result:nth-child(2) { --thread-color: #DC4FF5; }
.thread-result:nth-child(3) { --thread-color: #FBE8C8; }
.thread-result::before { border-color: var(--thread-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--thread-color) 16%, transparent); }
.thread-result strong { color: var(--thread-color); }
.thread-stage.is-resolved .thread-result { border-color: color-mix(in srgb, var(--thread-color) 45%, transparent); }
.thread-progress span { background: linear-gradient(90deg, #9582C3 0%, #F6895E 24%, #F34657 48%, #DC4FF5 72%, #FC90E4 100%); }

body.light-theme .thread-result:nth-child(1) { --thread-color: #02457C; }
body.light-theme .thread-result:nth-child(2) { --thread-color: #54498B; }
body.light-theme .thread-result:nth-child(3) { --thread-color: #F34657; }
body.light-theme .thread-result strong { color: var(--thread-color); }
body.light-theme .thread-progress span { background: linear-gradient(90deg, #899CC4 0%, #0473C5 30%, #02457C 52%, #9582C3 72%, #F34657 100%); }

@media (max-width: 560px) {
  .thread-stage { min-height: 380px; }
  .thread-stage-heading { top: 10px; font-size: 18px; }
  .thread-source-list, .thread-results { top: 100px; bottom: 55px; }
  .thread-canvas { top: 70px; bottom: 20px; height: calc(100% - 90px); }
  .thread-trigger, .thread-progress, .thread-state-label { display: none; }
  .thread-result { opacity: 1; transform: none; }
}
