#mode-rop {
  --rop-paper: #fffaf2;
  --rop-ink: #2c2418;
  --rop-muted: #6f5f4e;
  --rop-border: rgba(110, 84, 54, 0.18);
  --rop-accent: #b86d2d;
  --rop-accent-soft: rgba(184, 109, 45, 0.14);
  --rop-success: #1f7a4d;
  --rop-success-bg: rgba(31, 122, 77, 0.06);
  --rop-success-border: rgba(31, 122, 77, 0.5);
  --rop-danger: #9b2f3a;
  --rop-danger-bg: rgba(155, 47, 58, 0.06);
  --rop-danger-border: rgba(155, 47, 58, 0.5);
  
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(184, 109, 45, 0.12), transparent 30%),
    radial-gradient(circle at left bottom, rgba(90, 130, 168, 0.1), transparent 28%),
    linear-gradient(180deg, #fff 0%, #fffdf8 100%);
  padding: 8px 2px 18px;
}

#mode-rop::before {
  display: none;
}

.rop-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.rop-instructions {
  font-size: 0.96rem;
  color: var(--rop-muted);
  background: var(--rop-accent-soft);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 20px;
  border-left: 4px solid var(--rop-accent);
  line-height: 1.5;
}

.rop-workspace {
  display: grid;
  grid-template-columns: 1fr 50px 1fr;
  gap: 15px;
  margin-bottom: 24px;
  align-items: stretch;
}

@media (max-width: 800px) {
  .rop-workspace {
    grid-template-columns: 1fr;
  }
  .rop-controls-column {
    flex-direction: row !important;
    justify-content: center;
    gap: 15px;
    margin: 10px 0;
  }
}

.rop-workspace-card {
  border: none;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.rop-card-header {
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(110, 84, 54, 0.08);
  padding-bottom: 8px;
}

.rop-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rop-accent);
  font-weight: 700;
}

.rop-list-area {
  height: 480px;
  border: 2px dashed transparent;
  border-radius: 16px;
  background: transparent;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  transition: all 0.25s ease;
}

.rop-list-area.drag-over {
  background: rgba(184, 109, 45, 0.04);
  border-color: var(--rop-accent);
}

/* Empty placeholders to avoid box-in-box nesting when active */
.rop-list-area:empty {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.rop-list-area:empty::before {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 100%;
  color: var(--rop-muted);
  font-size: 0.92rem;
  border: 2px dashed rgba(110, 84, 54, 0.12);
  border-radius: 12px;
  background: rgba(110, 84, 54, 0.015);
  font-style: italic;
  opacity: 0.7;
}

#rop-source-list:empty::before {
  content: "All paragraphs moved";
}

#rop-target-list:empty::before {
  content: "Drag paragraphs here to re-order";
}


/* ROP Drag & Drop Card Item */
.rop-item {
  position: relative;
  background: #fff;
  border: 1px solid var(--rop-border);
  border-radius: 12px;
  padding: 14px 18px;
  cursor: grab;
  user-select: none;
  font-family: 'Lora', serif;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--rop-ink);
  box-shadow: 0 4px 12px rgba(42, 31, 18, 0.02);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rop-item:active {
  cursor: grabbing;
}

.rop-item.is-selected {
  border-color: var(--rop-accent);
  background: var(--rop-accent-soft);
  box-shadow: 0 8px 20px rgba(184, 109, 45, 0.15);
}

.rop-item.is-dragging {
  opacity: 0.4;
  transform: scale(0.98);
  border-style: dashed;
}

/* Handle icon for drag */
.rop-item-handle {
  display: flex;
  align-items: center;
  color: var(--rop-muted);
  opacity: 0.4;
  padding-top: 4px;
  cursor: grab;
}

.rop-item:hover .rop-item-handle {
  opacity: 0.8;
}

.rop-item-content {
  flex: 1;
}

/* Connectors and correctness styling post-submission */
.rop-item.pair-correct {
  border-color: var(--rop-success);
  background: var(--rop-success-bg);
}

.rop-item.pair-incorrect {
  border-color: var(--rop-danger);
  background: var(--rop-danger-bg);
}

/* Vertical visual connector lines linking adjacent boxes */
.rop-card-connector {
  width: 4px;
  height: 12px;
  align-self: center;
  margin: -12px auto;
  position: relative;
  z-index: 5;
  border-radius: 2px;
  transition: all 0.25s ease;
}

.rop-card-connector.is-correct {
  background-color: var(--rop-success);
  box-shadow: 0 0 6px var(--rop-success-border);
}

.rop-card-connector.is-incorrect {
  background-color: var(--rop-danger);
  box-shadow: 0 0 6px var(--rop-danger-border);
}

/* Number indicators shown after submit */
.rop-badge-number {
  position: absolute;
  top: -8px;
  left: -8px;
  background: var(--rop-muted);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  font-family: var(--font-primary, sans-serif);
}

.rop-badge-number.is-correct {
  background: var(--rop-success);
}

.rop-badge-number.is-incorrect {
  background: var(--rop-danger);
}

/* Center Controls Column */
.rop-controls-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.rop-arrow-btn {
  background: #fff;
  border: 1px solid var(--rop-border);
  color: var(--rop-ink);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.rop-arrow-btn:hover:not(:disabled) {
  background: var(--rop-accent-soft);
  color: var(--rop-accent);
  border-color: var(--rop-accent);
  transform: translateY(-1px);
}

.rop-arrow-btn:active:not(:disabled) {
  transform: translateY(0);
}

.rop-arrow-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.02);
}

/* Footer Actions & Scores */
.rop-footer-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rop-buttons-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.rop-result-box {
  border: 1px solid var(--rop-border);
  border-radius: 20px;
  background: #fffdf8;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rop-score-display {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--rop-ink);
}

.rop-score-display .score-badge {
  background: var(--rop-accent);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.95rem;
}

.rop-score-display .score-badge.max-score {
  background: var(--rop-success);
}

.rop-pair-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--rop-muted);
}

.rop-pair-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rop-pair-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.rop-pair-status.correct {
  background: var(--rop-success);
}

.rop-pair-status.incorrect {
  background: var(--rop-danger);
}

/* Accordion Explanation Panel */
.rop-explanation-panel {
  animation: ropSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes ropSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.rop-explanation-card {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 24px 0;
}

.rop-explanation-header {
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--rop-ink);
  border-bottom: 1px solid rgba(110, 84, 54, 0.08);
  padding-bottom: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rop-explanation-content {
  font-size: 0.98rem;
  color: var(--rop-ink);
  line-height: 1.7;
}

.rop-explanation-content p {
  margin-bottom: 12px;
}

.rop-explanation-content ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.rop-explanation-content li {
  margin-bottom: 6px;
}

/* Cohesion Highlighting Hover */
.cohesion-link {
  border-bottom: 2px dotted var(--rop-accent);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.cohesion-link:hover,
.cohesion-link.cohesion-link-hovered {
  background-color: var(--rop-accent-soft);
  border-bottom-style: solid;
}

/* Tooltip on cohesion-link */
.cohesion-link::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--rop-ink);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  font-family: var(--font-primary, sans-serif);
}

.cohesion-link:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Cohesion Feedback */
.rop-cohesion-feedback {
  margin-top: 20px;
  animation: ropSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.rop-cohesion-header {
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--rop-ink);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rop-cohesion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.rop-cohesion-card {
  border: 1px solid var(--rop-danger-border);
  background: var(--rop-danger-bg);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 4px 15px rgba(155, 47, 58, 0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rop-cohesion-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(155, 47, 58, 0.05);
}

.rop-cohesion-card-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.rop-cohesion-card-text {
  font-size: 0.94rem;
  color: var(--rop-ink);
  line-height: 1.5;
  font-family: var(--font-primary, sans-serif);
}

/* AI Critique Button & Panel */
.modern-btn--ai {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modern-btn--ai:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.modern-btn--ai:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
}

.rop-critique-panel {
  margin-top: 20px;
  animation: ropSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.rop-critique-card {
  border: 1px solid rgba(99, 102, 241, 0.2);
  background: rgba(99, 102, 241, 0.03);
  border-radius: 24px;
  padding: 24px;
}

.rop-critique-header {
  font-size: 1.08rem;
  font-weight: 600;
  color: #4f46e5;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
  padding-bottom: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.critique-header-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.rop-critique-content {
  font-size: 0.98rem;
  color: var(--rop-ink);
  line-height: 1.7;
  font-family: var(--font-primary, sans-serif);
  white-space: pre-line;
}

/* Spinner style */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

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

/* Split-Screen Review Layout */
.rop-review-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
  align-items: stretch;
}

.rop-review-left {
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  border-right: 1px solid rgba(110, 84, 54, 0.08);
  padding-right: 24px;
}

.rop-review-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0;
  max-height: 800px;
  overflow-y: auto;
}

@media (max-width: 900px) {
  .rop-review-split {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .rop-review-left {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid rgba(110, 84, 54, 0.08);
    padding-bottom: 20px;
  }
  .rop-review-right {
    max-height: none;
    overflow-y: visible;
  }
}

/* Correct Sequence Card Items (Left Side of Split Screen) */
.rop-correct-item {
  position: relative;
  background: var(--rop-success-bg);
  border: 1px solid var(--rop-success-border);
  border-left: 5px solid var(--rop-success);
  border-radius: 12px;
  padding: 14px 18px;
  font-family: 'Lora', serif;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--rop-ink);
  box-shadow: 0 4px 12px rgba(31, 122, 77, 0.02);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.rop-correct-badge {
  background: var(--rop-success);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  font-family: var(--font-primary, sans-serif);
}

/* Highlights and Bolds in critique and explanations */
.rop-highlight {
  background-color: #fef3c7; /* light amber highlight */
  color: #92400e;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95em;
  border: 1px solid #fde68a;
  display: inline-block;
}

.rop-explanation-content strong,
.rop-critique-content strong,
.dd-result-card-explanation-text strong,
.rmcma-explanation-content strong {
  color: var(--rop-accent);
  font-weight: 700;
}

