:root {
  --psych-space-1: 8px;
  --psych-space-2: 12px;
  --psych-space-3: 16px;
  --psych-space-4: 22px;
  --psych-space-5: 30px;
  --psych-radius-sm: 10px;
  --psych-radius-md: 14px;
  --psych-radius-lg: 18px;
  --psych-shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.28);
  --psych-shadow-glow: 0 0 36px rgba(212, 175, 55, 0.18);
  --psych-line: rgba(255, 255, 255, 0.11);
  --psych-line-soft: rgba(255, 255, 255, 0.07);
  --psych-text: #edf1f7;
  --psych-muted: #b8c2d0;
  --psych-muted-soft: #97a4b7;
  --psych-gold: #d4af37;
  --psych-bg: #0f1116;
}

html,
body {
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(1000px 420px at 50% -18%, rgba(212, 175, 55, 0.14), transparent 62%),
    radial-gradient(700px 320px at 100% 120%, rgba(212, 175, 55, 0.08), transparent 55%),
    linear-gradient(180deg, #11141b 0%, #0d1016 56%, #0a0c11 100%);
  color: var(--psych-text);
}

.psych-page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 10px 34px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.psych-page a:focus-visible,
.psych-page button:focus-visible {
  outline: 2px solid rgba(255, 215, 0, 0.9);
  outline-offset: 2px;
}

.psych-header {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--psych-line);
  border-radius: var(--psych-radius-lg);
  padding: 18px;
  background: linear-gradient(135deg, rgba(25, 29, 38, 0.95), rgba(16, 19, 26, 0.96));
  box-shadow: var(--psych-shadow-soft), var(--psych-shadow-glow);
  overflow: hidden;
}

.psych-header::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -140px;
  top: -160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.24), transparent 68%);
  pointer-events: none;
}

.psych-eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #c9b16b;
  font-weight: 700;
}

.psych-header h1 {
  margin: 0;
  font-size: clamp(26px, 4.4vw, 34px);
  color: #f6f8fb;
  line-height: 1.1;
}

.psych-subtitle {
  margin: 8px 0 0;
  color: var(--psych-muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 64ch;
}

.psych-back {
  width: 100%;
  border: 1px solid rgba(212, 175, 55, 0.4);
}

.psych-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.psych-guest,
.psych-empty,
.mindstate-card,
.risk-manager-card,
.summary-card,
.action-plan-card,
.detector-card {
  border-radius: var(--psych-radius-md);
  border: 1px solid var(--psych-line);
  background: linear-gradient(145deg, rgba(22, 26, 34, 0.95), rgba(15, 18, 25, 0.94));
  box-shadow: var(--psych-shadow-soft);
}

.psych-guest,
.psych-empty {
  padding: 16px;
}

.psych-guest-eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c9b16b;
  font-weight: 700;
}

.psych-guest h2,
.psych-empty h2 {
  margin: 0 0 10px;
  color: #f4f7fc;
}

.psych-guest-lead,
.psych-empty p {
  margin: 0 0 14px;
  color: var(--psych-muted);
  line-height: 1.55;
}

.psych-guest-list {
  margin: 0 0 14px;
  padding-left: 18px;
  color: var(--psych-muted);
  display: grid;
  gap: 8px;
}

.psych-guest-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mindstate-card,
.risk-manager-card,
.summary-card,
.action-plan-card {
  padding: 14px;
}

.operational-banner {
  border-radius: var(--psych-radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--psych-line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.operational-banner__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--psych-muted-soft);
}

.operational-banner__value {
  font-size: 14px;
}

.operational-banner.perm-green {
  background: rgba(46, 204, 113, 0.12);
  border-color: rgba(46, 204, 113, 0.3);
}

.operational-banner.perm-yellow,
.operational-banner.perm-orange {
  background: rgba(246, 198, 81, 0.13);
  border-color: rgba(246, 198, 81, 0.35);
}

.operational-banner.perm-red {
  background: rgba(231, 76, 60, 0.14);
  border-color: rgba(231, 76, 60, 0.35);
}

.mindstate-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mindstate-title {
  margin: 0;
  font-size: 20px;
}

.mindstate-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid #3a4351;
  background: #151b24;
  font-weight: 700;
  font-size: 13px;
  padding: 7px 12px;
}

.mindstate-badge.green { border-color: rgba(46, 204, 113, 0.5); color: #a9f0c7; }
.mindstate-badge.yellow { border-color: rgba(246, 198, 81, 0.55); color: #f7df9c; }
.mindstate-badge.orange { border-color: rgba(240, 146, 71, 0.55); color: #ffc79a; }
.mindstate-badge.red { border-color: rgba(231, 76, 60, 0.55); color: #ffb0a9; }

.mindstate-subtitle {
  margin: 10px 0 0;
  color: var(--psych-muted);
  font-size: 13px;
}

.mindstate-trigger {
  margin: 8px 0 0;
  color: #c8d1df;
  font-size: 13px;
}

.mindstate-rule {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: #f2f6fb;
  border-left: 3px solid rgba(212, 175, 55, 0.75);
  padding: 8px 0 8px 10px;
  background: rgba(212, 175, 55, 0.08);
  border-radius: 0 var(--psych-radius-sm) var(--psych-radius-sm) 0;
}

.mindstate-rule span {
  color: #f8d981;
  font-weight: 700;
}

.mindstate-links {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.mindstate-links a {
  color: #f6d77f;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 13px;
  font-weight: 600;
}

.risk-manager-head,
.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.risk-manager h2,
.psych-summary h2,
.action-plan h2 {
  margin: 0;
  font-size: 18px;
}

.risk-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--psych-line);
  font-size: 12px;
  font-weight: 700;
}

.risk-status--green { color: #9ceac0; border-color: rgba(46, 204, 113, 0.45); }
.risk-status--yellow,
.risk-status--orange { color: #f7de99; border-color: rgba(246, 198, 81, 0.45); }
.risk-status--red { color: #ffafa7; border-color: rgba(231, 76, 60, 0.45); }

.risk-tiles,
.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.risk-tile,
.summary-tile {
  border: 1px solid var(--psych-line-soft);
  border-radius: var(--psych-radius-sm);
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.risk-tile span,
.summary-tile span {
  display: block;
  color: var(--psych-muted-soft);
  font-size: 12px;
}

.risk-tile strong,
.summary-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  color: #f2f6fb;
}

.risk-why {
  margin: 12px 0 0;
  color: var(--psych-muted);
  font-size: 13px;
  line-height: 1.5;
}

.summary-trend {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trend-pill {
  border-radius: 999px;
  border: 1px solid var(--psych-line);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
}

.trend-pill.up { color: #ffb6b0; border-color: rgba(231, 76, 60, 0.5); }
.trend-pill.down { color: #9ceac0; border-color: rgba(46, 204, 113, 0.5); }
.trend-pill.up-good { color: #9ceac0; border-color: rgba(46, 204, 113, 0.5); }
.trend-pill.down-bad { color: #ffb6b0; border-color: rgba(231, 76, 60, 0.5); }

.summary-timeline {
  margin-top: 12px;
}

.timeline-label {
  display: block;
  margin-bottom: 7px;
  color: var(--psych-muted-soft);
  font-size: 12px;
}

.timeline-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.timeline-dot {
  width: 16px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.timeline-dot.is-win { background: rgba(46, 204, 113, 0.9); border-color: rgba(46, 204, 113, 0.95); }
.timeline-dot.is-loss { background: rgba(231, 76, 60, 0.9); border-color: rgba(231, 76, 60, 0.95); }
.timeline-dot.is-unknown { background: rgba(148, 163, 184, 0.72); border-color: rgba(148, 163, 184, 0.82); }

.action-plan-card {
  border-left: 4px solid rgba(212, 175, 55, 0.75);
}

.action-plan-card.is-red { border-left-color: rgba(231, 76, 60, 0.92); }
.action-plan-card.is-orange { border-left-color: rgba(240, 146, 71, 0.92); }
.action-plan-card.is-yellow { border-left-color: rgba(246, 198, 81, 0.92); }
.action-plan-card.is-green { border-left-color: rgba(46, 204, 113, 0.92); }

.action-priority,
.action-immediate,
.action-rule {
  margin: 10px 0 0;
  color: #dbe2ee;
  font-size: 13px;
  line-height: 1.5;
}

.action-priority {
  font-weight: 700;
  color: #f2f6fb;
}

.detector-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-row h2 {
  margin: 0;
  font-size: 18px;
}

.section-info-icon,
.tooltip-btn {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid #3a4556;
  color: #c6d0dd;
  background: #1a1f2a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
}

.detectors-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.detector-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.detector-card:hover {
  transform: translateY(-2px);
  border-color: rgba(212, 175, 55, 0.45);
}

.detector-card--priority {
  border-color: rgba(212, 175, 55, 0.62);
  box-shadow: var(--psych-shadow-soft), var(--psych-shadow-glow);
}

.detector-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.detector-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.priority-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #1a1608;
  background: linear-gradient(135deg, #f4ce67, #e3b744);
  border: 1px solid rgba(212, 175, 55, 0.85);
}

.detector-name {
  margin: 0;
  font-size: 15px;
  color: #e7ebf2;
}

.detector-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid #3a4350;
  font-size: 12px;
  font-weight: 700;
}

.detector-pill.green { color: #9ceac0; border-color: rgba(46, 204, 113, 0.45); }
.detector-pill.yellow { color: #f7de99; border-color: rgba(246, 198, 81, 0.45); }
.detector-pill.orange { color: #ffc594; border-color: rgba(240, 146, 71, 0.45); }
.detector-pill.red { color: #ffafa7; border-color: rgba(231, 76, 60, 0.45); }

.detector-confidence {
  color: var(--psych-muted-soft);
  font-size: 12px;
}

.detector-line {
  margin: 0;
  color: #d7dde6;
  font-size: 13px;
  line-height: 1.35;
  border: 1px solid #2a333e;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detector-line-detected {
  background: rgba(31, 38, 49, 0.4);
}

.detector-line-action {
  background: rgba(32, 46, 39, 0.35);
  border-color: rgba(77, 132, 95, 0.45);
}

.detector-line-why {
  background: rgba(212, 175, 55, 0.08);
  border-color: rgba(212, 175, 55, 0.3);
}

.detector-line-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #aab6c7;
  font-weight: 700;
}

.detector-line-text {
  color: #eef2f8;
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
}

.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  width: min(320px, calc(100vw - 16px));
  background: #12161d;
  border: 1px solid #2f3744;
  border-radius: 10px;
  padding: 9px 10px;
  color: #dbe2ec;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  max-height: calc(100vh - 16px);
  overflow: auto;
}

.hidden {
  display: none !important;
}

.psych-loading {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.skeleton-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--psych-radius-md);
  background: linear-gradient(135deg, rgba(22, 26, 34, 0.92), rgba(15, 18, 25, 0.96));
  border: 1px solid var(--psych-line);
  min-height: 82px;
}

.skeleton-card--lg {
  min-height: 120px;
}

.skeleton-card::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.12), transparent);
  animation: psychShimmer 1.35s infinite;
}

@keyframes psychShimmer {
  100% { transform: translateX(100%); }
}

@media (min-width: 760px) {
  .psych-page {
    padding: 24px 18px 36px;
    gap: 18px;
  }

  .psych-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 22px;
  }

  .psych-back {
    width: auto;
    min-width: 170px;
  }

  .psych-guest-cta {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .risk-tiles,
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .detectors-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
