.translate-grammar {
  margin: 0.5rem 0 0.65rem;
  padding: 0.65rem 0.7rem;
  background: var(--bg-passage);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.75;
}

.grammar-sentence {
  word-break: break-word;
}

.grammar-seg {
  padding: 0.08rem 0.12rem;
  border-radius: 4px;
  border-bottom: 2px solid transparent;
  cursor: default;
}

.grammar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.grammar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.grammar-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.gram-role-subject {
  background: rgba(99, 102, 241, 0.22);
  border-bottom-color: #6366f1;
  color: var(--text);
}

.gram-role-predicate {
  background: rgba(34, 197, 94, 0.2);
  border-bottom-color: #22c55e;
}

.gram-role-object {
  background: rgba(59, 130, 246, 0.2);
  border-bottom-color: #3b82f6;
}

.gram-role-attributive {
  background: rgba(245, 158, 11, 0.22);
  border-bottom-color: #f59e0b;
}

.gram-role-relative_clause {
  background: rgba(236, 72, 153, 0.22);
  border-bottom-color: #ec4899;
}

.gram-role-subject_clause {
  background: rgba(139, 92, 246, 0.22);
  border-bottom-color: #8b5cf6;
}

.gram-role-object_clause {
  background: rgba(6, 182, 212, 0.2);
  border-bottom-color: #06b6d4;
}

.gram-role-adverbial_clause {
  background: rgba(20, 184, 166, 0.2);
  border-bottom-color: #14b8a6;
}

.gram-role-prepositional {
  background: rgba(168, 85, 247, 0.18);
  border-bottom-color: #a855f7;
}

.gram-role-main {
  color: var(--text-muted);
}

html[data-theme="eyecare"] .grammar-seg {
  border-bottom-width: 2px;
}

html[data-theme="eyecare"] .gram-role-subject {
  background: rgba(99, 102, 241, 0.15);
}

html[data-theme="eyecare"] .gram-role-predicate {
  background: rgba(34, 197, 94, 0.18);
}

html[data-theme="eyecare"] .gram-role-relative_clause {
  background: rgba(236, 72, 153, 0.14);
}
